genvid.toolbox.AzureImageAPI

class genvid.toolbox.AzureImageAPI(clusters: genvid.toolbox.clusters.Clusters)

Bases: object

Class that contains the business logic for manipulations with source game images in Azure.

NAME = 'AzureImageAPI'
DESCRIPTION = 'Business logic for manipulations with source game images in Azure.'

Shared Image Gallery name to use by default if none provided

DEFAULT_RESOURCE_GROUP_NAME = 'Genvid'

Resource group to use by default in none provided

DEFAULT_VHD_STORAGE_ACCOUNT_NAME = 'genvidtechpublic'

Storage account name where vhd files are located.

MAX_CLUSTER_ID_LENGTH = 5

Maximum length of cluster id prefix

MAX_AZURE_RESOURCE_NAME_LENGTH = 15

Maximum length of cluster id prefix

CLUSTER_ID_SUFFIX = 'img'

Suffix added to the setup cluster. The save cluster will use this suffix + ‘save’

create_images(module: str = None, resource_group: str = None, gallery_name: str = None, storage_account_name: str = None, container_name: str = None, location: str = None, timeout: float = 120, shared_gallery_image_version: str = None, vhd_account_name: str = 'genvidtechpublic', image_source_version: str = None, keep_intermediate_resources: bool = False) → bool

Create azure images from vhd.

It copies vhd from genvid subscription to customer subscription and create image from it in a shared image gallery

Parameters:
  • resource_group – Name of resource group.
  • module – Terraform Module.
  • gallery_name – Shared image gallery name.
  • storage_account_name – Storage account to be created.
  • container_name – Container name to be created.
  • location – Azure location where the resources will be created.
  • timeout – The timeout in minutes.
  • image_source_version – Suffix used for wingame/server image url
  • keep_intermediate_resources – Keep intermediate image and blobs if True
save(cluster_id: str, module: str = None, plan: bool = False, timeout: float = 120, tfvars: str = '', version_suffix: str = None, shared_gallery_image_prefix: str = None)

Save Windows VM to a versioned image in a Shared Image Gallery

Creates an image from a VM generated using setup(). The necessary parameters are resolved from the cluster of the setup command (named after the cluster_id parameter appended with ‘img’). Meaning the cluster started by the setup command has to be up. Another cluster is generated for the purpose of saving the VM into an image.

Parameters:
  • cluster_id – Cluster name. Should be the same one used with setup().
  • module – Optional. Set it to use a Terraform module different than the one used by default.
  • plan – Optional. Set to True to only resolve the Terraform plan for creating the image without running it.
  • timeout – Optional. Set it to use a timeout is minutes different than the one used by default.
  • tfvars – Optional. Set it to a file path containing a JSON to override the Terraform variables default values.
  • version_suffix – Optional. Set it to append a string to the Image resource create in the process. It doesn’t affect the Image Version registered in the Shared Image Gallery.
  • shared_gallery_image_prefix – Optional. Set it to change the default prefix used for the Image Definition where the image will be registered.
clean(cluster_id: str, force: bool = False) → bool

Clean the clusters made to configure the game VM and save it.

This method will remove from Bastion the clusters created by the setup() and save() methods. Also, the temporary resources that were created in the process on Azure will be removed.

Parameters:
  • cluster_id – Cluster name. Should be the same one used with setup() and save().
  • force – Optional. Set to True to force the removal of the cluster create with setup() even if there is a problem with the Terraform.
force_clean(cluster_id: str)

Force clean the cluster from bastion.

setup(cluster_id: str, module: str = None, plan: bool = False, tfvars: str = '', timeout: float = 120, shared_gallery_image_version: str = None, location: str = None, shared_gallery_resource_group_name: str = None, gallery_name: str = None) → bool

Start Windows VM from an image in the Shared Image Gallery imported from Genvidtech with create_images().

Start the Windows VM to allow for drivers and configurations to be done by the user. The VM can after be saved back to an image using save().

Parameters:
  • cluster_id – Cluster name.
  • module – Optional. Set it to use a Terraform module different than the one used by default.
  • plan – Optional. Set to True to only resolve the Terraform plan for creating the image without running it.
  • tfvars – Optional. Set it to a file path containing a JSON to override the Terraform variables default values.
  • timeout – Optional. Set it to use a timeout is minutes different than the one used by default.
  • shared_gallery_image_version – Optional. Will default on the version of the SDK being used. Used to select which base image to use from the Azure Shared Image Gallery.
  • location – Optional. Azure location where the resources will be created. It has to be the same one used with create_images() to import the base images.
  • shared_gallery_resource_group_name – Optional. Azure Resource group containing the Shared Image Gallery with the base image to select to start the VM.
  • gallery_name – Shared image gallery name. Optional. Specify what Shared Image Gallery contains the base image needed to start the VM.
add_ip_address_to_firewall(public_ips, storage_account_name: str)

Add Public IP’s to list to allow access in Firewall and virtual networks of azure storage account.

Parameters:public_ips – Lists of List IP’s to be added.
add_external_ip_to_azure(storage_account_name: str)

Add your external IP to azure firewall settings.

add_cluster_id_suffix(cluster_id: str) → str
class azure_storage.AzureImageAPI

Implementation of genvid.toolbox.AzureImageAPI