9800 updates

This commit is contained in:
Chuck SmileyRekiere
2020-09-12 16:04:24 -06:00
parent 793392b40e
commit f09cbe3b98
2 changed files with 193 additions and 33 deletions

View File

@@ -136,6 +136,9 @@ def main():
# stdout logging
logging.basicConfig(format=FORMAT, handlers=[console_handler])
print("cisco series {}".format(args.series))
print("scheme {}".format(args.scheme))
egg = None # think "eggpect"
try:
if (scheme == "serial"):
@@ -163,13 +166,147 @@ def main():
#egg.logfile_read = sys.stdout.buffer
egg.logfile = FileAdapter(logg)
print("logg {}".format(logg))
i = egg.expect(["ssword:", "continue connecting (yes/no)?"], timeout=3)
time.sleep(0.1)
if i == 1:
egg.sendline('yes')
egg.expect('ssword:')
sleep(0.1)
egg.sendline(passwd)
logged_in_9800 = False
loop_count = 0
found_escape = False
if args.series == "9800":
while logged_in_9800 == False and loop_count <= 2:
#egg.sendline(CR)
i = egg.expect_exact(["Escape character is '^]'.",">","#","ser\:","ssword\:",pexpect.TIMEOUT],timeout=2)
if i == 0:
print("9800 found Escape charter is sending carriage return i: {} before: {} after: {}".format(i,egg.before,egg.after))
egg.sendline(CR)
found_escape = True
sleep(1)
j = egg.expect([">","#","ser\:","ssword\:",pexpect.TIMEOUT],timeout=3)
if j == 0:
print("9800 found > will elevate loging j: {} before {} after {}".format(j,egg.before,egg.after))
egg.sendline("en")
sleep(1)
k = egg.expect(["ssword\:",pexpect.TIMEOUT], timeout=2)
if k == 0:
print("9800 received password prompt will send password: {} k: {} before {} after {}".format(args.passwd, k,egg.before,egg.after))
egg.sendline(args.passwd)
sleep(1)
l = egg.expect(["#",pexpect.TIMEOUT],timeout=2)
if l == 0:
print("9800 Successfully received # prompt l {}".format(l))
logged_in_9800 = True
if l == 1:
print("9800 Timed out waiting for # prompt l {} before {} after {}".format(l,egg.before,egg.after))
if k == 1:
print("8900 received timeout after looking for password: prompt k {} before {} after {}".format(k,egg.before,egg.after))
if j == 1:
print("9800 found # so logged in can start sending commands j {}".format(j))
logged_in_9800 = True
if j == 2:
print("9800 found User\: will put in args.user {} j: {}".format(args.user,j))
egg.sendline(args.user)
sleep(1)
k = egg.expect(["ssword\:",pexpect.TIMEOUT], timeout=2)
if k == 0:
print("9800 received password prompt after sending User, sending password: {} k: {}".format(args.passwd,k))
egg.sendline(args.passwd)
sleep(1)
l = egg.expect(["#",pexpect.TIMEOUT],timeout=2)
if l == 0:
print("8900 Successfully received # prompt l: {}".format(l))
logged_in_9800 = True
if l == 1:
print("9800 Timed out waiting for # prompt l: {} before {} after {}".format(l,egg.before,egg.after))
if k == 1:
print("9800 received timeout after looking for password after sending user k: {} before {} after {}".format(k,egg.before,egg.after))
if j == 3:
print("9800 received Password prompt will send password {} j: {} before {} after {}".format(args.passwd,j,egg.before,egg.after))
egg.sendline(args.passwd)
sleep(1)
k = egg.expect(["#",pexpect.TIMEOUT],timeout=2)
if k == 0:
print("8900 Successfully received # prompt k: {} before {} after {}".format(k,egg.before,egg.after))
logged_in_9800 = True
if k == 1:
print("9800 Timed out waiting for # prompt k: {} before {} after {}".format(k,egg.before,egg.after))
if j == 4:
print("9800 timed out looking for >, #, User, Password j: {} before {} after {}".format(j,egg.before,egg.after))
egg.sendline(CR)
if i == 1:
print("9800 found > will elevate loging i: {} before {} after {}".format(i,egg.before,egg.after))
egg.sendline("en")
sleep(1)
k = egg.expect(["ssword\:",pexpect.TIMEOUT], timeout=2)
if k == 0:
print("9800 received password prompt will send password: {} k: {} before {} after {}".format(args.passwd, k, egg.before,egg.after))
egg.sendline(args.passwd)
sleep(1)
l = egg.expect(["#",pexpect.TIMEOUT],timeout=2)
if l == 0:
print("9800 Successfully received # prompt l {} before {} after {}".format(l, egg.before,egg.after))
logged_in_9800 = True
if l == 1:
print("9800 Timed out waiting for # prompt l {} before {} after {}".format(l,egg.before,egg.after))
if k == 1:
print("8900 received timeout after looking for password: prompt k {} before {} after {}".format(k,egg.before,egg.after))
if i == 2:
print("9800 found # so logged in can start sending commands i {} before {} after {}".format(i,egg.before,egg.after))
logged_in_9800 = True
if i == 3:
print("9800 found User will put in args.user {} j: {} before {} after {}".format(args.user,j, egg.before,egg.after))
egg.sendline(args.user)
sleep(1)
k = egg.expect(["ssword\:",pexpect.TIMEOUT], timeout=2)
if k == 0:
print("9800 received password prompt after sending User, sending password: {} k: {} before {} after {}".format(args.passwd,k, egg.before,egg.after))
egg.sendline(args.passwd)
sleep(0.1)
l = egg.expect(["#",pexpect.TIMEOUT],timeout=2)
if l == 0:
print("8900 Successfully received # prompt l: {}".format(l))
logged_in_9800 = True
if l == 1:
print("9800 Timed out waiting for # prompt l: {} before {} after {}".format(l,egg.before,egg.after))
if k == 1:
print("9800 received timeout after looking for password after sending user k: {} before {} after {}".format(k, egg.before,egg.after))
if i == 4:
print("9800 received password prompt will send password: {} k: {} before {} after {}".format(args.passwd, k, egg.before,egg.after))
egg.sendline(args.passwd)
sleep(1)
l = egg.expect(["#",pexpect.TIMEOUT],timeout=2)
if l == 0:
print("9800 Successfully received # prompt l {} before {} after {}".format(l,egg.before,egg.after))
logged_in_9800 = True
if l == 1:
print("9800 Timed out waiting for # prompt l {} before {} after {}".format(l,egg.before,egg.after))
#if i == 5:
# print("9800 pexpect found end of line i {} before {} after {}".format(i,egg.before,egg.after))
# egg.sendline(CR)
if i == 5:
print("9800 Timed out waiting for intial prompt will send carriage return and line feed i: {} before {} after {}".format(i, egg.before,egg.after))
egg.sendline(CR)
sleep(2)
loop_count += 1
if loop_count >= 3:
if found_escape == True:
print("9800 there may be another prompt present that not aware of")
print("9800 the excape was found see if we can send command")
else:
print("9800 did not find the initial escape will try the command anyway")
# 3504 series
else:
i = egg.expect(["ssword:", "continue connecting (yes/no)?"], timeout=3)
time.sleep(0.1)
if i == 1:
egg.sendline('yes')
egg.expect('ssword:')
sleep(0.1)
egg.sendline(passwd)
elif (scheme == "telnet"):
if (port is None):
@@ -316,9 +453,9 @@ def main():
# 3504 series
else:
egg.sendline(' ')
egg.expect('User\:')
egg.expect('User\:',timeout=3)
egg.sendline(user)
egg.expect('Password\:')
egg.expect('Password\:',timeout=3)
egg.sendline(passwd)
#if args.prompt in "WLC#" or args.prompt in "WLC>":
# egg.sendline("enable")
@@ -372,9 +509,9 @@ def main():
if (args.action == "summary"):
if args.series == "9800":
if band == "a":
command = "show ap dot11 5ghz summary"
command = "show ap dot11 5ghz monitor"
else:
command = "show ap dot11 24ghz summary"
command = "show ap dot11 24ghz monitor"
else:
command = "show ap summary"
@@ -469,9 +606,9 @@ def main():
if (args.action == "ap_channel"):
if args.series == "9800":
if band == "a":
command = "show ap dot11 5ghz monitor"
command = "show ap dot11 5ghz summary"
else:
command = "show ap dot11 24ghz monitor"
command = "show ap dot11 24ghz summary"
else:
command = "show ap channel %s"%(args.ap)

View File

@@ -246,7 +246,7 @@ class L3VariableTimeLongevity(LFCliBase):
if self.args.cisco_ctlr == None:
return
advanced = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", "ssh", "-d", self.args.cisco_ctlr, "-u",
advanced = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "-d", self.args.cisco_ctlr, "-u",
self.args.cisco_user, "-p", self.args.cisco_passwd,
"-a", self.args.cisco_ap,"--series", self.args.cisco_series,"--action", "summary"], capture_output=True)
pss = advanced.stdout.decode('utf-8', 'ignore')
@@ -258,7 +258,7 @@ class L3VariableTimeLongevity(LFCliBase):
if (line.startswith("---------")):
searchap = True
continue
#TODO need to test with 9800 series to chelck the values
if (searchap):
pat = "%s\s+\S+\s+\S+\s+\S+\s+\S+.* \S+\s+\S+\s+(\S+)\s+\["%(self.args.cisco_ap)
#print("AP line: %s"%(line))
@@ -271,36 +271,57 @@ class L3VariableTimeLongevity(LFCliBase):
print("WARNING: Cisco Controller reported %s stations, should be %s"%(sta_count, self.total_stas))
def controller_show_ap_channel(self):
advanced = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", "ssh", "-d", self.args.cisco_ctlr, "-u",
advanced = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "-d", self.args.cisco_ctlr, "-u",
self.args.cisco_user, "-p", self.args.cisco_passwd,
"-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--action", "ap_channel"], capture_output=True)
pss = advanced.stdout.decode('utf-8', 'ignore')
print(pss)
print("checking for 802.11{}".format(self.args.cisco_band))
for line in pss.splitlines():
#print("line {}".format(line))
search_str = "802.11{}".format(self.args.cisco_band)
if (line.lstrip().startswith(search_str)):
if self.args.cisco_series == "9800":
for line in pss.splitlines():
search_str = self.args.cisco_ap
print("line {}".format(line))
element_list = line.lstrip().split()
print("element_list {}".format(element_list))
print("ap: {} channel {} chan_width {}".format(self.args.cisco_ap,element_list[4],element_list[5]))
if (str(self.args.cisco_channel) in str(element_list[4])) and (str(self.args.cisco_chan_width) in str(element_list[5])):
print("ap configuration successful: channel {} in expected {} chan_width {} in expected {}"
.format(self.args.cisco_channel,element_list[4],self.args.cisco_chan_width,element_list[5]))
else:
print("AP WARNING: channel {} expected {} chan_width {} expected {}"
.format(element_list[4],self.cisco_channel,element_list[5],self.args.cisco_chan_width))
break
if (line.lstrip().startswith(search_str)):
print("line {}".format(line))
element_list = line.lstrip().split()
print("element_list {}".format(element_list))
# AP Name (0) mac (1) slot (2) Admin State [enable/disable] (3) Oper State [Up/Down] (4) Width (5) Txpwr (6,7) channel (8) mode (9)
print("ap: {} slof {} channel {} chan_width {}".format(element_list[0],element_list[2],element_list[8],element_list[5]))
if (str(self.args.cisco_channel) in str(element_list[8])) and (str(self.args.cisco_chan_width) in str(element_list[5])):
print("ap {} configuration successful: channel {} in expected {} chan_width {} in expected {}"
.format(element_list[0],self.args.cisco_channel,element_list[8],self.args.cisco_chan_width,element_list[5]))
else:
print("WARNING ap {} configuration: channel {} in expected {} chan_width {} in expected {}"
.format(element_list[0],self.args.cisco_channel,element_list[8],self.args.cisco_chan_width,element_list[5]))
break
else:
print("checking for 802.11{}".format(self.args.cisco_band))
for line in pss.splitlines():
#print("line {}".format(line))
search_str = "802.11{}".format(self.args.cisco_band)
if (line.lstrip().startswith(search_str)):
print("line {}".format(line))
element_list = line.lstrip().split()
print("element_list {}".format(element_list))
print("ap: {} channel {} chan_width {}".format(self.args.cisco_ap,element_list[4],element_list[5]))
if (str(self.args.cisco_channel) in str(element_list[4])) and (str(self.args.cisco_chan_width) in str(element_list[5])):
print("ap configuration successful: channel {} in expected {} chan_width {} in expected {}"
.format(self.args.cisco_channel,element_list[4],self.args.cisco_chan_width,element_list[5]))
else:
print("AP WARNING: channel {} expected {} chan_width {} expected {}"
.format(element_list[4],self.cisco_channel,element_list[5],self.args.cisco_chan_width))
break
print("configure ap {} channel {} chan_width {}".format(self.args.cisco_ap,self.args.cisco_channel,self.args.cisco_chan_width))
# Verify channel and channel width.
def controller_disable_ap(self):
#(Cisco Controller) >config 802.11a disable APA453.0E7B.CF9C
advanced = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", "ssh", "-d", self.args.cisco_ctlr, "-u",
advanced = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "-d", self.args.cisco_ctlr, "-u",
self.args.cisco_user, "-p", self.args.cisco_passwd,
"-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--action", "disable","--band",self.args.cisco_band], capture_output=True)
@@ -309,7 +330,7 @@ class L3VariableTimeLongevity(LFCliBase):
def controller_set_channel_ap(self):
#(Cisco Controller) >config 802.11a channel ap APA453.0E7B.CF9C 52
advanced = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", "ssh", "-d", self.args.cisco_ctlr, "-u",
advanced = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "-d", self.args.cisco_ctlr, "-u",
self.args.cisco_user, "-p", self.args.cisco_passwd,
"-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--action", "channel","--value",self.args.cisco_channel], capture_output=True)
@@ -320,7 +341,7 @@ class L3VariableTimeLongevity(LFCliBase):
def controller_set_channel_ap_36(self):
#(Cisco Controller) >config 802.11a channel ap APA453.0E7B.CF9C 36
cisco_channel_36 = "36"
advanced = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", "ssh", "-d", self.args.cisco_ctlr, "-u",
advanced = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "-d", self.args.cisco_ctlr, "-u",
self.args.cisco_user, "-p", self.args.cisco_passwd,
"-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--action", "channel","--value",cisco_channel_36], capture_output=True)
@@ -330,7 +351,7 @@ class L3VariableTimeLongevity(LFCliBase):
def controller_set_chan_width_ap(self):
#(Cisco Controller) >config 802.11a chan_width APA453.0E7B.CF9C 20
advanced = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", "ssh", "-d", self.args.cisco_ctlr, "-u",
advanced = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "-d", self.args.cisco_ctlr, "-u",
self.args.cisco_user, "-p", self.args.cisco_passwd,
"-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--action", "bandwidth","--value",self.args.cisco_chan_width], capture_output=True)
pss = advanced.stdout.decode('utf-8', 'ignore')
@@ -339,7 +360,7 @@ class L3VariableTimeLongevity(LFCliBase):
def controller_enable_ap(self):
#(Cisco Controller) >config 802.11a enable APA453.0E7B.CF9C
advanced = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", "ssh", "-d", self.args.cisco_ctlr, "-u",
advanced = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "-d", self.args.cisco_ctlr, "-u",
self.args.cisco_user, "-p", self.args.cisco_passwd,
"-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--action", "enable","--band",self.args.cisco_band], capture_output=True)
pss = advanced.stdout.decode('utf-8', 'ignore')
@@ -739,6 +760,8 @@ python3 test_l3_longevity.py --cisco_ctlr 192.168.100.112 --cisco_dfs True --mgr
parser.add_argument('--cisco_chan_width', help='--cisco_chan_width <20 40 80 160>',default="20",choices=["20","40","80","160"])
parser.add_argument('--cisco_band', help='--cisco_band <a | b | abgn>',default="a",choices=["a", "b", "abgn"])
parser.add_argument('--cisco_series', help='--cisco_series <9800 | 3504>',default="3504",choices=["9800","3504"])
parser.add_argument('--cisco_scheme', help='--cisco_scheme (serial|telnet|ssh): connect via serial, ssh or telnet',default="ssh",choices=["serial","telnet","ssh"])
parser.add_argument('--amount_ports_to_reset', help='--amount_ports_to_reset \"<min amount ports> <max amount ports>\" ', default=None)
parser.add_argument('--port_reset_seconds', help='--ports_reset_seconds \"<min seconds> <max seconds>\" ', default="10 30")