lib/sles4sap/sap_deployment_automation_framework/deployment_connector.pm

SYNOPSIS

This library contains various functions that help finding and connecting openQA job to the correct deployment VM. Deployment VM is recognized from other VMs by being tagged with deployment_id tag. Deployment ID is an unique identifier which is an OpenQA job ID of a job that created this VM. In single machine test Deployment ID equals test ID. This is not always true in case of multi-machine jobs. Deployment ID might be an ID of the parent job which executed the deployment itself.

Example: Job: 123456 - deployment module - created deployer VM tagged with "deployment_id=123456", Job: 123457 (child of 123456) - some test module Deployment ID returned from both jobs: 123456 - because it matches with existing VM tagged with "deployment_id=123456"

check_ssh_availability

check_ssh_availability($deployer_ip_addr [, ssh_port=>42 ,$wait_started=>'true', wait_timeout=>'42']);

Checks if deployer VM is running and listening on ssh port. Returns found state. Optionally function can wait till VM reaches requested state until timeout. Function dies only with internal errors, VM status should be evaluated and handled by caller.

deployer_ip_addr: Deployer VM IP address

wait_started: Probe SSH port in loop untill it is available or wait_timeoout is reached.

wait_timeout: Time in sec to stop probing SSH port.

ssh_port: Specify custom SSH port number. Default: 22

get_deployer_ip

get_deployer_ip(deployer_resource_group=>$deployer_resource_group, deployer_vm_name=>$deployer_vm_name);

Returns first public IP of deployer VM that is reachable and can be used for SDAF deployment connection.

deployer_resource_group: Deployer resource group. Default: get_required_var('SDAF_DEPLOYER_RESOURCE_GROUP')

deployer_vm_name: Deployer VM resource name

get_deployer_vm_name

get_deployer_vm_name(deployer_resource_group=>$deployer_resource_group, deployment_id=>'123456');

Returns deployer VM name which is tagged with deployment_id specified in parameter. This means that the VM was used to deploy the infrastructure under this ID and contains whole SDAF setup. Function returns VM name or undef if no VM was found. Function dies if there is more than one VM found, because two VM's must not have same ID.

deployer_resource_group: Deployer resource group. Default: get_required_var('SDAF_DEPLOYER_RESOURCE_GROUP')

deployment_id: Deployment ID

get_parent_ids

get_parent_ids();

Returns ARRAYREF of all parent job IDs acquired from current job data.

find_deployment_id

find_deployment_id(deployer_resource_group=>$deployer_resource_group);

Finds deployment ID for currently running test. Deployment ID is ID of an OpenQA test which created deployer VM. In case of multi-machine test this can be either parent test ID or current job id as well. This function collects all OpenQA job IDs related to current test run and checks if any of them match an existing deployer VM tagged with this ID.

Example: Job: 123456 - deployment module - created deployer VM tagged with "deployment_id=123456", Job: 123457 (child of 123456) - some test module Deployment ID returned from both jobs: 123456 - because it matches with existing VM tagged with "deployment_id=123456"

deployer_resource_group: Deployer resource group. Default: get_required_var('SDAF_DEPLOYER_RESOURCE_GROUP')

get_deployer_resources

get_deployer_resources(deployer_resource_group=>$deployer_resource_group [, deployment_id=>'123456', return_ids=1]);

Returns ARRAYREF of all resources belonging to deployer_resource_group tagged with deployment_id.

deployer_resource_group: Deployer resource group. Default: get_required_var('SDAF_DEPLOYER_RESOURCE_GROUP')

deployment_id: Deployment ID

return_value: Control the content of the returned array. It can either return array of resource IDs or resource names. Values allowed: id, name Default: name

destroy_deployer_vm

destroy_deployer_vm([timeout=>900]);

Collects resource id of all resources belonging to the deployer VM and deletes them. Cleanup deployer VM resources only, deployer resource group itself will stay intact.

timeout: Timeout for destroy command. Default: 800