Package pywbem :: Module cim_http

[frames] | no frames]

# Module cim_http

source code

Send HTTP/HTTPS requests to a WBEM server.

This module does not know anything about the fact that the data being transferred in the HTTP request and response is CIM-XML. It is up to the caller to provide CIM-XML formatted input data and interpret the result data as CIM-XML.

Classes
| Error Exception base class for catching any HTTP transport related errors.
| ConnectionError This exception is raised when there is a problem with the connection to the server.
| AuthError This exception is raised when an authentication error (401) occurs.
| TimeoutError This exception is raised when the client times out.
| HTTPTimeout HTTP timeout class that is a context manager (for use by 'with' statement).

Functions

wbem_request(url, data, creds, headers=`[``]`, debug=0, x509=None, verify_callback=None, ca_certs=None, no_verification=False, timeout=None) Send an HTTP or HTTPS request to a WBEM server and return the response. | source code

get_object_header(obj) Return the HTTP header required to make a CIM operation request using the given object. | source code

Function Details

### wbem_request(url, data, creds, headers=`[``]`, debug=0, x509=None, verify_callback=None, ca_certs=None, no_verification=False, timeout=None)

source code

Send an HTTP or HTTPS request to a WBEM server and return the response.

This function uses Python's built-in httplib module.

Parameters:
  - `url` (`unicode` or UTF-8 encoded `str`) - URL of the WBEM server (e.g. `"https://10.11.12.13:6988"`). For details, see the `url` parameter of WBEMConnection.__init__.
  - `data` (`unicode` or UTF-8 encoded `str`) - The CIM-XML formatted data to be sent as a request to the WBEM server.
  - `creds` - Credentials for authenticating with the WBEM server. For details, see the `creds` parameter of WBEMConnection.__init__.
  - `headers` (list of `unicode` or UTF-8 encoded `str`) - List of HTTP header fields to be added to the request, in addition to the standard header fields such as `Content-type`, `Content-length`, and `Authorization`.
  - `debug` (`bool`) - Boolean indicating whether to create debug information. Not currently used.
  - `x509` - Used for HTTPS with certificates. For details, see the `x509` parameter of WBEMConnection.__init__.
  - `verify_callback` - Used for HTTPS with certificates. For details, see the `verify_callback` parameter of WBEMConnection.__init__.
  - `ca_certs` - Used for HTTPS with certificates. For details, see the `ca_certs` parameter of WBEMConnection.__init__.
  - `no_verification` - Used for HTTPS with certificates. For details, see the `no_verification` parameter of WBEMConnection.__init__.
  - `timeout` (number) - Timeout in seconds, for requests sent to the server. If the server did not respond within the timeout duration, the socket for the connection will be closed, causing a TimeoutError to be raised. A value of `None` means there is no timeout. A value of `0` means the timeout is very short, and does not really make any sense. Note that not all situations can be handled within this timeout, so for some issues, this method may take longer to raise an exception.
Returns:
  The CIM-XML formatted response data from the WBEM server, as a `unicode` object.
Raises:
  - `AuthError`
  - `ConnectionError`
  - `TimeoutError`

### get_object_header(obj)

source code

Return the HTTP header required to make a CIM operation request using the given object. Return None if the object does not need to have a header.