From 603e26d6a333b8583b352b0a00aab46262b63638 Mon Sep 17 00:00:00 2001 From: hu-weihua Date: Wed, 26 Apr 2017 01:36:16 -0400 Subject: [PATCH 01/65] A candidate bundle to verify pegas+p9 --- .../autotest/bundle/rhels7.104-ppc64el.bundle | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 xCAT-test/autotest/bundle/rhels7.104-ppc64el.bundle diff --git a/xCAT-test/autotest/bundle/rhels7.104-ppc64el.bundle b/xCAT-test/autotest/bundle/rhels7.104-ppc64el.bundle new file mode 100644 index 000000000..b4a409a0c --- /dev/null +++ b/xCAT-test/autotest/bundle/rhels7.104-ppc64el.bundle @@ -0,0 +1,25 @@ +bmcdiscover_q +bmcdiscover_help +bmcdiscover_version +bmcdiscover_h +bmcdiscover_nmap_range +bmcdiscover_v +bmcdiscover_check_paswd +bmcdiscover_check_passwd_wrong +bmcdiscover_get_ipsource +bmcdiscover_range_w +bmcdiscover_range_u_p_i_ipsource +bmcdiscover_range_z +rpower_off +rpower_stat +rpower_boot +rpower_status +rpower_state +rpower_on +rpower_reset +rsetboot_hd_statcheck +rsetboot_net_statcheck +rsetboot_cd_statcheck +rsetboot_default_statcheck +reg_linux_diskfull_installation_flat +reg_linux_diskless_installation_flat From 45255ab48c30ce1c840e6121b84dbaae02f57999 Mon Sep 17 00:00:00 2001 From: XuWei Date: Thu, 27 Apr 2017 02:33:19 -0400 Subject: [PATCH 02/65] fix issue 2948, add bmc specific for rpower in usage & return if got error for ipmi mgt --- perl-xCAT/xCAT/Usage.pm | 3 +++ xCAT-server/lib/xcat/plugins/ipmi.pm | 1 + 2 files changed, 4 insertions(+) diff --git a/perl-xCAT/xCAT/Usage.pm b/perl-xCAT/xCAT/Usage.pm index 0cbba194a..049df54bd 100755 --- a/perl-xCAT/xCAT/Usage.pm +++ b/perl-xCAT/xCAT/Usage.pm @@ -26,6 +26,9 @@ my %usage = ( "rpower" => "Usage: rpower [--nodeps] [on|onstandby|off|suspend|reset|stat|state|boot] [-V|--verbose] [-m table.colum==expectedstatus][-m table.colum==expectedstatus...] [-r ] [-t ] rpower [-h|--help|-v|--version] + BMC (using IPMI) specific: + rpower noderange [on|off|softoff|reset|boot|stat|state|status|wake|suspend [-w timeout] [-o] [-r]] + rpower noderange [pduon|pduoff|pdustat] OpenBMC specific: rpower noderange [on|off|reset|boot|stat|state|status] KVM Virtualization specific: diff --git a/xCAT-server/lib/xcat/plugins/ipmi.pm b/xCAT-server/lib/xcat/plugins/ipmi.pm index 00302d365..fd35a443d 100644 --- a/xCAT-server/lib/xcat/plugins/ipmi.pm +++ b/xCAT-server/lib/xcat/plugins/ipmi.pm @@ -2510,6 +2510,7 @@ sub power_response { my $text = $codes{ $rsp->{code} }; unless ($text) { $text = sprintf("Unknown response %02xh", $rsp->{code}); } xCAT::SvrUtils::sendmsg([ 1, $text ], $callback, $sessdata->{node}, %allerrornodes); + return; } else { my $command = $sessdata->{subcommand}; my $status = $sessdata->{powerstatus}; From 6ba15adab1abb3bf6a0513e30c333c45f72493e3 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Fri, 28 Apr 2017 12:20:23 -0400 Subject: [PATCH 03/65] Three step hpm update for Firestone machines --- xCAT-server/lib/xcat/plugins/ipmi.pm | 284 +++++++++++++++++++++------ 1 file changed, 229 insertions(+), 55 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/ipmi.pm b/xCAT-server/lib/xcat/plugins/ipmi.pm index 00302d365..e4e94eaae 100644 --- a/xCAT-server/lib/xcat/plugins/ipmi.pm +++ b/xCAT-server/lib/xcat/plugins/ipmi.pm @@ -1762,6 +1762,56 @@ sub check_bmc_status_with_ipmitool { return 0; } +#----------------------------------------------------------------# +# Wait for OS to reboot by checking "nodestat" to be "sshd" : +# Arguments: +# initial_sleep: seconds to sleep before checking loop start +# inteval: inteval time to check +# retry: max retry time +# sessdata: session data for display +# verbose: verbose output +# Returns: +# 1 when OS is up +# 0 when no response of "sshd" from OS +#----------------------------------------------------------------# +sub wait_for_os_to_reboot { + my $initial_sleep = shift; + my $interval = shift; + my $retry = shift; + my $sessdata = shift; + my $verbose = shift; + my $cmd; + my $output; + if ($verbose) { + xCAT::SvrUtils::sendmsg("Sleeping for a few min waiting for node to power on before attempting to continue", $callback, $sessdata->{node}, %allerrornodes); + } + sleep($initial_sleep); # sleep for this many min for node to reboot + # Start testing every 10 sec for node to be booted. Give up after 5 min. + foreach (1..$retry) { + # Test node is booted in to OS + $cmd = "nodestat $sessdata->{node} | /usr/bin/grep sshd"; + $output = xCAT::Utils->runcmd($cmd, -1); + if ($::RUNCMD_RC == 0) { + # Node is ready to retry an upgrage + if ($verbose) { + xCAT::SvrUtils::sendmsg("Detected node booted. Will retry upgrade", $callback, $sessdata->{node}, %allerrornodes); + } + return 1; #Node booted + } + else { + # Still not booted, wait for 10 sec and try again + if ($verbose) { + $cmd = "nodestat $sessdata->{node}"; + $output = xCAT::Utils->runcmd($cmd, -1); + my ($nodename, $state) = split(/:/, $output); + xCAT::SvrUtils::sendmsg("($_) Node still not ready. Current state - $state, test again in 10 sec.", $callback, $sessdata->{node}, %allerrornodes); + } + sleep($interval); + } + } + return 0; #Node did not boot after requested delay +} + sub do_firmware_update { my $sessdata = shift; my $ret; @@ -1769,6 +1819,9 @@ sub do_firmware_update { my $verbose = 0; my $retry = 2; my $verbose_opt; + my $is_firestone = 0; + my $firestone_update_version; + my $htm_update_version; $ret = get_ipmitool_version(\$ipmitool_ver); exit $ret if $ret < 0; @@ -1789,7 +1842,7 @@ sub do_firmware_update { my $exit_with_success_func = sub { my ($node, $callback, $message) = @_; - my $status = "success to update firmware"; + my $status = "success updating firmware"; my $nodelist_table = xCAT::Table->new('nodelist'); if (!$nodelist_table) { xCAT::MsgUtils->message("S", "Unable to open nodelist table, denying"); @@ -1883,8 +1936,6 @@ sub do_firmware_update { } } - xCAT::SvrUtils::sendmsg("rflash started, upgrade failure will be retried up to $retry times. Please wait...", - $callback, $sessdata->{node}, %allerrornodes); # check for 8335-GTB Firmware above 1610A release. If below, exit if ($output =~ /8335-GTB/) { @@ -1903,6 +1954,69 @@ sub do_firmware_update { "Error: Current firmware level OP8v_$grs_version requires one-time manual update to at least version OP8v_1.7_2.55"); } } + + } + # For Firestone the update from 810 to 820 or from 820 to 810 needs to be done in 3 steps + # instead of usual one. + if ($output =~ /8335-GCA|8335-GTA/) { + $is_firestone = 1; + $cmd = $pre_cmd . " fru print 47"; + $output = xCAT::Utils->runcmd($cmd, -1); + if ($::RUNCMD_RC != 0) { + $exit_with_error_func->($sessdata->{node}, $callback, + "Running ipmitool command $cmd failed: $output"); + } + # Check what firmware version is currently running on the machine + if ($output =~ /OP8_v\d\.\d+_(\d+)\.\d+/) { + my $frs_version = $1; + if ($frs_version == 1) { + $firestone_update_version = "810"; + } + if ($frs_version == 2) { + $firestone_update_version = "820"; + } + } + else { + $exit_with_error_func->($sessdata->{node}, $callback, + "Unable to determine firmware version currently installed."); + } + + # Check what firmware version is specified in htm file + $cmd = "/usr/bin/grep -a FW_DESC $hpm_file"; + $output = xCAT::Utils->runcmd($cmd, -1); + if ($::RUNCMD_RC != 0) { + $exit_with_error_func->($sessdata->{node}, $callback, + "Running ipmitool command $cmd failed: $output"); + } + # Parse out build date from the description string + if ($output =~ /FW_DESC=8335 \w+ \w+ \w+ (\w+)/) { + my $htm_date= $1; + # Parse out the year from "mmddyyyy" (skip 4 digits, grab last 4) + if ($htm_date =~ /\d{4}(\d+)/) { + my $htm_year = $1; + if ($htm_year == 2016) { + $htm_update_version = "810"; + } + if ($htm_year == 2017) { + $htm_update_version = "820"; + } + } + } + else { + $exit_with_error_func->($sessdata->{node}, $callback, + "Unable to determine firmware version of $hpm_file."); + } + } + + if ($is_firestone and + (($firestone_update_version eq "820" and $htm_update_version eq "810") or + ($firestone_update_version eq "810" and $htm_update_version eq "820")) + ) { + xCAT::SvrUtils::sendmsg("rflash started, Please wait...", $callback, $sessdata->{node}, %allerrornodes); + $retry = 0; # No retry support for 3 step update process + } + else { + xCAT::SvrUtils::sendmsg("rflash started, upgrade failure will be retried up to $retry times. Please wait...", $callback, $sessdata->{node}, %allerrornodes); } RETRY_UPGRADE: @@ -1942,38 +2056,123 @@ RETRY_UPGRADE: } # step 4 upgrade firmware - $cmd = $pre_cmd . " -z " . $buffer_size . " hpm upgrade $hpm_file force "; - $cmd .= $verbose_opt; - my $rflash_log_file = xCAT::Utils->full_path($sessdata->{node}.".log", RFLASH_LOG_DIR); - $cmd .= " >".$rflash_log_file." 2>&1"; - if ($verbose) { - xCAT::SvrUtils::sendmsg([ 0, - "rflashing ... See the detail progress :\"tail -f $rflash_log_file\"" ], - $callback, $sessdata->{node}); - } + # For firestone machines if updating from 810 to 820 version or from 820 to 810, + # extra steps are needed. Hanled in "if" block, "else" block is normal update in a single step. + if ($is_firestone and + (($firestone_update_version eq "820" and $htm_update_version eq "810") or + ($firestone_update_version eq "810" and $htm_update_version eq "820")) + ) { - $output = xCAT::Utils->runcmd($cmd, -1); - # if upgrade command failed and we exausted number of retries - # report an error, exit to the caller and leave node in powered off state - # otherwise report an error, power on the node and try upgrade again - if ($::RUNCMD_RC != 0) { - # Since "hpm update" command in step 4 above redirects standard out and error to a log file, - # nothing gets returned from execution of the command. Here if RC is not zero, we - # extract all lines containing "Error" from that log file and display them in the sendmsg below - my $get_error_cmd = "/usr/bin/grep Error $rflash_log_file"; - $output = xCAT::Utils->runcmd($get_error_cmd, 0); - if ($retry == 0) { - # No more retries left, report an error and exit + # Step 4.1 + $cmd = $pre_cmd . " -z " . $buffer_size . " hpm upgrade $hpm_file component 0 force "; + $cmd .= $verbose_opt; + + my $rflash_log_file = xCAT::Utils->full_path($sessdata->{node}.".log", RFLASH_LOG_DIR); + $cmd .= " >".$rflash_log_file." 2>&1"; + if ($verbose) { + xCAT::SvrUtils::sendmsg([ 0, + "rflashing component 0, see the detail progress :\"tail -f $rflash_log_file\"" ], + $callback, $sessdata->{node}); + } + $output = xCAT::Utils->runcmd($cmd, -1); + if ($::RUNCMD_RC != 0) { + # Since "hpm update" command in step 4.1 above redirects standard out and error to a log file, + # nothing gets returned from execution of the command. Here if RC is not zero, we + # extract all lines containing "Error" from that log file and display them in the sendmsg below + my $get_error_cmd = "/usr/bin/grep Error $rflash_log_file"; + $output = xCAT::Utils->runcmd($get_error_cmd, 0); $exit_with_error_func->($sessdata->{node}, $callback, "Running ipmitool command $cmd failed with rc=$::RUNCMD_RC and the following error messages:\n$output\nSee the $rflash_log_file for details."); } - else { - # Error upgrading, set a flag to attempt a retry - xCAT::SvrUtils::sendmsg("Running attempt $retry of ipmitool command $cmd failed with rc=$::RUNCMD_RC and the following error messages:\n$output\nSee the $rflash_log_file for details.", $callback, $sessdata->{node}, %allerrornodes); - $failed_upgrade = 1; + + sleep(1); # Sleep for a second before next step + + # Step 4.2 + $cmd = $pre_cmd . " -z " . $buffer_size . " hpm upgrade $hpm_file component 1 force "; + $cmd .= $verbose_opt; + + my $rflash_log_file = xCAT::Utils->full_path($sessdata->{node}.".log", RFLASH_LOG_DIR); + $cmd .= " >>".$rflash_log_file." 2>&1"; + if ($verbose) { + xCAT::SvrUtils::sendmsg([ 0, + "rflashing component 1, see the detail progress :\"tail -f $rflash_log_file\"" ], + $callback, $sessdata->{node}); + } + $output = xCAT::Utils->runcmd($cmd, -1); + if ($::RUNCMD_RC != 0) { + # Since "hpm update" command in step 4.2 above redirects standard out and error to a log file, + # nothing gets returned from execution of the command. Here if RC is not zero, we + # extract all lines containing "Error" from that log file and display them in the sendmsg below + my $get_error_cmd = "/usr/bin/grep Error $rflash_log_file"; + $output = xCAT::Utils->runcmd($get_error_cmd, 0); + $exit_with_error_func->($sessdata->{node}, $callback, + "Running ipmitool command $cmd failed with rc=$::RUNCMD_RC and the following error messages:\n$output\nSee the $rflash_log_file for details."); + } + + # Wait for BMC to reboot before continuing to next step + unless (check_bmc_status_with_ipmitool($pre_cmd, 5, 60, 10, $sessdata, $verbose)) { + $exit_with_error_func->($sessdata->{node}, $callback, + "Timeout waiting for the bmc ready status. Firmware update suspended"); + } + + # Step 4.3 + $cmd = $pre_cmd . " -z " . $buffer_size . " hpm upgrade $hpm_file component 2 force "; + $cmd .= $verbose_opt; + + my $rflash_log_file = xCAT::Utils->full_path($sessdata->{node}.".log", RFLASH_LOG_DIR); + $cmd .= " >>".$rflash_log_file." 2>&1"; + if ($verbose) { + xCAT::SvrUtils::sendmsg([ 0, + "rflashing component 2, see the detail progress :\"tail -f $rflash_log_file\"" ], + $callback, $sessdata->{node}); + } + $output = xCAT::Utils->runcmd($cmd, -1); + if ($::RUNCMD_RC != 0) { + # Since "hpm update" command in step 4.3 above redirects standard out and error to a log file, + # nothing gets returned from execution of the command. Here if RC is not zero, we + # extract all lines containing "Error" from that log file and display them in the sendmsg below + my $get_error_cmd = "/usr/bin/grep Error $rflash_log_file"; + $output = xCAT::Utils->runcmd($get_error_cmd, 0); + $exit_with_error_func->($sessdata->{node}, $callback, + "Running ipmitool command $cmd failed with rc=$::RUNCMD_RC and the following error messages:\n$output\nSee the $rflash_log_file for details."); + } + } + + else { + $cmd = $pre_cmd . " -z " . $buffer_size . " hpm upgrade $hpm_file force "; + $cmd .= $verbose_opt; + + my $rflash_log_file = xCAT::Utils->full_path($sessdata->{node}.".log", RFLASH_LOG_DIR); + $cmd .= " >".$rflash_log_file." 2>&1"; + if ($verbose) { + xCAT::SvrUtils::sendmsg([ 0, + "rflashing ... See the detail progress :\"tail -f $rflash_log_file\"" ], + $callback, $sessdata->{node}); + } + + $output = xCAT::Utils->runcmd($cmd, -1); + # if upgrade command failed and we exausted number of retries + # report an error, exit to the caller and leave node in powered off state + # otherwise report an error, power on the node and try upgrade again + if ($::RUNCMD_RC != 0) { + # Since "hpm update" command in step 4 above redirects standard out and error to a log file, + # nothing gets returned from execution of the command. Here if RC is not zero, we + # extract all lines containing "Error" from that log file and display them in the sendmsg below + my $get_error_cmd = "/usr/bin/grep Error $rflash_log_file"; + $output = xCAT::Utils->runcmd($get_error_cmd, 0); + if ($retry == 0) { + # No more retries left, report an error and exit + $exit_with_error_func->($sessdata->{node}, $callback, + "Running ipmitool command $cmd failed with rc=$::RUNCMD_RC and the following error messages:\n$output\nSee the $rflash_log_file for details."); + } + else { + # Error upgrading, set a flag to attempt a retry + xCAT::SvrUtils::sendmsg("Running attempt $retry of ipmitool command $cmd failed with rc=$::RUNCMD_RC and the following error messages:\n$output\nSee the $rflash_log_file for details.", $callback, $sessdata->{node}, %allerrornodes); + $failed_upgrade = 1; - } + } + } } # step 5 power on @@ -1999,34 +2198,9 @@ RETRY_UPGRADE: "Running ipmitool command $cmd failed: $output"); } - my $node_ready_for_retry = 0; if ($failed_upgrade) { # Update has failed in step 4. Wait for node to reboot and try again - if ($verbose) { - xCAT::SvrUtils::sendmsg("Sleeping for a few min waiting for node to power on before attempting a retry", $callback, $sessdata->{node}, %allerrornodes); - } - sleep(300); # sleep for 5 min for node to reboot - # Start testing every 10 sec for node to be booted. Give up after 5 min. - foreach (1..30) { - # Test node is booted in to OS - $cmd = "nodestat $sessdata->{node} | grep sshd"; - $output = xCAT::Utils->runcmd($cmd, -1); - if ($::RUNCMD_RC == 0) { - # Node is ready to retry an upgrage - if ($verbose) { - xCAT::SvrUtils::sendmsg("Detected node booted. Will retry upgrade", $callback, $sessdata->{node}, %allerrornodes); - } - $node_ready_for_retry = 1; - last; - } - else { - # Still not booted, wait for 10 sec and try again - if ($verbose) { - xCAT::SvrUtils::sendmsg("Node still not ready, Test again in 10 sec.", $callback, $sessdata->{node}, %allerrornodes); - } - sleep(10); - } - } + my $node_ready_for_retry = wait_for_os_to_reboot(300,10,30,$sessdata,$verbose); if ($node_ready_for_retry) { $retry--; # decrement number of retries left # Yes, it is a goto statement here. Ugly, but removes the need to restructure From 0246781c8f352c85b9b02882b58115d4c5bdff2b Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Mon, 1 May 2017 14:48:30 -0400 Subject: [PATCH 04/65] Fixed error message as suggested by the review --- xCAT-server/lib/xcat/plugins/ipmi.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-server/lib/xcat/plugins/ipmi.pm b/xCAT-server/lib/xcat/plugins/ipmi.pm index e4e94eaae..505042365 100644 --- a/xCAT-server/lib/xcat/plugins/ipmi.pm +++ b/xCAT-server/lib/xcat/plugins/ipmi.pm @@ -1978,7 +1978,7 @@ sub do_firmware_update { } else { $exit_with_error_func->($sessdata->{node}, $callback, - "Unable to determine firmware version currently installed."); + "Unable to determine firmware version currently installed. Verify that \"$cmd | grep OP8_v\" command returns a version."); } # Check what firmware version is specified in htm file From db2ec5ddcc4f71630d7afed001b07f417ecdf650 Mon Sep 17 00:00:00 2001 From: XuWei Date: Tue, 2 May 2017 02:52:03 -0400 Subject: [PATCH 05/65] framework of rspconfig command for openbmc --- xCAT-server/lib/xcat/plugins/openbmc.pm | 261 +++++++++++++++--------- 1 file changed, 165 insertions(+), 96 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index 1672f244b..f4560d5af 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -50,17 +50,17 @@ sub unsupported { #------------------------------------------------------- sub handled_commands { return { - rpower => 'nodehm:mgt', - rinv => 'nodehm:mgt', getopenbmccons => 'nodehm:cons', - rsetboot => 'nodehm:mgt', - rspconfig => 'nodehm:mgt', - rvitals => 'nodehm:mgt', - rflash => 'nodehm:mgt', - reventlog => 'nodehm:mgt', - rspreset => 'nodehm:mgt', rbeacon => 'nodehm:mgt', renergy => 'nodehm:mgt', + reventlog => 'nodehm:mgt', + rflash => 'nodehm:mgt', + rinv => 'nodehm:mgt', + rpower => 'nodehm:mgt', + rsetboot => 'nodehm:mgt', + rspconfig => 'nodehm:mgt', + rspreset => 'nodehm:mgt', + rvitals => 'nodehm:mgt', }; } @@ -82,6 +82,30 @@ my %status_info = ( process => \&login_response, }, + REVENTLOG_REQUEST => { + method => "GET", + init_url => "$openbmc_project_url/logging/enumerate", + }, + REVENTLOG_RESPONSE => { + process => \&reventlog_response, + }, + REVENTLOG_CLEAR_REQUEST => { + method => "POST", + init_url => "$openbmc_url/records/events/action/clear", + data => "", + }, + REVENTLOG_CLEAR_RESPONSE => { + process => \&reventlog_response, + }, + + RINV_REQUEST => { + method => "GET", + init_url => "$openbmc_project_url/inventory/enumerate", + }, + RINV_RESPONSE => { + process => \&rinv_response, + }, + RPOWER_ON_REQUEST => { method => "PUT", init_url => "$openbmc_project_url/state/host0/attr/RequestedHostTransition", @@ -114,43 +138,11 @@ my %status_info = ( process => \&rpower_response, }, - RINV_REQUEST => { - method => "GET", - init_url => "$openbmc_project_url/inventory/enumerate", - }, - RINV_RESPONSE => { - process => \&rinv_response, - }, - RSETBOOT_HD_REQUEST => { + RSETBOOT_SET_REQUEST => { method => "PUT", init_url => "", - data => "", }, - RSETBOOT_HD_RESPONSE => { - process => \&rsetboot_response, - }, - RSETBOOT_NET_REQUEST => { - method => "PUT", - init_url => "", - data => "", - }, - RSETBOOT_NET_RESPONSE => { - process => \&rsetboot_response, - }, - RSETBOOT_CD_REQUEST => { - method => "PUT", - init_url => "", - data => "", - }, - RSETBOOT_CD_RESPONSE => { - process => \&rsetboot_response, - }, - RSETBOOT_DEF_REQUEST => { - method => "PUT", - init_url => "", - data => "", - }, - RSETBOOT_DEF_RESPONSE => { + RSETBOOT_SET_RESPONSE => { process => \&rsetboot_response, }, RSETBOOT_STATUS_REQUEST => { @@ -160,20 +152,21 @@ my %status_info = ( RSETBOOT_STATUS_RESPONSE => { process => \&rsetboot_response, }, - REVENTLOG_REQUEST => { + + RSPCONFIG_GET_REQUEST => { method => "GET", - init_url => "$openbmc_project_url/logging/enumerate", + init_url => "", }, - REVENTLOG_RESPONSE => { - process => \&reventlog_response, + RSPCONFIG_GET_RESPONSE => { + process => \&rspconfig_response, }, - REVENTLOG_CLEAR_REQUEST => { + RSPCONFIG_SET_REQUEST => { method => "POST", - init_url => "$openbmc_url/records/events/action/clear", + init_url => "", data => "", }, - REVENTLOG_CLEAR_RESPONSE => { - process => \&reventlog_response, + RSPCONFIG_SET_RESPONSE => { + process => \&rspconfig_response, }, ); @@ -193,11 +186,10 @@ $::RESPONSE_SERVICE_UNAVAILABLE = "503 Service Unavailable"; cur_status => "LOGIN_REQUEST", cur_url => "", method => "", - back_urls => (), }, ); - 'cur_url', 'method', 'back_urls' used for path has a trailing-slash + 'cur_url', 'method' used for path has a trailing-slash =cut @@ -260,7 +252,7 @@ sub preprocess_request { return; } - my $parse_result = parse_args($command, $extrargs); + my $parse_result = parse_args($command, $extrargs, $noderange); if (ref($parse_result) eq 'ARRAY') { $callback->({ errorcode => $parse_result->[0], data => $parse_result->[1] }); $request = {}; @@ -361,9 +353,10 @@ sub process_request { sub parse_args { my $command = shift; my $extrargs = shift; + my $noderange = shift; my $check = undef; - if (scalar(@ARGV) > 1 and $command ne "rsetboot" and $command ne "reventlog") { + if (scalar(@ARGV) > 1 and $command ne "rsetboot" and $command ne "reventlog" and $command ne "rspconfig") { return ([ 1, "Only one option is supported at the same time" ]); } @@ -412,7 +405,37 @@ sub parse_args { unless ($subcommand =~ /^\d$|^\d+$|^all$|^clear$/) { return ([ 1, "Unsupported command: $command $subcommand" ]); } + } elsif ($command eq "rspconfig") { + if (!defined($extrargs)) { + return ([ 1, "No option specified for $command" ]); + } + # + # disable function until fully tested + # + $check = unsupported($callback); if (ref($check) eq "ARRAY") { return $check; } + my $setorget; + foreach $subcommand (@ARGV) { + if ($subcommand =~ /^(\w+)=(.*)/) { + return ([ 1, "Can not configure and display nodes' value at the same time" ]) if ($setorget and $setorget eq "get"); + my $key = $1; + my $value = $2; + return ([ 1, "Unsupported command: $command $key" ]) unless ($key =~ /^ip$|^netmask$|^gateway$/); + + my $nodes_num = @$noderange; + return ([ 1, "Invalid parameter for option $key" ]) unless ($value); + return ([ 1, "Invalid parameter for option $key: $value" ]) unless (xCAT::NetworkUtils->isIpaddr($value)); + if ($key eq "ip") { + return ([ 1, "Can not configure more than 1 nodes' ip at the same time" ]) if ($nodes_num >= 2); + } + $setorget = "set"; + } elsif ($subcommand =~ /^ip$|^netmask$|^gateway$/) { + return ([ 1, "Can not configure and display nodes' value at the same time" ]) if ($setorget and $setorget eq "set"); + $setorget = "get"; + } else { + return ([ 1, "Unsupported command: $command $subcommand" ]); + } + } } else { return ([ 1, "Command is not supported." ]); } @@ -480,22 +503,12 @@ sub parse_command_status { } $subcommand = $ARGV[0]; - if ($subcommand eq "hd") { - $next_status{LOGIN_RESPONSE} = "RSETBOOT_HD_REQUEST"; - $next_status{RSETBOOT_HD_REQUEST} = "RSETBOOT_HD_RESPONSE"; - # modify $status_info{RSETBOOT_SET_REQUEST}{data} if $persistent or $uefi - } elsif ($subcommand eq "net") { - $next_status{LOGIN_RESPONSE} = "RSETBOOT_NET_REQUEST"; - $next_status{RSETBOOT_NET_REQUEST} = "RSETBOOT_NET_RESPONSE"; - # modify $status_info{RSETBOOT_SET_REQUEST}{data} if $persistent or $uefi - } elsif ($subcommand eq "cd"){ - $next_status{LOGIN_RESPONSE} = "RSETBOOT_CD_REQUEST"; - $next_status{RSETBOOT_CD_REQUEST} = "RSETBOOT_CD_RESPONSE"; - # modify $status_info{RSETBOOT_SET_REQUEST}{data} if $persistent or $uefi - } elsif ($subcommand eq "default" or $subcommand eq "def") { - $next_status{LOGIN_RESPONSE} = "RSETBOOT_DEF_REQUEST"; - $next_status{RSETBOOT_DEF_REQUEST} = "RSETBOOT_DEF_RESPONSE"; - # modify $status_info{RSETBOOT_SET_REQUEST}{data} if $persistent or $uefi + if ($subcommand =~ /^hd$|^net$|^cd$|^default$|^def$/) { + $next_status{LOGIN_RESPONSE} = "RSETBOOT_SET_REQUEST"; + $next_status{RSETBOOT_SET_REQUEST} = "RSETBOOT_SET_RESPONSE"; + # modify $status_info{RSETBOOT_SET_REQUEST}{data} + $next_status{RSETBOOT_SET_RESPONSE} = "RSETBOOT_STATUS_REQUEST"; + $next_status{RSETBOOT_STATUS_REQUEST} = "RSETBOOT_STATUS_RESPONSE"; } elsif ($subcommand eq "stat") { $next_status{LOGIN_RESPONSE} = "RSETBOOT_STATUS_REQUEST"; $next_status{RSETBOOT_STATUS_REQUEST} = "RSETBOOT_STATUS_RESPONSE"; @@ -528,6 +541,30 @@ sub parse_command_status { } } + if ($command eq "rspconfig") { + my @options = (); + foreach $subcommand (@ARGV) { + if ($subcommand =~ /^ip$|^netmask$|^gateway$/) { + $next_status{LOGIN_RESPONSE} = "RSPCONFIG_GET_REQUEST"; + $next_status{RSPCONFIG_GET_REQUEST} = "RSPCONFIG_GET_RESPONSE"; + push @options, $subcommand; + } elsif ($subcommand =~ /^(\w+)=(.+)/) { + my $key = $1; + my $value = $2; + $next_status{LOGIN_RESPONSE} = "RSPCONFIG_SET_REQUEST"; + $next_status{RSPCONFIG_SET_REQUEST} = "RSPCONFIG_SET_RESPONSE"; + $next_status{RSPCONFIG_SET_RESPONSE} = "RSPCONFIG_GET_REQUEST"; + $next_status{RSPCONFIG_GET_REQUEST} = "RSPCONFIG_GET_RESPONSE"; + if ($key eq "ip") { + $status_info{RSPCONFIG_SET_RESPONSE}{ip} = $value; + } + $status_info{RSPCONFIG_SET_REQUEST}{data} = ""; # wait for interface, ip/netmask/gateway is $value + push @options, $key; + } + } + $next_status{RSPCONFIG_GET_RESPONSE}{argv} = join(",", @options); + } + print Dumper(\%next_status) . "\n"; } @@ -912,32 +949,11 @@ sub rsetboot_response { my $response_info = decode_json $response->content; - if ($node_info{$node}{cur_status} eq "RSETBOOT_HD_RESPONSE") { - if ($response_info->{'message'} eq $::RESPONSE_OK) { - xCAT::SvrUtils::sendmsg("Hard Drive", $callback, $node); - } - } - - if ($node_info{$node}{cur_status} eq "RSETBOOT_NET_RESPONSE") { - if ($response_info->{'message'} eq $::RESPONSE_OK) { - xCAT::SvrUtils::sendmsg("Network", $callback, $node); - } - } - - if ($node_info{$node}{cur_status} eq "RSETBOOT_CD_RESPONSE") { - if ($response_info->{'message'} eq $::RESPONSE_OK) { - xCAT::SvrUtils::sendmsg("CD/DVD", $callback, $node); - } - } - - if ($node_info{$node}{cur_status} eq "RSETBOOT_DEF_RESPONSE") { - if ($response_info->{'message'} eq $::RESPONSE_OK) { - xCAT::SvrUtils::sendmsg("boot override inactive", $callback, $node); - } - } - - if ($node_info{$node}{cur_status} eq "RSETBOOT_STATUS_RESPONSE") { - # wait for more information + if ($node_info{$node}{cur_status} eq "RSETBOOT_GET_RESPONSE") { + xCAT::SvrUtils::sendmsg("Hard Drive", $callback, $node); #if response data is hd + xCAT::SvrUtils::sendmsg("Network", $callback, $node); #if response data is net + xCAT::SvrUtils::sendmsg("CD/DVD", $callback, $node); #if response data is net + xCAT::SvrUtils::sendmsg("boot override inactive", $callback, $node); #if response data is def } if ($next_status{ $node_info{$node}{cur_status} }) { @@ -1009,4 +1025,57 @@ sub reventlog_response { } } +#------------------------------------------------------- + +=head3 rspconfig_response + + Deal with response of rspconfig command + Input: + $node: nodename of current response + $response: Async return response + +=cut + +#------------------------------------------------------- +sub rspconfig_response { + my $node = shift; + my $response = shift; + + my $response_info = decode_json $response->content; + + if ($node_info{$node}{cur_status} eq "RSPCONFIG_GET_RESPONSE") { + my $grep_string = $status_info{RSPCONFIG_GET_RESPONSE}{argv}; + my $data; + my @output; + if ($grep_string =~ "ip") { + $data = ""; # got data from response + push @output, "BMC IP: $data"; + } + if ($grep_string =~ "netmask") { + $data = ""; # got data from response + push @output, "BMC Netmask: $data"; + } + if ($grep_string =~ "gateway") { + $data = ""; # got data from response + push @output, "BMC Gateway: $data"; + } + + xCAT::SvrUtils::sendmsg("$_", $callback, $node) foreach (@output); + } + + if ($node_info{$node}{cur_status} eq "RSPCONFIG_SET_RESPONSE" and $response_info->{'message'} eq $::RESPONSE_OK) { + if ($status_info{RSPCONFIG_SET_RESPONSE}{ip}) { + $node_info{$node}{bmc} = $status_info{RSPCONFIG_SET_RESPONSE}{ip}; + print "$node: DEBUG BMC IP is $node_info{$node}{bmc}\n"; + } + } + + if ($next_status{ $node_info{$node}{cur_status} }) { + $node_info{$node}{cur_status} = $next_status{ $node_info{$node}{cur_status} }; + gen_send_request($node); + } else { + $wait_node_num--; + } +} + 1; From 8826307c6ec7514c40db323c380de04544d42147 Mon Sep 17 00:00:00 2001 From: XuWei Date: Tue, 2 May 2017 04:13:41 -0400 Subject: [PATCH 06/65] modified depending on comments --- xCAT-server/lib/xcat/plugins/ipmi.pm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/xCAT-server/lib/xcat/plugins/ipmi.pm b/xCAT-server/lib/xcat/plugins/ipmi.pm index fd35a443d..516ce40ee 100644 --- a/xCAT-server/lib/xcat/plugins/ipmi.pm +++ b/xCAT-server/lib/xcat/plugins/ipmi.pm @@ -2364,6 +2364,12 @@ sub power { my $rc = 0; my $text; my $code; + + if (($sessdata->{subcommand} eq "suspend" or $sessdata->{subcommand} eq "wake") and isopenpower($sessdata)) { + xCAT::SvrUtils::sendmsg([ 1, "unsupported command power $sessdata->{subcommand} for OpenPower" ], $callback, $sessdata->{node}, %allerrornodes); + return; + } + if ($sessdata->{subcommand} eq "reseat") { reseat_node($sessdata); } elsif (not $sessdata->{acpistate} and is_systemx($sessdata)) { #Only implemented for IBM servers From 7c68f4595e94ceaf4f5bc6a1e180325e621499a3 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Tue, 2 May 2017 09:34:18 -0400 Subject: [PATCH 07/65] sleep time fixes in comments and message --- xCAT-server/lib/xcat/plugins/ipmi.pm | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/ipmi.pm b/xCAT-server/lib/xcat/plugins/ipmi.pm index 505042365..102061a59 100644 --- a/xCAT-server/lib/xcat/plugins/ipmi.pm +++ b/xCAT-server/lib/xcat/plugins/ipmi.pm @@ -1785,8 +1785,8 @@ sub wait_for_os_to_reboot { if ($verbose) { xCAT::SvrUtils::sendmsg("Sleeping for a few min waiting for node to power on before attempting to continue", $callback, $sessdata->{node}, %allerrornodes); } - sleep($initial_sleep); # sleep for this many min for node to reboot - # Start testing every 10 sec for node to be booted. Give up after 5 min. + sleep($initial_sleep); # sleep initially for $initial_sleep seconds for node to reboot + # Start testing every $interval sec for node to be booted. Give up after $retry times. foreach (1..$retry) { # Test node is booted in to OS $cmd = "nodestat $sessdata->{node} | /usr/bin/grep sshd"; @@ -1799,12 +1799,12 @@ sub wait_for_os_to_reboot { return 1; #Node booted } else { - # Still not booted, wait for 10 sec and try again + # Still not booted, wait for $interval sec and try again if ($verbose) { $cmd = "nodestat $sessdata->{node}"; $output = xCAT::Utils->runcmd($cmd, -1); my ($nodename, $state) = split(/:/, $output); - xCAT::SvrUtils::sendmsg("($_) Node still not ready. Current state - $state, test again in 10 sec.", $callback, $sessdata->{node}, %allerrornodes); + xCAT::SvrUtils::sendmsg("($_) Node still not ready. Current state - $state, test again in $interval sec.", $callback, $sessdata->{node}, %allerrornodes); } sleep($interval); } @@ -2059,6 +2059,7 @@ RETRY_UPGRADE: # For firestone machines if updating from 810 to 820 version or from 820 to 810, # extra steps are needed. Hanled in "if" block, "else" block is normal update in a single step. + my $rflash_log_file = xCAT::Utils->full_path($sessdata->{node}.".log", RFLASH_LOG_DIR); if ($is_firestone and (($firestone_update_version eq "820" and $htm_update_version eq "810") or ($firestone_update_version eq "810" and $htm_update_version eq "820")) @@ -2068,7 +2069,6 @@ RETRY_UPGRADE: $cmd = $pre_cmd . " -z " . $buffer_size . " hpm upgrade $hpm_file component 0 force "; $cmd .= $verbose_opt; - my $rflash_log_file = xCAT::Utils->full_path($sessdata->{node}.".log", RFLASH_LOG_DIR); $cmd .= " >".$rflash_log_file." 2>&1"; if ($verbose) { xCAT::SvrUtils::sendmsg([ 0, @@ -2092,7 +2092,6 @@ RETRY_UPGRADE: $cmd = $pre_cmd . " -z " . $buffer_size . " hpm upgrade $hpm_file component 1 force "; $cmd .= $verbose_opt; - my $rflash_log_file = xCAT::Utils->full_path($sessdata->{node}.".log", RFLASH_LOG_DIR); $cmd .= " >>".$rflash_log_file." 2>&1"; if ($verbose) { xCAT::SvrUtils::sendmsg([ 0, @@ -2120,7 +2119,6 @@ RETRY_UPGRADE: $cmd = $pre_cmd . " -z " . $buffer_size . " hpm upgrade $hpm_file component 2 force "; $cmd .= $verbose_opt; - my $rflash_log_file = xCAT::Utils->full_path($sessdata->{node}.".log", RFLASH_LOG_DIR); $cmd .= " >>".$rflash_log_file." 2>&1"; if ($verbose) { xCAT::SvrUtils::sendmsg([ 0, @@ -2143,7 +2141,6 @@ RETRY_UPGRADE: $cmd = $pre_cmd . " -z " . $buffer_size . " hpm upgrade $hpm_file force "; $cmd .= $verbose_opt; - my $rflash_log_file = xCAT::Utils->full_path($sessdata->{node}.".log", RFLASH_LOG_DIR); $cmd .= " >".$rflash_log_file." 2>&1"; if ($verbose) { xCAT::SvrUtils::sendmsg([ 0, From e6157c6d51ebbae537b36f87f5d253d26ae02072 Mon Sep 17 00:00:00 2001 From: Amanda Duffy Date: Tue, 2 May 2017 13:49:51 -0400 Subject: [PATCH 08/65] Add piflash man page --- xCAT-client/pods/man1/piflash.1.pod | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 xCAT-client/pods/man1/piflash.1.pod diff --git a/xCAT-client/pods/man1/piflash.1.pod b/xCAT-client/pods/man1/piflash.1.pod new file mode 100644 index 000000000..f10afcde1 --- /dev/null +++ b/xCAT-client/pods/man1/piflash.1.pod @@ -0,0 +1,13 @@ + +=head1 NAME + +B - Remotely applies firmware updates to servers. + +=head1 SYNOPSIS + +B --package + + +=head1 DESCRIPTION + +B Remotely applies firmware updates to servers. \ No newline at end of file From cf57aba831c23202b07e5b004a87c31de701a752 Mon Sep 17 00:00:00 2001 From: hu-weihua Date: Tue, 2 May 2017 22:22:42 -0400 Subject: [PATCH 09/65] add more case and description --- .../autotest/bundle/rhels7.104-ppc64el.bundle | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/xCAT-test/autotest/bundle/rhels7.104-ppc64el.bundle b/xCAT-test/autotest/bundle/rhels7.104-ppc64el.bundle index b4a409a0c..e1ed1f7a4 100644 --- a/xCAT-test/autotest/bundle/rhels7.104-ppc64el.bundle +++ b/xCAT-test/autotest/bundle/rhels7.104-ppc64el.bundle @@ -1,3 +1,4 @@ +#The cases in this bundle are used to test hardware control against P9 server and 2 kinds provision on P9 server. bmcdiscover_q bmcdiscover_help bmcdiscover_version @@ -17,9 +18,28 @@ rpower_status rpower_state rpower_on rpower_reset +rsetboot_h +rsetboot_help +rsetboot_v +rsetboot_node_invalidnode +rsetboot_noderange_net +rsetboot_node_invalidaction +rsetboot_group_net rsetboot_hd_statcheck rsetboot_net_statcheck rsetboot_cd_statcheck rsetboot_default_statcheck +reventlog_null +reventlog_all +reventlog_clear +reventlog_numofentries +rspconfig_ip +rspconfig_ip_invalid +rspconfig_netmask +rspconfig_netmask_invalid +rspconfig_gateway +rspconfig_gateway_invalid +rspconfig_node_invalid +rspconfig_ip_null reg_linux_diskfull_installation_flat reg_linux_diskless_installation_flat From f0a6d22c9e058612d4158abbf9f6658b982867c0 Mon Sep 17 00:00:00 2001 From: XuWei Date: Tue, 2 May 2017 22:22:33 -0400 Subject: [PATCH 10/65] modified depending on comments --- .../references/man1/rspconfig.1.rst | 7 +++ perl-xCAT/xCAT/Usage.pm | 4 +- xCAT-client/pods/man1/rspconfig.1.pod | 4 ++ xCAT-server/lib/xcat/plugins/openbmc.pm | 49 ++++++------------- 4 files changed, 28 insertions(+), 36 deletions(-) diff --git a/docs/source/guides/admin-guides/references/man1/rspconfig.1.rst b/docs/source/guides/admin-guides/references/man1/rspconfig.1.rst index 38df32d0a..43b873c1c 100644 --- a/docs/source/guides/admin-guides/references/man1/rspconfig.1.rst +++ b/docs/source/guides/admin-guides/references/man1/rspconfig.1.rst @@ -43,6 +43,13 @@ BMC specific: \ **rspconfig**\ \ *noderange*\ \ **garp**\ =\ *time*\ +OpenBMC specific: +================= + + +\ **rspconfig**\ \ *noderange*\ {\ **vlan | ip | netmask | gateway**\ } + + MPA specific: ============= diff --git a/perl-xCAT/xCAT/Usage.pm b/perl-xCAT/xCAT/Usage.pm index 8e2786a52..e3f61a31a 100755 --- a/perl-xCAT/xCAT/Usage.pm +++ b/perl-xCAT/xCAT/Usage.pm @@ -132,9 +132,11 @@ my %usage = ( rspconfig [snmpdest|alert|community] [-V|--verbose] rspconfig [snmpdest=|alert=|community=] BMC specific: - rspconfig [ip|netmask|gateway|backupgateway|garp] + rspconfig [vlan|ip|netmask|gateway|backupgateway|garp] rspconfig [garp=] rspconfig [userid= username= password=] + OpenBMC specific: + rspconfig [vlan|ip|netmask|gateway] iDataplex specific: rspconfig [thermprofile] rspconfig [thermprofile=] diff --git a/xCAT-client/pods/man1/rspconfig.1.pod b/xCAT-client/pods/man1/rspconfig.1.pod index 783eed89e..1b8ff24c4 100644 --- a/xCAT-client/pods/man1/rspconfig.1.pod +++ b/xCAT-client/pods/man1/rspconfig.1.pod @@ -22,6 +22,10 @@ B I {B|B|B|B|B| B I B=I