def run(self, line): """ Main firmware update worker function :param line: string of arguments passed in :type line: str. """ try: (options, args) = self._parse_arglist(line) except: if ("-h" in line) or ("--help" in line): return ReturnCodes.SUCCESS else: raise InvalidCommandLineErrorOPTS("") if args: raise InvalidCommandLineError('fwintegritycheck command takes no ' \ 'arguments') if options.encode and options.user and options.password: options.user = Encryption.decode_credentials(options.user) options.password = Encryption.decode_credentials(options.password) self.firmwareintegritycheckvalidation(options) if self.typepath.defs.isgen9: raise IncompatibleiLOVersionError('fwintegritycheck command is ' \ 'only available on iLO 5.') licenseres = self._rdmc.app.filter('HpeiLOLicense.', None, None) 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.typepath.defs.hpilofirmwareupdatetype results = self._rdmc.app.filter(select, None, None) try: results = results[0] except: pass bodydict = results.resp.dict path = bodydict['Oem']['Hpe']['Actions']\ ['#HpeiLOUpdateServiceExt.StartFirmwareIntegrityCheck']['target'] self._rdmc.app.post_handler(path, {}) return ReturnCodes.SUCCESS
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
def run(self, line): """ Main iscsi configuration 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 len(args) > 2: raise InvalidCommandLineError("Invalid number of parameters. " \ "virtualmedia command takes a maximum of 2 parameters.") else: self.virtualmediavalidation(options) resp = self.rdmc.app.get_handler('/rest/v1/Managers/1/VirtualMedia/1', silent=True) if not resp.status == 200: raise IloLicenseError('') self.auxcommands['select'].run("VirtualMedia.") ilover = self.rdmc.app.getiloversion() if self.rdmc.app.monolith.is_redfish: isredfish = True paths = self.auxcommands['get'].getworkerfunction("@odata.id", options, results=True, uselist=False) ids = self.auxcommands['get'].getworkerfunction("Id", options, results=True, uselist=False) paths = {ind: path for ind, path in enumerate(paths)} ids = {ind: id for ind, id in enumerate(ids)} for path in paths: paths[path] = paths[path]['@odata.id'] else: isredfish = False paths = self.auxcommands['get'].getworkerfunction("links/self/href", options, \ results=True, uselist=False) ids = self.auxcommands['get'].getworkerfunction("Id", options, results=True, uselist=False) paths = {ind: path for ind, path in enumerate(paths)} ids = {ind: id for ind, id in enumerate(ids)} for path in paths: paths[path] = paths[path]['links']['self']['href'] # To keep indexes consistent between versions if not list(ids.keys())[0] == list(list(ids.values())[0].values())[0]: finalpaths = {} for path in paths: finalpaths.update( {int(list(ids[path].values())[0]): paths[path]}) paths = finalpaths if options.removevm: self.vmremovehelper(args, options, paths, isredfish, ilover) elif len(args) == 2: self.vminserthelper(args, options, paths, isredfish, ilover) elif options.bootnextreset: self.vmbootnextreset(args, paths) elif not args: self.vmdefaulthelper(options, paths) else: raise InvalidCommandLineError("Invalid parameter(s). Please run"\ " 'help virtualmedia' for parameters.") self.cmdbase.logout_routine(self, options) #Return code return ReturnCodes.SUCCESS
def run(self, line): """ Main iscsi configuration worker function :param line: string of arguments passed in :type line: str. """ try: (options, args) = self._parse_arglist(line) except: if ("-h" in line) or ("--help" in line): return ReturnCodes.SUCCESS else: raise InvalidCommandLineErrorOPTS("") if len(args) > 2: raise InvalidCommandLineError("Invalid number of parameters. " \ "virtualmedia command takes a maximum of 2 parameters.") else: self.virtualmediavalidation(options) resp = self._rdmc.app.get_handler(\ '/rest/v1/Managers/1/VirtualMedia/1', response=True,\ silent=True) if not resp.status == 200: raise IloLicenseError('') self.selobj.run("VirtualMedia.") ilover = self._rdmc.app.getiloversion() if self._rdmc.app.current_client.monolith.is_redfish: isredfish = True paths = self.getobj.getworkerfunction("@odata.id", options, \ "@odata.id", results=True, multivals=True, uselist=False) ids = self.getobj.getworkerfunction("Id", options, \ "Id", results=True, multivals=True, uselist=False) for path in paths: paths[path] = paths[path]['@odata.id'] else: isredfish = False paths = self.getobj.getworkerfunction(\ "links", options, "links/self/href", \ newargs=['links', 'self', 'href'],\ results=True, multivals=True, uselist=False) ids = self.getobj.getworkerfunction("Id", options, \ "Id", results=True, multivals=True, uselist=False) for path in paths: paths[path] = paths[path]['links']['self']['href'] # To keep indexes consistent between versions if not ids.keys()[0] == ids.values()[0].values()[0]: finalpaths = {} for path in paths: finalpaths.update({int(ids[path].values()[0]): paths[path]}) paths = finalpaths if options.removevm: self.vmremovehelper(args, options, paths, isredfish, ilover) elif len(args) == 2: self.vminserthelper(args, options, paths, isredfish, ilover) elif options.bootnextreset: self.vmbootnextreset(args, paths) elif not args: self.vmdefaulthelper(options, paths) else: raise InvalidCommandLineError("Invalid parameter(s). Please run"\ " 'help virtualmedia' for parameters.") return ReturnCodes.SUCCESS