Skip to content

Commit

Permalink
PC new logs added in regristration cleanup
Browse files Browse the repository at this point in the history
  credentials crypted with GPG_PASSPHRASE
  • Loading branch information
m-dati committed Jan 9, 2025
1 parent 14d4921 commit c64d022
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion tests/publiccloud/registration.pm
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ use strict;
use utils;
use publiccloud::utils;
use publiccloud::ssh_interactive "select_host_console";
# DEBUG:
use Data::Dumper;
# use publiccloud::instance 'upload_check_logs_tar';

sub run {
my ($self, $args) = @_;
Expand All @@ -32,16 +35,29 @@ sub run {
if (is_sle('>15-SP5') && is_container_host()) {
$self->{instance}->ssh_assert_script_run('sudo zypper -n in --force-resolution -y curl');
}
record_info("DEBUG:", Dumper($self));
}

sub cleanup {
my ($self) = @_;
$self->{instance}->upload_log('/var/log/cloudregister', log_name => $autotest::current_test->{name} . '-cloudregister.log');
$self->registration_logs();
if (is_azure()) {
record_info('azuremetadata', $self->{instance}->run_ssh_command(cmd => "sudo /usr/bin/azuremetadata --api latest --subscriptionId --billingTag --attestedData --signature --xml"));
}
}

sub registration_logs {
my $self = shift;
my @remotelogs = ('/etc/hosts', '/var/log/zypper.log', '/var/log/cloudregister', '/tmp/SCCcredentials.gpg');
# encrypt sensible remote file
my $encryptkey = get_var('GPG_PASSPHRASE');
my $encrypt = "sudo gpg -c --batch --passphrase $encryptkey --output /tmp/SCCcredentials.gpg /etc/zypp/credentials.d/SCCcredentials";
$self->{instance}->run_ssh_command(cmd => $encrypt) if ($encryptkey);
# tar and upload logs
$self->{instance}->upload_check_logs_tar(@remotelogs);
return;
}

sub test_flags {
return {fatal => 1, publiccloud_multi_module => 1};
}
Expand Down

0 comments on commit c64d022

Please sign in to comment.