libcloud.common.ovh module

class libcloud.common.ovh.OvhConnection(user_id, *args, **kwargs)[source]

Bases: ConnectionUserAndKey

A connection to the Ovh API

Wraps SSL connections to the Ovh API, automagically injecting the parameters that the API needs for each request.

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

LOCATIONS = {'BHS1': {'country': 'CA', 'id': 'BHS1', 'name': 'Beauharnois, Quebec 1'}, 'BHS2': {'country': 'CA', 'id': 'BHS2', 'name': 'Beauharnois, Quebec 2'}, 'BHS3': {'country': 'CA', 'id': 'BHS3', 'name': 'Beauharnois, Quebec 3'}, 'BHS4': {'country': 'CA', 'id': 'BHS4', 'name': 'Beauharnois, Quebec 4'}, 'BHS5': {'country': 'CA', 'id': 'BHS5', 'name': 'Beauharnois, Quebec 5'}, 'BHS6': {'country': 'CA', 'id': 'BHS6', 'name': 'Beauharnois, Quebec 6'}, 'DC1': {'country': 'FR', 'id': 'DC1', 'name': 'Paris DC1'}, 'FRA1': {'country': 'DE', 'id': 'FRA1', 'name': 'Frankfurt 1'}, 'GRA1': {'country': 'FR', 'id': 'GRA1', 'name': 'Gravelines 1'}, 'GRA2': {'country': 'FR', 'id': 'GRA2', 'name': 'Gravelines 2'}, 'GSW': {'country': 'FR', 'id': 'GSW', 'name': 'Paris GSW'}, 'HIL1': {'country': 'US', 'id': 'HIL1', 'name': 'Hillsboro, Oregon 1'}, 'LON1': {'country': 'UK', 'id': 'LON1', 'name': 'London 1'}, 'P19': {'country': 'FR', 'id': 'P19', 'name': 'Paris P19'}, 'RBX1': {'country': 'FR', 'id': 'RBX1', 'name': 'Roubaix 1'}, 'RBX2': {'country': 'FR', 'id': 'RBX2', 'name': 'Roubaix 2'}, 'RBX3': {'country': 'FR', 'id': 'RBX3', 'name': 'Roubaix 3'}, 'RBX4': {'country': 'FR', 'id': 'RBX4', 'name': 'Roubaix 4'}, 'RBX5': {'country': 'FR', 'id': 'RBX5', 'name': 'Roubaix 5'}, 'RBX6': {'country': 'FR', 'id': 'RBX6', 'name': 'Roubaix 6'}, 'RBX7': {'country': 'FR', 'id': 'RBX7', 'name': 'Roubaix 7'}, 'SBG1': {'country': 'FR', 'id': 'SBG1', 'name': 'Strasbourg 1'}, 'SBG2': {'country': 'FR', 'id': 'SBG2', 'name': 'Strasbourg 2'}, 'SBG3': {'country': 'FR', 'id': 'SBG3', 'name': 'Strasbourg 3'}, 'SGP1': {'country': 'SG', 'id': 'SGP1', 'name': 'Singapore 1'}, 'SYD1': {'country': 'AU', 'id': 'SYD1', 'name': 'Sydney 1'}, 'VIN1': {'country': 'US', 'id': 'VIN1', 'name': 'Vint Hill, Virginia 1'}, 'WAW1': {'country': 'PL', 'id': 'WAW1', 'name': 'Warsaw 1'}}
add_default_headers(headers)[source]

Adds default headers (such as Authorization, X-Foo-Bar) to the passed headers

Should return a dictionary.

add_default_params(params)[source]

Adds default parameters (such as API key, version, etc.) to the passed params

Should return a dictionary.

allow_insecure = True
get_timestamp()[source]
host: str = 'api.ovh.com'
make_signature(method, action, params, data, timestamp)[source]
request(action, params=None, data=None, headers=None, method='GET', raw=False)[source]

Request a given action.

Basically a wrapper around the connection object’s request that does some helpful pre-processing.

Parameters:
  • action (str) – A path. This can include arguments. If included, any extra parameters are appended to the existing ones.

  • 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”.

  • raw (bool) – True to perform a “raw” request aka only send the headers and use the rawResponseCls class. This is used with storage API when uploading a file.

  • stream (bool) – True to return an iterator in Response.iter_content and allow streaming of the response data (for downloading large files)

  • retry_failed – True if failed requests should be retried. This argument can override module level constant and environment variable value on per-request basis.

Returns:

An Response instance.

Return type:

Response instance

request_consumer_key(user_id)[source]
request_path = '/1.0'
responseCls

alias of OvhResponse

timestamp = None
ua: List[str] = []
class libcloud.common.ovh.OvhResponse(response, connection)[source]

Bases: JsonResponse

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