genvid.toolbox.AzureImageAPI
- class genvid.toolbox.AzureImageAPI(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.'
- DEFAULT_GALLERY_NAME = 'SDKgallery'
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: Optional[str] = None, resource_group: Optional[str] = None, gallery_name: Optional[str] = None, storage_account_name: Optional[str] = None, container_name: Optional[str] = None, location: Optional[str] = None, timeout: float = 120, shared_gallery_image_version: Optional[str] = None, vhd_account_name: str = 'genvidtechpublic', image_source_version: Optional[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: Optional[str] = None, plan: bool = False, timeout: float = 120, tfvars: str = '', version_suffix: Optional[str] = None, shared_gallery_image_prefix: Optional[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()
andsave()
methods. Also, the temporary resources that were created in the process on Azure will be removed.
- setup(cluster_id: str, module: Optional[str] = None, plan: bool = False, tfvars: str = '', timeout: float = 120, shared_gallery_image_version: Optional[str] = None, location: Optional[str] = None, shared_gallery_resource_group_name: Optional[str] = None, gallery_name: Optional[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.
- class azure_storage.AzureImageAPI
Implementation of
genvid.toolbox.AzureImageAPI