lib/saputils.pm

SYNOPSIS

Package with utility functionality for tests on SLES for SAP Applications.

This package is a stateless library. To keep this library as generic as possible avoid as much as possible any other dependency usage, like other base class or testapi module Avoid using get_var/set_var at this level.

calculate_hana_topology calculate_hana_topology(input_format=>[script|json], input => $saphanasr_showAttr_format_input_format_output);

Expect `SAPHanaSR-showAttr --format=$input_format` as input.
Returns parsed perl value decoded from json remap output from like :
        Hosts/vmhana01/remoteHost="vmhana02"
        Hosts/vmhana01/sync_state="PRIM"
        Hosts/vmhana01/vhost="vmhana01"
        Hosts/vmhana02/remoteHost="vmhana01"
        Hosts/vmhana02/sync_state="SOK"
        Hosts/vmhana02/vhost="vmhana02"

output looks like:
{
      'Host' => {
                  'vmhana01' => {
                                       'clone_state' => 'DEMOTED',
                                       'score' => '100',
                                       'srah' => '-',
                                       'version' => '2.00.077.00.1710325774',
                                       'vhost' => 'vmhana01',
                                       'site' => 'site_a'
                                     },
                  'vmhana02' => {
                                       'clone_state' => 'PROMOTED',
                                       'score' => '150',
                                       'vhost' => 'vmhana02',
                                       'srah' => '-',
                                       'version' => '2.00.077.00.1710325774',
                                       'site' => 'site_b'
                                     }
                },
      'Site' => {
                  'site_a' => {
                                 'srMode' => 'sync',
                                 'srPoll' => 'SOK',
                                 'mns' => 'vmhana01'
                               },
                  'site_b' => {
                                 'srPoll' => 'PRIM',
                                 'mns' => 'vmhana02',
                                 'srMode' => 'sync'
                               }
                }
    };
input_format - format of the 'SAPHanaSR-showAttr --format='
input - stdout of 'SAPHanaSR-showAttr --format=<input_format>'

check_hana_topology check_hana_topology(input => calculate_hana_topology($saphanasr_showAttr_format_script_output) [, online_str => '12345678']]);

Expect the output of saputils::calculate_hana_topology as input.
Uses calculate_hana_topology to get a hash of hashes, and then
checks the output to make sure that the cluster is working and ready.

The checks performed are:
- All node_states are online
- All sync_states are either SOK or PRIM
input - return value of calculate_hana_topology
node_state_match - used to match the online state in field node_state. Default is '4' which means Online

check_crm_output check_crm_output(input => $crm_mon_output);

input: the output of the command 'crm_mon -r -R -n -N -1'
output: whether the conditions are met (return 1) or not (return 0)

Conditions:
- No resources are in 'Starting' state
- No 'Failed Resource Actions' present
input - stdout of 'crm_mon -R -r -n -N -1'

get_primary_node get_primary_node(topology_data=>$topology_data);

Returns hostname of current primary node obtained from B<calculate_hana_topology()> output.
topology_data - Output from `calculate_hana_topology()` function

get_failover_node get_failover_node(topology_data=>$topology_data);

Returns hostname of current failover (replica) node obtained from B<calculate_hana_topology()> output.
Returns node hostname even if it's in 'SFAIL' state.
topology_data - Output from `calculate_hana_topology()` function