qe-sap-deployment test lib
Copyright 2022 SUSE LLC
SPDX-License-Identifier: FSFAP
QE SAP <qe-sap@suse.de>
Package with common methods and default or constant values for qe-sap-deployment
Returns a hash containing file paths for config files
Create all needed folders
Scans yaml config for '%OPENQA_VARIABLE%' placeholders and searches for values in OpenQA defined variables.
Returns hash with openqa variable key/value pairs.
Writes "ansible" section into yaml config file.
$args{ansible_section} defines section(key) name.
$args{section_content} defines content of names section.
Example:
@playbook_list = ("pre-cluster.yaml", "cluster_sbd_prep.yaml");
qesap_create_ansible_section(ansible_section=>'create', section_content=>\@playbook_list);
Install all Python requirements of the qe-sap-deployment in a dedicated virtual environment
qesap_upload_logs([failok=1])
Collect and upload logs present in @log_files.
Get the qe-sap-deployment code
Replaces yaml config file variables with parameters defined by OpenQA testode, yaml template or yaml schedule.
Openqa variables need to be added as a hash with key/value pair inside %run_args{openqa_variables}.
Example:
my %variables;
$variables{HANA_SAR} = get_required_var("HANA_SAR");
$variables{HANA_CLIENT_SAR} = get_required_var("HANA_CLIENT_SAR");
qesap_yaml_replace(openqa_variables=>\%variables);
qesap_execute(cmd => $qesap_script_cmd [, verbose => 1, cmd_options => $cmd_options] );
cmd_options - allows to append additional qesap.py commans arguments like "qesap.py terraform -d"
Example:
qesap_execute(cmd => 'terraform', cmd_options => '-d') will result in:
qesap.py terraform -d
Execute qesap glue script commands. Check project documentation for available options:
https://github.com/SUSE/qe-sap-deployment
Test only returns execution result, failure has to be handled by calling method.
Return the path of the generated inventory
Get the number of cluster nodes from the inventory.yaml
Return the path used by the qesap script as -chdir argument for terraform
It is useful if test would like to call terraform
qesap_prepare_env(variables=>{dict with variables}, provider => 'aws');
Prepare terraform environment.
- creates file structures
- pulls git repository
- external config files
- installs pip requirements and OS packages
- generates config files with qesap script
For variables example see 'qesap_yaml_replace'
Returns only result, failure handling has to be done by calling method.
Use Ansible to run a command remotely on some or all
the hosts from the inventory.yaml
qesap_prepare_env(cmd=>{string}, provider => 'aws');
Use Ansible to run a command remotely and get the stdout.
Command could be executed with elevated privileges
qesap_ansible_script_output(cmd => 'crm status', provider => 'aws', host => 'vmhana01', root => 1);
It uses playbook data/sles4sap/script_output.yaml
1. ansible-playbook run the playbook
2. the playbook executes the command and redirects the output to file, both remotely
3. the playbook download the file locally
4. the file is read and stored to be returned to the caller
Creates a AWS credentials file as required by QE-SAP Terraform deployment code.
Creates a AWS config file in ~/.aws as required by the QE-SAP Terraform & Ansible deployment code.
Return a list of the public IP addresses of the systems deployed by qesapdeployment, as reported
by C<terraform output>. Needs to run after C<qesap_execute(cmd => 'terraform');> call.