def wait_for_state_change(self, wait_time=1200): """ Wait for the iLO UpdateService to a move to terminal state. :param options: command line options :type options: list. :param wait_time: time to wait on upload :type wait_time: int. """ total_time = 0 spinner = ['|', '/', '-', '\\'] state = "" sys.stdout.write("Waiting for iLO UpdateService to finish processing the component\n") while total_time < wait_time: state, _ = self.get_update_service_state() if state == "ERROR": return False elif state != "COMPLETED" and state != "IDLE" and state != "COMPLETE": # Lets try again after 8 seconds count = 0 # fancy spinner while count <= 32: sys.stdout.write('Updating: %s\r' % spinner[count % 4]) time.sleep(0.25) count += 1 total_time += 8 else: break if total_time > wait_time: raise TimeOutError("UpdateService in " + state + " state for " + str(wait_time) + "s") return True
def run(self, line): """ Main firmware update worker function :param line: string of arguments passed in :type line: str. """ try: (options, args) = self.rdmc.rdmc_parse_arglist(self, line) except (InvalidCommandLineErrorOPTS, SystemExit): if ("-h" in line) or ("--help" in line): return ReturnCodes.SUCCESS else: raise InvalidCommandLineErrorOPTS("") if args: raise InvalidCommandLineError( 'fwintegritycheck command takes no arguments') self.firmwareintegritycheckvalidation(options) if self.rdmc.app.typepath.defs.isgen9: raise IncompatibleiLOVersionError('fwintegritycheck command is ' \ 'only available on iLO 5.') licenseres = self.rdmc.app.select(selector='HpeiLOLicense.') try: licenseres = licenseres[0] except: pass if not licenseres.dict['LicenseFeatures']['FWScan']: raise IloLicenseError( "This command is not available with this iLO license.") select = self.rdmc.app.typepath.defs.hpilofirmwareupdatetype results = self.rdmc.app.select(selector=select) try: results = results[0] except: pass bodydict = results.resp.dict path = bodydict['Oem']['Hpe']['Actions']\ ['#HpeiLOUpdateServiceExt.StartFirmwareIntegrityCheck']['target'] self.rdmc.app.post_handler(path, {}) if options.results: results_string = "Awaiting results of firmware integrity check..." self.rdmc.ui.printer(results_string) polling = 50 found = False while polling > 0: if not polling % 5: self.rdmc.ui.printer('.') get_results = self.rdmc.app.get_handler(bodydict['@odata.id'],\ service=True, silent=True) if get_results: curr_time = strptime(bodydict['Oem']['Hpe']\ ['CurrentTime'], "%Y-%m-%dT%H:%M:%SZ") scan_time = strptime(get_results.dict['Oem']['Hpe']\ ['FirmwareIntegrity']['LastScanTime'], "%Y-%m-%dT%H:%M:%SZ") if scan_time > curr_time: self.rdmc.ui.printer('\nScan Result: %s\n' % get_results.dict\ ['Oem']['Hpe']['FirmwareIntegrity']['LastScanResult']) found = True break polling -= 1 time.sleep(1) if not found: self.rdmc.ui.error( '\nPolling timed out before scan completed.\n') TimeOutError("") self.cmdbase.logout_routine(self, options) #Return code return ReturnCodes.SUCCESS