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.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 createdlocation (
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 fromname (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_create_cloud_service(name, location, description=None, extended_properties=None)[source]
Create an azure cloud service.
- Parameters:
name (
str
) – Name of the service to createlocation (
str
) – Standard azure location stringdescription (
str
) – Optional descriptionextended_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 createlocation (
str
) – Standard azure location stringdescription (
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_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.
libcloud.compute.base.NodeDriver.create_node()
ssh_key: Supports
NodeAuthSSHKey
as an authentication method for nodes.password: Supports
NodeAuthPassword
as an authentication method for nodes.generates_password: Returns a password attribute on the Node object returned from creation.
- 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
ofNode
- 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
ofStorageVolume
- 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 nameex_deployment_slot (
str
) – Options are “production” (default) or “Staging”. (Optional)
- Return type:
bool
- 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 change_deployment_to_xml(configuration, treat_warnings_as_error, mode, extended_properties)[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 doc_from_xml(document_element_name, inner_xml=None)[source]
Wraps the specified xml in an xml root element with default azure namespaces
- 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 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]
- 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
- 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
- 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
- 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
- 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
- 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
- class libcloud.compute.drivers.azure.VirtualIP[source]
Bases:
WindowsAzureData
- class libcloud.compute.drivers.azure.VirtualIPs[source]
Bases:
WindowsAzureDataTypedList
- 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