def __init__(self, host, login_account, login_password): self.redfish_client = redfish_client(base_url=host, \ username=login_account, password=login_password, \ default_prefix="/redfish/v1") self.redfish_client.login(auth=AuthMethod.SESSION) self.SYSTEMS_RESOURCES = ex1_get_resource_directory(self) self.MESSAGE_REGISTRIES = ex2_get_base_registry(self)
def __init__(self, host, login_account, login_password): try: self.redfish_client = redfish_client(base_url=host, \ username=login_account, password=login_password, \ default_prefix="/redfish/v1") except: raise self.redfish_client.login(auth=AuthMethod.SESSION) self.SYSTEMS_RESOURCES = self.ex1_get_resource_directory() self.MESSAGE_REGISTRIES = self.ex2_get_base_registry()
def getGen(self, url=None, logger=None): """Function designed to verify the servers platform :param url: The URL to perform the request on. :type url: str. :param logger: The logger handler. :type logger: str. """ self.url = url try: redfishclient = redfish_client(base_url=self.url, \ username=None, password=None, default_prefix="/redfish/v1") response = redfishclient.get(path="/redfish/v1") except Exception as excp: try: restclient = rest_client(base_url=self.url, username=None, \ password=None, default_prefix="/rest/v1") response = restclient.get(path="/rest/v1") except Exception as excep: if logger: if not type(excep) == type(excp): logger.error(u"Gen get rest error:" + str(excep) + u"\n") raise excp self.ilogen = None try: self.ilogen = response.dict["Oem"]["Hp"]["Manager"][0]\ ["ManagerType"] except: self.ilogen = response.dict["Oem"]["Hpe"]["Manager"][0]\ ["ManagerType"] if self.ilogen is None: raise UnableToObtainIloVersionError( "Unable to find the iloversion") self.ilogen = self.ilogen.split(' ')[-1] self.flagiften = False if int(self.ilogen) >= 5: self.flagiften = True if self.flagiften: self.defs = definevalstenplus() else: self.defs = definevalsNine()
def getgen(self, url=None, logger=None): """Function designed to verify the servers platform :param url: The URL to perform the request on. :type url: str. :param logger: The logger handler. :type logger: str. """ self.url = url try: redfishclient = redfish_client(base_url=self.url, \ username=None, password=None, default_prefix="/redfish/v1") response = redfishclient.get(path="/redfish/v1") except Exception as excp: try: restclient = rest_client(base_url=self.url, username=None, \ password=None, default_prefix="/rest/v1") response = restclient.get(path="/rest/v1") except Exception as excep: logger = logger if not logger else LOGGER if type(excep) != type(excp): logger.error(u"Gen get rest error:"+str(excep)+u"\n") raise excp self.ilogen = None try: self.ilogen = response.dict["Oem"]["Hp"]["Manager"][0]\ ["ManagerType"] except: self.ilogen = response.dict["Oem"]["Hpe"]["Manager"][0]\ ["ManagerType"] if self.ilogen is None: raise UnableToObtainIloVersionError("Unable to find the iloversion") self.ilogen = self.ilogen.split(' ')[-1] self.flagiften = False if int(self.ilogen) >= 5: self.flagiften = True if self.flagiften: self.defs = Definevalstenplus() else: self.defs = DefinevalsNine()
import sys import ilorest # When running on the server locally use the following commented values # iLO_host = "blobstore://." # iLO_account = "None" # iLO_password = "******" # When running remotely connect using the iLO address, iLO account name, # and password to send https requests iLO_host = "https://10.0.0.100" login_account = "admin" login_password = "******" ## Create a REDFISH object REDFISH_OBJ = ilorest.redfish_client(base_url=iLO_host,username=login_account, \ password=login_password, default_prefix='/redfish/v1') # Login into the server and create a session REDFISH_OBJ.login(auth="session") # Do a GET on a given path response = REDFISH_OBJ.get("/redfish/v1/systems/1", None) # Print out the response sys.stdout.write("%s\n" % response) # Logout of the current session REDFISH_OBJ.logout()