lib/qesapdeployment.pm

NAME

qe-sap-deployment test lib

COPYRIGHT

Copyright 2022 SUSE LLC
SPDX-License-Identifier: FSFAP

AUTHORS

QE SAP <qe-sap@suse.de>

DESCRIPTION

Package with common methods and default or constant  values for qe-sap-deployment

Methods

qesap_get_file_paths

Returns a hash containing file paths for config files

qesap_create_folder_tree

Create all needed folders

qesap_get_variables

Scans yaml config for '%OPENQA_VARIABLE%' placeholders and searches for values in OpenQA defined variables.
Returns hash with openqa variable key/value pairs.

qesap_create_ansible_section

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);

qesap_pip_install

Install all Python requirements of the qe-sap-deployment in a dedicated virtual environment

qesap_upload_logs

qesap_upload_logs([failok=1])

Collect and upload logs present in @log_files.
FAILOK - used as failok for the upload_logs. continue even in case upload fails

qesap_get_deployment_code

Get the qe-sap-deployment code

qesap_yaml_replace

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

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.

qesap_get_inventory

Return the path of the generated inventory

qesap_get_nodes_number

Get the number of cluster nodes from the inventory.yaml

qesap_get_terraform_dir

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

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.

qesap_ansible_cmd

Use Ansible to run a command remotely on some or all
the hosts from the inventory.yaml

qesap_prepare_env(cmd=>{string}, provider => 'aws');
PROVIDER - Cloud provider name, used to find the inventory
CMD - command to run remotely
USER - user on remote host, default to 'cloudadmin'
FILTER - filter hosts in the inventory

qesap_ansible_script_output

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
PROVIDER - Cloud provider name, used to find the inventory
CMD - command to run remotely
HOST - filter hosts in the inventory
USER - user on remote host, default to 'cloudadmin'
ROOT - 1 to enable remote execution with elevated user, default to 0

qesap_create_aws_credentials

Creates a AWS credentials file as required by QE-SAP Terraform deployment code.

qesap_create_aws_config

Creates a AWS config file in ~/.aws as required by the QE-SAP Terraform & Ansible deployment code.

qesap_remote_hana_public_ips

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.