libcloud.common.gridscale module

Common settings and connection objects for gridscale

class libcloud.common.gridscale.GridscaleBaseDriver(user_id, key, **kwargs)[source]

Bases: BaseDriver

Parameters:
  • key (str) – API key or username to be used (required)

  • secret (str) – Secret password to be used (required)

  • secure (bool) – Whether to use HTTPS or HTTP. Note: Some providers only support HTTPS, and it is on by default.

  • host (str) – Override hostname used for connections.

  • port (int) – Override port used for connections.

  • api_version (str) – Optional API version. Only used by drivers which support multiple API versions.

  • region (str) – Optional driver region. Only used by drivers which support multiple regions.

Return type:

None

connectionCls

alias of GridscaleConnection

name = 'gridscale'
website = 'https://gridscale.io'
class libcloud.common.gridscale.GridscaleConnection(user_id, key, secure=True, host=None, port=None, url=None, timeout=None, proxy_url=None, backoff=None, retry_delay=None)[source]

Bases: ConnectionUserAndKey, PollingConnection

gridscale connection class Authentication using uuid and api token

Initialize user_id and key; set secure to an int based on passed value.

add_default_headers(headers)[source]

add parameters that are necessary for each request to be successful

Parameters:

headers (str) – Authentication token

Returns:

None

async_request(*poargs, **kwargs)[source]

Perform an ‘async’ request to the specified path. Keep in mind that this function is blocking and ‘async’ in this case means that the hit URL only returns a job ID which is the periodically polled until the job has completed.

This function works like this:

  • Perform a request to the specified path. Response should contain a ‘job_id’.

  • Returned ‘job_id’ is then used to construct a URL which is used for retrieving job status. Constructed URL is then periodically polled until the response indicates that the job has completed or the timeout of ‘self.timeout’ seconds has been reached.

Parameters:
  • action (str) – A path

  • params (dict) – Optional mapping of additional parameters to send. If None, leave as an empty dict.

  • data (unicode) – A body of data to send with the request.

  • headers (dict) – Extra headers to add to the request None, leave as an empty dict.

  • method (str) – An HTTP method such as “GET” or “POST”.

  • context (dict) – Context dictionary which is passed to the functions which construct initial and poll URL.

Returns:

An Response instance.

Return type:

Response instance

encode_data(data)[source]

Encode body data.

Override in a provider’s subclass.

get_poll_request_kwargs(response, context, request_kwargs)[source]

Return keyword arguments which are passed to the request() method when polling for the job status.

Parameters:
  • response (dict) – Response object returned by poll request.

  • request_kwargs – Kwargs previously used to initiate the poll request.

:return dict Keyword arguments

has_completed(response)[source]

Return job completion status.

Parameters:

response (HTTPResponse) – Response object returned by poll request.

:return bool True if the job has completed, False otherwise.

host: str = 'api.gridscale.io'
responseCls

alias of GridscaleResponse

class libcloud.common.gridscale.GridscaleResponse(response, connection)[source]

Bases: JsonResponse

Gridscale API Response

Parameters:
  • response (httplib.HTTPResponse) – HTTP response object. (optional)

  • connection (Connection) – Parent connection object.

parse_error()[source]

Parse the error messages.

Override in a provider’s subclass.

Returns:

Parsed error.

Return type:

str

success()[source]

Determine if our request was successful.

The meaning of this can be arbitrary; did we receive OK status? Did the node get created? Were we authenticated?

Return type:

bool

Returns:

True or False

valid_response_codes = [<HTTPStatus.OK: 200>, <HTTPStatus.ACCEPTED: 202>, <HTTPStatus.NO_CONTENT: 204>]