Skip to content

Commit

Permalink
Align qesap regression LTSS to HanaSR (os-autoinst#20796)
Browse files Browse the repository at this point in the history
Change the qesap regression implementation of LTSS registration to be
more aligned to the one implemented for HanaSR. Use more similar
variables, use functions from the registration library. Allow LTSS to be
enabled in all conf.yaml.
  • Loading branch information
mpagot authored Dec 13, 2024
1 parent 758c7fa commit a988190
Show file tree
Hide file tree
Showing 17 changed files with 79 additions and 79 deletions.
2 changes: 1 addition & 1 deletion data/sles4sap/qe_sap_deployment/qesap_aws.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ ansible:
secondary_site: 'miky'
use_sap_hana_sr_angi: '%USE_SR_ANGI%'
create:
- %REGISTRATION_PLAYBOOK%.yaml -e reg_code='%SCC_REGCODE_SLES4SAP%' -e email_address='[email protected]' -e use_suseconnect=%SUSECONNECT%
- %REGISTRATION_PLAYBOOK%.yaml -e reg_code='%SCC_REGCODE_SLES4SAP%' -e email_address='[email protected]' %REG_ARGS%
- fully-patch-system.yaml
- pre-cluster.yaml
- sap-hana-preconfigure.yaml
Expand Down
2 changes: 1 addition & 1 deletion data/sles4sap/qe_sap_deployment/qesap_aws_fencing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ ansible:
secondary_site: 'miky'
use_sap_hana_sr_angi: '%USE_SR_ANGI%'
create:
- %REGISTRATION_PLAYBOOK%.yaml -e reg_code='%SCC_REGCODE_SLES4SAP%' -e email_address='[email protected]'
- %REGISTRATION_PLAYBOOK%.yaml -e reg_code='%SCC_REGCODE_SLES4SAP%' -e email_address='[email protected]' %REG_ARGS%
- fully-patch-system.yaml
- pre-cluster.yaml
- sap-hana-preconfigure.yaml
Expand Down
2 changes: 1 addition & 1 deletion data/sles4sap/qe_sap_deployment/qesap_aws_sapconf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ ansible:
secondary_site: 'miky'
use_sap_hana_sr_angi: '%USE_SR_ANGI%'
create:
- %REGISTRATION_PLAYBOOK%.yaml -e reg_code='%SCC_REGCODE_SLES4SAP%' -e email_address='[email protected]'
- %REGISTRATION_PLAYBOOK%.yaml -e reg_code='%SCC_REGCODE_SLES4SAP%' -e email_address='[email protected]' %REG_ARGS%
- fully-patch-system.yaml
- pre-cluster.yaml
- sap-hana-preconfigure.yaml -e use_sapconf=true
Expand Down
2 changes: 1 addition & 1 deletion data/sles4sap/qe_sap_deployment/qesap_azure.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ ansible:
secondary_site: 'miky'
use_sap_hana_sr_angi: '%USE_SR_ANGI%'
create:
- %REGISTRATION_PLAYBOOK%.yaml -e reg_code='%SCC_REGCODE_SLES4SAP%' -e email_address='[email protected]'
- %REGISTRATION_PLAYBOOK%.yaml -e reg_code='%SCC_REGCODE_SLES4SAP%' -e email_address='[email protected]' %REG_ARGS%
- fully-patch-system.yaml
- pre-cluster.yaml
- sap-hana-preconfigure.yaml -e use_reboottimeout=900
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ ansible:
secondary_site: 'miky'
use_sap_hana_sr_angi: '%USE_SR_ANGI%'
create:
- %REGISTRATION_PLAYBOOK%.yaml -e reg_code='%SCC_REGCODE_SLES4SAP%' -e email_address='[email protected]'
- %REGISTRATION_PLAYBOOK%.yaml -e reg_code='%SCC_REGCODE_SLES4SAP%' -e email_address='[email protected]' %REG_ARGS%
- fully-patch-system.yaml
- pre-cluster.yaml
- sap-hana-preconfigure.yaml -e use_reboottimeout=900
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ ansible:
secondary_site: 'miky'
use_sap_hana_sr_angi: '%USE_SR_ANGI%'
create:
- %REGISTRATION_PLAYBOOK%.yaml -e reg_code='%SCC_REGCODE_SLES4SAP%' -e email_address='[email protected]'
- %REGISTRATION_PLAYBOOK%.yaml -e reg_code='%SCC_REGCODE_SLES4SAP%' -e email_address='[email protected]' %REG_ARGS%
- fully-patch-system.yaml
- pre-cluster.yaml
- sap-hana-preconfigure.yaml -e use_reboottimeout=900
Expand Down
50 changes: 0 additions & 50 deletions data/sles4sap/qe_sap_deployment/qesap_azure_ltss.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion data/sles4sap/qe_sap_deployment/qesap_azure_sapconf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ ansible:
secondary_site: 'miky'
use_sap_hana_sr_angi: '%USE_SR_ANGI%'
create:
- %REGISTRATION_PLAYBOOK%.yaml -e reg_code='%SCC_REGCODE_SLES4SAP%' -e email_address='[email protected]'
- %REGISTRATION_PLAYBOOK%.yaml -e reg_code='%SCC_REGCODE_SLES4SAP%' -e email_address='[email protected]' %REG_ARGS%
- fully-patch-system.yaml
- pre-cluster.yaml
- sap-hana-preconfigure.yaml -e use_sapconf=true -e use_reboottimeout=900
Expand Down
2 changes: 1 addition & 1 deletion data/sles4sap/qe_sap_deployment/qesap_azure_uri.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ ansible:
secondary_site: 'miky'
use_sap_hana_sr_angi: '%USE_SR_ANGI%'
create:
- %REGISTRATION_PLAYBOOK%.yaml -e reg_code='%SCC_REGCODE_SLES4SAP%' -e email_address='[email protected]' -e use_suseconnect=%SUSECONNECT%
- %REGISTRATION_PLAYBOOK%.yaml -e reg_code='%SCC_REGCODE_SLES4SAP%' -e email_address='[email protected]' %REG_ARGS%
- fully-patch-system.yaml
- pre-cluster.yaml
- sap-hana-preconfigure.yaml -e use_sapconf=%USE_SAPCONF%
Expand Down
2 changes: 1 addition & 1 deletion data/sles4sap/qe_sap_deployment/qesap_gcp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ ansible:
secondary_site: 'miky'
use_sap_hana_sr_angi: '%USE_SR_ANGI%'
create:
- %REGISTRATION_PLAYBOOK%.yaml -e reg_code='%SCC_REGCODE_SLES4SAP%' -e email_address='[email protected]'
- %REGISTRATION_PLAYBOOK%.yaml -e reg_code='%SCC_REGCODE_SLES4SAP%' -e email_address='[email protected]' %REG_ARGS%
- fully-patch-system.yaml
- pre-cluster.yaml
- sap-hana-preconfigure.yaml
Expand Down
2 changes: 1 addition & 1 deletion data/sles4sap/qe_sap_deployment/qesap_gcp_fencing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ ansible:
secondary_site: 'miky'
use_sap_hana_sr_angi: '%USE_SR_ANGI%'
create:
- %REGISTRATION_PLAYBOOK%.yaml -e reg_code='%SCC_REGCODE_SLES4SAP%' -e email_address='[email protected]'
- %REGISTRATION_PLAYBOOK%.yaml -e reg_code='%SCC_REGCODE_SLES4SAP%' -e email_address='[email protected]' %REG_ARGS%
- fully-patch-system.yaml
- pre-cluster.yaml
- sap-hana-preconfigure.yaml
Expand Down
2 changes: 1 addition & 1 deletion data/sles4sap/qe_sap_deployment/qesap_gcp_sapconf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ ansible:
secondary_site: 'miky'
use_sap_hana_sr_angi: '%USE_SR_ANGI%'
create:
- %REGISTRATION_PLAYBOOK%.yaml -e reg_code='%SCC_REGCODE_SLES4SAP%' -e email_address='[email protected]'
- %REGISTRATION_PLAYBOOK%.yaml -e reg_code='%SCC_REGCODE_SLES4SAP%' -e email_address='[email protected]' %REG_ARGS%
- fully-patch-system.yaml
- pre-cluster.yaml
- sap-hana-preconfigure.yaml -e use_sapconf=true
Expand Down
34 changes: 33 additions & 1 deletion lib/qesapdeployment.pm
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ our @EXPORT = qw(
qesap_ansible_script_output_file
qesap_ansible_script_output
qesap_ansible_fetch_file
qesap_ansible_reg_module
qesap_ansible_error_detection
qesap_create_ansible_section
qesap_remote_hana_public_ips
qesap_wait_for_ssh
Expand Down Expand Up @@ -105,7 +107,6 @@ our @EXPORT = qw(
qesap_az_list_container_files
qesap_az_diagnostic_log
qesap_terrafom_ansible_deploy_retry
qesap_ansible_error_detection
qesap_test_postfail
);

Expand Down Expand Up @@ -1135,6 +1136,37 @@ sub qesap_ansible_fetch_file {
return $args{out_path} . $args{file};
}

=head3 qesap_ansible_reg_module
Compose the ansible-playbook argument for the registration.yaml playbook,
about an additional module registration
-e sles_modules='[{"key":"SLES-LTSS-Extended-Security/12.5/x86_64","value":"*******"}]'
Known limitation is that registration.yaml supports multiple modules to be registered,
this code only supports one.
=over
=item B<reg> - name and reg_code for the additional extension to register.
This argument is a two element comma separated list string.
Like: 'SLES-LTSS-Extended-Security/12.5/x86_64,123456789'
First string before the comma has to be a valid SCC extension name, later used by Ansible
as argument for SUSEConnect or registercloudguest argument.
Second string has to be valid registration code for the particular extension.
=back
=cut

sub qesap_ansible_reg_module {
my (%args) = @_;
croak 'Missing mandatory "reg" argument' unless $args{reg};
my @reg_args = split(/,/, $args{reg});
die "Missing reg_code for '$reg_args[0]'" if (@reg_args != 2);
return "-e sles_modules='[{" .
"\"key\":\"$reg_args[0]\"," .
"\"value\":\"$reg_args[1]\"}]'";
}

=head3 qesap_create_aws_credentials
Creates a AWS credentials file as required by QE-SAP Terraform deployment code.
Expand Down
15 changes: 1 addition & 14 deletions lib/sles4sap_publiccloud.pm
Original file line number Diff line number Diff line change
Expand Up @@ -909,13 +909,6 @@ sub delete_network_peering {
=item B<ptf_container> - name of the container for PTF files (optional)
=item B<ltss> - name and reg_code for LTSS extension to register.
This argument is a two element comma separated list string.
Like: 'SLES-LTSS-Extended-Security/12.5/x86_64,123456789'
First string before the comma has to be a valid SCC extension name, later used by Ansible
as argument for SUSEConnect or registercloudguest argument.
Second string has to be valid registration code for the particular LTSS extension.
=back
=cut

Expand All @@ -941,13 +934,7 @@ sub create_playbook_section_list {
my @reg_args = ('registration.yaml');
push @reg_args, "-e reg_code=$args{scc_code} -e email_address=''";
push @reg_args, '-e use_suseconnect=true' if ($args{registration} eq 'suseconnect');
if ($args{ltss}) {
my @ltss_args = split(/,/, $args{ltss});
die "Missing reg_code for '$ltss_args[0]'" if scalar @ltss_args != 2;
push @reg_args, "-e sles_modules='[{" .
"\"key\":\"$ltss_args[0]\"," .
"\"value\":\"$ltss_args[1]\"}]'";
}
push @reg_args, qesap_ansible_reg_module(reg => $args{ltss}) if ($args{ltss});
# Add registration module as first element
push @playbook_list, join(' ', @reg_args);

Expand Down
13 changes: 13 additions & 0 deletions t/14_qesap_ansible.t
Original file line number Diff line number Diff line change
Expand Up @@ -519,4 +519,17 @@ subtest '[qesap_ansible_fetch_file] integration' => sub {
'The default local file path is /tmp/ansible_script_output/testout.txt');
};

subtest '[qesap_ansible_reg_module]' => sub {
my $ret = qesap_ansible_reg_module(reg => 'CRAB,ALGAE');
note("ret:$ret");
ok($ret eq "-e sles_modules='[{\"key\":\"CRAB\",\"value\":\"ALGAE\"}]'");
};

subtest '[qesap_ansible_reg_module] wrong arguments' => sub {
dies_ok { qesap_ansible_reg_module() } "Missing argument";
dies_ok { qesap_ansible_reg_module(reg => '') } "Empty argument";
dies_ok { qesap_ansible_reg_module(reg => 'CRAB') } "Only one argument instead of exactly 2";
dies_ok { qesap_ansible_reg_module(reg => 'CRAB,ALGAE,SPONGE') } "Too much arguments";
};

done_testing;
3 changes: 1 addition & 2 deletions tests/sles4sap/publiccloud/qesap_terraform.pm
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ sub run {
}

$playbook_configs{scc_code} = get_required_var('SCC_REGCODE_SLES4SAP') if ($os_image_name =~ 'byos');
my @addons = grep { defined $_ && $_ } split(/,/, get_var('SCC_ADDONS'));
my @addons = split(/,/, get_var('SCC_ADDONS', ''));
# This implementation has a known limitation
# if SCC_ADDONS has two or more elements (like "ltss,ltss_es")
# only the last one will be added to the playbook argument.
Expand All @@ -188,7 +188,6 @@ sub run {
# it simplify version calculation.
$name = get_addon_fullname($addon) if ($addon =~ 'ltss');
if ($name) {
record_info($name, "Register '$name' with code '$ADDONS_REGCODE{$name}'");
$playbook_configs{ltss} = join(',', join('/', $name, scc_version(), 'x86_64'), $ADDONS_REGCODE{$name});
$playbook_configs{registration} = 'suseconnect' if ($os_image_name =~ 'byos' && $reg_mode !~ 'noreg');
}
Expand Down
21 changes: 20 additions & 1 deletion tests/sles4sap/qesapdeployment/configure.pm
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use publiccloud::azure_client;
use publiccloud::utils qw(get_ssh_private_key_path);
use testapi;
use serial_terminal 'select_serial_terminal';
use registration qw(get_addon_fullname scc_version %ADDONS_REGCODE);
use qesapdeployment;

sub run {
Expand Down Expand Up @@ -47,7 +48,25 @@ sub run {
$variables{SLES4SAP_PUBSSHKEY} = get_ssh_private_key_path() . '.pub';
$variables{REGISTRATION_PLAYBOOK} = get_var('QESAPDEPLOY_REGISTRATION_PLAYBOOK', 'registration');
$variables{REGISTRATION_PLAYBOOK} =~ s/\.yaml$//;
$variables{SUSECONNECT} = get_var('QESAPDEPLOY_USE_SUSECONNECT', 'false');

my $reg_args;
$reg_args = "-e use_suseconnect=true " if (get_var('QESAPDEPLOY_USE_SUSECONNECT'));
my @addons = split(/,/, get_var('SCC_ADDONS', ''));
# This implementation has a known limitation
# if SCC_ADDONS has two or more elements (like "ltss,ltss_es")
# only the first one will be added to the playbook argument.
foreach my $addon (@addons) {
my $name;
# Keep the code simple by only support ltss addons,
# it simplifies version calculation.
$name = get_addon_fullname($addon) if ($addon =~ 'ltss');
if ($name) {
$reg_args .= qesap_ansible_reg_module(reg => join(',', join('/', $name, scc_version(), 'x86_64'), $ADDONS_REGCODE{$name}));
# exit from the addons loop not to pack on the playbook command line more than one "-e sles_module"
last;
}
}
$variables{REG_ARGS} = $reg_args;

# Only BYOS images needs it
$variables{SCC_REGCODE_SLES4SAP} = get_var('SCC_REGCODE_SLES4SAP', '');
Expand Down

0 comments on commit a988190

Please sign in to comment.