libcloud.compute.drivers.azure module

Driver for Microsoft Azure Virtual Machines service.

http://azure.microsoft.com/en-us/services/virtual-machines/

class libcloud.compute.drivers.azure.AsynchronousOperationResult(request_id=None)[source]

Bases: WindowsAzureData

class libcloud.compute.drivers.azure.AttachedTo[source]

Bases: WindowsAzureData

class libcloud.compute.drivers.azure.AvailabilityResponse[source]

Bases: WindowsAzureData

class libcloud.compute.drivers.azure.AzureHTTPRequest[source]

Bases: object

class libcloud.compute.drivers.azure.AzureHTTPResponse(status, message, headers, body)[source]

Bases: object

class libcloud.compute.drivers.azure.AzureKeyPair(fingerprint='', path='')[source]

Bases: WindowsAzureData

class libcloud.compute.drivers.azure.AzureNodeDriver(subscription_id=None, key_file=None, **kwargs)[source]

Bases: NodeDriver

subscription_id contains the Azure subscription id in the form of GUID key_file contains the Azure X509 certificate in .pem form

NODE_STATE_MAP: Dict[str, NodeState] = {'BusyRole': NodeState.PENDING, 'CreatingRole': NodeState.PENDING, 'CreatingVM': NodeState.PENDING, 'CyclingRole': NodeState.TERMINATED, 'DeletingVM': NodeState.PENDING, 'FailedStartingRole': NodeState.TERMINATED, 'FailedStartingVM': NodeState.TERMINATED, 'Provisioning': NodeState.PENDING, 'ReadyRole': NodeState.RUNNING, 'RestartingRole': NodeState.REBOOTING, 'RoleStateUnknown': NodeState.UNKNOWN, 'StartingRole': NodeState.PENDING, 'StartingVM': NodeState.PENDING, 'StoppedDeallocated': NodeState.TERMINATED, 'StoppedVM': NodeState.STOPPED, 'StoppingRole': NodeState.PENDING, 'StoppingVM': NodeState.PENDING, 'UnresponsiveRole': NodeState.TERMINATED}
attach_volume()[source]

Attaches volume to node.

Parameters:
  • node (Node) – Node to attach volume to.

  • volume (StorageVolume) – Volume to attach.

  • device (str) – Where the device is exposed, e.g. ‘/dev/sdb’

Rytpe:

bool

connectionCls

alias of AzureServiceManagementConnection

create_node(name, size, image, ex_cloud_service_name, ex_storage_service_name=None, ex_new_deployment=False, ex_deployment_slot='Production', ex_deployment_name=None, ex_admin_user_id='azureuser', ex_custom_data=None, ex_virtual_network_name=None, ex_network_config=None, auth=None, **kwargs)[source]

Create Azure Virtual Machine

Reference: http://bit.ly/1fIsCb7 [www.windowsazure.com/en-us/documentation/]

We default to:

  • 3389/TCP - RDP - 1st Microsoft instance.

  • RANDOM/TCP - RDP - All succeeding Microsoft instances.

  • 22/TCP - SSH - 1st Linux instance

  • RANDOM/TCP - SSH - All succeeding Linux instances.

The above replicates the standard behavior of the Azure UI. You can retrieve the assigned ports to each instance by using the following private function:

_get_endpoint_ports(service_name) Returns public,private port key pair.

@inherits: NodeDriver.create_node

Parameters:
  • image (NodeImage) – The image to use when creating this node

  • size (NodeSize) – The size of the instance to create

  • ex_cloud_service_name (str) – Required. Name of the Azure Cloud Service.

  • ex_storage_service_name (str) – Optional: Name of the Azure Storage Service.

  • ex_new_deployment (boolean) – Optional. Tells azure to create a new deployment rather than add to an existing one.

  • ex_deployment_slot (str) – Optional: Valid values: production| staging. Defaults to production.

  • ex_deployment_name (str) – Optional. The name of the deployment. If this is not passed in we default to using the Cloud Service name.

  • ex_custom_data (str) – Optional script or other data which is injected into the VM when it’s beginning provisioned.

  • ex_admin_user_id (str) – Optional. Defaults to ‘azureuser’.

  • ex_virtual_network_name (str) – Optional. If this is not passed in no virtual network is used.

  • ex_network_config (ConfigurationSet) – Optional. The ConfigurationSet to use for network configuration

create_volume()[source]

Create a new volume.

Parameters:
  • size (int) – Size of volume in gigabytes (required)

  • name (str) – Name of the volume to be created

  • location (NodeLocation) – Which data center to create a volume in. If empty, undefined behavior will be selected. (optional)

  • snapshot (VolumeSnapshot) – Snapshot from which to create the new volume. (optional)

Returns:

The newly created volume.

Return type:

StorageVolume

create_volume_snapshot()[source]

Creates a snapshot of the storage volume.

Parameters:
  • volume (StorageVolume) – The StorageVolume to create a VolumeSnapshot from

  • name (str) – Name of created snapshot (optional)

Return type:

VolumeSnapshot

destroy_node(node, ex_cloud_service_name=None, ex_deployment_slot='Production')[source]

Remove Azure Virtual Machine

This removes the instance, but does not remove the disk. You will need to use destroy_volume. Azure sometimes has an issue where it will hold onto a blob lease for an extended amount of time.

Parameters:
  • ex_cloud_service_name (str) – Required. Name of the Azure Cloud Service.

  • ex_deployment_slot (str) – Optional: The name of the deployment slot. If this is not passed in we default to production.

destroy_volume()[source]

Destroys a storage volume.

Parameters:

volume (StorageVolume) – Volume to be destroyed

Return type:

bool

detach_volume()[source]

Detaches a volume from a node.

Parameters:

volume (StorageVolume) – Volume to be detached

Return type:

bool

ex_add_instance_endpoints(node, endpoints, ex_deployment_slot='Production')[source]
ex_create_cloud_service(name, location, description=None, extended_properties=None)[source]

Create an azure cloud service.

Parameters:
  • name (str) – Name of the service to create

  • location (str) – Standard azure location string

  • description (str) – Optional description

  • extended_properties (dict) – Optional extended_properties

Return type:

bool

ex_create_storage_service(name, location, description=None, affinity_group=None, extended_properties=None)[source]

Create an azure storage service.

Parameters:
  • name (str) – Name of the service to create

  • location (str) – Standard azure location string

  • description (str) – (Optional) Description of storage service.

  • affinity_group (str) – (Optional) Azure affinity group.

  • extended_properties (dict) – (Optional) Additional configuration options support by Azure.

Return type:

bool

ex_destroy_cloud_service(name)[source]

Delete an azure cloud service.

Parameters:

name (str) – Name of the cloud service to destroy.

Return type:

bool

ex_destroy_storage_service(name)[source]

Destroy storage service. Storage service must not have any active blobs. Sometimes Azure likes to hold onto volumes after they are deleted for an inordinate amount of time, so sleep before calling this method after volume deletion.

Parameters:

name (str) – Name of storage service.

Return type:

bool

ex_list_cloud_services()[source]
ex_set_instance_endpoints(node, endpoints, ex_deployment_slot='Production')[source]

For example:

endpoint = ConfigurationSetInputEndpoint(
    name='SSH',
    protocol='tcp',
    port=port,
    local_port='22',
    load_balanced_endpoint_set_name=None,
    enable_direct_server_return=False
)
{
    'name': 'SSH',
    'protocol': 'tcp',
    'port': port,
    'local_port': '22'
}
features: Dict[str, List[str]] = {'create_node': ['password']}
List of available features for a driver.
list_images(location=None)[source]

Lists all images

Return type:

list of NodeImage

list_locations()[source]

Lists all locations

Return type:

list of NodeLocation

list_nodes(ex_cloud_service_name)[source]

List all nodes

ex_cloud_service_name parameter is used to scope the request to a specific Cloud Service. This is a required parameter as nodes cannot exist outside of a Cloud Service nor be shared between a Cloud Service within Azure.

Parameters:

ex_cloud_service_name (str) – Cloud Service name

Return type:

list of Node

list_sizes()[source]

Lists all sizes

Return type:

list of NodeSize

list_volumes(node=None)[source]

Lists volumes of the disks in the image repository that are associated with the specified subscription.

Pass Node object to scope the list of volumes to a single instance.

Return type:

list of StorageVolume

name: str = 'Azure Virtual machines'
raise_for_response(response, valid_response)[source]
reboot_node(node, ex_cloud_service_name=None, ex_deployment_slot=None)[source]

Reboots a node.

ex_cloud_service_name parameter is used to scope the request to a specific Cloud Service. This is a required parameter as nodes cannot exist outside of a Cloud Service nor be shared between a Cloud Service within Azure.

Parameters:
  • ex_cloud_service_name (str) – Cloud Service name

  • ex_deployment_slot (str) – Options are “production” (default) or “Staging”. (Optional)

Return type:

bool

class service_location(is_affinity_group, service_location)

Bases: tuple

Create new instance of service_location(is_affinity_group, service_location)

is_affinity_group

Alias for field number 0

service_location

Alias for field number 1

type: Provider | str = 'azure'
website: str = 'http://azure.microsoft.com/en-us/services/virtual-machines/'
class libcloud.compute.drivers.azure.AzureNodeLocation(id, name, country, driver, available_services, virtual_machine_role_sizes)[source]

Bases: NodeLocation

Parameters:
  • id (str) – Location ID.

  • name (str) – Location name.

  • country (str) – Location country.

  • driver (NodeDriver) – Driver this location belongs to.

  • extra (dict) – Optional provided specific attributes associated with this location.

class libcloud.compute.drivers.azure.AzureXmlSerializer[source]

Bases: object

static add_role_to_xml(role_name, system_configuration_set, os_virtual_hard_disk, role_type, network_configuration_set, availability_set_name, data_virtual_hard_disks, vm_image_name, role_size)[source]
static capture_role_to_xml(post_capture_action, target_image_name, target_image_label, provisioning_configuration)[source]
static certificate_file_to_xml(data, certificate_format, password)[source]
static change_deployment_to_xml(configuration, treat_warnings_as_error, mode, extended_properties)[source]
static create_affinity_group_to_xml(name, label, description, location)[source]
static create_deployment_to_xml(name, package_url, label, configuration, start_deployment, treat_warnings_as_error, extended_properties)[source]
static create_hosted_service_to_xml(service_name, label, description, location, affinity_group=None, extended_properties=None)[source]
static create_storage_service_input_to_xml(service_name, description, label, affinity_group, location, geo_replication_enabled, extended_properties)[source]
static create_storage_service_to_xml(service_name, label, description, location, affinity_group, extended_properties=None)[source]
static data_to_xml(data, xml=None)[source]
Creates an xml fragment from the specified data.
data: Array of tuples, where first: xml element name

second: xml element text third: conversion function

static data_virtual_hard_disk_to_xml(host_caching, disk_label, disk_name, lun, logical_disk_size_in_gb, media_link, source_media_link)[source]
static disk_to_xml(has_operating_system, label, media_link, name, os)[source]
static doc_from_data(document_element_name, data, extended_properties=None)[source]
static doc_from_xml(document_element_name, inner_xml=None)[source]

Wraps the specified xml in an xml root element with default azure namespaces

static extended_properties_dict_to_xml_fragment(extended_properties)[source]
static linux_configuration_to_xml(configuration, xml)[source]
static network_configuration_to_xml(configuration, xml)[source]
static os_image_to_xml(label, media_link, name, os)[source]
static regenerate_keys_to_xml(key_type)[source]
static restart_role_operation_to_xml()[source]
static role_to_xml(availability_set_name, data_virtual_hard_disks, network_configuration_set, os_virtual_hard_disk, vm_image_name, role_name, role_size, role_type, system_configuration_set, xml)[source]
static rollback_upgrade_to_xml(mode, force)[source]
static shutdown_role_operation_to_xml()[source]
static start_role_operation_to_xml()[source]
static subscription_certificate_to_xml(public_key, thumbprint, data)[source]
static swap_deployment_to_xml(production, source_deployment)[source]
static update_affinity_group_to_xml(label, description)[source]
static update_deployment_status_to_xml(status)[source]
static update_hosted_service_to_xml(label, description, extended_properties)[source]
static update_role_to_xml(role_name, os_virtual_hard_disk, role_type, network_configuration_set, availability_set_name, data_virtual_hard_disks, vm_image_name, role_size)[source]
static update_storage_service_input_to_xml(description, label, geo_replication_enabled, extended_properties)[source]
static upgrade_deployment_to_xml(mode, package_url, configuration, label, role_to_upgrade, force, extended_properties)[source]
static virtual_machine_deployment_to_xml(deployment_name, deployment_slot, label, role_name, system_configuration_set, os_virtual_hard_disk, role_type, network_configuration_set, availability_set_name, data_virtual_hard_disks, role_size, virtual_network_name, vm_image_name)[source]
static walk_upgrade_domain_to_xml(upgrade_domain)[source]
static windows_configuration_to_xml(configuration, xml)[source]
class libcloud.compute.drivers.azure.CertificateSetting(thumbprint='', store_name='', store_location='')[source]

Bases: WindowsAzureData

Initializes a certificate setting.

thumbprint:

Specifies the thumbprint of the certificate to be provisioned. The thumbprint must specify an existing service certificate.

store_name:

Specifies the name of the certificate store from which retrieve certificate.

store_location:

Specifies the target certificate store location on the virtual machine The only supported value is LocalMachine.

class libcloud.compute.drivers.azure.ComputeCapability[source]

Bases: WindowsAzureData

class libcloud.compute.drivers.azure.ConfigurationSet[source]

Bases: WindowsAzureData

class libcloud.compute.drivers.azure.ConfigurationSetInputEndpoint(name='', protocol='', port='', local_port='', load_balanced_endpoint_set_name='', enable_direct_server_return=False)[source]

Bases: WindowsAzureData

class libcloud.compute.drivers.azure.ConfigurationSetInputEndpoints[source]

Bases: WindowsAzureDataTypedList

list_type

alias of ConfigurationSetInputEndpoint

xml_element_name = 'InputEndpoint'
class libcloud.compute.drivers.azure.ConfigurationSets[source]

Bases: WindowsAzureDataTypedList

list_type

alias of ConfigurationSet

class libcloud.compute.drivers.azure.Credentials[source]

Bases: WindowsAzureData

class libcloud.compute.drivers.azure.Deployment[source]

Bases: WindowsAzureData

class libcloud.compute.drivers.azure.Deployments[source]

Bases: WindowsAzureDataTypedList

list_type

alias of Deployment

class libcloud.compute.drivers.azure.Disk[source]

Bases: WindowsAzureData

class libcloud.compute.drivers.azure.Disks[source]

Bases: WindowsAzureDataTypedList

list_type

alias of Disk

class libcloud.compute.drivers.azure.DomainJoin[source]

Bases: WindowsAzureData

class libcloud.compute.drivers.azure.HostedService[source]

Bases: WindowsAzureData, ReprMixin

class libcloud.compute.drivers.azure.HostedServiceProperties[source]

Bases: WindowsAzureData

class libcloud.compute.drivers.azure.HostedServices[source]

Bases: WindowsAzureDataTypedList, ReprMixin

list_type

alias of HostedService

class libcloud.compute.drivers.azure.Images[source]

Bases: WindowsAzureDataTypedList

list_type

alias of OSImage

class libcloud.compute.drivers.azure.InputEndpoint[source]

Bases: WindowsAzureData

class libcloud.compute.drivers.azure.InputEndpoints[source]

Bases: WindowsAzureDataTypedList

list_type

alias of InputEndpoint

class libcloud.compute.drivers.azure.InstanceEndpoint[source]

Bases: WindowsAzureData

class libcloud.compute.drivers.azure.InstanceEndpoints[source]

Bases: WindowsAzureDataTypedList

list_type

alias of InstanceEndpoint

class libcloud.compute.drivers.azure.KeyPairs[source]

Bases: WindowsAzureDataTypedList

list_type

alias of AzureKeyPair

class libcloud.compute.drivers.azure.LinuxConfigurationSet(host_name=None, user_name=None, user_password=None, disable_ssh_password_authentication=None, custom_data=None)[source]

Bases: WindowsAzureData

class libcloud.compute.drivers.azure.LoadBalancerProbe[source]

Bases: WindowsAzureData

class libcloud.compute.drivers.azure.Location[source]

Bases: WindowsAzureData

class libcloud.compute.drivers.azure.Locations[source]

Bases: WindowsAzureDataTypedList

list_type

alias of Location

class libcloud.compute.drivers.azure.OSDiskConfiguration[source]

Bases: WindowsAzureData

class libcloud.compute.drivers.azure.OSImage[source]

Bases: WindowsAzureData

class libcloud.compute.drivers.azure.OSVirtualHardDisk(source_image_name=None, media_link=None, host_caching=None, disk_label=None, disk_name=None)[source]

Bases: WindowsAzureData

class libcloud.compute.drivers.azure.OperatingSystem[source]

Bases: WindowsAzureData

class libcloud.compute.drivers.azure.OperatingSystemFamilies[source]

Bases: WindowsAzureDataTypedList

list_type

alias of OperatingSystemFamily

class libcloud.compute.drivers.azure.OperatingSystemFamily[source]

Bases: WindowsAzureData

class libcloud.compute.drivers.azure.OperatingSystems[source]

Bases: WindowsAzureDataTypedList

list_type

alias of OperatingSystem

class libcloud.compute.drivers.azure.Operation[source]

Bases: WindowsAzureData

class libcloud.compute.drivers.azure.OperationError[source]

Bases: WindowsAzureData

class libcloud.compute.drivers.azure.PersistentVMDowntimeInfo[source]

Bases: WindowsAzureData

class libcloud.compute.drivers.azure.PublicKey(fingerprint='', path='')[source]

Bases: WindowsAzureData

class libcloud.compute.drivers.azure.PublicKeys[source]

Bases: WindowsAzureDataTypedList

list_type

alias of PublicKey

class libcloud.compute.drivers.azure.Role[source]

Bases: WindowsAzureData

class libcloud.compute.drivers.azure.RoleInstance[source]

Bases: WindowsAzureData

class libcloud.compute.drivers.azure.RoleInstanceList[source]

Bases: WindowsAzureDataTypedList

list_type

alias of RoleInstance

class libcloud.compute.drivers.azure.RoleList[source]

Bases: WindowsAzureDataTypedList

list_type

alias of Role

class libcloud.compute.drivers.azure.SSH[source]

Bases: WindowsAzureData

class libcloud.compute.drivers.azure.ScalarListOf(list_type, xml_element_name)[source]

Bases: list

A list of scalar types which carries with it the type that’s expected to go in it along with its xml element name. Used for deserializaion and construction of the lists

class libcloud.compute.drivers.azure.StoredCertificateSettings[source]

Bases: WindowsAzureDataTypedList

list_type

alias of CertificateSetting

class libcloud.compute.drivers.azure.Subscription[source]

Bases: WindowsAzureData

class libcloud.compute.drivers.azure.SubscriptionCertificate[source]

Bases: WindowsAzureData

class libcloud.compute.drivers.azure.SubscriptionCertificates[source]

Bases: WindowsAzureDataTypedList

list_type

alias of SubscriptionCertificate

class libcloud.compute.drivers.azure.UpgradeStatus[source]

Bases: WindowsAzureData

class libcloud.compute.drivers.azure.VMImage[source]

Bases: WindowsAzureData

class libcloud.compute.drivers.azure.VMImages[source]

Bases: WindowsAzureDataTypedList

list_type

alias of VMImage

class libcloud.compute.drivers.azure.VirtualIP[source]

Bases: WindowsAzureData

class libcloud.compute.drivers.azure.VirtualIPs[source]

Bases: WindowsAzureDataTypedList

list_type

alias of VirtualIP

class libcloud.compute.drivers.azure.VirtualMachinesRoleSizes[source]

Bases: WindowsAzureData

libcloud.compute.drivers.azure.WINDOWS_SERVER_REGEX = re.compile('Win|SQL|SharePoint|Visual|Dynamics|DynGP|BizTalk')

Sizes must be hardcoded because Microsoft doesn’t provide an API to fetch them From http://msdn.microsoft.com/en-us/library/windowsazure/dn197896.aspx

Prices are for Linux instances in East US data center. To see what pricing will actually be, visit: http://azure.microsoft.com/en-gb/pricing/details/virtual-machines/

class libcloud.compute.drivers.azure.WindowsAzureData[source]

Bases: object

This is the base of data class. It is only used to check whether it is instance or not.

class libcloud.compute.drivers.azure.WindowsAzureDataTypedList[source]

Bases: WindowsAzureData

list_type = None
xml_element_name = None
class libcloud.compute.drivers.azure.WindowsConfigurationSet(computer_name=None, admin_password=None, reset_password_on_first_logon=None, enable_automatic_updates=None, time_zone=None, admin_user_name=None)[source]

Bases: WindowsAzureData