mirror of
https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
synced 2025-12-21 21:07:01 +00:00
Merge branch 'master' of https://github.com/greearb/lanforge-scripts
This commit is contained in:
@@ -398,6 +398,8 @@ def main():
|
|||||||
#9800 series
|
#9800 series
|
||||||
if args.series == "9800":
|
if args.series == "9800":
|
||||||
while logged_in_9800 == False and loop_count <= 2:
|
while logged_in_9800 == False and loop_count <= 2:
|
||||||
|
logg.info("9800 establishing Telnet egg {} ".format(egg))
|
||||||
|
sleep(5)
|
||||||
egg.sendline(CR)
|
egg.sendline(CR)
|
||||||
sleep(3)
|
sleep(3)
|
||||||
try:
|
try:
|
||||||
@@ -417,7 +419,7 @@ def main():
|
|||||||
j = egg.expect_exact(["WLC>","WLC#","User:","Password:",pexpect.TIMEOUT],timeout=3)
|
j = egg.expect_exact(["WLC>","WLC#","User:","Password:",pexpect.TIMEOUT],timeout=3)
|
||||||
sleep(0.1)
|
sleep(0.1)
|
||||||
if j == 0:
|
if j == 0:
|
||||||
logg.info("9800 found WLC# will elevate loging i:{} j:{} before {} after {}".format(i,j,egg.before,egg.after))
|
logg.info("9800 found WLC> will elevate loging i:{} j:{} before {} after {}".format(i,j,egg.before,egg.after))
|
||||||
egg.sendline("en")
|
egg.sendline("en")
|
||||||
sleep(0.1)
|
sleep(0.1)
|
||||||
k = egg.expect_exact(["Password:",pexpect.TIMEOUT], timeout=2)
|
k = egg.expect_exact(["Password:",pexpect.TIMEOUT], timeout=2)
|
||||||
@@ -437,7 +439,7 @@ def main():
|
|||||||
logg.info("9800 found # so logged in can start sending commands i:{} j:{}".format(i,j))
|
logg.info("9800 found # so logged in can start sending commands i:{} j:{}".format(i,j))
|
||||||
logged_in_9800 = True
|
logged_in_9800 = True
|
||||||
if j == 2:
|
if j == 2:
|
||||||
logg.info("9800 found User\: will put in args.user {} i:{} j:{}".format(args.user,i,j))
|
logg.info("9800 found User: will put in args.user {} i:{} j:{}".format(args.user,i,j))
|
||||||
egg.sendline(args.user)
|
egg.sendline(args.user)
|
||||||
sleep(0.1)
|
sleep(0.1)
|
||||||
k = egg.expect_exact(["Password:",pexpect.TIMEOUT], timeout=2)
|
k = egg.expect_exact(["Password:",pexpect.TIMEOUT], timeout=2)
|
||||||
@@ -465,11 +467,22 @@ def main():
|
|||||||
if k == 1:
|
if k == 1:
|
||||||
logg.info("9800 Timed out waiting for # prompt i:{} j:{} k:{} before {} after {}".format(i,j,k,egg.before,egg.after))
|
logg.info("9800 Timed out waiting for # prompt i:{} j:{} k:{} before {} after {}".format(i,j,k,egg.before,egg.after))
|
||||||
if j == 4:
|
if j == 4:
|
||||||
logg.info("9800 timed out looking for WLC>,WLC#,User:,Password: i:{} j:{} before {} after {}".format(i,j,egg.before,egg.after))
|
logg.info("9800 timed out looking for WLC>,WLC#,User:,Password: loop_count {} i {} j {} before {} after {}".format(loop_count,i,j,egg.before,egg.after))
|
||||||
logg.info("9800 send carriage return to see if get prompt back ")
|
logg.info("9800 Closing the connection and try to re-establish loop_count {} i {} j {}".format(loop_count,i,j))
|
||||||
egg.sendline(CR)
|
egg.close(force = True)
|
||||||
sleep(0.4)
|
sleep(1)
|
||||||
|
#egg.close(force = True)
|
||||||
|
#sleep(0.2)
|
||||||
|
|
||||||
|
# re establish telnet
|
||||||
|
cmd = "telnet %s %d"%(host, port)
|
||||||
|
logg.info("Spawn: "+cmd+NL)
|
||||||
|
egg = pexpect.spawn(cmd)
|
||||||
|
egg.logfile = FileAdapter(logg)
|
||||||
|
time.sleep(0.1)
|
||||||
|
logged_in_9800 = False
|
||||||
|
loop_count = 0
|
||||||
|
found_escape = False
|
||||||
|
|
||||||
if i == 1:
|
if i == 1:
|
||||||
logg.info("9800 found WLC> will elevate loging i:{} before {} after {}".format(i,egg.before,egg.after))
|
logg.info("9800 found WLC> will elevate loging i:{} before {} after {}".format(i,egg.before,egg.after))
|
||||||
@@ -578,34 +591,54 @@ def main():
|
|||||||
logg.info("9800 Timed out waiting for # prompt i:{} j:{} k:{} before {} after {}".format(i,j,k,egg.before,egg.after))
|
logg.info("9800 Timed out waiting for # prompt i:{} j:{} k:{} before {} after {}".format(i,j,k,egg.before,egg.after))
|
||||||
if j == 4:
|
if j == 4:
|
||||||
logg.info("9800 timed out looking WLC>, WLC#, User:, Password: i:{} j:{} before {} after {}".format(i,j,egg.before,egg.after))
|
logg.info("9800 timed out looking WLC>, WLC#, User:, Password: i:{} j:{} before {} after {}".format(i,j,egg.before,egg.after))
|
||||||
egg.sendline(CR)
|
logg.info("9800 Timed out waiting for initial prompt send logout loop_count: {} i: {} j: {} before {} after {}".format(loop_count, i, j, egg.before,egg.after))
|
||||||
sleep(0.1)
|
logg.info("9800 Closing the connection and try to re-establish, ")
|
||||||
|
egg.close(force = True)
|
||||||
|
sleep(1)
|
||||||
|
#egg.close(force = True)
|
||||||
|
#sleep(0.2)
|
||||||
|
|
||||||
|
# re establish telnet
|
||||||
|
cmd = "telnet %s %d"%(host, port)
|
||||||
|
logg.info("Spawn: "+cmd+NL)
|
||||||
|
egg = pexpect.spawn(cmd)
|
||||||
|
egg.logfile = FileAdapter(logg)
|
||||||
|
time.sleep(0.1)
|
||||||
|
logged_in_9800 = False
|
||||||
|
loop_count = 0
|
||||||
|
found_escape = False
|
||||||
if i == 6:
|
if i == 6:
|
||||||
logg.info("9800 recieved Bad secrets, to many password attempts i: {} before {} after {}".format(i, egg.before,egg.after))
|
logg.info("9800 recieved Bad secrets, to many password attempts i: {} before {} after {}".format(i, egg.before,egg.after))
|
||||||
egg.sendline(CR)
|
egg.sendline(CR)
|
||||||
sleep(0.2)
|
sleep(0.2)
|
||||||
if i == 7:
|
if i == 7:
|
||||||
logg.info("9800 Timed out waiting for initial prompt send logout i: {} before {} after {}".format(i, egg.before,egg.after))
|
logg.info("9800 Timed out waiting for initial prompt send logout loop_count: {} i: {} before {} after {}".format(loop_count, i, egg.before,egg.after))
|
||||||
egg.sendline(CR)
|
logg.info("9800 Closing the connection and try to re-establish, ")
|
||||||
sleep(0.2)
|
egg.close(force = True)
|
||||||
r = 0
|
sleep(0.1)
|
||||||
while( r <= 120):
|
#egg.close(force = True)
|
||||||
egg.expect(pexpect.TIMEOUT,timeout=0)
|
#sleep(0.2)
|
||||||
logg.info("Not seeing prompts r {} before {} after {}".format(r,egg.before,egg.after))
|
|
||||||
egg.sendline("Hello?")
|
# re establish telnet
|
||||||
sleep(1)
|
cmd = "telnet %s %d"%(host, port)
|
||||||
loop_count += 1
|
logg.info("Spawn: "+cmd+NL)
|
||||||
|
egg = pexpect.spawn(cmd)
|
||||||
|
egg.logfile = FileAdapter(logg)
|
||||||
|
time.sleep(0.1)
|
||||||
|
logged_in_9800 = False
|
||||||
|
loop_count = 0
|
||||||
|
found_escape = False
|
||||||
|
|
||||||
if loop_count >= 3:
|
if loop_count >= 3:
|
||||||
if found_escape == True:
|
if found_escape == True:
|
||||||
logg.info("9800 there may be another prompt present that not aware of")
|
logg.info("9800 there may be another prompt present that not aware of")
|
||||||
logg.info("9800 will send escape to close telnet")
|
logg.info("9800 will send escape to close telnet")
|
||||||
r = 0
|
r = 0
|
||||||
while( r <= 120):
|
while( r <= 10):
|
||||||
egg.expect(pexpect.TIMEOUT,timeout=0)
|
egg.expect(pexpect.TIMEOUT,timeout=0)
|
||||||
logg.info("Not seeing prompts r {} before {} after {}".format(r,egg.before,egg.after))
|
logg.info("Not seeing prompts r {} before {} after {}".format(r,egg.before,egg.after))
|
||||||
egg.sendline("Hello?")
|
egg.sendline("Hello?")
|
||||||
sleep(1)
|
sleep(3)
|
||||||
egg.sendline("\x1b\r")
|
egg.sendline("\x1b\r")
|
||||||
logg.info("9800 the excape was found... close egg session")
|
logg.info("9800 the excape was found... close egg session")
|
||||||
egg.close(force = True)
|
egg.close(force = True)
|
||||||
|
|||||||
Reference in New Issue
Block a user