def verifyIncorrectPPID(self,ip): command = 'show -d properties=PPID' path = '/mcmanager' print "Verifying PPID" logging.info("Verifying PPID") ppid = self.telnet_con(ip, path, command) print ppid logging.info(ppid) if "PPID = MC1_PPID1234567890" in ppid: prints.color("RED","PPID INCORRECT => FAILED") return 1 else: return 0
def turn_on(self,ip, timeout): logging.info("-" * 50) logging.info("Turning ON Block") logging.info("-" * 50) turn_on_command = '/usr/local/bin/libi2ctest -c 0 100 100 3 -a 0xbe -m 0 3 0x01 0x80 0x5a 1' logging.info("Sending Command %s to turn on" % turn_on_command) turn_on = self.telnet_con(ip,'on',turn_on_command) logging.info(turn_on) print "-" * 50 prints.color ("GREEN",'Turning ON Block') print "-" * 50 print turn_on print "-" * 50 logging.info("Esperando %d segundos" % timeout) prints.color("CYAN","Esperando %d segundos" % timeout) time.sleep(timeout)
def turn_off(self,ip, timeout): logging.info("-" * 50) logging.info("Turning OFF Block") logging.info("-" * 50) turn_off_command = '/usr/local/bin/libi2ctest -c 0 100 100 3 -a 0xbe -m 0 3 0x01 0x00 0xd3 1' logging.info("Sending Command %s to turn off" % turn_off_command) turn_off = self.telnet_con(ip,'off',turn_off_command) logging.info(turn_off) print "-" * 50 prints.color("YELLOW" ,'Turning OFF Block') print "-" * 50 print turn_off print "-" * 50 logging.info("Esperando %d segundos" % timeout) prints.color("CYAN","Esperando %d segundos" % timeout) time.sleep(timeout)
def load_mcfiles(self,ip,syscfg): path = '/DEVICEMANAGER/RACK1/POWERBAY1/MC1' inventoryCommand = 'load -source tftp://172.101.112.100/%s/inventory.conf -import conf' % syscfg.strip() logging.info("Cargando configuracion => %s" % inventoryCommand) result = self.telnet_con(ip,path,inventoryCommand) print result logging.info(result) if "ERROR" in result: print "-" * 50 prints.color("RED", "Reintente de nuevo verifique que el LED de la MC no este en azul, si lo esta favor de reinsertarla") print "-" * 50 sys.exit(1) # Ahora hay que reiniciar rebootCommand = 'reboot' rebootResult = self.telnetConsoleRoot(ip,rebootCommand) print rebootResult
def verifyBlockStatus(self,ip,block_qty): blocks = int(block_qty) command = 'show -d properties=STATUS' bloques_malos = [] for block_index in range(1,blocks + 1): path = '/DEVICEMANAGER/RACK1/BLOCK%d' % block_index logging.info("Verifying Block Status => %s" % block_index) print "Verifying Block Status => %s" % block_index bloc_status = self.telnet_con(ip, path, command) logging.info(bloc_status) if "= NA" in bloc_status or "ABSENT" in bloc_status: prints.color("RED","STATUS => NOT OK") bloques_malos.append(block_index) else: prints.color("GREEN","STATUS => OK") if bloques_malos != []: print "Porfavor revise los Bloques que estan mal => %s" % bloques_malos return 1 return 0
def configure_single(self, firmware, chassis, width, ip, block): fw = firmware.replace(".","") fw = fw.strip() chassis = chassis.strip() width = width.strip() show_test_result_command = 'show -d properties=LastUpgradeStatus' bc_commands = [ 'load -source tftp://172.101.112.100/%s/%s/BC_SB.bin -install' % (chassis,fw), 'load -source tftp://172.101.112.100/%s/%s/BC_BL.bin -install' % (chassis,fw), 'load -source tftp://172.101.112.100/%s/%s/BC_OP.bin -install' % (chassis,fw), 'load -source tftp://172.101.112.100/%s/%s/BC_FT.bin -import fantable' % (chassis,fw), 'load -source tftp://172.101.112.100/%s/%s/BC_FP.bin -install' % (chassis,fw), 'load -source tftp://172.101.112.100/%s/%s/%s.bin -import conf' % (chassis,fw,width), ] logging.info("BC_COMMANDS => %s" % bc_commands) count = 1 bc_path = '/DEVICEMANAGER/RACK1/BLOCK%d/BC/' % block logging.info("BC_CURRENT_PATH => %s" % bc_path) prints.color("GREEN", 'Current Path => %s' % bc_path) for bccommand in bc_commands: prints.color("YELLOW",'Ejecutando => ' + bccommand) logging.info("EJECUTANDO => %s" % bccommand) print "-" * 50 bc_result = self.telnet_con(ip,bc_path,bccommand) logging.info("RESULT => %s" % bc_result) print bc_result time.sleep(5) while 1: upgrade_result = self.telnet_con(ip,bc_path,show_test_result_command) logging.info("UPGRADE_RESULT => %s" % upgrade_result) print upgrade_result if "UPDATE_IN_PROGRESS" in upgrade_result or "DOWNLOAD_IN_PROGRESS" in upgrade_result or "= NA" in upgrade_result: segundos = count * 30 prints.color("CYAN", 'Esperando => %d segundos' % segundos) time.sleep(segundos) if segundos == 300: logging.warning("FAILED TIMEOUT EXCEEDED %s" % bccommand) sys.exit(1) count += 1 continue elif "UPDATE_SUCCESSFUL" in upgrade_result: print "-" * 50 prints.color("GREEN", "TEST PASSED") logging.info("-" * 50) logging.info("TEST PASSED") logging.info("-" * 50) print "-" * 50 break elif "ERROR" in upgrade_result or "UPDATE_FAILED" in upgrade_result: print "-" * 50 prints.color("RED", "TEST %s FAILED" % bccommand) logging.warning("-" * 50) logging.warning("TEST [%s] FAILED" % bccommand) logging.warning("-" * 50) print "-" * 50 sys.exit(1) break else: break
def printPass(self): prints.color('GREEN','::::::::: ::: :::::::: ::::::::') prints.color('GREEN',':+: :+: :+: :+: :+: :+: :+: :+: ') prints.color('GREEN','+:+ +:+ +:+ +:+ +:+ +:+') prints.color('GREEN','+#++:++#+ +#++:++#++: +#++:++#++ +#++:++#++') prints.color('GREEN','+#+ +#+ +#+ +#+ +#+') prints.color('GREEN','#+# #+# #+# #+# #+# #+# #+#') prints.color('GREEN','### ### ### ######## ######## ') prints.color('GREEN','') prints.color('GREEN','============================================')
def verify_preconfiguration(self,firmware,ip,block_qty): blocks = int(block_qty) fw = firmware.strip() command = 'show -d properties=FirmwareVersion' components = { 'BLOCK' : blocks, 'IM' : '/DEVICEMANAGER/RACK1/POWERBAY1/IM/', 'MC': '/DEVICEMANAGER/RACK1/POWERBAY1/MC1', } for component in components: if component == 'BLOCK': for block_index in range(1,components['BLOCK'] + 1): path = '/DEVICEMANAGER/RACK1/BLOCK%d/BC/' % block_index logging.info("Verifying %s %s Firmware" % (component,block_index)) print "Verifying %s %s Firmware" % (component,block_index) verify_firmware = self.telnet_con(ip, path, command) if fw in verify_firmware: print '-' * 50 print "Expected Firmware [%s]" % fw print '-' * 50 print "Detected Firmware [%s]" % verify_firmware logging.info("Expected Firmware [%s]" % fw) logging.info("Detected Firmware [%s]" % verify_firmware) print '-' * 50 prints.color("GREEN", "TEST PASSED") print '-' * 50 logging.info("TEST PASSED") else: logging.info("Verifying Block Firmware") print "Verifying Block Firmware" print '-' * 50 print "Expected Firmware [%s]" % fw print "Detected Firmware [%s]" % verify_firmware logging.info("Expected Firmware [%s]" % fw) logging.info("Detected Firmware [%s]" % verify_firmware) print '-' * 50 prints.color("RED", "Expected Firmware [%s]" % fw) print '-' * 50 logging.info("TEST FAIL Expected Firmware [%s]" % fw) sys.exit(1) else: logging.info("Verifying %s Firmware" % component) print "Verifying %s Firmware" % component verify_firmware = self.telnet_con(ip, components[component], command) if fw in verify_firmware: print '-' * 50 print "Expected Firmware [%s]" % fw print "Detected Firmware [%s]" % verify_firmware logging.info("Expected Firmware [%s]" % fw) logging.info("Detected Firmware [%s]" % verify_firmware) print '-' * 50 prints.color("GREEN", "TEST PASSED") print '-' * 50 logging.info("TEST PASSED") else: logging.info("Verifying Block Firmware") print '-' * 50 print "Verifying Block Firmware" print "Expected Firmware [%s]" % fw print "Detected Firmware [%s]" % verify_firmware logging.info("Expected Firmware [%s]" % fw) logging.info("Detected Firmware [%s]" % verify_firmware) print '-' * 50 prints.color("RED", "Expected Firmware [%s]" % fw) print '-' * 50 logging.info("TEST FAIL Expected Firmware [%s]" % fw) sys.exit(1)