Skip to content

Commit

Permalink
Add SCC_DEBUG_SUSECONNECT to set debug flag for suseconnect
Browse files Browse the repository at this point in the history
  • Loading branch information
foursixnine committed Nov 29, 2023
1 parent 300d653 commit 5300680
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
28 changes: 16 additions & 12 deletions lib/registration.pm
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ our @SLE12_MODULES = qw(
sle-module-public-cloud
);

# Set SCC_DEBUG_SUSECONNECT=1 to enable debug output of SUSEConnect globally
my $debug_flag = get_var('SCC_DEBUG_SUSECONNECT') ? '--debug' : '';

# Method to determine if a short name references a module based on what's defined
# on %SLE15_MODULES
sub is_module {
Expand Down Expand Up @@ -192,7 +195,7 @@ sub add_suseconnect_product {

my $try_cnt = 0;
while ($try_cnt++ <= $retry) {
eval { assert_script_run("SUSEConnect -p $name/$version/$arch $params", timeout => $timeout); };
eval { assert_script_run("SUSEConnect $debug_flag -p $name/$version/$arch $params", timeout => $timeout); };
if ($@) {
record_info('retry', "SUSEConnect failed to activate the module $name. Retrying...");
sleep 60 * $try_cnt; # we wait a bit longer for each retry
Expand Down Expand Up @@ -225,7 +228,7 @@ sub ssh_add_suseconnect_product {
$retries //= 3;
$delay //= 10;

script_retry("ssh $remote sudo SUSEConnect -p $name/$version/$arch $params", delay => $delay, retry => $retries, timeout => $timeout);
script_retry("ssh $remote sudo SUSEConnect $debug_flag -p $name/$version/$arch $params", delay => $delay, retry => $retries, timeout => $timeout);
}

=head2 remove_suseconnect_product
Expand All @@ -240,7 +243,7 @@ sub remove_suseconnect_product {
$version //= scc_version();
$arch //= get_required_var('ARCH');
$params //= '';
script_retry("SUSEConnect -d -p $name/$version/$arch $params", retry => 5, delay => 60, timeout => 180);
script_retry("SUSEConnect $debug_flag -d -p $name/$version/$arch $params", retry => 5, delay => 60, timeout => 180);
}

=head2 ssh_remove_suseconnect_product
Expand All @@ -257,7 +260,7 @@ sub ssh_remove_suseconnect_product {
$version //= scc_version();
$arch //= get_required_var('arch');
$params //= '';
script_retry("ssh $remote sudo SUSEConnect -d -p $name/$version/$arch $params", retry => 5, delay => 60, timeout => 180);
script_retry("ssh $remote sudo SUSEConnect $debug_flag -d -p $name/$version/$arch $params", retry => 5, delay => 60, timeout => 180);
}

=head2 cleanup_registration
Expand All @@ -270,7 +273,7 @@ variable set.

sub cleanup_registration {
# Remove registration from the system
assert_script_run 'SUSEConnect --cleanup';
assert_script_run "SUSEConnect $debug_flag --cleanup";
# Define proxy SCC if provided
my $proxyscc = get_var('SCC_URL');
assert_script_run "echo \"url: $proxyscc\" > /etc/SUSEConnect" if $proxyscc;
Expand All @@ -286,10 +289,10 @@ SUSEConnect --url with SMT/RMT server.

sub register_product {
if (get_var('SMT_URL')) {
assert_script_run('SUSEConnect --url ' . get_var('SMT_URL') . ' ' . uc(get_var('SLE_PRODUCT')) . '/' . scc_version(get_var('HDDVERSION')) . '/' . get_var('ARCH'), 200);
assert_script_run("SUSEConnect $debug_flag --url " . get_var('SMT_URL') . ' ' . uc(get_var('SLE_PRODUCT')) . '/' . scc_version(get_var('HDDVERSION')) . '/' . get_var('ARCH'), 200);
} else {
my $scc_reg_code = is_sles4sap ? get_required_var('SCC_REGCODE_SLES4SAP') : get_required_var('SCC_REGCODE');
assert_script_run('SUSEConnect -r ' . $scc_reg_code, 200);
assert_script_run("SUSEConnect $debug_flag -r " . $scc_reg_code, 200);
}
}

Expand Down Expand Up @@ -906,21 +909,22 @@ sub scc_deregistration {
record_soft_failure 'bsc#1189543 - Stale python2 module blocks de-registration after system migration';
add_suseconnect_product('sle-module-python2');
}
my $deregister_ret = script_run('SUSEConnect --de-register --debug > /tmp/SUSEConnect.debug 2>&1', 300);
# We don't need to pass $debug_flag to SUSEConnect, because it's already set
my $deregister_ret = script_run("SUSEConnect --de-register --debug > /tmp/SUSEConnect.debug 2>&1", 300);
if ($deregister_ret) {
# See git blame for previous workarounds.
upload_logs "/tmp/SUSEConnect.debug";
die "SUSEConnect --de-register returned error code $deregister_ret";
}
my $output = script_output 'SUSEConnect -s';
die "System is still registered" unless $output =~ /Not Registered/;
my $output = script_output "SUSEConnect $debug_flag -s"
die "System is still registered" unless $output =~ /Not Registered/;
save_screenshot;
}
else {
assert_script_run("zypper removeservice `zypper services --show-enabled-only --sort-by-name | awk {'print\$5'} | sed -n '1,2!p'`");
assert_script_run('rm /etc/zypp/credentials.d/* /etc/SUSEConnect');
my $output = script_output 'SUSEConnect -s';
die "System is still registered" unless $output =~ /Not Registered/;
my $output = script_output "SUSEConnect $debug_flag -s"
die "System is still registered" unless $output =~ /Not Registered/;
save_screenshot;
}
}
Expand Down
1 change: 1 addition & 0 deletions variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ RESCUECD | boolean | false | Indicates rescue image to be used.
RESCUESYSTEM | boolean | false | Indicates rescue system under test.
ROOTONLY | boolean | false | Request installation to create only the root account, no user account.
RESET_HOSTNAME| boolean | false | If set to true content of /etc/hostname file will be erased
SCC_DEBUG_SUSECONNECT | boolean | false | Set to pass debug flag to SUSEConnect
SCC_ADDONS | string | | Comma separated list of modules to be enabled using SCC/RMT.
SCC_DOCKER_IMAGE | string | | The content of /etc/zypp/credentials.d/SCCcredentials used by container-suseconnect-zypp zypper service in SLE base container images
SELECT_FIRST_DISK | boolean | false | Enables test module to select first disk for the installation. Is used for baremetal machine tests with multiple disks available, including cases when server still has previous installation.
Expand Down

0 comments on commit 5300680

Please sign in to comment.