lib/publiccloud/azure.pm

az_arch Provides architecture tag x64 or Arm64 compatible with Azure syntax, based on '*ARCH' job settings

az_sku Centralized sku definition and default value, based on PUBLIC_CLOUD_AZURE_SKU

Call: az_sku(<default>);
    when PUBLIC_CLOUD_AZURE_SKU undefined, the default from input is used:
    when <default> is undefined too, hardcoded string used; i.e. az_sku(), default = 'gen2'; 

decode_azure_json

my $json_obj = decode_azure_json($str);

Helper function to decode json string, retrieved from az, into a json object. Due to https://github.com/Azure/azure-cli/issues/9903 we need to strip all color codes from that string first.

resource_group_exist

$self->resource_group_exist();

Checks if the Azure resource group exists and returns boolean

img_blob_exists

Finds the image blob in Azure

* Requires image name parameter, e.g. 'SLES15-SP5-BYOS.aarch64-1.0.0-Azure-Build1.68.xz'
* Returns 0 if the image blob  has not been found or 1 if the image blob has ben found.

get_image_version

Finds the image version in Azure

Returns the image version id or undef if not found.

Return example: '/subscriptions/SMTHNG-XYZ-123/resourceGroups/openqa-upload/providers/Microsoft.Compute/galleries/test_image_gallery/images/SLE-15-SP5-AZURE-BYOS-X64-GEN2/versions/1.64.100'

find_img

my $image_id = $self->find_img($name);

Requires the image name: * The variable may also be URL and the name will be extracted from it. * The name is then used to search for the image blob.

Does the following steps: 1) Checks if the image blob exists 2) Checks if the image version exists

* If the image definition does not exist the image version does not either.

Return example: '/subscriptions/SMTHNG-XYZ-123/resourceGroups/openqa-upload/providers/Microsoft.Compute/galleries/test_image_gallery/images/SLE-15-SP5-AZURE-BYOS-X64-GEN2/versions/1.64.100' If either blob or the image version were not found then the default empty list or undef in the scalar context is returned.

generate_img_version Build the image Version for upload to the Compute Gallery. The expected format is 'X.Y.Z'. We assemble the img version by the PUBLIC_CLOUD_BUILD (Format: 'X.Y') and the digits of PUBLIC_CLOUD_KIWI_BUILD, formatted as integer

generate_azure_image_definition

my $definition = $self->generate_azure_image_definition();

Generates the Azure Image name from the job settings. If PUBLIC_CLOUD_AZURE_IMAGE_DEFINITION defined, its content is returned; otherwise, image definition name based on distri, version, flavor and SKU returned.

Note: Image definitions shall be distinct names and can only serve one architecture!

Example: 'SLE-MICRO-5.4-BYOS-AZURE-X86_64-GEN2'

B<return> a string with the image full name distri-version-flavor-arch-sku

get_blob_name

Calculate the image (blob) name
from the file name used in SUSE download server (usually PUBLIC_CLOUD_IMAGE_LOCATION)

B<return> a string with the image name
FILE - filename, usually extracted from PUBLIC_CLOUD_IMAGE_LOCATION

get_blob_uri

Calculate the image URI in the Azure Blob Server
from the file name used in SUSE download server (usually PUBLIC_CLOUD_IMAGE_LOCATION)

PUBLIC_CLOUD_STORAGE_ACCOUNT setting is used to compose the url

B<return> a string with the image uri on the blob server
FILE - filename, usually extracted from PUBLIC_CLOUD_IMAGE_LOCATION

upload_img

1) Create resources 2) Upload the image blob 3) Create image definition 4) Create new image version for that definition. Use the link to the uploaded blob to create this version

my $parsed_id = $self->parse_instance_id($instance); say $parsed_id->{vm_name}; say $parsed_id->{resource_group};

Extract resource group and vm name from full instance id which looks like /subscriptions/c011786b-59d7-4817-880c-7cd8a6ca4b19/resourceGroups/openqa-suse-de-1ec3f5a05b7c0712/providers/Microsoft.Compute/virtualMachines/openqa-suse-de-1ec3f5a05b7c0712

cleanup This method is called called after each test on failure or success to revoke the credentials