How to use the redfish.rest_client function in redfish

To help you get started, we’ve selected a few redfish examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github HewlettPackard / python-ilorest-library-old / src / redfish / ris / tpdefs.py View on Github external
: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/", is_redfish=True)
            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"]
github HewlettPackard / python-ilorest-library-old / examples / Rest / _restobject.py View on Github external
def __init__(self, host, login_account, login_password):
        self.rest_client = rest_client(base_url=host, \
                          username=login_account, password=login_password, \
                          default_prefix="/rest/v1")
        self.rest_client.login(auth=AuthMethod.SESSION)
        self.SYSTEMS_RESOURCES = self.ex1_get_resource_directory()
        self.MESSAGE_REGISTRIES = self.ex2_get_base_registry()
github HewlettPackard / chef-ilorest-cookbook / files / _restobject.py View on Github external
def __init__(self, host, login_account, login_password):
        self.rest_client = rest_client(base_url=host, \
                          username=login_account, password=login_password, \
                          default_prefix="/rest/v1")
        self.rest_client.login(auth=AuthMethod.SESSION)
        self.SYSTEMS_RESOURCES = self.ex1_get_resource_directory()
        self.MESSAGE_REGISTRIES = self.ex2_get_base_registry()
github HewlettPackard / python-ilorest-library-old / examples / quickstart.py View on Github external
import sys
import redfish

# When running on the server locally use the following commented values
# iLO_host = "blobstore://."
# iLO_account = "None"
# iLO_password = "None"

# 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 = "password"

# Create a REST object
REST_OBJ = redfish.rest_client(base_url=iLO_host,username=login_account, \
                      password=login_password, default_prefix='/rest/v1')

# Login into the server and create a session
REST_OBJ.login(auth="session")

# Do a GET on a given path
response = REST_OBJ.get("/rest/v1/systems/1", None)

# Print out the response
sys.stdout.write("%s\n" % response)

# Logout of the current session
REST_OBJ.logout()