pycloudlib.azure.cloud module¶
Azure Cloud type.
-
class
pycloudlib.azure.cloud.
Azure
(tag: str, timestamp_suffix: bool = True, config_file: Union[pathlib.Path, _io.StringIO, None] = None, *, client_id: Optional[str] = None, client_secret: Optional[str] = None, subscription_id: Optional[str] = None, tenant_id: Optional[str] = None, region: Optional[str] = None, username: Optional[str] = None)[source]¶ Bases:
pycloudlib.cloud.BaseCloud
Azure Cloud Class.
-
__init__
(tag: str, timestamp_suffix: bool = True, config_file: Union[pathlib.Path, _io.StringIO, None] = None, *, client_id: Optional[str] = None, client_secret: Optional[str] = None, subscription_id: Optional[str] = None, tenant_id: Optional[str] = None, region: Optional[str] = None, username: Optional[str] = None)[source]¶ Initialize the connection to Azure.
Azure will try to read user credentials form the /home/$USER/.azure folder. However, we can overwrite those credentials with the provided id parameters.
Parameters: - tag – string used to name and tag resources with
- timestamp_suffix – bool set True to append a timestamp suffix to the tag
- config_file – path to pycloudlib configuration file
- client_id – user’s client id
- client_secret – user’s client secret access key
- subscription_id – user’s subscription id key
- tenant_id – user’s tenant id key
- region – The region where the instance will be created
-
create_key_pair
(key_name)[source]¶ Create a pair of ssh keys.
This method creates an a pair of ssh keys in the class resource group.
Parameters: key_name – string, The name of the ssh resource.
-
daily_image
(release: str, *, image_type: pycloudlib.cloud.ImageType = <ImageType.GENERIC: 'generic'>, **kwargs)[source]¶ Find the image info for the latest daily image for a given release.
Parameters: release – string, Ubuntu release to look for. Returns: A string representing an Ubuntu image
-
delete_image
(image_id, **kwargs)[source]¶ Delete an image from Azure.
Parameters: image_id – string, The id of the image to be deleted
-
delete_key
(key_name)[source]¶ Delete a ssh key from the class resource group.
Parameters: key_name – string, The name of the ssh resource.
-
get_instance
(instance_id, search_all=False)[source]¶ Get an instance by id.
Parameters: - instance_id – string, The instance name to search by
- search_all – boolean, Flag that indicates that if we should search for the instance in the entire reach of the subsctription id. If false, we will search only in the resource group created by this instance.
Returns: An instance object to use to manipulate the instance further.
-
image_serial
(image_id)[source]¶ Find the image serial of the latest daily image for a particular release.
Parameters: image_id – string, Ubuntu image id Returns: string, serial of latest image
-
launch
(image_id, instance_type='Standard_DS1_v2', user_data=None, wait=True, name=None, inbound_ports=None, username=None, **kwargs)[source]¶ Launch virtual machine on Azure.
Parameters: - image_id – string, Ubuntu image to use
- user_data – string, user-data to pass to virtual machine
- wait – boolean, wait for instance to come up
- name – string, optional name to give the vm when launching. Default results in a name of <tag>-vm
- inbound_ports – List of strings, optional inbound ports to enable in the instance.
- kwargs – dict, other named arguments to provide to virtual_machines.begin_create_or_update
Returns: Azure Instance object
Raises: ValueError on invalid image_id
-
released_image
(release)[source]¶ Get the released image.
Parameters: release – string, Ubuntu release to look for Returns: string, id of latest image
-
snapshot
(instance, clean=True, delete_provisioned_user=True, **kwargs)[source]¶ Snapshot an instance and generate an image from it.
Parameters: - instance – Instance to snapshot
- clean – Run instance clean method before taking snapshot
- delete_provisioned_user – Deletes the last provisioned user
- kwargs – Other named arguments specific to this implementation
Returns: An image id string
-