Product and Software: This script will work for any code later than ArubaOS 3.2.
#!/bin/sh # ADD_MAC_ADDR # Giles Scott # gscott AT arubanetworks dot com # Quick utility to add a MAC to the switch localdb # December 2007 Not Supported by Aruba Networks # Switch API can change between releases # This script was tested against AOS 3.2.0.1 # Tested on RH Linux and Cygwin (for windows) requires wget and awk # file format mac addr as xxxxxxxxxxxx # add_mac_addr <controllerip> <user> <passwd> <file> <role>
# Check command line if [ $# -lt 5 ] then echo "add_mac_addr" echo "example" echo "add_mac_addr <controllerip> <user> <passwd> <file> <role>" echo "mac format should be 000102030405" echo " exit -1 fi
if [ ! -e $4 ] then echo "Unable to open file $4" exit -1 fi
# Read the command line LOCALDBADD="/screens/cmnutil/execCommandReturnResult.xml?%20exit%20$%20local-userdb%20add" SWITCH_IP=$1 SWITCH_USER=$2 SWITCH_PASSWD=$3 CSV=$4 ROLE=$5 AWK=" awk -F '>' ' /<ERROR>/,/<\/ERROR/ {$1=\"\";$2=\"\"; print}'"
# Login to the controller and store the SESSION cookie wget --quiet --no-check-certificate --save-cookies aruba-cookie --keep-session-cookies -O aruba-login \ --post-data="opcode=login&url=%2Fscreens%2Fwms%2Fwms.login%3Furl%3D%2F&needxml=0&uid=$SWITCH_USER&passwd=$SWITCH_PASSWD&login=Login" \ https://$SWITCH_IP:4343/screens/wms/wms.login
# Now add lots of MAC address's
cat $CSV | awk -F ',' ' \ {printf "\r
adding mac %s password %s role %s", $1, $1,"'$ROLE'" ;\ system( \ "wget --quiet --no-check-certificate --load-cookies aruba-cookie -O aruba-out \ https://"'$SWITCH_IP'":4343"'$LOCALDBADD'"%20username%20%22" $1 "%22"\ "%20password%20%22" $1 "%22" \ "%20role%20%22" "'$ROLE'" "%22" \ "@@1197295663469") ; \ system ( "cat aruba-out" ) } '
# Logout and clean-up temp files wget --quiet --no-check-certificate --load-cookies aruba-cookie -O aruba-logout "https://$SWITCH_IP:4343/logout.html" rm aruba-cookie ;rm aruba-login ;rm aruba-out ;rm aruba-logout
echo "