# 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)

  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: 200>, <HTTPStatus.CREATED: 201>, <HTTPStatus.ACCEPTED: 202>, <HTTPStatus.NO_CONTENT: 204>)
  REDIRECT_RESPONSE_CODES = (<HTTPStatus.MOVED_PERMANENTLY: 301>, <HTTPStatus.FOUND: 302>, <HTTPStatus.SEE_OTHER: 303>, <HTTPStatus.USE_PROXY: 305>, <HTTPStatus.TEMPORARY_REDIRECT: 307>)
  configure_from_url(url)

    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)

    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

  get_connect_kwargs()
  get_connection_type()

    Returns the proper connection type

  get_status_code(response)

    Returns the integer status code from the response, which can be either a Webob.Response (used in testing) or httplib.Response

  make_auth_plugin(creds, insecure)

    Returns an instantiated authentication plugin.

class glance.common.client.HTTPSClientAuthConnection(host, port, key_file, cert_file, ca_file, timeout=None, insecure=False)

  Bases: `http.client.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()

    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.

glance.common.client.handle_redirects(func)

  Wrap the _do_request function to handle HTTP redirects.

glance.common.client.handle_unauthenticated(func)

  Wrap a function to re-authenticate and retry.

this page last updated: 2026-03-19 02:17:34

Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.

found an error? report a bug