lib/publiccloud/provider.pm

METHODS

init

Needs provider specific credentials, e.g. key_id, key_secret, region.

conv_openqa_tf_name

Does the conversion between PUBLIC_CLOUD_PROVIDER and Terraform providers name.

find_img

Retrieves the image-id by given image name.

upload_image

Upload a image to the CSP. Required parameter is the location of the image file. UEFI images are supported by giving the optional parameter type = 'uefi'. This is only supported on GCE at the momment.

Retrieves the image-id after upload or die.

img_proof

  img_proof(instance_type => <string>, cleanup => <bool>, tests => <string>, timeout => <seconds>, results_dir => <string>, distro => <string>);

Call img-proof tool and retrieves a hashref as result. Do not die if img-proof call exit with error. $result_hash = { instance => <publiccloud:instance>, # instance object logfile => <string>, # the pytest logfile results => <string>, # json results file tests => <int>, # total number of tests pass => <int>, # successful tests skip => <int>, # skipped tests fail => <int>, # number of failed tests error => <int>, # number of errors };

parse_img_proof_output

Parse the output from img-proof command and retrieves instance-id, ip and logfile names.

create_ssh_key

Creates an ssh keypair in a given file path by $args{ssh_private_key_file}

run_img_proof

called by childs within img-proof function

get_image_id

    get_image_id([$img_url]);

Retrieves the CSP image id if exists, otherwise exception is thrown. The given $img_url is optional, if not present it retrieves from PUBLIC_CLOUD_IMAGE_LOCATION.

create_instance

Creates an instance on the public cloud provider. Retrieves a publiccloud::instance object.

image defines the image_id to create the instance. instance_type defines the flavor of the instance. If not specified, it will load it from PUBLIC_CLOUD_INSTANCE_TYPE.

create_instances

Creates multiple instances on the public cloud provider. Retrieves an array of publiccloud::instance objects.

image defines the image_id to create the instance. instance_type defines the flavor of the instance. If not specified, it will load it from PUBLIC_CLOUD_INSTANCE_TYPE.

on_terraform_apply_timeout

This method can be overwritten by child classes to do some special cleanup task if 'apply' fails. Terraform was already terminated using the QUIT signal and openqa has a valid shell. The working directory is always the terraform directory, where the statefile and the *.tf is placed.

on_terraform_destroy_timeout

This method can be overwritten by child classes to do some special cleanup task if 'destroy' fails. Terraform was already terminated using the QUIT signal and openqa has a valid shell. The working directory is always the terraform directory, where the statefile and the *.tf is placed.

terraform_apply

Calls terraform tool and applies the corresponding configuration .tf file

terraform_destroy

Destroys the current terraform deployment

__vault_login

Login to vault using _SECRET_PUBLIC_CLOUD_REST_USER and _SECRET_PUBLIC_CLOUD_REST_PW. The retrieved VAULT_TOKEN is stored in this instance and used for further publiccloud::provider::vault_api() calls.

vault_login

Wrapper arround <$self-vault_login()>> to have retry capability.

__vault_api

Invoke a vault API call. It use _SECRET_PUBLIC_CLOUD_REST_URL as base url. Depending on the method (get|post) you can pass additional data as json.

vault_api

Wrapper around <$self-vault_api()>> to get retry capability.

vault_get_secrets

  my $data = $csp->vault_get_secrets('/azure/creds/openqa-role')

This is a wrapper around vault_api() to retrieve secrets from aws, gce or azure secret engine. It prepend '/v1/' + $NAMESPACE to the given path before sending the request. It stores lease_id and also adjust the token-live-time.

vault_revoke

Revoke a previous retrieved credential

cleanup

This method is called called after each test on failure or success.

stop_instance

This function implements a provider specifc stop call for a given instance.

start_instance

This function implements a provider specifc start call for a given instance.