def scoutCreateSsid24Radius(ip, username, password, ssid, vlan, bridgeGroup, radioSub, gigaSub, radiusIp, sharedSecret, authPort, acctPort, radiusTimeout, radiusGroup, methodList): """Function that deploys a 2.4GHz 802.1x SSID to an AP using user provided arguments. """ scoutSsh = scout_auth.sshInfo(ip=ip, username=username, password=password) jinjaEnv = scout_env.scoutJinjaEnv() commandDebug = scout_env.scoutEnv() ssid = ssid vlan = vlan bridgeGroup = bridgeGroup radioSub = radioSub gigaSub = gigaSub radiusIp = radiusIp sharedSecret = sharedSecret authPort = authPort acctPort = acctPort radiusTimeout = radiusTimeout radiusGroup = radiusGroup methodList = methodList cmdTemplate = jinjaEnv.get_template("scout_create_radius_ssid_24") cmds = cmdTemplate.render(password=password,ssid=ssid,vlan=vlan,bridgeGroup=bridgeGroup,radioSub=radioSub,gigaSub=gigaSub,radiusIp=radiusIp,sharedSecret=sharedSecret,authPort=authPort,acctPort=acctPort,radiusTimeout=radiusTimeout,radiusGroup=radiusGroup,methodList=methodList) scoutCommands = cmds.splitlines() channel = scoutSsh.invoke_shell() print("INFO: Deploying 2.4GHz RADIUS SSID {0} to {1}...".format(ssid,ip)) for command in scoutCommands: channel.send('{}\n'.format(command)) if commandDebug == "on": commands = channel.recv(65535) print(commands) time.sleep(.10) scoutSsh.close()
def scoutChangeIp(ip, username, password, newIp, subnetMask): """Function that identifies SSH info, collects sys args, calls the scout_change_ap_ip command set, opens a SSH connection to the AP, executes the IP change, terminates the old SSH connection, opens a new one, and runs the scout_do_wr command set to save new IP change. """ scoutSsh = scout_auth.sshInfo(ip=ip, username=username, password=password) jinjaEnv = scout_env.scoutJinjaEnv() commandDebug = scout_env.scoutEnv() newIp = newIp subnetMask = subnetMask cmdTemplate = jinjaEnv.get_template("scout_change_ap_ip") cmds = cmdTemplate.render(password=password, newIp=newIp, subnetMask=subnetMask) scoutCommands = cmds.splitlines() channel = scoutSsh.invoke_shell() print("INFO: Changing IP from {0} to {1}...".format(ip, newIp)) for command in scoutCommands: channel.send('{}\n'.format(command)) if commandDebug == "on": commands = channel.recv(65535) print(commands) time.sleep(.10) scoutSsh.close() scoutDoWr(ip=newIp, username=username, password=password)
def scoutCreateSsid5(ip, username, password, ssid, wpa2Pass, vlan, bridgeGroup, radioSub, gigaSub): """Function that deploys a 5GHz SSID to an AP using user provided arguments. """ scoutSsh = scout_auth.sshInfo(ip=ip, username=username, password=password) jinjaEnv = scout_env.scoutJinjaEnv() commandDebug = scout_env.scoutEnv() ssid = ssid wpa2Pass = wpa2Pass vlan = vlan bridgeGroup = bridgeGroup radioSub = radioSub gigaSub = gigaSub cmdTemplate = jinjaEnv.get_template("scout_create_ssid_5") cmds = cmdTemplate.render(password=password,ssid=ssid,wpa2Pass=wpa2Pass,vlan=vlan,bridgeGroup=bridgeGroup,radioSub=radioSub,gigaSub=gigaSub) scoutCommands = cmds.splitlines() channel = scoutSsh.invoke_shell() print("INFO: Deploying 5GHz SSID {0} to {1}...".format(ssid,ip)) for command in scoutCommands: channel.send('{}\n'.format(command)) if commandDebug == "on": commands = channel.recv(65535) print(commands) time.sleep(.10) scoutSsh.close()
def scoutDisableRadius(ip, username, password): """Function that disables RADIUS on AP.""" scoutSsh = scout_auth.sshInfo(ip=ip, username=username, password=password) jinjaEnv = scout_env.scoutJinjaEnv() commandDebug = scout_env.scoutEnv() cmdTemplate = jinjaEnv.get_template("scout_disable_ap_radius") cmds = cmdTemplate.render(password=password) scoutCommands = cmds.splitlines() channel = scoutSsh.invoke_shell() print("INFO: Disabling RADIUS on {}...".format(ip)) for command in scoutCommands: channel.send('{}\n'.format(command)) if commandDebug == "on": commands = channel.recv(65535) print(commands) time.sleep(.10) scoutSsh.close()
def scoutWriteDefault(ip, username, password): """Function that wipes AP memory back to default.""" scoutSsh = scout_auth.sshInfo(ip=ip, username=username, password=password) jinjaEnv = scout_env.scoutJinjaEnv() commandDebug = scout_env.scoutEnv() cmdTemplate = jinjaEnv.get_template("scout_write_default") cmds = cmdTemplate.render(password=password) scoutCommands = cmds.splitlines() channel = scoutSsh.invoke_shell() print("INFO: Erasing config on {}...".format(ip)) for command in scoutCommands: channel.send('{}\n'.format(command)) if commandDebug == "on": commands = channel.recv(65535) print(commands) time.sleep(.10) scoutSsh.close()
def scoutDoWr(ip, username, password): """Function that performs write command on AP.""" scoutSsh = scout_auth.sshInfo(ip=ip, username=username, password=password) jinjaEnv = scout_env.scoutJinjaEnv() commandDebug = scout_env.scoutEnv() cmdTemplate = jinjaEnv.get_template("scout_do_wr") cmds = cmdTemplate.render(password=password) scoutCommands = cmds.splitlines() channel = scoutSsh.invoke_shell() print("INFO: Committing changes on {}...".format(ip)) for command in scoutCommands: channel.send('{}\n'.format(command)) if commandDebug == "on": commands = channel.recv(65535) print(commands) time.sleep(.10) scoutSsh.close()
def scoutChangeName(ip, username, password, apName): """Function that changes the hostname of AP.""" scoutSsh = scout_auth.sshInfo(ip=ip, username=username, password=password) jinjaEnv = scout_env.scoutJinjaEnv() commandDebug = scout_env.scoutEnv() apName = apName cmdTemplate = jinjaEnv.get_template("scout_change_ap_name") cmds = cmdTemplate.render(apName=apName, password=password) scoutCommands = cmds.splitlines() channel = scoutSsh.invoke_shell() print("INFO: Changing AP hostname on {}...".format(ip)) for command in scoutCommands: channel.send('{}\n'.format(command)) if commandDebug == "on": commands = channel.recv(65535) print(commands) time.sleep(.10) scoutSsh.close()
def scoutEnableSnmp(ip, username, password, snmp): """Function that enables SNMP on AP.""" scoutSsh = scout_auth.sshInfo(ip=ip, username=username, password=password) jinjaEnv = scout_env.scoutJinjaEnv() commandDebug = scout_env.scoutEnv() snmp = snmp cmdTemplate = jinjaEnv.get_template("scout_enable_ap_snmp") cmds = cmdTemplate.render(password=password, snmp=snmp) scoutCommands = cmds.splitlines() channel = scoutSsh.invoke_shell() print("INFO: Enabling SNMP server on {}...".format(ip)) for command in scoutCommands: channel.send('{}\n'.format(command)) if commandDebug == "on": commands = channel.recv(65535) print(commands) time.sleep(.10) scoutSsh.close()
def scoutTftpBackup(ip, username, password, tftpIp): """Function that performs TFTP backup of AP config.""" scoutSsh = scout_auth.sshInfo(ip=ip, username=username, password=password) jinjaEnv = scout_env.scoutJinjaEnv() commandDebug = scout_env.scoutEnv() tftpIp = tftpIp cmdTemplate = jinjaEnv.get_template("scout_do_tftp_backup") cmds = cmdTemplate.render(password=password, tftpIp=tftpIp) scoutCommands = cmds.splitlines() channel = scoutSsh.invoke_shell() print("INFO: Generating TFTP backup for {0} and sending to {1}...".format( ip, tftpIp)) for command in scoutCommands: channel.send('{}\n'.format(command)) if commandDebug == "on": commands = channel.recv(65535) print(commands) time.sleep(.10) scoutSsh.close()
def scoutDeleteSsid5(ip, username, password, ssid, vlan, radioSub, gigaSub): """Function that deletes an existing 5GHz SSID from an AP. """ scoutSsh = scout_auth.sshInfo(ip=ip, username=username, password=password) jinjaEnv = scout_env.scoutJinjaEnv() commandDebug = scout_env.scoutEnv() ssid = ssid vlan = vlan radioSub = radioSub gigaSub = gigaSub cmdTemplate = jinjaEnv.get_template("scout_delete_ssid_5") cmds = cmdTemplate.render(password=password,ssid=ssid,vlan=vlan,radioSub=radioSub,gigaSub=gigaSub) scoutCommands = cmds.splitlines() channel = scoutSsh.invoke_shell() print("INFO: Removing 5GHz SSID {0} from {1}...".format(ssid,ip)) for command in scoutCommands: channel.send('{}\n'.format(command)) if commandDebug == "on": commands = channel.recv(65535) print(commands) time.sleep(.10) scoutSsh.close()