glance.common.client module¶
- class glance.common.client.BaseClient(host, port=None, timeout=None, use_ssl=False, auth_token=None, creds=None, doc_root=None, key_file=None, cert_file=None, ca_file=None, insecure=False, configure_via_auth=True)[source]¶
Bases:
object
A base client class
- DEFAULT_CA_FILE_PATH = '/etc/ssl/certs/ca-certificates.crt:/etc/pki/tls/certs/ca-bundle.crt:/etc/ssl/ca-bundle.pem:/etc/ssl/cert.pem'¶
- DEFAULT_DOC_ROOT = None¶
- DEFAULT_PORT = 80¶
- OK_RESPONSE_CODES = (HTTPStatus.OK, HTTPStatus.CREATED, HTTPStatus.ACCEPTED, HTTPStatus.NO_CONTENT)¶
- REDIRECT_RESPONSE_CODES = (HTTPStatus.MOVED_PERMANENTLY, HTTPStatus.FOUND, HTTPStatus.SEE_OTHER, HTTPStatus.USE_PROXY, HTTPStatus.TEMPORARY_REDIRECT)¶
- configure_from_url(url)[source]¶
Setups the connection based on the given url.
The form is:
<http|https>://<host>:port/doc_root
- do_request(method, action, body=None, headers=None, params=None)[source]¶
Make a request, returning an HTTP response object.
- Parameters:
method – HTTP verb (GET, POST, PUT, etc.)
action – Requested path to append to self.doc_root
body – Data to send in the body of the request
headers – Headers to send with the request
params – Key/value pairs to use in query string
- Returns:
HTTP response object
- class glance.common.client.HTTPSClientAuthConnection(host, port, key_file, cert_file, ca_file, timeout=None, insecure=False)[source]¶
Bases:
HTTPSConnection
Class to make a HTTPS connection, with support for full client-based SSL Authentication
- :see http://code.activestate.com/recipes/
577548-https-httplib-client-connection-with-certificate-v/
- connect()[source]¶
Connect to a host on a given (SSL) port. If ca_file is pointing somewhere, use it to check Server Certificate.
Redefined/copied and extended from httplib.py:1105 (Python 2.6.x). This is needed to pass cert_reqs=ssl.CERT_REQUIRED as parameter to ssl.wrap_socket(), which forces SSL to check server certificate against our client certificate.