Reference Documentation¶
redfish.rest.v1¶
Direct module for working with Redfish/REST technology.
-
class
redfish.rest.v1.AuthMethod¶ Bases:
objectAUTH Method class
BASIC, SESSION, CERTIFICATE variables translate to their string counterparts basic, session, certificate.
-
exception
redfish.rest.v1.JsonDecodingError¶ Bases:
exceptions.ExceptionRaised when there is an error in json data.
-
class
redfish.rest.v1.LegacyRestClient(**client_kwargs)¶ Bases:
redfish.rest.v1.RestClientClass for a Legacy REST client instance. Instantiates appropriate Rest object based on existing configuration. Use this to retrieve a pre-configured Legacy Rest Class.
Basic arguments include (These can be omitted for most local connections):
- base_url: The IP or Hostname of the server to perform operations on.
- username: The username of the account to login with.
- password: The username of the account to login with.
For full description of the arguments allowed see
RestClient
-
class
redfish.rest.v1.RedfishClient(**client_kwargs)¶ Bases:
redfish.rest.v1.RestClientClass for a Redfish client instance. Instantiates appropriate Redfish object based on existing configuration. Use this to retrieve a pre-configured Redfish Class.
Basic arguments include (These can be omitted for most local connections):
- base_url: The IP or Hostname of the server to perform operations on. None for local.
- username: The username of the account to login with.
- password: The username of the account to login with.
For full description of the arguments allowed see
RestClient
-
class
redfish.rest.v1.RestClient(default_prefix='/redfish/v1/', is_redfish=True, username=None, password=None, auth=None, **client_kwargs)¶ Bases:
redfish.rest.v1.RestClientBaseREST client with Redfish and LegacyRest support built on top.
Parameters: - default_prefix (str) – The root of the REST API, either /redfish/v1/ or /rest/v1.
- is_redfish (bool) – Flag to force redfish conformance, even on LegacyRest clients.
- username (str) – The username of the account to login with.
- password (str) – The password of the account to login with.
- auth (str or
AuthMethodclass variable.) – The authentication type to force. - **client_kwargs – Arguments to create a
RestClientBaseinstance.
-
base_url¶ The connection’s URL to make calls against
-
basic_auth¶ The Client’s basic auth header, if any.
-
login(auth='session')¶ Login to a Redfish or LegacyRest server. If auth is not supplied login will intelligently choose the authentication mode based on the arguments passed. Basic authentication MUST be specified with auth.
Parameters: auth (str or AuthMethodclass variable) – The auth type to login with.
-
login_url¶ The login URI from the root response. This is where we post the credentials for a login.
-
logout()¶ Logout of session.
YOU MUST CALL THIS WHEN YOU ARE DONE TO FREE UP SESSIONS
-
password¶ The password, if any. Once a login function has been called the credentials are removed from memory for security and this will return None.
-
proxy¶ The connection’s proxy, if any.
-
session_key¶ The Client’s session key, if any.
-
session_location¶ The session URI. Used for deleting the session when we logout.
-
username¶ The username, if any. Once a login function has been called the credentials are removed from memory for security and this will return None.
-
class
redfish.rest.v1.RestClientBase(biospassword=None, **client_kwargs)¶ Bases:
objectBase REST client. Each RestClientBase has a connection object built by parsing the client_kwargs. This connection is used for communicating remotely or locally.
Parameters: - biospassword (str) – The iLO Gen9 bios password. See
bios_password() - **client_kwargs – Arguments to pass to the client argument. For possible values see
redfish.rest.connections.Blobstore2Connectionfor a local connection orredfish.rest.connections.HttpConnectionfor remote connection.
-
bios_password¶ Property for the biospassword. Only required on Gen9 iLO 4 when RBSU bios password is set and modifying bios settings
-
delete(path, headers=None)¶ Perform a DELETE request
Parameters: - path (str) – The URI path.
- args (dict) – Any query to add to the URI. (Can also be directly added to the URI)
Returns: A
redfish.rest.containers.RestResponseobject
-
get(path, args=None, headers=None)¶ Perform a GET request
Parameters: - path (str) – The URI path.
- args (dict) – Any query to add to the URI. (Can also be directly added to the URI)
- headers (dict) – Any extra headers to add to the request.
Returns: A
redfish.rest.containers.RestResponseobject
-
head(path, headers=None)¶ Perform a HEAD request
Parameters: - path (str) – The URI path.
- headers (dict) – Any extra headers to add to the request.
Returns: A
redfish.rest.containers.RestResponseobject
-
patch(path, body, args=None, headers=None)¶ Perform a PATCH request
Parameters: - path (str) – The URI path.
- body (dict) – The body to pass with the request.
- args (dict) – Any query to add to the URI. (Can also be directly added to the URI)
- headers (dict) – Any extra headers to add to the request.
Returns: A
redfish.rest.containers.RestResponseobject
-
post(path, body, args=None, headers=None)¶ Perform a POST request
Parameters: - path (str) – The URI path.
- body (dict) – The body to pass with the request.
- args (dict) – Any query to add to the URI. (Can also be directly added to the URI)
- headers (dict) – Any extra headers to add to the request.
Returns: A
redfish.rest.containers.RestResponseobject
-
put(path, body, args=None, headers=None)¶ Perform a PUT request
Parameters: - path (str) – The URI path.
- body (dict) – The body to pass with the request.
- args (dict) – Any query to add to the URI. (Can also be directly added to the URI)
- headers (dict) – Any extra headers to add to the request.
Returns: A
redfish.rest.containers.RestResponseobject
- biospassword (str) – The iLO Gen9 bios password. See
-
exception
redfish.rest.v1.ServerDownOrUnreachableError¶ Bases:
exceptions.ExceptionRaised when server is unreachable.
redfish.rest.connections¶
All Connections for interacting with REST.
-
class
redfish.rest.connections.Blobstore2Connection(**conn_kwargs)¶ Bases:
objectA connection for communicating locally with HPE servers
Parameters: **conn_kwargs – Arguments to pass to the connection initialization. Possible arguments for **conn_kwargs include:
Username: The username to login with Password: The password to login with -
cert_login()¶ Login using a certificate NOT IMPLEMENTED
-
rest_request(path='', method='GET', args=None, body=None, headers=None)¶ Rest request for blobstore client
Parameters: - path (str) – The URI path to perform the operation on.
- method (str) – method to perform on the path.
- args (dict) – Any query to add to the URI. (Can also be directly added to the URI)
- body (dict) – body payload to include in the request if needed.
- headers (dict) – Any extra headers to add to the request.
Returns: A
redfish.rest.containers.RestResponseobject
-
-
exception
redfish.rest.connections.ChifDriverMissingOrNotFound¶ Bases:
exceptions.ExceptionRaised when CHIF driver is missing or not found.
-
exception
redfish.rest.connections.DecompressResponseError¶ Bases:
exceptions.ExceptionRaised when decompressing the response failed.
-
class
redfish.rest.connections.HttpConnection(base_url, **client_kwargs)¶ Bases:
objectHTTP connection capable of authenticating with HTTPS and Http/Socks Proxies
Parameters: - base_url (str) – The URL to make HTTP calls against
- **client_kwargs – Arguments to pass to the connection initialization. These are passed to a urllib3 PoolManager. All arguments that can be passed to a PoolManager are valid arguments.
-
cert_login()¶ Login using a certificate NOT IMPLEMENTED
-
proxy¶ The proxy, if any.
-
rest_request(path, method='GET', args=None, body=None, headers=None)¶ Format and do HTTP Rest request
Parameters: - path (str) – The URI path to perform the operation on.
- method (str) – method to perform on the path.
- args (dict) – Any query to add to the URI. (Can also be directly added to the URI)
- body (dict) – body payload to include in the request if needed.
- headers (dict) – Any extra headers to add to the request.
Returns: A
redfish.rest.containers.RestResponseobject
-
exception
redfish.rest.connections.InvalidCredentialsError¶ Bases:
exceptions.ExceptionRaised when invalid credentials have been provided.
-
exception
redfish.rest.connections.RetriesExhaustedError¶ Bases:
exceptions.ExceptionRaised when retry attempts have been exhausted.
-
exception
redfish.rest.connections.SecurityStateError¶ Bases:
exceptions.ExceptionRaised when there is a strict security state without authentication.
redfish.rest.containers¶
Containers used for REST requests and responses.
-
class
redfish.rest.containers.RestRequest(path, method='GET', data='', url=None)¶ Bases:
objectHolder for Request information
Parameters: - path (str) – The URI path.
- method (str) – method to be implemented
- data (dict) – body payload for the rest call
-
body¶ The body to pass along with the request, if any.
-
method¶ The method to implement.
-
path¶ The path the request is made against.
-
class
redfish.rest.containers.RestResponse(rest_request, http_response)¶ Bases:
objectReturned by Rest requests
Parameters: - rest_request (
RestRequestobject) – Holder for request information - http_response (
HTTPResponseobject) – Response from HTTP
-
dict¶ The response body data as an dict
-
getheader(name)¶ Case-insensitive search for an individual header
Parameters: name (str) – The header name to retrieve. Returns: returns a header from HTTP response or None if not found.
-
getheaders()¶ Get all headers included in the response.
-
loaddict(newdict)¶ Property for setting JSON data. Used during initialization.
Parameters: newdict (str) – The string data to set as JSON data.
-
obj¶ The response body data as an object
-
ori¶ The original response body data
-
path¶ The path the request was made against.
-
read¶ The response body, attempted to be translated into json, else is a string.
-
request¶ The saved http request the response was generated by.
-
session_key¶ The saved session key for the connection.
-
session_location¶ The saved session location, used for logging out.
-
status¶ The status code of the request.
- rest_request (