lib/sles4sap/ipaddr2.pm
SYNOPSIS
Library to manage ipaddr2 tests
ipaddr2_azure_resource_group
my $rg = ipaddr2_azure_resource_group();
Get the Azure resource group name for this test
ipaddr2_azure_storage_account
my $storage_account = ipaddr2_azure_storage_account();
Get a unique storage account name. Not including the jobId result in error like: The storage account named ip2tstorageaccount already exists under the subscription
ipaddr2_cloudinit_create
my $cloud_init_file = ipaddr2_cloudinit_create();
Create the cloud-init.txt profile file
- scc_code - Optional argument. If present, registration will be added in bootcmd section of the cloud-init profile file. Having registration enabled is particularly important for BYOS images: this profile also try to install nginx, this stage needs a previous registration.
-
- nginx_root - Optional argument: default is /srv/www/htdocs. This argument allow to overwrite the location where the index.html, generated by the test and used to identify each node, is stored. As the test is not using any nginx configuration file, this location has to match to the default root folder configured by the particular version of nginx installed in the SUT. Default value is/was value for nginx installable in 15sp5 and sp6. 12sp5 needs /usr/share/nginx/html
-
- external_repo - Optional argument: allow to add a PackageHub product
-
ipaddr2_infra_deploy
my $rg = ipaddr2_infra_deploy();
Create a deployment in Azure designed for this specific test.
1. Create a resource group to contain all 2. Create a vnet and subnet in it 3. Create one Public IP 4. Create 2 VM to run the cluster, both running a web server and that are behind the LB 5. Create 1 additional VM that get 6. Create a Load Balancer with 2 VM in backend and with an IP as frontend
- region - existing resource group
-
- os - existing Load balancer NAME
-
- diagnostic - enable diagnostic features if 1
-
- cloudinit_profile - filename of the cloud-init profile. Usually this one is the return value of ipaddr2_cloudinit_create. Presence of this optional argument also enable cloud-init features in various deployment stages.
-
- trusted_launch - Enable or disable Trusted Launch. Default 1: Enabled. If configured to 0 the result in az vm create is executed with '--security-type Standard'
-
ipaddr2_bastion_pubip
my $bastion_ip = ipaddr2_bastion_pubip();
Get the only public IP in the deployment associated to the VM used as bastion.
ipaddr2_bastion_ssh_addr
script_run(join(' ', 'ssh', ipaddr2_bastion_ssh_addr(), 'whoami');
Help to create ssh command that target the only VM in the deployment that has public IP.
- bastion_ip - Public IP address of the bastion. Calculated if not provided. Providing it as an argument is recommended in order to avoid having to query Azure to get it.
-
ipaddr2_bastion_key_accept
ipaddr2_bastion_key_accept()
For the worker to accept the ssh key of the bastion
- bastion_ip - Public IP address of the bastion. Calculated if not provided. Providing it as an argument is recommended in order to avoid having to query Azure to get it.
-
ipaddr2_internal_key_accept
ipaddr2_internal_key_accept()
For the worker to accept the host key of the internal VMs. This function always use cloudadmin as user in any ssh connections.
- bastion_ip - Public IP address of the bastion. Calculated if not provided. Providing it as an argument is recommended in order to avoid having to query Azure to get it.
-
- key_checking - optional parameter allow to tune value for StrictHostKeyChecking ssh option. default to 'accept-new'
-
ipaddr2_internal_key_gen
ipaddr2_internal_key_gen()
Create, on the /tmp folder of the Worker, two ssh key sets: one ssh key pair for each internal VM. Then upload in each internal VM the ssh key pair using scp and add pub key in the authorized_keys of the other internal VM. It also runs the first connection to accept the host keys. All this process it to have a suitable key set to allow password-less ssh between the two internal VM: it is later on needed by crm cluster init/join
- bastion_ip - Public IP address of the bastion. Calculated if not provided. Providing it as an argument is recommended in order to avoid having to query Azure to get it.
-
- key_checking - optional parameter allow to tune value for StrictHostKeyChecking ssh option. default to 'accept-new'
-
- user - set custom user name. Default is cloudadmin. User root activate special behavior. This argument is needed as crm needs keys for different users when operate in root or rootless mode.
-
ipaddr2_internal_key_authorize
ipaddr2_internal_key_authorize(src => '1', dst => '2', key_checking = 'no');
Add pub ssh key for a specific user to the same use authorized_key file on the other internal VM
- src - id of the internal VM that want to have its public key recorded on the other
-
- src - id of the internal VM has to add the other VM pub key in its authorized_key list
-
- key_checking - tune value for StrictHostKeyChecking ssh option.
-
- bastion_ip - Public IP address of the bastion. Calculated if not provided. Providing it as an argument is recommended in order to avoid having to query Azure to get it.
-
- user - set custom user name. Default is cloudadmin. User root activate special behavior. This argument is needed as crm needs keys for different users when operate in root ro rootless mode.
-
ipaddr2_deployment_sanity
ipaddr2_deployment_sanity()
Run some checks on the existing deployment using the az command line. die in case of failure
ipaddr2_os_sanity
ipaddr2_os_sanity()
Run some OS level checks on the various VMs composing the deployment. die in case of failure. Tests are targeting all the VM. Tests are independent by the cluster status.
- bastion_ip - Public IP address of the bastion. Calculated if not provided. Providing it as an argument is recommended in order to avoid having to query Azure to get it.
-
- user - user expected to be able to ssh connect password-less from one internal VM to the other. Default is cloudadmin.
-
ipaddr2_cluster_sanity
ipaddr2_cluster_sanity()
Run some cluster level checks
- id - ID of the internal VM where to run the crm commands. Default is 1.
-
- bastion_ip - Public IP address of the bastion. Calculated if not provided. Providing it as an argument is recommended in order to avoid having to query Azure to get it.
-
ipaddr2_os_connectivity_sanity
ipaddr2_os_connectivity_sanity()
Run some OS level checks about internal connectivity. die in case of failure
- bastion has to be able to ping the internal VM using the internal private IP - bastion has to be able to ping the internal VM using the internal VM hostname
- bastion_ip - Public IP address of the bastion. Calculated if not provided. Providing it as an argument is recommended in order to avoid having to query Azure to get it.
-
ipaddr2_cloudinit_sanity
ipaddr2_cloudinit_sanity()
Run some checks about cloud-init
- bastion_ip - Public IP address of the bastion. Calculated if not provided. Providing it as an argument is recommended in order to avoid having to query Azure to get it.
-
ipaddr2_cloudinit_logs
ipaddr2_cloudinit_logs()
Collect some cloud-init related logs
- bastion_ip - Public IP address of the bastion. Calculated if not provided. Providing it as an argument is recommended in order to avoid having to query Azure to get it.
-
ipaddr2_os_network_sanity
ipaddr2_os_network_sanity()
Check that private IP are in the network configuration on the internal VMs
- bastion_ip - Public IP address of the bastion. Calculated if not provided. Providing it as an argument is recommended in order to avoid having to query Azure to get it.
-
ipaddr2_os_ssh_sanity
ipaddr2_os_ssh_sanity()
Run some OS level checks on the various VMs ssh keys and configurations. die in case of failure
- bastion_ip - Public IP address of the bastion. Calculated if not provided. Providing it as an argument is recommended in order to avoid having to query Azure to get it.
-
- user - user supposed to be able to ssh connect password-less from one internal VM to the other. Value for this argument is used to decide the home folder where to look for the keys. Default is cloudadmin. User root activate some special logic.
-
ipaddr2_ssh_bastion_assert_script_run
ipaddr2_ssh_bastion_assert_script_run(
bastion_ip => '1.2.3.4',
cmd => 'whoami');
run a command on the bastion using assert_script_run
- bastion_ip - Public IP address of the bastion. Calculated if not provided. Providing it as an argument is recommended in order to avoid having to query Azure to get it.
-
- cmd - command to run there
-
ipaddr2_ssh_bastion_script_run
my $ret = ipaddr2_ssh_bastion_script_run(
bastion_ip => '1.2.3.4',
cmd => 'whoami');
run a command on the bastion using script_run
- bastion_ip - Public IP address of the bastion. Calculated if not provided. Providing it as an argument is recommended in order to avoid having to query Azure to get it.
-
- cmd - command to run there
-
ipaddr2_ssh_bastion_script_output
my $ret = ipaddr2_ssh_bastion_script_output(
bastion_ip => '1.2.3.4',
cmd => 'whoami');
run a command on the bastion using script_output
- bastion_ip - Public IP address of the bastion. Calculated if not provided. Providing it as an argument is recommended in order to avoid having to query Azure to get it.
-
- cmd - command to run there
-
ipaddr2_ssh_internal_cmd
script_run(ipaddr2_ssh_internal_cmd(
id => 2,
bastion_ip => '1.2.3.4',
cmd => 'whoami'));
Compose an ssh command. Command is composed to be executed on one of the two internal VM. Command will use -J option to use the bastion as a proxy. This function does not really execute any command, it only return a string. Other functions can use result command string as input for various testapi functions, like assert_script_run or script_output.
- id - ID of the internal VM. Used to compose its name and as address for ssh.
-
- bastion_ip - Public IP address of the bastion. Calculated if not provided. Providing it as an argument is recommended in order to avoid having to query Azure to get it.
-
- cmd - Command to be run on the internal VM.
-
ipaddr2_ssh_internal
ipaddr2_ssh_internal(
id => 2,
bastion_ip => '1.2.3.4',
cmd => 'whoami');
run a command on one of the two internal VM through the bastion using the assert_script_run API
- id - ID of the internal VM. Used to compose its name and as address for ssh.
-
- cmd - Command to be run on the internal VM.
-
- bastion_ip - Public IP address of the bastion. Calculated if not provided. Providing it as an argument is recommended in order to avoid having to query Azure to get it.
-
- timeout - Execution timeout, default 90sec
-
ipaddr2_ssh_internal_output
ipaddr2_ssh_internal_output(
id => 2,
bastion_ip => '1.2.3.4',
cmd => 'whoami');
Runs $cmd through the bastion on one of the two internal VMs using script_output. Return the command output.
- id - ID of the internal VM. Used to compose its name and as address for ssh.
-
- cmd - Command to be run on the internal VM.
-
- bastion_ip - Public IP address of the bastion. Calculated if not provided. Providing it as an argument is recommended in order to avoid having to query Azure to get it.
-
- timeout - Execution timeout, default 90sec
-
ipaddr2_cluster_create
ipaddr2_cluster_create();
Initialize and configure the Pacemaker cluster on the two internal nodes
- bastion_ip - Public IP address of the bastion. Calculated if not provided. Providing it as an argument is recommended in order to avoid having to query Azure to get it.
-
- rootless - Enable or disable the rootless mode. Default is normal root mode.
-
ipaddr2_registeration_check
my $is_registered = ipaddr2_registeration_check(id => 1);
Check if image is registered. Return 1 is it is registered, 0 if at least one is not.
- id - VM id where to install and configure the web server
-
- bastion_ip - Public IP address of the bastion. Calculated if not provided. Providing it as an argument is recommended in order to avoid having to query Azure to get it.
-
ipaddr2_registeration_set
ipaddr2_registeration_set(id => 1, scc_code => '1234567890');
Register the image. Notice that this library also support registration through ipaddr2_infra_deploy
- id - VM id where to install and configure the web server
-
- scc_code - registration code
-
- bastion_ip - Public IP address of the bastion. Calculated if not provided. Providing it as an argument is recommended in order to avoid having to query Azure to get it.
-
ipaddr2_configure_web_server(id => 1);
This function is in charge to: 1. install the nginx package 2. create a web page file 3. enable and start the system
- id - VM id where to install and configure the web server
-
- bastion_ip - Public IP address of the bastion. Calculated if not provided. Providing it as an argument is recommended in order to avoid having to query Azure to get it.
-
- nginx_root - Optional argument: default is /srv/www/htdocs. This argument allows to overwrite the location where the index.html, generated by the test and used to identify each node, is stored. As the test is not using any nginx configuration file, this location has to match to the default root folder configured by the particular version of nginx installed in the SUT. Default value is/was value for nginx installable in 15sp5 and sp6. 12sp5 needs /usr/share/nginx/html
-
- external_repo - Optional argument: allow to add a PackageHub product
-
ipaddr2_refresh_repo
ipaddr2_refresh_repo(id => 1);
Call zypper refresh
- id - VM id where to install and configure the web server
-
ipaddr2_deployment_logs
ipaddr2_deployment_logs()
Collect logs from the cloud infrastructure
ipaddr2_infra_destroy
ipaddr2_infra_destroy();
Destroy the deployment by deleting the resource group
ipaddr2_get_internal_vm_name
my $vm_name = ipaddr2_get_internal_vm_name(id => 42);
compose and return a string for the vm name
- id - VM id number
-
ipaddr2_get_internal_vm_private_ip
my $private_ip = ipaddr2_get_internal_vm_private_ip(id => 42);
compose and return a string representing the VM private IP
- id - VM id number
-
ipaddr2_get_worker_tmp_for_internal_vm
my $vm_tmp = ipaddr2_get_worker_tmp_for_internal_vm(42);
Return a path in /tmp of the worker used to store files associated two one of the internal VM
ipaddr2_crm_move
ipaddr2_crm_move(destination => 2);
move the rsc_web_00 resource to the indicated node
- destination - VM id where to move the rsc_web_00 resource
-
- id - VM id where to run the command, not so important as long as it is in the cluster. Default 1.
-
- bastion_ip - Public IP address of the bastion. Calculated if not provided. Providing it as an argument is recommended in order to avoid having to query Azure to get it.
-
ipaddr2_crm_clear
ipaddr2_crm_clear();
clear all location constrain used during the test
- id - VM id where to run the command, not so important as long as it is in the cluster. Default 1.
-
- bastion_ip - Public IP address of the bastion. Calculated if not provided. Providing it as an argument is recommended in order to avoid having to query Azure to get it.
-
ipaddr2_wait_for_takeover
die "Takeover does not happens in time" unless ipaddr2_wait_for_takeover(destination => 2);
Wait that web server is responding from the node indicated by id. This check is implemented running a curl request from the bastion and using the virtual IP address ar URL. This is possible because the webserver on each node is configured to return its hostname in the response. Return 1 as soon as it gets the id in the response. Return 0 if not within 10 minutes.
- destination - VM id that from where the web server response is expected to come from
-
- bastion_ip - Public IP address of the bastion. Calculated if not provided. Providing it as an argument is recommended in order to avoid having to query Azure to get it.
-
ipaddr2_get_web
ipaddr2_get_web(str_match => 'openqa_vm_01');
Runs a curl request from the bastion and using the virtual IP address as URL. Return result of searching str_match in the curl response
- web_url - webserver url
-
- str_match - string to search in the curl output
-
- bastion_ip - Public IP address of the bastion. Calculated if not provided. Providing it as an argument is recommended in order to avoid having to query Azure to get it.
-
ipaddr2_test_master_vm
ipaddr2_test_master_vm(id => 2);
Check the status on the VM that is supposed to have the resources.
- id - VM id that is expected to be master
-
- bastion_ip - Public IP address of the bastion. Calculated if not provided. Providing it as an argument is recommended in order to avoid having to query Azure to get it.
-
ipaddr2_test_other_vm
ipaddr2_test_other_vm(id => 1);
Check the status on the VM that is supposed not to have the resources.
- id - VM id that is expected not to be master
-
- bastion_ip - Public IP address of the bastion. Calculated if not provided. Providing it as an argument is recommended in order to avoid having to query Azure to get it.
-