def fcr_state_persist_disabled(): """ Check if FCR is disabled, if not bail out and ask user to enable it. When FCR is disabled, do a reboot then check FCR is still disabled. """ host = (sys.argv[1]) user = sys.argv[2] password = sys.argv[7] #test_file = '/home/RunFromHere/ini/SwitchMatrix.csv' #csv_file = csv.DictReader(open(test_file, 'r'), delimiter=',', quotechar='"') fcr_state = fcr_tools.switch_status() state = fcr_state['fcr_enabled'] if state is False: #the same to here disabled is false, enabled is true anturlar.fos_cmd("switchdisable") print('\n\nSleeping: 10') liabhar.JustSleep(10) enabled = fcr_tools.switch_status() if enabled['fcr_enabled'] is False: anturlar.fos_cmd("switchenable") print('\n\nSleeping: 10') liabhar.JustSleep(10) print("\n\nENABLE/DISABLE TEST PASSED") else: pass else: print("\n\nENABLE/DISABLE TEST FAILED") print("Please disable fcr for this test and try again") sys.exit(0) print('Sleeping: 10') liabhar.JustSleep(10) si = anturlar.SwitchInfo() cn = si.chassisname() a = cofra.switch_power_off_on(cn, 'off') print('Sleeping: 20') liabhar.JustSleep(20) a = cofra.switch_power_off_on(cn, 'on') print('Sleeping: 120') liabhar.JustSleep(120) anturlar.connect_tel_noparse(host, user, password) fcr_state = fcr_tools.switch_status() state = fcr_state['fcr_enabled'] if state is False: print('Reboot Complete. FCR State remains consistent') print('TEST PASSED') else: print('FCR State changed.') print('TEST FAILED') sys.exit(0)#######################
def fcr_state_persist_disabled(): """ Check if FCR is disabled, if not bail out and ask user to enable it. When FCR is disabled, do a reboot then check FCR is still disabled. """ host = (sys.argv[1]) user = sys.argv[2] password = sys.argv[7] #test_file = '/home/RunFromHere/ini/SwitchMatrix.csv' #csv_file = csv.DictReader(open(test_file, 'r'), delimiter=',', quotechar='"') fcr_state = fcr_tools.switch_status() state = fcr_state['fcr_enabled'] if state is False: #the same to here disabled is false, enabled is true anturlar.fos_cmd("switchdisable") print('\n\nSleeping: 10') liabhar.JustSleep(10) enabled = fcr_tools.switch_status() if enabled['fcr_enabled'] is False: anturlar.fos_cmd("switchenable") print('\n\nSleeping: 10') liabhar.JustSleep(10) print("\n\nENABLE/DISABLE TEST PASSED") else: pass else: print("\n\nENABLE/DISABLE TEST FAILED") print("Please disable fcr for this test and try again") sys.exit(0) print('Sleeping: 10') liabhar.JustSleep(10) si = anturlar.SwitchInfo() cn = si.chassisname() a = cofra.switch_power_off_on(cn, 'off') print('Sleeping: 20') liabhar.JustSleep(20) a = cofra.switch_power_off_on(cn, 'on') print('Sleeping: 120') liabhar.JustSleep(120) anturlar.connect_tel_noparse(host, user, password) fcr_state = fcr_tools.switch_status() state = fcr_state['fcr_enabled'] if state is False: print('Reboot Complete. FCR State remains consistent') print('TEST PASSED') else: print('FCR State changed.') print('TEST FAILED') sys.exit(0) #######################
def fcr_state_persist_enabled(): #print(sys.argv) host = (sys.argv[1]) user = sys.argv[2] password = sys.argv[7] test_file = '/home/RunFromHere/ini/SwitchMatrix.csv' csv_file = csv.DictReader(open(test_file, 'r'), delimiter=',', quotechar='"') fcr_state = switch_status() state = fcr_state['fcr_enabled'] if state is True: anturlar.fos_cmd("switchdisable") print('\n\nSleeping: 10') liabhar.JustSleep(10) enabled = switch_status() if enabled['fcr_enabled'] is True: anturlar.fos_cmd("switchenable") print('\n\nSleeping: 10') liabhar.JustSleep(10) print("\n\nENABLE/DISABLE TEST PASSED") else: pass else: print("\n\nENABLE/DISABLE TEST FAILED") print("Please enable fcr for this test and try again") sys.exit(0) print('\n\nSleeping: 10') liabhar.JustSleep(10) si = anturlar.SwitchInfo() cn = si.chassisname() a = cofra.switch_power_off_on(cn, 'off') print('\n\nSleeping: 20') liabhar.JustSleep(20) a = cofra.switch_power_off_on(cn, 'on') print('\n\nSleeping: 120') liabhar.JustSleep(120) anturlar.connect_tel_noparse(host, user, password) si = anturlar.SwitchInfo() print("GETTINGFCRSTATE") fcr_state = switch_status() state = fcr_state['fcr_enabled'] if state is True: print('Reboot Complete. FCR State remains consistent') print('TEST PASSED') else: print('FCR State changed.') print('TEST FAILED')