pycloudlib.azure.instance module

Azure instance.

class pycloudlib.azure.instance.AzureInstance(key_pair, client, instance, network_client, *, username: str | None = None, get_boot_diagnostics: bool = False, status: VMInstanceStatus = VMInstanceStatus.ACTIVE)[source]

Bases: BaseInstance

Azure backed instance.

__init__(key_pair, client, instance, network_client, *, username: str | None = None, get_boot_diagnostics: bool = False, status: VMInstanceStatus = VMInstanceStatus.ACTIVE)[source]

Set up instance.

Parameters:
  • key_pair – SSH key object

  • client – Azure compute management client

  • instance – created azure instance object

  • username – username to use when connecting via SSH

add_network_interface(**kwargs) str[source]

Add network interface to instance.

Creates NIC and adds to the VM instance.

NOTE: It will deallocate the virtual machine, add the NIC, then start the virtual machine.

Returns the private ip address of the new NIC.

console_log() str | None[source]

Return the instance console log.

deallocate()[source]

De-allocates the VM. Releases the resources to modify VM.

delete(wait=True) List[Exception][source]

Delete instance.

generalize()[source]

Set the OS state of the instance to generalized.

property id

Return instance id.

property image_id

Return the image_id from which this instance was created.

property ip

Return IP address of instance.

property location: str

Return instance location.

property name

Return instance name.

property offer

Return instance sku.

remove_network_interface(ip_address: str)[source]

Remove nic from running instance.

Args: ip_address: private ip address of the NIC

shutdown(wait=True, **kwargs)[source]

Shutdown the instance.

Parameters:

wait – wait for the instance shutdown

property sku

Return instance sku.

start(wait=True)[source]

Start the instance.

Parameters:

wait – wait for the instance to start.

property status: VMInstanceStatus

Return VM instance status.

wait_for_delete()[source]

Wait for instance to be deleted.

wait_for_stop(**kwargs)[source]

Wait for instance stop.

class pycloudlib.azure.instance.BootDiagnostics(console_log_url, logs)

Bases: tuple

console_log_url

Alias for field number 0

logs

Alias for field number 1

class pycloudlib.azure.instance.VMInstanceStatus(value)[source]

Bases: Enum

Represents VM Instance state during its lifecycle.

ACTIVE = 2
DELETED = 3
FAILED_PROVISION = 1
STOPPED = 4