libcloud.common.azure module
- class libcloud.common.azure.AzureActiveDirectoryConnection(key, secret, secure=True, host=None, port=None, tenant_id=None, identity=None, cloud_environment='default', **kwargs)[source]
Bases:
ConnectionUserAndKeyRepresents a single connection to Azure using Azure AD for Blob
Initialize user_id and key; set secure to an
intbased on passed value.- API_VERSION = '2017-11-09'
- add_default_headers(headers)[source]
Adds default headers (such as Authorization, X-Foo-Bar) to the passed headers
Should return a dictionary.
- conn_class
alias of
LibcloudConnection
- connect(**kwargs)[source]
Establish a connection with the API server.
- Parameters:
host (
str) – Optional host to override our defaultport (
int) – Optional port to override our default
- Returns:
A connection
- driver
alias of
AzureBaseDriver
- name = 'Azure AD Auth'
- rawResponseCls
alias of
AzureRawResponse
- request(action, params=None, data=None, headers=None, method='GET', raw=False, stream=False, json=None, retry_failed=None, *kwargs)[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 emptydict.data (
unicode) – A body of data to send with the request.headers (
dict) – Extra headers to add to the request None, leave as an emptydict.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
Responseinstance.- Return type:
Responseinstance
- responseCls
alias of
AzureResponse
- class libcloud.common.azure.AzureBaseDriver(key, secret=None, secure=True, host=None, port=None, api_version=None, region=None, **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
- name = 'Microsoft Azure Service Management API'
- class libcloud.common.azure.AzureConnection(user_id, key, secure=True, host=None, port=None, url=None, timeout=None, proxy_url=None, backoff=None, retry_delay=None)[source]
Bases:
ConnectionUserAndKeyRepresents a single connection to Azure
Initialize user_id and key; set secure to an
intbased on passed value.- API_VERSION = '2012-02-12'
- add_default_params(params)[source]
Adds default parameters (such as API key, version, etc.) to the passed params
Should return a dictionary.
- pre_connect_hook(params, headers)[source]
A hook which is called before connecting to the remote server. This hook can perform a final manipulation on the params, headers and url parameters.
- Parameters:
params (
dict) – Request parameters.headers (
dict) – Request headers.
- rawResponseCls
alias of
AzureRawResponse
- responseCls
alias of
AzureResponse
- class libcloud.common.azure.AzureRawResponse(connection, response=None)[source]
Bases:
RawResponse- Parameters:
connection (
Connection) – Parent connection object.
- class libcloud.common.azure.AzureResponse(response, connection)[source]
Bases:
XmlResponse- Parameters:
response (
httplib.HTTPResponse) – HTTP response object. (optional)connection (
Connection) – Parent connection object.
- parse_body()[source]
Parse response body.
Override in a provider’s subclass.
- Returns:
Parsed body.
- Return type:
str
- parse_error(msg=None)[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:
TrueorFalse
- valid_response_codes = [<HTTPStatus.NOT_FOUND: 404>, <HTTPStatus.CONFLICT: 409>, <HTTPStatus.BAD_REQUEST: 400>, <HTTPStatus.TEMPORARY_REDIRECT: 307>, <HTTPStatus.PARTIAL_CONTENT: 206>]
- class libcloud.common.azure.AzureServiceManagementConnection(subscription_id, key_file, *args, **kwargs)[source]
Bases:
CertificateConnectionAuthentication class for “Service Account” authentication.
Check to see if PyCrypto is available, and convert key file path into a key string if the key is in a file.
- Parameters:
subscription_id (
str) – Azure subscription ID.key_file (
str) – The PEM file used to authenticate with the service.
- add_default_headers(headers)[source]
@inherits:
Connection.add_default_headersTODO: move to constant..
- driver
alias of
AzureBaseDriver
- keyfile = ''
- name = 'Azure Service Management API Connection'
- rawResponseCls
alias of
AzureRawResponse
- responseCls
alias of
AzureResponse