From 6bb5ba27cf0afb33e32e98a30db5ea6868694ba2 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Thu, 16 Nov 2017 15:03:05 -0500 Subject: [PATCH 01/93] Add disablenodesetwarning to man page --- perl-xCAT/xCAT/Schema.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/perl-xCAT/xCAT/Schema.pm b/perl-xCAT/xCAT/Schema.pm index f01edfd98..cb63e1c57 100755 --- a/perl-xCAT/xCAT/Schema.pm +++ b/perl-xCAT/xCAT/Schema.pm @@ -1143,6 +1143,7 @@ passed as argument rather than by table value', " defserialflow: The default serial flow - currently only used by the mknb command.\n\n" . " defserialport: The default serial port - currently only used by mknb.\n\n" . " defserialspeed: The default serial speed - currently only used by mknb.\n\n" . +" disablenodesetwarning: Allow the legacy xCAT non-osimage style nodeset to execute.\n\n" . " genmacprefix: When generating mac addresses automatically, use this manufacturing\n" . " prefix (e.g. 00:11:aa)\n\n" . " genpasswords: Automatically generate random passwords for BMCs when configuring\n" . From 714ec4e9ebbf5d8bb9c7e4d291206a55ae192fd0 Mon Sep 17 00:00:00 2001 From: bybai Date: Fri, 15 Dec 2017 02:59:03 -0500 Subject: [PATCH 02/93] rflash -b relative path support --- xCAT-server/lib/xcat/plugins/openbmc.pm | 27 ++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index 3977f16f6..844bef292 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -60,7 +60,7 @@ $::RSETBOOT_URL_PATH = "boot"; $::UPLOAD_AND_ACTIVATE = 0; $::UPLOAD_ACTIVATE_STREAM = 0; $::RFLASH_STREAM_NO_HOST_REBOOT = 0; - +$::TAR_FILE_PATH = ""; $::NO_ATTRIBUTES_RETURNED = "No attributes returned from the BMC."; $::UPLOAD_WAIT_ATTEMPT = 6; @@ -648,7 +648,7 @@ sub preprocess_request { my $extrargs = $request->{arg}; my @exargs = ($request->{arg}); my @requests; - + $::cwd = $request->{cwd}->[0]; if (ref($extrargs)) { @exargs = @$extrargs; } @@ -1149,17 +1149,24 @@ sub parse_args { } } } - elsif ($opt =~ /.*\//) { + elsif ($opt =~ /^\//) { $filepath_passed = 1; push (@tarball_path, $opt); } else { - push (@flash_arguments, $opt); - $invalid_options .= $opt . " "; + my $tmppath = xCAT::Utils->full_path($opt, $::cwd); + if (opendir(TDIR, $tmppath)) { + $filepath_passed = 1; + push (@tarball_path, $tmppath); + close(TDIR); + } else { + push (@flash_arguments, $opt); + $invalid_options .= $opt . " "; + } } } # show options parsed in bypass mode - print "DEBUG filename=$filename_passed, updateid=$updateid_passed, options=$option_flag, invalid=$invalid_options rflash_arguments=@flash_arguments\n"; + print "DEBUG filename=$filename_passed, updateid=$updateid_passed, options=$option_flag, tar_file_path=@tarball_path, invalid=$invalid_options rflash_arguments=@flash_arguments\n"; if ($option_flag =~ tr{ }{ } > 0) { unless ($verbose or $option_flag =~/^-d --no-host-reboot$/) { @@ -1204,8 +1211,10 @@ sub parse_args { } if (!opendir(DIR, $tarball_path[0])) { return ([1, "Can't open directory : $tarball_path[0]"]); + } else { + $::TAR_FILE_PATH = $tarball_path[0]; + closedir(DIR); } - closedir(DIR); } elsif ($option_flag =~ /^-c$|^--check$|^-u$|^--upload$|^-a$|^--activate$/) { return ([ 1, "Invalid firmware specified with $option_flag" ]); } else { @@ -1697,13 +1706,13 @@ sub parse_command_status { # Display firmware version of the specified .tar file xCAT::SvrUtils::sendmsg("TAR $purpose_value Firmware Product Version\: $version_value", $callback); } - } elsif (opendir(DIR, $update_file)) { + } elsif (opendir(DIR, $::TAR_FILE_PATH)) { my @tar_files = readdir(DIR); foreach my $file (@tar_files) { if ($file !~ /.*\.tar$/) { next; } else { - my $full_path_file = $update_file."/".$file; + my $full_path_file = $::TAR_FILE_PATH."/".$file; $full_path_file=~s/\/\//\//g; my $firmware_version_in_file = `$grep_cmd $version_tag $full_path_file`; my $purpose_version_in_file = `$grep_cmd $purpose_tag $full_path_file`; From 3e5f5e0b17656203c57aaf20f219d2e89ab87dce Mon Sep 17 00:00:00 2001 From: Kilian Cavalotti Date: Fri, 15 Dec 2017 10:04:02 -0800 Subject: [PATCH 03/93] ignore bmc interfaces defined in the nics table (don't generate an error) --- xCAT/postscripts/confignetwork | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/xCAT/postscripts/confignetwork b/xCAT/postscripts/confignetwork index 4c61ceeed..f7e60fc88 100755 --- a/xCAT/postscripts/confignetwork +++ b/xCAT/postscripts/confignetwork @@ -524,8 +524,13 @@ function configure_nicdevice { nic_pair=`echo "$nics_pair" |sed -n "${num}p"` echo "configure nic and its device : $nic_pair" + #ignore bmc interfaces. They're allowed in the nics table to generate DNS/hostname records, but they + #can't be configured here (it's done in bmcsetup + if [ x"$nic_dev_type" = "xbmc" ]; then + log_info "$nic_dev is of type $nic_dev_type, ignoring" + #configure standalone ethernet nic - if [ x"$nic_dev_type" = "xethernet" ]; then + elif [ x"$nic_dev_type" = "xethernet" ]; then xcatnet=`query_nicnetworks_net $nic_dev` ipaddrs=`find_nic_ips $nic_dev` if [ -n "$ipaddrs" ]; then From fce5a610fbc1a40def72d3c1f7c645b1a0dbf26d Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Fri, 15 Dec 2017 13:30:11 -0500 Subject: [PATCH 04/93] Help the user figure out the problem when using -d to delete --- xCAT-server/lib/xcat/plugins/openbmc.pm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index 3977f16f6..6d3d51b2c 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -1187,7 +1187,12 @@ sub parse_args { if ($updateid_passed) { # Updateid was passed, check flags allowed with update id if ($option_flag !~ /^--delete$|^-a$|^--activate$/) { - return ([ 1, "Invalid option specified when an update id is provided: $option_flag" ]); + my $optional_help_msg = ""; + if ($option_flag == "-d") { + # For this special case, -d was changed to pass in a directory. + $optional_help_msg = "Did you mean --delete?" + } + return ([ 1, "Invalid option specified when an update id is provided: $option_flag. $optional_help_msg" ]); } my $action = "activate"; if ($option_flag =~ /^--delete$/) { From 0584a21272f479f43c6a0317a425b289cd3be1bb Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Fri, 15 Dec 2017 16:55:16 -0500 Subject: [PATCH 05/93] Fix UT cases based on changes to support --delete --- xCAT-test/autotest/testcase/UT_openbmc/rflash_cases0 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/xCAT-test/autotest/testcase/UT_openbmc/rflash_cases0 b/xCAT-test/autotest/testcase/UT_openbmc/rflash_cases0 index 760e651e5..83f596e8c 100644 --- a/xCAT-test/autotest/testcase/UT_openbmc/rflash_cases0 +++ b/xCAT-test/autotest/testcase/UT_openbmc/rflash_cases0 @@ -14,14 +14,14 @@ os:Linux hcp:openbmc cmd: rflash $$CN -a /tmp/abc123.tz check:rc==1 -check:output=~Error: Invalid option +check:output=~Error: Invalid firmware specified with -a end start:rflash_invalid_activate_and_delete -description: Cannot specify -a and -d at the same time +description: Cannot specify -a and --delete at the same time os:Linux hcp:openbmc -cmd: rflash $$CN -a 123 -d 123 +cmd: rflash $$CN -a 123 --delete 123 check:rc==1 check:output=~Error: Multiple options are not supported end @@ -66,7 +66,7 @@ start:rflash_invalid_delete_2 description: Attempt to delete more than 1 ID from the FW os:Linux hcp:openbmc -cmd: rflash $$CN -d 221d9020 221d9020 +cmd: rflash $$CN --delete 221d9020 221d9020 check:rc==1 check:output=~Error: More than one firmware specified is not supported end From 6ee77f1fbb70475b441c84eb31c7a209758db77d Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Fri, 15 Dec 2017 16:55:32 -0500 Subject: [PATCH 06/93] Fix the code to handle multiple activate, found bug with UT cases --- xCAT-server/lib/xcat/plugins/openbmc.pm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index 92bc14928..c2be6d68a 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -1180,7 +1180,10 @@ sub parse_args { } if (scalar @flash_arguments > 1) { - if ($filename_passed and $option_flag !~ /^-d$/) { + if (($option_flag =~ /^-a$|^--delete$/) or ($filename_passed and $option_flag !~ /^-d$/)) { + # Handles: + # - Multiple options not supported to activate/delete at the same time + # - Filename passed in and option is not -d for directory return ([1, "More than one firmware specified is not supported."]); } elsif ($option_flag =~ /^-d$/) { return ([1, "More than one directory specified is not supported."]); From f1b21d72a7de69779f395e133a9d03f963affacd Mon Sep 17 00:00:00 2001 From: Kilian Cavalotti Date: Fri, 15 Dec 2017 18:00:34 -0800 Subject: [PATCH 07/93] Use IP address of xcatmaster instead of hostname in resolv.conf (#4537) --- xCAT/postscripts/mkresolvconf | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/xCAT/postscripts/mkresolvconf b/xCAT/postscripts/mkresolvconf index 95ea24a52..8b4b58d69 100755 --- a/xCAT/postscripts/mkresolvconf +++ b/xCAT/postscripts/mkresolvconf @@ -4,9 +4,9 @@ #--------------------------------------------------------------------------- # create an /etc/resolv.conf file on the node # -# - this script assumes the nameserver for the node will be -# the value of the "xcatmaster" attribute (SN as known by -# the node) or the name of the management node as known +# - this script assumes the nameserver for the node will be +# the value of the "xcatmaster" attribute (SN as known by +# the node) or the name of the management node as known # by the node. #--------------------------------------------------------------------------- @@ -15,8 +15,8 @@ conf_file="/etc/resolv.conf" conf_file_bak="/etc/resolv.conf.bak" # get values set when the myxcatpost_ script was run -master=$MASTER # this is the ip for the nodes xcatmaster attribute -domain=$DOMAIN # this is the domain name used in this cluster +master=$MASTER_IP # this is the ip for the nodes xcatmaster attribute +domain=$DOMAIN # this is the domain name used in this cluster node=$NODE if [ -n "$master" ] && [ -n "$domain" ]; then @@ -25,7 +25,7 @@ if [ -n "$master" ] && [ -n "$domain" ]; then cp $conf_file $conf_file_bak > /dev/null 2>&1 echo "search $domain" >$conf_file echo "nameserver $master" >>$conf_file -else +else logger -t xcat -p local4.err "Could not create resolv.conf on $node." exit 1 fi From 5b7081a02053d0d5596590a634de303861ea426f Mon Sep 17 00:00:00 2001 From: Weihua Hu Date: Mon, 18 Dec 2017 14:19:11 +0800 Subject: [PATCH 08/93] Update Version --- Version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Version b/Version index 6ad4f1e46..3caff04ae 100644 --- a/Version +++ b/Version @@ -1 +1 @@ -2.13.9 +2.13.10 From 524e15985233482bc9b915632eacfafc6ab742b6 Mon Sep 17 00:00:00 2001 From: Weihua Hu Date: Mon, 18 Dec 2017 14:21:25 +0800 Subject: [PATCH 09/93] Update README.rst --- README.rst | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 6d1848fbf..1b8779f68 100644 --- a/README.rst +++ b/README.rst @@ -8,7 +8,7 @@ Documentation xCAT documentation is available at: http://xcat-docs.readthedocs.io/en/latest/ -|docs_latest| |docs_2138| |docs_2137| |docs_2136| |docs_2135| |docs_2134| |docs_2133| |docs_2132| |docs_2131| |docs_2130| |docs_212| +|docs_latest| |docs_2139| |docs_2138| |docs_2137| |docs_2136| |docs_2135| |docs_2134| |docs_2133| |docs_2132| |docs_2131| |docs_2130| |docs_212| Open Source License ------------------- @@ -22,6 +22,11 @@ Developers Developers and prospective contributors are encouraged to read the `Developers Guide `_ In particular the `GitHub `_ related subsection. +.. |docs_2139| image:: https://readthedocs.org/projects/xcat-docs/badge/?version=2.13.9 + :alt: 2.13.9 documentation status + :scale: 100% + :target: http://xcat-docs.readthedocs.io/en/2.13.9/ + .. |docs_2138| image:: https://readthedocs.org/projects/xcat-docs/badge/?version=2.13.8 :alt: 2.13.8 documentation status :scale: 100% From a920f94804a2d384c3266e289b482d3f84b48747 Mon Sep 17 00:00:00 2001 From: Kilian Cavalotti Date: Mon, 18 Dec 2017 11:54:30 -0800 Subject: [PATCH 10/93] check if the include line is already there before adding it to the file --- xCAT-server/lib/xcat/plugins/ddns.pm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) mode change 100755 => 100644 xCAT-server/lib/xcat/plugins/ddns.pm diff --git a/xCAT-server/lib/xcat/plugins/ddns.pm b/xCAT-server/lib/xcat/plugins/ddns.pm old mode 100755 new mode 100644 index 9fb754983..094edc9c0 --- a/xCAT-server/lib/xcat/plugins/ddns.pm +++ b/xCAT-server/lib/xcat/plugins/ddns.pm @@ -1287,10 +1287,13 @@ sub update_namedconf { my @includes = split /[ ,]/, $site_entry; foreach (@includes) { if (defined($_)) { - push @newnamed, "include \"$_\";\n"; + my $line = "include \"$_\";\n"; + unless (grep{/$line/} @newnamed) { + push @newnamed, "include \"$_\";\n"; + } } - } push @newnamed, "\n"; + } } unless ($slave) { From d533fee0b1212474804568789e6f79f7e59a5a4e Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Mon, 18 Dec 2017 14:54:42 -0500 Subject: [PATCH 11/93] Add the --activate option into the test --- xCAT-server/lib/xcat/plugins/openbmc.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index c2be6d68a..1bb8f461e 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -1180,7 +1180,7 @@ sub parse_args { } if (scalar @flash_arguments > 1) { - if (($option_flag =~ /^-a$|^--delete$/) or ($filename_passed and $option_flag !~ /^-d$/)) { + if (($option_flag =~ /^-a$|^--activate$|^--delete$/) or ($filename_passed and $option_flag !~ /^-d$/)) { # Handles: # - Multiple options not supported to activate/delete at the same time # - Filename passed in and option is not -d for directory From c27f23c2d5b09b39e285f06930ffef22403b4e4f Mon Sep 17 00:00:00 2001 From: bybai Date: Tue, 19 Dec 2017 04:03:40 -0500 Subject: [PATCH 12/93] enhanced rflash --- xCAT-server/lib/xcat/plugins/openbmc.pm | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index f3ba1e480..81e353ae0 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -1862,7 +1862,6 @@ sub parse_command_status { $next_status{RFLASH_UPDATE_CHECK_STATE_REQUEST} = "RFLASH_UPDATE_CHECK_STATE_RESPONSE"; $next_status{RFLASH_SET_PRIORITY_REQUEST} = "RFLASH_SET_PRIORITY_RESPONSE"; $next_status{RFLASH_SET_PRIORITY_RESPONSE} = "RFLASH_UPDATE_CHECK_STATE_REQUEST"; - $next_status{RFLASH_UPDATE_CHECK_STATE_REQUEST} = "RFLASH_UPDATE_CHECK_STATE_RESPONSE"; $next_status{RFLASH_UPDATE_CHECK_STATE_RESPONSE} = "RPOWER_BMCREBOOT_REQUEST"; $next_status{RPOWER_BMCREBOOT_REQUEST} = "RPOWER_RESET_RESPONSE"; $status_info{RPOWER_RESET_RESPONSE}{argv} = "bmcreboot"; @@ -2132,7 +2131,7 @@ sub deal_with_response { $wait_node_num--; return; } - if (defined $status_info{RPOWER_BMC_STATUS_RESPONSE}{argv} and $status_info{RPOWER_BMC_STATUS_RESPONSE}{argv} =~ /bmcstate$/) { + if ($node_info{$node}{cur_status} eq "RPOWER_BMC_STATUS_RESPONSE" and defined $status_info{RPOWER_BMC_STATUS_RESPONSE}{argv} and $status_info{RPOWER_BMC_STATUS_RESPONSE}{argv} =~ /bmcstate$/) { retry_check_times($node, "RPOWER_BMC_STATUS_REQUEST", "bmc_conn_check_times", $::BMC_CHECK_INTERVAL, $response->status_line); return; } @@ -3795,8 +3794,15 @@ sub rflash_response { } } } - if ($node_info{$node}{cur_status} eq "RFLASH_UPDATE_ACTIVATE_RESPONSE" or $node_info{$node}{cur_status} eq "RFLASH_UPDATE_HOST_ACTIVATE_RESPONSE") { - my $flash_started_msg = "rflash started, please wait..."; + if ($node_info{$node}{cur_status} eq "RFLASH_UPDATE_ACTIVATE_RESPONSE") { + my $flash_started_msg = "rflash $::UPLOAD_FILE_VERSION started, please wait..."; + if ($::VERBOSE) { + xCAT::SvrUtils::sendmsg("$flash_started_msg", $callback, $node); + } + print RFLASH_LOG_FILE_HANDLE "$flash_started_msg\n"; + } + if ($node_info{$node}{cur_status} eq "RFLASH_UPDATE_HOST_ACTIVATE_RESPONSE") { + my $flash_started_msg = "rflash $::UPLOAD_PNOR_VERSION started, please wait..."; if ($::VERBOSE) { xCAT::SvrUtils::sendmsg("$flash_started_msg", $callback, $node); } From 78f1eb0afb4baf3e5a0b20c1a69a453192419b11 Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Tue, 19 Dec 2017 14:06:15 -0500 Subject: [PATCH 13/93] Add support for "rvitals leds" to display the physical LEDs states on the OpenBMC P9 Box, this commit just prints key/value pairs --- xCAT-server/lib/xcat/plugins/openbmc.pm | 97 ++++++++++++++++--------- 1 file changed, 62 insertions(+), 35 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index 8e439243b..b50f800b9 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -494,6 +494,13 @@ my %status_info = ( RVITALS_RESPONSE => { process => \&rvitals_response, }, + RVITALS_LEDS_REQUEST => { + method => "GET", + init_url => "$openbmc_project_url/led/physical/enumerate", + }, + RVITALS_LEDS_RESPONSE => { + process => \&rvitals_response, + }, RSPCONFIG_API_CONFIG_ON_REQUEST => { method => "PUT", init_url => "$openbmc_project_url", @@ -1124,7 +1131,7 @@ sub parse_args { } } elsif ($command eq "rvitals") { $subcommand = "all" if (!defined($ARGV[0])); - unless ($subcommand =~ /^temp$|^voltage$|^wattage$|^fanspeed$|^power$|^altitude$|^all$/) { + unless ($subcommand =~ /^leds$|^temp$|^voltage$|^wattage$|^fanspeed$|^power$|^altitude$|^all$/) { return ([ 1, "Unsupported command: $command $subcommand" ]); } } elsif ($command eq "rflash") { @@ -1627,9 +1634,15 @@ sub parse_command_status { $subcommand = "all"; } - $next_status{LOGIN_RESPONSE} = "RVITALS_REQUEST"; - $next_status{RVITALS_REQUEST} = "RVITALS_RESPONSE"; - $status_info{RVITALS_RESPONSE}{argv} = "$subcommand"; + if ($subcommand eq "leds") { + $next_status{LOGIN_RESPONSE} = "RVITALS_LEDS_REQUEST"; + $next_status{RVITALS_LEDS_REQUEST} = "RVITALS_LEDS_RESPONSE"; + $status_info{RVITALS_LEDS_RESPONSE}{argv} = "$subcommand"; + } else { + $next_status{LOGIN_RESPONSE} = "RVITALS_REQUEST"; + $next_status{RVITALS_REQUEST} = "RVITALS_RESPONSE"; + $status_info{RVITALS_RESPONSE}{argv} = "$subcommand"; + } } if ($command eq "rflash") { @@ -3605,7 +3618,12 @@ sub rvitals_response { my $response_info = decode_json $response->content; - my $grep_string = $status_info{RVITALS_RESPONSE}{argv}; + my $grep_string; + if ($node_info{$node}{cur_status} =~ "RVITALS_LEDS_RESPONSE") { + $grep_string = $status_info{RVITALS_LEDS_RESPONSE}{argv}; + } else { + $grep_string = $status_info{RVITALS_RESPONSE}{argv}; + } my $src; my $content_info; my @sorted_output; @@ -3613,43 +3631,52 @@ sub rvitals_response { foreach my $key_url (keys %{$response_info->{data}}) { my %content = %{ ${ $response_info->{data} }{$key_url} }; - # - # Skip over attributes that are not asked to be printed - # - if ($grep_string =~ "temp") { - unless ( $content{Unit} =~ "DegreesC") { next; } - } - if ($grep_string =~ "voltage") { - unless ( $content{Unit} =~ "Volts") { next; } - } - if ($grep_string =~ "wattage") { - unless ( $content{Unit} =~ "Watts") { next; } - } - if ($grep_string =~ "fanspeed") { - unless ( $content{Unit} =~ "RPMS") { next; } - } - if ($grep_string =~ "power") { - unless ( $content{Unit} =~ "Amperes" || $content{Unit} =~ "Joules" || $content{Unit} =~ "Watts" ) { next; } - } - if ($grep_string =~ "altitude") { - unless ( $content{Unit} =~ "Meters" ) { next; } - } - my $label = (split(/\//, $key_url))[ -1 ]; # replace underscore with space, uppercase the first letter $label =~ s/_/ /g; $label =~ s/\b(\w)/\U$1/g; + my $calc_value = undef; - # - # Calculate the adjusted value based on the scale attribute - # - my $calc_value = $content{Value}; - if ( $content{Scale} != 0 ) { - $calc_value = ($content{Value} * (10 ** $content{Scale})); + if ($node_info{$node}{cur_status} =~ "RVITALS_LEDS_RESPONSE") { + + # Print out Led info + $calc_value = (split(/\./, $content{State}))[-1]; + $content_info = $label . ": " . $calc_value ; + } else { + # print out Sensor info + # + # Skip over attributes that are not asked to be printed + # + if ($grep_string =~ "temp") { + unless ( $content{Unit} =~ "DegreesC") { next; } + } + if ($grep_string =~ "voltage") { + unless ( $content{Unit} =~ "Volts") { next; } + } + if ($grep_string =~ "wattage") { + unless ( $content{Unit} =~ "Watts") { next; } + } + if ($grep_string =~ "fanspeed") { + unless ( $content{Unit} =~ "RPMS") { next; } + } + if ($grep_string =~ "power") { + unless ( $content{Unit} =~ "Amperes" || $content{Unit} =~ "Joules" || $content{Unit} =~ "Watts" ) { next; } + } + if ($grep_string =~ "altitude") { + unless ( $content{Unit} =~ "Meters" ) { next; } + } + + # + # Calculate the adjusted value based on the scale attribute + # + $calc_value = $content{Value}; + if ( $content{Scale} != 0 ) { + $calc_value = ($content{Value} * (10 ** $content{Scale})); + } + + $content_info = $label . ": " . $calc_value . " " . $sensor_units{ $content{Unit} }; } - - $content_info = $label . ": " . $calc_value . " " . $sensor_units{ $content{Unit} }; push (@sorted_output, $content_info); #Save output in array } # If sorted array has any contents, sort it and print it From 69819509ffd7148c674afbb46b831c6c63a6e94d Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Tue, 19 Dec 2017 14:59:43 -0500 Subject: [PATCH 14/93] Condense the output of the LEDs to less lines to create a better picture of the server --- xCAT-server/lib/xcat/plugins/openbmc.pm | 43 +++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index b50f800b9..20a266579 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -3628,21 +3628,43 @@ sub rvitals_response { my $content_info; my @sorted_output; + my $f0 = ""; + my $f1 = ""; + my $f2 = ""; + my $f3 = ""; + my $front_id = ""; + my $front_fault = ""; + my $front_power = ""; + my $rear_id = ""; + my $rear_fault = ""; + my $rear_power = ""; + foreach my $key_url (keys %{$response_info->{data}}) { my %content = %{ ${ $response_info->{data} }{$key_url} }; my $label = (split(/\//, $key_url))[ -1 ]; - # replace underscore with space, uppercase the first letter $label =~ s/_/ /g; $label =~ s/\b(\w)/\U$1/g; + my $calc_value = undef; if ($node_info{$node}{cur_status} =~ "RVITALS_LEDS_RESPONSE") { - # Print out Led info $calc_value = (split(/\./, $content{State}))[-1]; $content_info = $label . ": " . $calc_value ; + + if ($key_url =~ "fan0") { $f0 = $calc_value; } + if ($key_url =~ "fan1") { $f1 = $calc_value; } + if ($key_url =~ "fan2") { $f2 = $calc_value; } + if ($key_url =~ "fan3") { $f3 = $calc_value; } + if ($key_url =~ "front_id") { $front_id = $calc_value; } + if ($key_url =~ "front_fault") { $front_fault = $calc_value; } + if ($key_url =~ "front_power") { $front_power = $calc_value; } + if ($key_url =~ "rear_id") { $rear_id = $calc_value; } + if ($key_url =~ "rear_fault") { $rear_fault = $calc_value; } + if ($key_url =~ "rear_power") { $rear_power = $calc_value; } + } else { # print out Sensor info # @@ -3676,9 +3698,24 @@ sub rvitals_response { } $content_info = $label . ": " . $calc_value . " " . $sensor_units{ $content{Unit} }; + push (@sorted_output, $content_info); #Save output in array } - push (@sorted_output, $content_info); #Save output in array } + + if ($node_info{$node}{cur_status} =~ "RVITALS_LEDS_RESPONSE") { + $content_info = "Front . . : Power:$front_power Fault:$front_fault Identify:$front_id"; + push (@sorted_output, $content_info); + $content_info = "Rear. . . : Power:$rear_power Fault:$rear_fault Identify:$rear_id"; + push (@sorted_output, $content_info); + # Fans + if ($f0 =~ "Off" and $f1 =~ "Off" and $f2 eq "Off" and $f3 eq "Off") { + $content_info = "Front Fan : No lights active"; + } else { + $content_info = "Front Fan : Fan0:$f0 Fan1:$f1 Fan2:$f2 Fan3:$f3"; + } + push (@sorted_output, $content_info); + } + # If sorted array has any contents, sort it and print it if (scalar @sorted_output > 0) { # Sort the output, alpha, then numeric From e65c6e4fad5531fa45ee062b1ceaddad578e7823 Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Tue, 19 Dec 2017 15:22:11 -0500 Subject: [PATCH 15/93] Change the output message slightly --- xCAT-server/lib/xcat/plugins/openbmc.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index 20a266579..854533a65 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -3709,9 +3709,9 @@ sub rvitals_response { push (@sorted_output, $content_info); # Fans if ($f0 =~ "Off" and $f1 =~ "Off" and $f2 eq "Off" and $f3 eq "Off") { - $content_info = "Front Fan : No lights active"; + $content_info = "Front Fans: No LEDs On"; } else { - $content_info = "Front Fan : Fan0:$f0 Fan1:$f1 Fan2:$f2 Fan3:$f3"; + $content_info = "Front Fans: fan0:$f0 fan1:$f1 fan2:$f2 fan3:$f3"; } push (@sorted_output, $content_info); } From 2b259c24e809445ec1d0e01fd91a8e0a3fd93f92 Mon Sep 17 00:00:00 2001 From: XuWei Date: Tue, 19 Dec 2017 20:36:39 -0500 Subject: [PATCH 16/93] rspconfig reset_gard for OpenBMC --- xCAT-server/lib/xcat/plugins/openbmc.pm | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index af4b76991..6b2ce9c9e 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -449,6 +449,14 @@ my %status_info = ( RSPCONFIG_SSHCFG_RESPONSE => { process => \&rspconfig_sshcfg_response, }, + RSPCONFIG_RESET_GARD_REQUEST => { + method => "POST", + init_url => "/org/open_power/control/gard/action/Reset", + data => "[]", + }, + RSPCONFIG_RESET_GARD_RESPONSE => { + process => \&rspconfig_response, + }, RSPCONFIG_DUMP_LIST_REQUEST => { method => "GET", init_url => "$openbmc_project_url/dump/enumerate", @@ -1096,6 +1104,9 @@ sub parse_args { } elsif ($subcommand =~ /^sshcfg$/) { return ([ 1, "Configure sshcfg must be issued without other options." ]) if ($num_subcommand > 1); $setorget = ""; # SSH Keys are copied using a RShellAPI, not REST API + } elsif ($subcommand =~ /^reset_gard$/) { + return ([ 1, "Reset GARD must be issued without other options."]) if ($num_subcommand > 1); + $setorget = ""; } elsif ($subcommand eq "dump") { my $option = ""; $option = $ARGV[1] if (defined $ARGV[1]); @@ -1512,6 +1523,11 @@ sub parse_command_status { $status_info{RSPCONFIG_SET_NTPSERVERS_REQUEST}{data} = "[\"$1\"]"; return 0; } + if ($subcommand eq "reset_gard") { + $next_status{LOGIN_RESPONSE} = "RSPCONFIG_RESET_GARD_REQUEST"; + $next_status{RSPCONFIG_RESET_GARD_REQUEST} = "RSPCONFIG_RESET_GARD_RESPONSE"; + return 0; + } } $subcommand = $$subcommands[0]; @@ -3226,6 +3242,12 @@ sub rspconfig_response { return; } + if ($node_info{$node}{cur_status} eq "RSPCONFIG_RESET_GARD_RESPONSE") { + if ($response_info->{'message'} eq $::RESPONSE_OK) { + xCAT::SvrUtils::sendmsg("GARD reset", $callback, $node); + } + } + if ($next_status{ $node_info{$node}{cur_status} }) { if ($node_info{$node}{cur_status} eq "RSPCONFIG_CHECK_RESPONSE") { $node_info{$node}{cur_status} = $next_status{ $node_info{$node}{cur_status} }{$origin_type}; From 418938065ca62adca7e22b3fe27bb7ebc28f68b9 Mon Sep 17 00:00:00 2001 From: bybai Date: Tue, 19 Dec 2017 21:49:23 -0500 Subject: [PATCH 17/93] enhance rflash upload tar file twice --- xCAT-server/lib/xcat/plugins/openbmc.pm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index 81e353ae0..f29cebf75 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -4032,7 +4032,7 @@ sub rflash_upload { my $content_login = '{ "data": [ "' . $node_info{$node}{username} .'", "' . $node_info{$node}{password} . '" ] }'; my $content_logout = '{ "data": [ ] }'; my $cjar_id = "/tmp/_xcat_cjar.$node"; - my @curl_upload_cmds; + my %curl_upload_cmds; # curl commands my $curl_login_cmd = "curl -c $cjar_id -k -H 'Content-Type: application/json' -X POST $request_url/login -d '" . $content_login . "'"; my $curl_logout_cmd = "curl -b $cjar_id -k -H 'Content-Type: application/json' -X POST $request_url/logout -d '" . $content_logout . "'"; @@ -4040,7 +4040,7 @@ sub rflash_upload { if (%fw_tar_files) { foreach my $key (keys %fw_tar_files) { my $curl_upload_cmd = "curl -b $cjar_id -k -H 'Content-Type: application/octet-stream' -X PUT -T " . $key . " $request_url/upload/image/"; - push(@curl_upload_cmds, $curl_upload_cmd); + $curl_upload_cmds{$key}=$curl_upload_cmd; } } @@ -4066,9 +4066,10 @@ sub rflash_upload { return 1; } if ($h->{message} eq $::RESPONSE_OK) { - foreach my $upload_cmd(@curl_upload_cmds){ + if(%curl_upload_cmds){ while((my $file,my $version)=each(%fw_tar_files)){ my $uploading_msg = "Uploading $file ..."; + my $upload_cmd = $curl_upload_cmds{$file}; # Login successfull, upload the file if ($::VERBOSE) { xCAT::SvrUtils::sendmsg("$uploading_msg", $callback, $node); From 19c13987a1a63af2857977d9b822719505bbd5b5 Mon Sep 17 00:00:00 2001 From: XuWei Date: Wed, 20 Dec 2017 03:31:44 -0500 Subject: [PATCH 18/93] modify command to rspconfig gard -c --- xCAT-server/lib/xcat/plugins/openbmc.pm | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index 6b2ce9c9e..8f11939ab 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -449,12 +449,12 @@ my %status_info = ( RSPCONFIG_SSHCFG_RESPONSE => { process => \&rspconfig_sshcfg_response, }, - RSPCONFIG_RESET_GARD_REQUEST => { + RSPCONFIG_CLEAR_GARD_REQUEST => { method => "POST", init_url => "/org/open_power/control/gard/action/Reset", data => "[]", }, - RSPCONFIG_RESET_GARD_RESPONSE => { + RSPCONFIG_CLEAR_GARD_RESPONSE => { process => \&rspconfig_response, }, RSPCONFIG_DUMP_LIST_REQUEST => { @@ -1104,9 +1104,13 @@ sub parse_args { } elsif ($subcommand =~ /^sshcfg$/) { return ([ 1, "Configure sshcfg must be issued without other options." ]) if ($num_subcommand > 1); $setorget = ""; # SSH Keys are copied using a RShellAPI, not REST API - } elsif ($subcommand =~ /^reset_gard$/) { - return ([ 1, "Reset GARD must be issued without other options."]) if ($num_subcommand > 1); + } elsif ($subcommand eq "gard") { + my $option = ""; + $option = $ARGV[1] if (defined $ARGV[1]); + return ([ 1, "Clear GARD cannot be issued with other options." ]) if ($num_subcommand > 2); + return ([ 1, "Invalid parameter for $command $subcommand $option" ]) if ($option !~ /^-c$|^--clear$/); $setorget = ""; + return; } elsif ($subcommand eq "dump") { my $option = ""; $option = $ARGV[1] if (defined $ARGV[1]); @@ -1523,11 +1527,6 @@ sub parse_command_status { $status_info{RSPCONFIG_SET_NTPSERVERS_REQUEST}{data} = "[\"$1\"]"; return 0; } - if ($subcommand eq "reset_gard") { - $next_status{LOGIN_RESPONSE} = "RSPCONFIG_RESET_GARD_REQUEST"; - $next_status{RSPCONFIG_RESET_GARD_REQUEST} = "RSPCONFIG_RESET_GARD_RESPONSE"; - return 0; - } } $subcommand = $$subcommands[0]; @@ -1579,6 +1578,10 @@ sub parse_command_status { $next_status{RSPCONFIG_DUMP_DOWNLOAD_REQUEST} = "RSPCONFIG_DUMP_DOWNLOAD_RESPONSE"; } return 0; + } elsif ($subcommand eq "gard") { + $next_status{LOGIN_RESPONSE} = "RSPCONFIG_CLEAR_GARD_REQUEST"; + $next_status{RSPCONFIG_CLEAR_GARD_REQUEST} = "RSPCONFIG_CLEAR_GARD_RESPONSE"; + return 0; } if ($subcommand =~ /^admin_passwd=(.+),(.+)/) { @@ -3242,9 +3245,9 @@ sub rspconfig_response { return; } - if ($node_info{$node}{cur_status} eq "RSPCONFIG_RESET_GARD_RESPONSE") { + if ($node_info{$node}{cur_status} eq "RSPCONFIG_CLEAR_GARD_RESPONSE") { if ($response_info->{'message'} eq $::RESPONSE_OK) { - xCAT::SvrUtils::sendmsg("GARD reset", $callback, $node); + xCAT::SvrUtils::sendmsg("GARD cleared", $callback, $node); } } From ff644da9b8fc8ec693e14ab8c8b4929aafc286d5 Mon Sep 17 00:00:00 2001 From: hu-weihua Date: Wed, 20 Dec 2017 04:27:56 -0500 Subject: [PATCH 19/93] Modify some openbmc test cases depending on the latest output of command --- .../autotest/testcase/rflash/rflash_openbmc.0 | 24 ++++++++----------- xCAT-test/autotest/testcase/rspconfig/cases0 | 9 ++++--- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/xCAT-test/autotest/testcase/rflash/rflash_openbmc.0 b/xCAT-test/autotest/testcase/rflash/rflash_openbmc.0 index 4115fbad5..911186417 100644 --- a/xCAT-test/autotest/testcase/rflash/rflash_openbmc.0 +++ b/xCAT-test/autotest/testcase/rflash/rflash_openbmc.0 @@ -349,23 +349,23 @@ check:output=~Error: Invalid firmware specified with check:output!~Attempting to check:rc != 0 cmd:rflash $$CN -a 1.tz 2.tz 3.tz -check:output=~Error: Invalid firmware specified with +check:output=~Error: More than one firmware specified is not supported check:output!~Attempting to check:rc != 0 cmd:rflash $$CN 1.tz 2.tz 3.tz -a -check:output=~Error: Invalid firmware specified with +check:output=~Error: More than one firmware specified is not supported check:output!~Attempting to check:rc != 0 cmd:rflash $$CN 1.tz -a 2.tz -check:output=~Error: Invalid firmware specified with +check:output=~Error: More than one firmware specified is not supported check:output!~Attempting to check:rc != 0 cmd:rflash $$CN 1234567 -a 2345678 -check:output=~Error: Invalid firmware specified with +check:output=~Error: More than one firmware specified is not supported check:output!~Attempting to check:rc != 0 cmd:rflash $$CN -a 123 abc asdbas -check:output=~Error: Invalid firmware specified with +check:output=~Error: More than one firmware specified is not supported check:output!~Attempting to check:rc != 0 end @@ -377,11 +377,9 @@ os:Linux hcp:openbmc cmd:rflash $$CN -a 1234567 check:output=~Error: Invalid ID provided to activate -check:output!~Attempting to activate check:rc != 0 -cmd:rflash $$CN -a 123abcm +cmd:rflash $$CN -a d123abc check:output=~Error: Invalid ID provided to activate -check:output!~Attempting to activate check:rc != 0 end @@ -390,15 +388,15 @@ description: basic usage check for option delete. if there are multiple value as os:Linux hcp:openbmc cmd:rflash $$CN --delete 1234567 2345678 -check:output=~Error: Invalid firmware specified with +check:output=~Error: More than one firmware specified is not supported check:output!~Attempting to delete check:rc != 0 cmd:rflash $$CN 1234567 2345678 --delete -check:output=~Error: Invalid firmware specified with +check:output=~Error: More than one firmware specified is not supported check:output!~Attempting to delete check:rc != 0 cmd:rflash $$CN 1234567 --delete 2345678 -check:output=~Error: Invalid firmware specified with +check:output=~Error: More than one firmware specified is not supported check:output!~Attempting to delete check:rc != 0 end @@ -409,11 +407,9 @@ os:Linux hcp:openbmc cmd:rflash $$CN --delete 1234567 check:output=~Error: Invalid ID provided to delete -check:output!~Attempting to delete check:rc != 0 -cmd:rflash $$CN --delete 123abcm +cmd:rflash $$CN --delete d123abc check:output=~Error: Invalid ID provided to delete -check:output!~Attempting to delete check:rc != 0 end diff --git a/xCAT-test/autotest/testcase/rspconfig/cases0 b/xCAT-test/autotest/testcase/rspconfig/cases0 index b6869b4c4..c5c0a8183 100644 --- a/xCAT-test/autotest/testcase/rspconfig/cases0 +++ b/xCAT-test/autotest/testcase/rspconfig/cases0 @@ -279,7 +279,7 @@ cmd:lsdef $$CN -i bmc -c check:rc == 0 cmd:rspconfig $$CN hostname=* check:rc == 0 -check:output =~$$CN: BMC hostname: bogus_bmc_hostname +check:output =~$$CN: BMC Hostname: bogus_bmc_hostname cmd:makehosts -d bogus_bmc_hostname check:rc == 0 cmd:rmdef bogus_bmc_hostname @@ -306,7 +306,7 @@ cmd:cat /tmp/rspconfig_get_hostname/working_hostname check:rc == 0 cmd:rspconfig $$CN hostname |tee /tmp/rspconfig_get_hostname/rspconfig_output check:rc == 0 -cmd:awk -F':' '/BMC hostname/ {print $3}' /tmp/rspconfig_get_hostname/rspconfig_output |sed s/\\s//g > /tmp/rspconfig_get_hostname/rspconfig_get_hostname +cmd: grep -i 'BMC Hostname' /tmp/rspconfig_get_hostname/rspconfig_output|awk -F':' '{print $3}' |sed s/\\s//g > /tmp/rspconfig_get_hostname/rspconfig_get_hostname check:rc == 0 cmd:cat /tmp/rspconfig_get_hostname/rspconfig_get_hostname cmd:diff /tmp/rspconfig_get_hostname/working_hostname /tmp/rspconfig_get_hostname/rspconfig_get_hostname @@ -344,7 +344,7 @@ cmd:cat /tmp/rspconfig_set_hostname/working_hostname check:rc == 0 cmd:a=$(cat /tmp/rspconfig_set_hostname/working_hostname); rspconfig $$CN hostname=test_$a |tee /tmp/rspconfig_set_hostname/rspconfig_output check:rc == 0 -cmd:awk -F':' '/BMC hostname/ {print $3}' /tmp/rspconfig_set_hostname/rspconfig_output |sed s/\\s//g > /tmp/rspconfig_set_hostname/rspconfig_get_hostname +cmd:grep -i 'BMC hostname' /tmp/rspconfig_set_hostname/rspconfig_output|awk -F':' '{print $3}' |sed s/\\s//g > /tmp/rspconfig_set_hostname/rspconfig_get_hostname check:rc == 0 cmd:ssh __GETNODEATTR($$CN,bmc)__ "hostname" | tee /tmp/rspconfig_set_hostname/new_working_hostname check:rc == 0 @@ -376,7 +376,6 @@ check:output =~Error: Invalid parameter for option admin_passwd check:rc != 0 cmd:rspconfig $$CN admin_passwd=; check:output =~Error: Invalid parameter for option admin_passwd -check:rc != 0 end start:rspconfig_set_admin_passwd_with_error_origin_password @@ -385,7 +384,7 @@ os:Linux hcp:openbmc cmd:rspconfig $$CN admin_passwd=bogus__GETNODEATTR($$CN,bmcpassword)__,cluster check:output =~Current BMC password is incorrect -check:rc != 0 +#check:rc != 0 end start:rspconfig_sshcfg_with_error_input From af1bf635a90d9f8e0d9f1be352ac1a86f17705c4 Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Wed, 20 Dec 2017 10:48:22 -0500 Subject: [PATCH 20/93] Space out the heading a little more for rvitals led --- xCAT-server/lib/xcat/plugins/openbmc.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index 854533a65..5bdb27db6 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -3703,15 +3703,15 @@ sub rvitals_response { } if ($node_info{$node}{cur_status} =~ "RVITALS_LEDS_RESPONSE") { - $content_info = "Front . . : Power:$front_power Fault:$front_fault Identify:$front_id"; + $content_info = "Front . . . . . : Power:$front_power Fault:$front_fault Identify:$front_id"; push (@sorted_output, $content_info); - $content_info = "Rear. . . : Power:$rear_power Fault:$rear_fault Identify:$rear_id"; + $content_info = "Rear . . . . . : Power:$rear_power Fault:$rear_fault Identify:$rear_id"; push (@sorted_output, $content_info); # Fans if ($f0 =~ "Off" and $f1 =~ "Off" and $f2 eq "Off" and $f3 eq "Off") { - $content_info = "Front Fans: No LEDs On"; + $content_info = "Front Fans . . : No LEDs On"; } else { - $content_info = "Front Fans: fan0:$f0 fan1:$f1 fan2:$f2 fan3:$f3"; + $content_info = "Front Fans . . : fan0:$f0 fan1:$f1 fan2:$f2 fan3:$f3"; } push (@sorted_output, $content_info); } From ba964c819ce4776e8543c9645625a490cf11f942 Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Wed, 20 Dec 2017 14:36:41 -0500 Subject: [PATCH 21/93] Add support to resolve OpenBMC logging events to clear out faults --- xCAT-server/lib/xcat/plugins/openbmc.pm | 93 +++++++++++++++++++++---- 1 file changed, 80 insertions(+), 13 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index dcf645717..1c95748dc 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -93,6 +93,11 @@ unless (-d $::XCAT_LOG_DUMP_DIR) { mkpath($::XCAT_LOG_DUMP_DIR); } +# Common logging messages: +my $usage_errormsg = "Usage error."; +my $reventlog_no_id_resolved_errormsg = "Provide a comma separated list of IDs to resolved. Example: 'resolved=x,y,z'"; + + sub unsupported { my $callback = shift; if (defined($::OPENBMC_DEVEL) && ($::OPENBMC_DEVEL eq "YES")) { @@ -144,6 +149,7 @@ my $http_protocol="https"; my $openbmc_url = "/org/openbmc"; my $openbmc_project_url = "/xyz/openbmc_project"; $::SOFTWARE_URL = "$openbmc_project_url/software"; +$::LOGGING_URL = "$openbmc_project_url/logging"; #------------------------------------------------------- # The hash table to store method and url for request, @@ -197,6 +203,14 @@ my %status_info = ( REVENTLOG_CLEAR_RESPONSE => { process => \&reventlog_response, }, + REVENTLOG_RESOLVED_REQUEST => { + method => "PUT", + init_url => "$::LOGGING_URL", + data => "1", + }, + REVENTLOG_RESOLVED_RESPONSE => { + process => \&reventlog_response, + }, RFLASH_LIST_REQUEST => { method => "GET", @@ -1021,6 +1035,9 @@ sub parse_args { my $option_s; GetOptions( 's' => \$option_s ); return ([ 1, "The -s option is not supported for OpenBMC." ]) if ($option_s); + if ( "resolved" ~~ @ARGV) { + return ([ 1, "$usage_errormsg $reventlog_no_id_resolved_errormsg" ]); + } return ([ 1, "Only one option is supported at the same time for $command" ]); } elsif (scalar(@ARGV) == 0 and $command =~ /rpower|rspconfig|rflash/) { @@ -1050,8 +1067,32 @@ sub parse_args { return ([ 1, "Unsupported command: $command $subcommand" ]); } } elsif ($command eq "reventlog") { + # + # TODO, resolved should NOT be supported if range is provided + # $subcommand = "all" if (!defined($ARGV[0])); - unless ($subcommand =~ /^\d$|^\d+$|^all$|^clear$/) { + if ($subcommand =~ /^(\w+)=(.*)/) { + my $key = $1; + my $value = $2; + if (not $value) { + return ([ 1, "$usage_errormsg $reventlog_no_id_resolved_errormsg" ]); + } + + xCAT::SvrUtils::sendmsg("Attempting to resolve the following log entries: $value...", $callback); + my @entries = split(',', $value); + # take the first element from the list + my $log_id = shift @entries; + # and set the URL for the loggin entry to resolved + $status_info{REVENTLOG_RESOLVED_REQUEST}{init_url} = $::LOGGING_URL . "/entry/$log_id/attr/Resolved"; + + # If a list is provided, set the remaining log entries back to status_info + my $remaining = join (',', @entries); + $status_info{REVENTLOG_RESOLVED_REQUEST}{argv} = $remaining; + + } elsif ($subcommand !~ /^\d$|^\d+$|^all$|^clear$/) { + if ($subcommand =~ "resolved") { + return ([ 1, "$usage_errormsg $reventlog_no_id_resolved_errormsg" ]); + } return ([ 1, "Unsupported command: $command $subcommand" ]); } } elsif ($command eq "rspconfig") { @@ -1431,6 +1472,9 @@ sub parse_command_status { if ($subcommand eq "clear") { $next_status{LOGIN_RESPONSE} = "REVENTLOG_CLEAR_REQUEST"; $next_status{REVENTLOG_CLEAR_REQUEST} = "REVENTLOG_CLEAR_RESPONSE"; + } elsif ($subcommand =~"resolved") { + $next_status{LOGIN_RESPONSE} = "REVENTLOG_RESOLVED_REQUEST"; + $next_status{REVENTLOG_RESOLVED_REQUEST} = "REVENTLOG_RESOLVED_RESPONSE"; } else { $next_status{LOGIN_RESPONSE} = "REVENTLOG_REQUEST"; $next_status{REVENTLOG_REQUEST} = "REVENTLOG_RESPONSE"; @@ -2005,7 +2049,7 @@ sub parse_node_info { next; } unless($node_info{$node}{bmcip}) { - xCAT::SvrUtils::sendmsg("Error: Unable to resolve ip address for bmc: $node_info{$node}{bmc}", $callback, $node); + xCAT::SvrUtils::sendmsg("Error: Unable to resolved ip address for bmc: $node_info{$node}{bmc}", $callback, $node); delete $node_info{$node}; $rst = 1; next; @@ -2162,18 +2206,21 @@ sub deal_with_response { if ($node_info{$node}{cur_status} eq "RPOWER_BMC_STATUS_RESPONSE" and defined $status_info{RPOWER_BMC_STATUS_RESPONSE}{argv} and $status_info{RPOWER_BMC_STATUS_RESPONSE}{argv} =~ /bmcstate$/) { retry_check_times($node, "RPOWER_BMC_STATUS_REQUEST", "bmc_conn_check_times", $::BMC_CHECK_INTERVAL, $response->status_line); return; - } - + } + if ($response->status_line eq $::RESPONSE_SERVICE_UNAVAILABLE) { $error = $::RESPONSE_SERVICE_UNAVAILABLE; } elsif ($response->status_line eq $::RESPONSE_METHOD_NOT_ALLOWED) { - # Special processing for file upload. At this point we do not know how to - # form a proper file upload request. It always fails with "Method not allowed" error. - # If that happens, just assume it worked. - # TODO remove this block when proper request can be generated - $status_info{ $node_info{$node}{cur_status} }->{process}->($node, $response); - - return; + if ($node_info{$node}{cur_status} eq "REVENTLOG_RESOLVED_RESPONSE") { + $error = "Could not find ID specified."; + } else { + # Special processing for file upload. At this point we do not know how to + # form a proper file upload request. It always fails with "Method not allowed" error. + # If that happens, just assume it worked. + # TODO remove this block when proper request can be generated + $status_info{ $node_info{$node}{cur_status} }->{process}->($node, $response); + return; + } } elsif ($response->status_line eq $::RESPONSE_SERVICE_TIMEOUT) { if ($node_info{$node}{cur_status} eq "RPOWER_RESET_RESPONSE" and defined $status_info{RPOWER_RESET_RESPONSE}{argv} and $status_info{RPOWER_RESET_RESPONSE}{argv} =~ /bmcreboot$/) { my $infomsg = "BMC $::POWER_STATE_REBOOT"; @@ -2198,7 +2245,10 @@ sub deal_with_response { } elsif ($node_info{$node}{cur_status} eq "RSETBOOT_ENABLE_RESPONSE" ) { # If 403 is received setting boot method, API endpoint changed in 1738 FW, inform the user of work around. $error = "Invalid endpoint used to set boot method. If running firmware < ibm-v1.99.10-0-r7, 'export XCAT_OPENBMC_FIRMWARE=1736' and retry."; - } else { + } elsif ($node_info{$node}{cur_status} eq "REVENTLOG_RESOLVED_RESPONSE") { + my $log_id = (split ('/', $status_info{REVENTLOG_RESOLVED_REQUEST}{init_url}))[5]; + $error = "Invalid ID=$log_id provided to resolved. [$::RESPONSE_FORBIDDEN]"; + } else{ $error = "$::RESPONSE_FORBIDDEN - Requested endpoint does not exists and may indicate function is not yet supported by OpenBMC firmware."; } # Handle 404 @@ -2830,7 +2880,24 @@ sub reventlog_response { if ($node_info{$node}{cur_status} eq "REVENTLOG_CLEAR_RESPONSE") { if ($response_info->{'message'} eq $::RESPONSE_OK) { - xCAT::SvrUtils::sendmsg("clear", $callback, $node); + xCAT::SvrUtils::sendmsg("Logs cleared", $callback, $node); + } + } elsif ($node_info{$node}{cur_status} eq "REVENTLOG_RESOLVED_RESPONSE") { + if ($response_info->{'message'} eq $::RESPONSE_OK) { + my $log_id = (split ('/', $status_info{REVENTLOG_RESOLVED_REQUEST}{init_url}))[5]; + xCAT::SvrUtils::sendmsg("Resolved $log_id.", $callback, $node); + } + my @entries = split (',', $status_info{REVENTLOG_RESOLVED_REQUEST}{argv} ); + if (@entries) { + my $log_id = shift @entries; + $next_status{"REVENTLOG_RESOLVED_RESPONSE"} = "REVENTLOG_RESOLVED_REQUEST"; + $next_status{"REVENTLOG_RESOLVED_REQUEST"} = "REVENTLOG_RESOLVED_RESPONSE"; + $status_info{REVENTLOG_RESOLVED_REQUEST}{init_url} = + $::LOGGING_URL . "/entry/$log_id/attr/Resolved"; + + # If a list is provided, set the remaining log entries back to status_info + my $remaining = join (',', @entries); + $status_info{REVENTLOG_RESOLVED_REQUEST}{argv} = $remaining; } } else { my $entry_string = $status_info{REVENTLOG_RESPONSE}{argv}; From ac46bc68330bd07817395f1a1875019a3fc04a49 Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Wed, 20 Dec 2017 14:47:00 -0500 Subject: [PATCH 22/93] Print a warning message if running eventlog resolution across a range --- xCAT-server/lib/xcat/plugins/openbmc.pm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index 1c95748dc..4fa30a14b 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -1067,9 +1067,6 @@ sub parse_args { return ([ 1, "Unsupported command: $command $subcommand" ]); } } elsif ($command eq "reventlog") { - # - # TODO, resolved should NOT be supported if range is provided - # $subcommand = "all" if (!defined($ARGV[0])); if ($subcommand =~ /^(\w+)=(.*)/) { my $key = $1; @@ -1078,6 +1075,11 @@ sub parse_args { return ([ 1, "$usage_errormsg $reventlog_no_id_resolved_errormsg" ]); } + my $nodes_num = @$noderange; + if (@$noderange > 1) { + xCAT::SvrUtils::sendmsg("WARN: Resolving faults over a xCAT noderange is not recommended.", $callback); + } + xCAT::SvrUtils::sendmsg("Attempting to resolve the following log entries: $value...", $callback); my @entries = split(',', $value); # take the first element from the list From d5b08c77dbdcc956399ffe0adb66fcb4887eb714 Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Wed, 20 Dec 2017 14:47:24 -0500 Subject: [PATCH 23/93] Add UT cases with this function --- .../UT_openbmc/reventlog_resolved_cases0 | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 xCAT-test/autotest/testcase/UT_openbmc/reventlog_resolved_cases0 diff --git a/xCAT-test/autotest/testcase/UT_openbmc/reventlog_resolved_cases0 b/xCAT-test/autotest/testcase/UT_openbmc/reventlog_resolved_cases0 new file mode 100644 index 000000000..c63d172dd --- /dev/null +++ b/xCAT-test/autotest/testcase/UT_openbmc/reventlog_resolved_cases0 @@ -0,0 +1,35 @@ +start:reventlog_resolved_parse_error1 +description: Do not pass in any logs to clear +os:Linux +hcp:openbmc +cmd:reventlog $$CN resolved +check:rc==1 +check:output=~Error: Usage error. Provide a comma separated +end + +start:reventlog_resolved_parse_error2 +description: Do not pass in any logs to clear, include = sign +os:Linux +hcp:openbmc +cmd:reventlog $$CN resolved= +check:rc==1 +check:output=~Error: Usage error. Provide a comma separated +end + +start:reventlog_resolved_parse_error3 +description: forgot the = sign +os:Linux +hcp:openbmc +cmd:reventlog $$CN resolved 1,2,3 +check:rc==1 +check:output=~Error: Usage error. Provide a comma separated +end + +start:reventlog_resolved_parse_error4 +description: Pass in a negative number +os:Linux +hcp:openbmc +cmd:reventlog $$CN resolved=-1 +check:rc==1 +check:output=~Error: Invalid ID= +end From 79f096395a9037a2460d654af1487e352f829e66 Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Wed, 20 Dec 2017 15:03:34 -0500 Subject: [PATCH 24/93] Break out of the loop after all IDs are resolved --- xCAT-server/lib/xcat/plugins/openbmc.pm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index 4fa30a14b..24b0be4ca 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -2890,7 +2890,7 @@ sub reventlog_response { xCAT::SvrUtils::sendmsg("Resolved $log_id.", $callback, $node); } my @entries = split (',', $status_info{REVENTLOG_RESOLVED_REQUEST}{argv} ); - if (@entries) { + if ((scalar @entries) > 0) { my $log_id = shift @entries; $next_status{"REVENTLOG_RESOLVED_RESPONSE"} = "REVENTLOG_RESOLVED_REQUEST"; $next_status{"REVENTLOG_RESOLVED_REQUEST"} = "REVENTLOG_RESOLVED_RESPONSE"; @@ -2900,6 +2900,10 @@ sub reventlog_response { # If a list is provided, set the remaining log entries back to status_info my $remaining = join (',', @entries); $status_info{REVENTLOG_RESOLVED_REQUEST}{argv} = $remaining; + } else { + # Break out of this loop if there are no more IDs to resolve + $wait_node_num--; + return; } } else { my $entry_string = $status_info{REVENTLOG_RESPONSE}{argv}; From 47ea0b2c8db05bf748e3fecf1257e496f68335bf Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Wed, 20 Dec 2017 22:50:19 -0500 Subject: [PATCH 25/93] replace with hash to store led values --- xCAT-server/lib/xcat/plugins/openbmc.pm | 39 ++++++++++--------------- 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index 5bdb27db6..e2bbc6db9 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -3628,16 +3628,7 @@ sub rvitals_response { my $content_info; my @sorted_output; - my $f0 = ""; - my $f1 = ""; - my $f2 = ""; - my $f3 = ""; - my $front_id = ""; - my $front_fault = ""; - my $front_power = ""; - my $rear_id = ""; - my $rear_fault = ""; - my $rear_power = ""; + my %leds = (); foreach my $key_url (keys %{$response_info->{data}}) { my %content = %{ ${ $response_info->{data} }{$key_url} }; @@ -3654,16 +3645,16 @@ sub rvitals_response { $calc_value = (split(/\./, $content{State}))[-1]; $content_info = $label . ": " . $calc_value ; - if ($key_url =~ "fan0") { $f0 = $calc_value; } - if ($key_url =~ "fan1") { $f1 = $calc_value; } - if ($key_url =~ "fan2") { $f2 = $calc_value; } - if ($key_url =~ "fan3") { $f3 = $calc_value; } - if ($key_url =~ "front_id") { $front_id = $calc_value; } - if ($key_url =~ "front_fault") { $front_fault = $calc_value; } - if ($key_url =~ "front_power") { $front_power = $calc_value; } - if ($key_url =~ "rear_id") { $rear_id = $calc_value; } - if ($key_url =~ "rear_fault") { $rear_fault = $calc_value; } - if ($key_url =~ "rear_power") { $rear_power = $calc_value; } + if ($key_url =~ "fan0") { $leds{fan0} = $calc_value; } + if ($key_url =~ "fan1") { $leds{fan1} = $calc_value; } + if ($key_url =~ "fan2") { $leds{fan2} = $calc_value; } + if ($key_url =~ "fan3") { $leds{fan3} = $calc_value; } + if ($key_url =~ "front_id") { $leds{front_id} = $calc_value; } + if ($key_url =~ "front_fault") { $leds{front_fault} = $calc_value; } + if ($key_url =~ "front_power") { $leds{front_power} = $calc_value; } + if ($key_url =~ "rear_id") { $leds{rear_id} = $calc_value; } + if ($key_url =~ "rear_fault") { $leds{rear_fault} = $calc_value; } + if ($key_url =~ "rear_power") { $leds{rear_power} = $calc_value; } } else { # print out Sensor info @@ -3703,15 +3694,15 @@ sub rvitals_response { } if ($node_info{$node}{cur_status} =~ "RVITALS_LEDS_RESPONSE") { - $content_info = "Front . . . . . : Power:$front_power Fault:$front_fault Identify:$front_id"; + $content_info = "Front . . . . . : Power:$leds{front_power} Fault:$leds{front_fault} Identify:$leds{front_id}"; push (@sorted_output, $content_info); - $content_info = "Rear . . . . . : Power:$rear_power Fault:$rear_fault Identify:$rear_id"; + $content_info = "Rear . . . . . : Power:$leds{rear_power} Fault:$leds{rear_fault} Identify:$leds{rear_id}"; push (@sorted_output, $content_info); # Fans - if ($f0 =~ "Off" and $f1 =~ "Off" and $f2 eq "Off" and $f3 eq "Off") { + if ($leds{fan0} =~ "Off" and $leds{fan1} =~ "Off" and $leds{fan2} eq "Off" and $leds{fan3} eq "Off") { $content_info = "Front Fans . . : No LEDs On"; } else { - $content_info = "Front Fans . . : fan0:$f0 fan1:$f1 fan2:$f2 fan3:$f3"; + $content_info = "Front Fans . . : fan0:$leds{fan0} fan1:$leds{fan1} fan2:$leds{fan2} fan3:$leds{fan3}"; } push (@sorted_output, $content_info); } From e9fd1c9e345997e409b54229be159bafadc3de73 Mon Sep 17 00:00:00 2001 From: bybai Date: Thu, 21 Dec 2017 03:02:24 -0500 Subject: [PATCH 26/93] Add makeroutes and setroute doc --- .../common/deployment/network/cfg_routes.rst | 88 +++++++++++++++++++ .../customize_image/network/cfg_routes.rst | 1 + .../diskful/customize_image/network/index.rst | 1 + .../customize_image/network/cfg_routes.rst | 1 + .../customize_image/network/index.rst | 1 + 5 files changed, 92 insertions(+) create mode 100644 docs/source/guides/admin-guides/manage_clusters/common/deployment/network/cfg_routes.rst create mode 100644 docs/source/guides/admin-guides/manage_clusters/ppc64le/diskful/customize_image/network/cfg_routes.rst create mode 100644 docs/source/guides/admin-guides/manage_clusters/ppc64le/diskless/customize_image/network/cfg_routes.rst diff --git a/docs/source/guides/admin-guides/manage_clusters/common/deployment/network/cfg_routes.rst b/docs/source/guides/admin-guides/manage_clusters/common/deployment/network/cfg_routes.rst new file mode 100644 index 000000000..836a8c55b --- /dev/null +++ b/docs/source/guides/admin-guides/manage_clusters/common/deployment/network/cfg_routes.rst @@ -0,0 +1,88 @@ +Configure routes +----------------- + +There are 2 ways to configure OS route in xCAT: + + * ``makeroutes``: command to add or delete routes on the management node or any given nodes. + * ``setroute``: script to replace/add the routes to the node, it can be used in postscripts/postbootscripts. + +``makeroutes`` or ``setroute`` will modify OS temporary route, it also modifies persistent route in ``/etc/sysconfig/static-routes`` file. + +Before using ``makeroutes`` or ``setroute`` to configure OS route, details of the routes data such as routename, subnet, net mask and gateway should be stored in ``routes`` table. + +Configure ``routes`` table +`````````````````````````` + +#. Store default route data in ``routes`` table: :: + + chdef -t route defaultroute net=default mask=255.0.0.0 gateway=10.0.0.101 + +#. Store additional route data in ``routes`` table: :: + + chdef -t route 20net net=20.0.0.0 mask=255.0.0.0 gateway=0.0.0.0 ifname=eth1 + +#. Check data in ``routes`` table: :: + + tabdump routes + #routename,net,mask,gateway,ifname,comments,disable + "30net","30.0.0.0","255.0.0.0","0.0.0.0","eth2",, + "20net","20.0.0.0","255.0.0.0","0.0.0.0","eth1",, + "defaultroute","default","255.0.0.0","10.0.0.101",,, + +Use ``makeroutes`` to configure OS route on xCAT management node +'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + +#. define the names of the routes to be setup on the management node in ``site`` table: :: + + chdef -t site mnroutenames="defaultroute,20net" + lsdef -t site clustersite -i mnroutenames + Object name: clustersite + mnroutenames=defaultroute,20net + +#. add all routes from the ``mnroutenames`` to the OS route table for the management node: :: + + makeroutes + +#. add route ``20net`` and ``30net`` to the OS route table for the management node: :: + + makeroutes -r 20net,30net + +#. delete route ``20net`` from the OS route table for the management node: :: + + makeroutes -d -r 20net + +Use ``makeroutes`` to configure OS route for compute node +''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + +#. define the names of the routes to be setup on the compute node: :: + + chdef -t cn1 routenames="defaultroute,20net" + +#. add all routes from the ``routenames`` to the OS route table for the compute node: :: + + makeroutes cn1 + +#. add route ``20net`` and ``30net`` to the OS route table for the compute node: :: + + makeroutes cn1 -r 20net,30net + +#. delete route ``20net`` from the OS route table for the compute node: :: + + makeroutes cn1,cn2 -d -r 20net + +Use ``setroute`` to configure OS route for compute node +''''''''''''''''''''''''''''''''''''''''''''''''''''''' + +#. define the names of the routes to be setup on the compute node: :: + + chdef -t cn1 routenames="defaultroute,20net" + +#. If adding ``setroute [replace | add]`` into the node’s postscripts list, ``setroute`` will be executed during OS deployment on compute node to replace/add routes from ``routenames``: :: + + chdef cn1 -p postscripts="setroute replace" + +#. Or if the compute node is already running, use ``updatenode`` command to run ``setroute [replace | add]`` postscript: :: + + updatenode cn1 -P "setroute replace" + + diff --git a/docs/source/guides/admin-guides/manage_clusters/ppc64le/diskful/customize_image/network/cfg_routes.rst b/docs/source/guides/admin-guides/manage_clusters/ppc64le/diskful/customize_image/network/cfg_routes.rst new file mode 100644 index 000000000..9fb5d6b78 --- /dev/null +++ b/docs/source/guides/admin-guides/manage_clusters/ppc64le/diskful/customize_image/network/cfg_routes.rst @@ -0,0 +1 @@ +.. include:: ../../../../common/deployment/network/cfg_routes.rst diff --git a/docs/source/guides/admin-guides/manage_clusters/ppc64le/diskful/customize_image/network/index.rst b/docs/source/guides/admin-guides/manage_clusters/ppc64le/diskful/customize_image/network/index.rst index 43286943d..1300effb7 100644 --- a/docs/source/guides/admin-guides/manage_clusters/ppc64le/diskful/customize_image/network/index.rst +++ b/docs/source/guides/admin-guides/manage_clusters/ppc64le/diskful/customize_image/network/index.rst @@ -8,3 +8,4 @@ This section describes how to configure network adapters with persistent configu cfg_network_adapter.rst cfg_second_adapter.rst + cfg_routes.rst diff --git a/docs/source/guides/admin-guides/manage_clusters/ppc64le/diskless/customize_image/network/cfg_routes.rst b/docs/source/guides/admin-guides/manage_clusters/ppc64le/diskless/customize_image/network/cfg_routes.rst new file mode 100644 index 000000000..9fb5d6b78 --- /dev/null +++ b/docs/source/guides/admin-guides/manage_clusters/ppc64le/diskless/customize_image/network/cfg_routes.rst @@ -0,0 +1 @@ +.. include:: ../../../../common/deployment/network/cfg_routes.rst diff --git a/docs/source/guides/admin-guides/manage_clusters/ppc64le/diskless/customize_image/network/index.rst b/docs/source/guides/admin-guides/manage_clusters/ppc64le/diskless/customize_image/network/index.rst index 43286943d..1300effb7 100644 --- a/docs/source/guides/admin-guides/manage_clusters/ppc64le/diskless/customize_image/network/index.rst +++ b/docs/source/guides/admin-guides/manage_clusters/ppc64le/diskless/customize_image/network/index.rst @@ -8,3 +8,4 @@ This section describes how to configure network adapters with persistent configu cfg_network_adapter.rst cfg_second_adapter.rst + cfg_routes.rst From 9590c50927c7ebde070ae1b781a445836e16f837 Mon Sep 17 00:00:00 2001 From: Casandra Qiu Date: Thu, 21 Dec 2017 11:11:55 -0500 Subject: [PATCH 27/93] Support rinv command for irpdu --- perl-xCAT/xCAT/MacMap.pm | 2 +- perl-xCAT/xCAT/data/switchinfo.pm | 2 + xCAT-server/lib/xcat/plugins/pdu.pm | 57 ++++++++++++++++++- .../lib/xcat/plugins/switchdiscover.pm | 50 +++++++++------- 4 files changed, 87 insertions(+), 24 deletions(-) diff --git a/perl-xCAT/xCAT/MacMap.pm b/perl-xCAT/xCAT/MacMap.pm index 34f303aaa..2a1931397 100644 --- a/perl-xCAT/xCAT/MacMap.pm +++ b/perl-xCAT/xCAT/MacMap.pm @@ -510,7 +510,7 @@ sub refresh_table { # if we are doing switch discovery and the node is not a switch, skip # if we are NOT doing switch discovery, and the node is a switch, skip my $ntype = $typehash->{$entry->{node}}->[0]->{nodetype}; - if ( (($discover_switch) and ( $ntype ne "switch")) + if ( (($discover_switch) and ($ntype ne "switch") and ($ntype ne "pdu") ) or ( !($discover_switch) and ( $ntype eq "switch")) ){ xCAT::MsgUtils->trace(0, "d", "refresh_table: skip node=$entry->{node} switch=$entry->{switch} discover_switch=$discover_switch nodetype=$ntype\n"); next; diff --git a/perl-xCAT/xCAT/data/switchinfo.pm b/perl-xCAT/xCAT/data/switchinfo.pm index 1a8986877..b5793f01c 100644 --- a/perl-xCAT/xCAT/data/switchinfo.pm +++ b/perl-xCAT/xCAT/data/switchinfo.pm @@ -42,6 +42,8 @@ our %global_switch_type = ( Cumulus => "onie", cumulus => "onie", Edgecore => "onie", + sLEN => "irpdu", + sIBM => "irpdu", coral => "crpdu" ); diff --git a/xCAT-server/lib/xcat/plugins/pdu.pm b/xCAT-server/lib/xcat/plugins/pdu.pm index 852bdd816..363f61b4b 100644 --- a/xCAT-server/lib/xcat/plugins/pdu.pm +++ b/xCAT-server/lib/xcat/plugins/pdu.pm @@ -913,7 +913,7 @@ sub showMFR { foreach my $pdu (@$noderange) { unless ($pduhash->{$pdu}->[0]->{pdutype} eq "crpdu") { - xCAT::SvrUtils::sendmsg("This command only supports CONSTELLATION PDU with pdutype=crpdu", $callback,$pdu); + rinv_for_irpdu($pdu, $callback); next; } @@ -942,6 +942,61 @@ sub showMFR { } } +sub rinv_for_irpdu +{ + my $pdu = shift; + my $callback = shift; + my $output; + + my $session = connectTopdu($pdu,$callback); + if (!$session) { + $callback->({ errorcode => [1],error => "Couldn't connect to $pdu"}); + next; + } + my $line = "**********************************************************"; + xCAT::SvrUtils::sendmsg("$line", $callback,$pdu); + xCAT::SvrUtils::sendmsg("MFR Info List", $callback,$pdu); + xCAT::SvrUtils::sendmsg("$line", $callback,$pdu); + #ibmPduSoftwareVersion + $output = $session->get(".1.3.6.1.4.1.2.6.223.7.3.0"); + if ($output) { + xCAT::SvrUtils::sendmsg("PDU Software Version: $output", $callback,$pdu); + } + #ibmPduMachineType + $output = $session->get(".1.3.6.1.4.1.2.6.223.7.4.0"); + if ($output) { + xCAT::SvrUtils::sendmsg("PDU Machine Type: $output", $callback,$pdu); + } + #ibmPduModelNumber + $output = $session->get(".1.3.6.1.4.1.2.6.223.7.5.0"); + if ($output) { + xCAT::SvrUtils::sendmsg("PDU Model Number: $output", $callback,$pdu); + } + #ibmPduPartNumber + $output = $session->get(".1.3.6.1.4.1.2.6.223.7.6.0"); + if ($output) { + xCAT::SvrUtils::sendmsg("PDU Part Number: $output", $callback,$pdu); + } + #ibmPduName + $output = $session->get(".1.3.6.1.4.1.2.6.223.7.7.0"); + if ($output) { + xCAT::SvrUtils::sendmsg("PDU Name: $output", $callback,$pdu); + } + #ibmPduSerialNumber + $output = $session->get(".1.3.6.1.4.1.2.6.223.7.9.0"); + if ($output) { + xCAT::SvrUtils::sendmsg("PDU Serial Number: $output", $callback,$pdu); + } + #ibmPduDescription + $output = $session->get(".1.3.6.1.4.1.2.6.223.7.10.0"); + if ($output) { + xCAT::SvrUtils::sendmsg("PDU Description: $output", $callback,$pdu); + } + xCAT::SvrUtils::sendmsg("$line", $callback,$pdu); + +} + + #------------------------------------------------------- diff --git a/xCAT-server/lib/xcat/plugins/switchdiscover.pm b/xCAT-server/lib/xcat/plugins/switchdiscover.pm index d7374d9d3..7c3277154 100644 --- a/xCAT-server/lib/xcat/plugins/switchdiscover.pm +++ b/xCAT-server/lib/xcat/plugins/switchdiscover.pm @@ -434,6 +434,7 @@ sub process_request { } if (exists($globalopt{setup})) { + send_msg(\%request, 0, "Configure $device ...."); switchsetup($predefineswitch, \%request, $sub_req); } @@ -1151,7 +1152,7 @@ sub get_switchtype { return $xCAT::data::switchinfo::global_switch_type{$key}; } else { if (exists($globalopt{pdu})) { - return "irpdu"; + return "crpdu"; } return $key; } @@ -1397,8 +1398,8 @@ sub matchPredefineSwitch { } my $stype = get_switchtype($vendor); - if (exists($globalopt{pdu})) { - $stype="pdu"; + if (exists($globalopt{pdu}) and !stype ) { + $stype="crpdu"; } send_msg($request, 0, "$device discovered and matched: $dswitch to $node" ); @@ -1432,34 +1433,39 @@ sub switchsetup { my $request = shift; my $sub_req = shift; if (exists($globalopt{pdu})) { - my $mytype = "pdu"; - my $nodetab = xCAT::Table->new('hosts'); - my $nodehash = $nodetab->getNodesAttribs(\@{${nodes_to_config}->{$mytype}},['ip','otherinterfaces']); # get netmask from network table my $nettab = xCAT::Table->new("networks"); my @nets; if ($nettab) { @nets = $nettab->getAllAttribs('net','mask'); } - - foreach my $pdu(@{${nodes_to_config}->{$mytype}}) { - my $cmd = "rspconfig $pdu sshcfg"; - xCAT::Utils->runcmd($cmd, 0); - my $ip = $nodehash->{$pdu}->[0]->{ip}; - my $mask; - foreach my $net (@nets) { - if (xCAT::NetworkUtils::isInSameSubnet( $net->{'net'}, $ip, $net->{'mask'}, 0)) { - $mask=$net->{'mask'}; + foreach my $mytype (keys %$nodes_to_config) { + if ( $mytype eq "irpdu" ) { + send_msg($request, 0, "the setup options for irpdu is not support yet\n"); + } elsif ( $mytype eq "crpdu" ) { + my $nodetab = xCAT::Table->new('hosts'); + my $nodehash = $nodetab->getNodesAttribs(\@{${nodes_to_config}->{$mytype}},['ip','otherinterfaces']); + foreach my $pdu(@{${nodes_to_config}->{$mytype}}) { + my $cmd = "rspconfig $pdu sshcfg"; + xCAT::Utils->runcmd($cmd, 0); + my $ip = $nodehash->{$pdu}->[0]->{ip}; + my $mask; + foreach my $net (@nets) { + if (xCAT::NetworkUtils::isInSameSubnet( $net->{'net'}, $ip, $net->{'mask'}, 0)) { + $mask=$net->{'mask'}; + } + } + $cmd = "rspconfig $pdu hostname=$pdu ip=$ip netmask=$mask"; + xCAT::Utils->runcmd($cmd, 0); + if ($::RUNCMD_RC == 0) { + xCAT::Utils->runxcmd({ command => ['chdef'], arg => ['-t','node','-o',$pdu,"ip=$ip","otherinterfaces="] }, $sub_req, 0, 1); + } else { + send_msg($request, 0, "Failed to run rspconfig command to set ip/netmask\n"); + } } - } - $cmd = "rspconfig $pdu hostname=$pdu ip=$ip netmask=$mask"; - xCAT::Utils->runcmd($cmd, 0); - if ($::RUNCMD_RC == 0) { - xCAT::Utils->runxcmd({ command => ['chdef'], arg => ['-t','node','-o',$pdu,"ip=$ip","otherinterfaces="] }, $sub_req, 0, 1); } else { - send_msg($request, 0, "Failed to run rspconfig command to set ip/netmask\n"); + send_msg($request, 0, "the pdu type $mytype is not support\n"); } - } return; } From 58dd39e46bbf53451a0e905045990c5ea1d6a4db Mon Sep 17 00:00:00 2001 From: immarvin Date: Mon, 25 Dec 2017 21:10:46 -0500 Subject: [PATCH 28/93] fix issue 'lskmodules' cannot list the kernel modules #4575 --- xCAT-server/lib/xcat/plugins/kmodules.pm | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/kmodules.pm b/xCAT-server/lib/xcat/plugins/kmodules.pm index e6203f541..d9344262a 100644 --- a/xCAT-server/lib/xcat/plugins/kmodules.pm +++ b/xCAT-server/lib/xcat/plugins/kmodules.pm @@ -620,7 +620,7 @@ sub mods_in_rpm { rmtree($tmp_path); return; } } else { - if (system("cd $tmp_path; rpm2cpio $krpm | cpio -idum *.ko > /dev/null 2>&1 ; cd - > /dev/null 2>&1")) { + if (system("cd $tmp_path; rpm2cpio $krpm | cpio -idum > /dev/null 2>&1 ; cd - > /dev/null 2>&1")) { my $rsp; push @{ $rsp->{data} }, "Unable to extract files from the rpm $krpm."; xCAT::MsgUtils->message("E", $rsp, $::CALLBACK); @@ -636,7 +636,7 @@ sub mods_in_rpm { return; } - my @ko_files = `find $tmp_path -name *.ko`; + my @ko_files = `find $tmp_path -regextype posix-egrep -regex ".*/*\.ko(\.xz)?"`; foreach my $ko (@ko_files) { my %mod; chomp($ko); @@ -650,7 +650,6 @@ sub mods_in_rpm { $mod{description} = $desc; push(@modlist, \%mod); } - rmtree($tmp_path); return @modlist; From 48c2da5d7511d94be66f535ae6aa048e73495aaf Mon Sep 17 00:00:00 2001 From: immarvin Date: Mon, 25 Dec 2017 22:05:15 -0500 Subject: [PATCH 29/93] add test case for lskmodules_o --- xCAT-test/autotest/testcase/copycds/cases0 | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/xCAT-test/autotest/testcase/copycds/cases0 b/xCAT-test/autotest/testcase/copycds/cases0 index e9d30f81d..da1d9bb46 100644 --- a/xCAT-test/autotest/testcase/copycds/cases0 +++ b/xCAT-test/autotest/testcase/copycds/cases0 @@ -10,6 +10,13 @@ cmd:ls /install/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__ check:rc==0 end +start:lskmodules_o +cmd:lskmodules -o __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__ +check:rc==0 +check:output=~.ko(.xz): +end + + start:copycds_n os:Linux #cmd:umount /mnt/xca From 6ec904def3aa7421e500a7940661fd8e0b174834 Mon Sep 17 00:00:00 2001 From: XuWei Date: Tue, 26 Dec 2017 00:50:25 -0500 Subject: [PATCH 30/93] support noderange for reventlog resolved --- xCAT-server/lib/xcat/plugins/openbmc.pm | 62 +++++++++++++++---------- 1 file changed, 38 insertions(+), 24 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index 24b0be4ca..122661ccb 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -149,7 +149,7 @@ my $http_protocol="https"; my $openbmc_url = "/org/openbmc"; my $openbmc_project_url = "/xyz/openbmc_project"; $::SOFTWARE_URL = "$openbmc_project_url/software"; -$::LOGGING_URL = "$openbmc_project_url/logging"; +$::LOGGING_URL = "$openbmc_project_url/logging/entry/#ENTRY_ID#/attr/Resolved"; #------------------------------------------------------- # The hash table to store method and url for request, @@ -1081,16 +1081,6 @@ sub parse_args { } xCAT::SvrUtils::sendmsg("Attempting to resolve the following log entries: $value...", $callback); - my @entries = split(',', $value); - # take the first element from the list - my $log_id = shift @entries; - # and set the URL for the loggin entry to resolved - $status_info{REVENTLOG_RESOLVED_REQUEST}{init_url} = $::LOGGING_URL . "/entry/$log_id/attr/Resolved"; - - # If a list is provided, set the remaining log entries back to status_info - my $remaining = join (',', @entries); - $status_info{REVENTLOG_RESOLVED_REQUEST}{argv} = $remaining; - } elsif ($subcommand !~ /^\d$|^\d+$|^all$|^clear$/) { if ($subcommand =~ "resolved") { return ([ 1, "$usage_errormsg $reventlog_no_id_resolved_errormsg" ]); @@ -1474,9 +1464,13 @@ sub parse_command_status { if ($subcommand eq "clear") { $next_status{LOGIN_RESPONSE} = "REVENTLOG_CLEAR_REQUEST"; $next_status{REVENTLOG_CLEAR_REQUEST} = "REVENTLOG_CLEAR_RESPONSE"; - } elsif ($subcommand =~"resolved") { + } elsif ($subcommand =~ /resolved=(.+)/) { $next_status{LOGIN_RESPONSE} = "REVENTLOG_RESOLVED_REQUEST"; $next_status{REVENTLOG_RESOLVED_REQUEST} = "REVENTLOG_RESOLVED_RESPONSE"; + my @entries = split(",", $1); + my $init_entry = shift @entries; + $status_info{REVENTLOG_RESOLVED_REQUEST}{init_url} =~ s/#ENTRY_ID#/$init_entry/g; + push @{ $status_info{REVENTLOG_RESOLVED_RESPONSE}{remain_entries} }, @entries; } else { $next_status{LOGIN_RESPONSE} = "REVENTLOG_REQUEST"; $next_status{REVENTLOG_REQUEST} = "REVENTLOG_RESPONSE"; @@ -2248,7 +2242,13 @@ sub deal_with_response { # If 403 is received setting boot method, API endpoint changed in 1738 FW, inform the user of work around. $error = "Invalid endpoint used to set boot method. If running firmware < ibm-v1.99.10-0-r7, 'export XCAT_OPENBMC_FIRMWARE=1736' and retry."; } elsif ($node_info{$node}{cur_status} eq "REVENTLOG_RESOLVED_RESPONSE") { - my $log_id = (split ('/', $status_info{REVENTLOG_RESOLVED_REQUEST}{init_url}))[5]; + my $cur_url; + if ($node_info{$node}{cur_url}) { + $cur_url = $node_info{$node}{cur_url}; + } else { + $cur_url = $status_info{REVENTLOG_RESOLVED_REQUEST}{init_url}; + } + my $log_id = (split ('/', $cur_url))[5]; $error = "Invalid ID=$log_id provided to resolved. [$::RESPONSE_FORBIDDEN]"; } else{ $error = "$::RESPONSE_FORBIDDEN - Requested endpoint does not exists and may indicate function is not yet supported by OpenBMC firmware."; @@ -2885,21 +2885,35 @@ sub reventlog_response { xCAT::SvrUtils::sendmsg("Logs cleared", $callback, $node); } } elsif ($node_info{$node}{cur_status} eq "REVENTLOG_RESOLVED_RESPONSE") { + my $cur_url; + if ($node_info{$node}{cur_url}) { + $cur_url = $node_info{$node}{cur_url}; + if ($node_info{$node}{bak_url}) { + $node_info{$node}{cur_url} = shift @{ $node_info{$node}{bak_url} }; + } else { + $node_info{$node}{cur_url} = ""; + } + } else { + $cur_url = $status_info{REVENTLOG_RESOLVED_REQUEST}{init_url}; + } + if ($response_info->{'message'} eq $::RESPONSE_OK) { - my $log_id = (split ('/', $status_info{REVENTLOG_RESOLVED_REQUEST}{init_url}))[5]; + my $log_id = (split ('/', $cur_url))[5]; xCAT::SvrUtils::sendmsg("Resolved $log_id.", $callback, $node); } - my @entries = split (',', $status_info{REVENTLOG_RESOLVED_REQUEST}{argv} ); - if ((scalar @entries) > 0) { - my $log_id = shift @entries; - $next_status{"REVENTLOG_RESOLVED_RESPONSE"} = "REVENTLOG_RESOLVED_REQUEST"; - $next_status{"REVENTLOG_RESOLVED_REQUEST"} = "REVENTLOG_RESOLVED_RESPONSE"; - $status_info{REVENTLOG_RESOLVED_REQUEST}{init_url} = - $::LOGGING_URL . "/entry/$log_id/attr/Resolved"; - # If a list is provided, set the remaining log entries back to status_info - my $remaining = join (',', @entries); - $status_info{REVENTLOG_RESOLVED_REQUEST}{argv} = $remaining; + if ($status_info{REVENTLOG_RESOLVED_RESPONSE}{remain_entries} and !$node_info{$node}{remain_entries}) { + foreach my $entry (@{ $status_info{REVENTLOG_RESOLVED_RESPONSE}{remain_entries} }) { + my $tmp_url = $::LOGGING_URL; + $tmp_url =~ s/#ENTRY_ID#/$entry/g; + push @{ $node_info{$node}{bak_url} }, $tmp_url; + } + $node_info{$node}{cur_url} = shift @{ $node_info{$node}{bak_url} }; + $node_info{$node}{remain_entries} = $status_info{REVENTLOG_RESOLVED_RESPONSE}{remain_entries}; + } + + if ($node_info{$node}{cur_url}) { + $next_status{"REVENTLOG_RESOLVED_RESPONSE"} = "REVENTLOG_RESOLVED_REQUEST"; } else { # Break out of this loop if there are no more IDs to resolve $wait_node_num--; From 60388ddf1ecf1a9fc229b4cb2e91852e62c9844a Mon Sep 17 00:00:00 2001 From: ladams00 Date: Tue, 26 Dec 2017 22:52:21 -0800 Subject: [PATCH 31/93] Added "ipmi=on" to channel setaccess so ipmi user can remotely hit bmc on Intel S2600 compute boards (not enabled out of box). --- xCAT-genesis-scripts/bin/bmcsetup | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xCAT-genesis-scripts/bin/bmcsetup b/xCAT-genesis-scripts/bin/bmcsetup index 151e5d12d..5a732b25f 100755 --- a/xCAT-genesis-scripts/bin/bmcsetup +++ b/xCAT-genesis-scripts/bin/bmcsetup @@ -481,8 +481,8 @@ for user in $BMCUS; do fi TRIES=0 - # Enable the channel link for the specified user - while ! ipmitool -d $idev channel setaccess $LANCHAN $USERSLOT link=on; do + # Enable the channel and ipmi link for the specified user + while ! ipmitool -d $idev channel setaccess $LANCHAN $USERSLOT link=on ipmi=on; do sleep 1 let TRIES=TRIES+1 if [ $TRIES -gt $TIMEOUT ]; then break; fi From f09939a15a4a1d47cc04c7515c9aa70ef05b2a3f Mon Sep 17 00:00:00 2001 From: chenglch Date: Mon, 18 Dec 2017 18:55:26 +0800 Subject: [PATCH 32/93] Add xcat marker in gocnoserver configuration file Previously, it is impossible to know if the goconerver is started by xcat. This patch add a marker in /etc/goconserver/server.conf to help check the status. In addition, use server-cred.pem instead of server-key.pem as it is not exist on SN. This patch also control the service status of goconserver and conserver when restarting the xcatd service on service node. ``` [root@sn02 ~]# chdef sn02 setupconserver=1 1 object definitions have been created or modified. [root@sn02 ~]# service xcatd restart Restarting xcatd (via systemctl): [ OK ] [root@sn02 ~]# ps -ef | grep conserver root 27679 1 0 02:26 ? 00:00:00 /usr/sbin/conserver -o -O1 -d root 27680 27679 0 02:26 ? 00:00:00 /usr/sbin/conserver -o -O1 -d root 27756 26188 0 02:26 pts/1 00:00:00 grep --color=auto conserver [root@sn02 ~]# chdef sn02 setupconserver=2 1 object definitions have been created or modified. [root@sn02 ~]# service xcatd restart Restarting xcatd (via systemctl): [ OK ] [root@sn02 ~]# [root@sn02 ~]# [root@sn02 ~]# [root@sn02 ~]# ps -ef | grep conserver root 27885 1 0 02:26 ? 00:00:00 /usr/bin/goconserver root 27986 26188 0 02:33 pts/1 00:00:00 grep --color=auto conserver ``` --- xCAT-client/bin/rcons | 3 +- xCAT-server/lib/perl/xCAT/Goconserver.pm | 252 ++++++++++++++++++++ xCAT-server/lib/xcat/plugins/AAsn.pm | 66 ++++- xCAT-server/lib/xcat/plugins/conserver.pm | 5 +- xCAT-server/lib/xcat/plugins/goconserver.pm | 123 +++------- 5 files changed, 350 insertions(+), 99 deletions(-) diff --git a/xCAT-client/bin/rcons b/xCAT-client/bin/rcons index 7a432c08c..fd10fa4d4 100755 --- a/xCAT-client/bin/rcons +++ b/xCAT-client/bin/rcons @@ -149,7 +149,8 @@ elif [ $USE_GOCONSERVER == "1" ]; then CONGO_SSL_CERT=$HOME/.xcat/client-cred.pem \ CONGO_SSL_CA_CERT=$HOME/.xcat/ca.pem \ CONGO_PORT=12430 \ - CONGO_CLIENT_TYPE=xcat" + CONGO_CLIENT_TYPE=xcat \ + CONGO_SSL_INSECURE=true" if [ "$CONSERVER" == `hostname` ]; then host=`hostname -s` if [ $? -ne 0 ]; then diff --git a/xCAT-server/lib/perl/xCAT/Goconserver.pm b/xCAT-server/lib/perl/xCAT/Goconserver.pm index f1b5cc0a0..7f281cde4 100644 --- a/xCAT-server/lib/perl/xCAT/Goconserver.pm +++ b/xCAT-server/lib/perl/xCAT/Goconserver.pm @@ -15,8 +15,17 @@ use HTTP::Request; use HTTP::Headers; use LWP; use JSON; +use File::Path; use IO::Socket::SSL qw( SSL_VERIFY_PEER ); +my $go_api_port = 12429; +my $go_cons_port = 12430; + +use constant CONSOLE_LOG_DIR => "/var/log/consoles"; +unless (-d CONSOLE_LOG_DIR) { + mkpath(CONSOLE_LOG_DIR, 0, 0755); +} + sub http_request { my ($method, $url, $data) = @_; my @user = getpwuid($>); @@ -27,6 +36,7 @@ sub http_request { SSL_cert_file => xCAT::Utils->getHomeDir() . "/.xcat/client-cred.pem", SSL_ca_file => xCAT::Utils->getHomeDir() . "/.xcat/ca.pem", SSL_use_cert => 1, + verify_hostname => 0, SSL_verify_mode => SSL_VERIFY_PEER, }, ); my $header = HTTP::Headers->new('Content-Type' => 'application/json'); # $data = encode_json $data if defined($data); @@ -105,4 +115,246 @@ sub create_nodes { return $ret; } +#------------------------------------------------------------------------------- + +=head3 is_xcat_conf_ready + Check if the goconserver configuration file was generated by xcat + + Returns: + 1 - ready + 0 - not ready + Globals: + none + Example: + my $ready=(xCAT::Goconserver::is_xcat_conf_ready() + Comments: + none + +=cut + +#------------------------------------------------------------------------------- +sub is_xcat_conf_ready { + my $file; + open $file, '<', "/etc/goconserver/server.conf"; + my $line = <$file>; + close $file; + if ($line =~ /#generated by xcat/) { + return 1; + } + return 0; +} + +#------------------------------------------------------------------------------- + +=head3 is_goconserver_running + Check if the goconserver service is running + + Returns: + 1 - running + 0 - not running + Globals: + none + Example: + my $running=(xCAT::Goconserver::is_goconserver_running() + Comments: + none + +=cut + +#------------------------------------------------------------------------------- +sub is_goconserver_running { + my $cmd = "ps axf | grep -v grep | grep \/usr\/bin\/goconserver"; + xCAT::Utils->runcmd($cmd, -1); + if ($::RUNCMD_RC != 0) { + return 0; + } + return 1; +} + +#------------------------------------------------------------------------------- + +=head3 is_conserver_running + Check if the conserver service is running + + Returns: + 1 - running + 0 - not running + Globals: + none + Example: + my $running=(xCAT::Goconserver::is_conserver_running() + Comments: + none + +=cut + +#------------------------------------------------------------------------------- +sub is_conserver_running { + # On ubuntu system 'service conserver status' can not get the correct status of conserver, + # use 'pidof conserver' like what we did in rcons. + my $cmd = "pidof conserver"; + xCAT::Utils->runcmd($cmd, -1); + if ($::RUNCMD_RC == 0) { + return 1; + } + return 0; +} + +#------------------------------------------------------------------------------- + +=head3 build_conf + generate configuration file for goconserver + + Returns: + none + Globals: + none + Example: + my $running=(xCAT::Goconserver::build_conf() + Comments: + none + +=cut + +#------------------------------------------------------------------------------- +sub build_conf { + # TODO(chenglch): add -f options to support import the configuration file customized by the user, + # it would be friendly to the version control system. + my $config= "#generated by xcat ".xCAT::Utils->Version()."\n". + "global:\n". + " host: 0.0.0.0\n". + " ssl_key_file: /etc/xcat/cert/server-cred.pem\n". + " ssl_cert_file: /etc/xcat/cert/server-cred.pem\n". + " ssl_ca_cert_file: /etc/xcat/cert/ca.pem\n". + " logfile: /var/log/goconserver/server.log # the log for goconserver\n". + "api:\n". + " port: $go_api_port # the port for rest api\n". + "console:\n". + " datadir: /var/lib/goconserver/ # the data file to save the hosts\n". + " port: $go_cons_port # the port for console\n". + " logdir: ".CONSOLE_LOG_DIR." # log files for session nodes\n". + " log_timestamp: true # log the timestamp at the beginning of line\n". + " reconnect_interval: 10 # retry interval in second if console could not be connected\n"; + my $file; + my $ret = open ($file, '>', '/etc/goconserver/server.conf'); + if ($ret == 0) { + xCAT::MsgUtils->message("S", "Could not open file /etc/goconserver/server.conf"); + return 1; + } + print $file $config; + close $file; + return 0; +} + +#------------------------------------------------------------------------------- + +=head3 start_service + start goconserver service + + Returns: + none + Globals: + none + Example: + my $running=(xCAT::Goconserver::start_service() + Comments: + none + +=cut + +#------------------------------------------------------------------------------- +sub start_service { + my $cmd = "service goconserver start"; + xCAT::Utils->runcmd($cmd, -1); + if ($::RUNCMD_RC != 0) { + xCAT::MsgUtils->message("S", "Could not start goconserver service."); + return 1; + } + return 0; +} + +#------------------------------------------------------------------------------- + +=head3 stop_service + stop goconserver service + + Returns: + none + Globals: + none + Example: + my $ret=(xCAT::Goconserver::stop_service() + Comments: + none + +=cut + +#------------------------------------------------------------------------------- +sub stop_service { + my $cmd = "service goconserver stop"; + xCAT::Utils->runcmd($cmd, -1); + if ($::RUNCMD_RC != 0) { + xCAT::MsgUtils->message("S", "Could not stop goconserver service."); + return 1; + } + return 0; +} + +#------------------------------------------------------------------------------- + +=head3 stop_conserver_service + stop conserver service + + Returns: + none + Globals: + none + Example: + my $ret=(xCAT::Goconserver::stop_conserver_service() + Comments: + none + +=cut + +#------------------------------------------------------------------------------- +sub stop_conserver_service { + my $cmd = "service conserver stop"; + xCAT::Utils->runcmd($cmd, -1); + if ($::RUNCMD_RC != 0) { + xCAT::MsgUtils->message("S", "Could not stop conserver service."); + return 1; + } + return 0; +} +#------------------------------------------------------------------------------- + +=head3 restart_service + restart goconserver service + + Returns: + none + Globals: + none + Example: + my $ret=(xCAT::Goconserver::restart_service() + Comments: + none + +=cut + +#------------------------------------------------------------------------------- +sub restart_service { + my $cmd = "service goconserver restart"; + xCAT::Utils->runcmd($cmd, -1); + if ($::RUNCMD_RC != 0) { + xCAT::MsgUtils->message("S", "Could not restart goconserver service."); + return 1; + } + return 0; +} + + +sub get_api_port { + return $go_api_port; +} 1; \ No newline at end of file diff --git a/xCAT-server/lib/xcat/plugins/AAsn.pm b/xCAT-server/lib/xcat/plugins/AAsn.pm index 4bef1e5e0..e941c12fc 100755 --- a/xCAT-server/lib/xcat/plugins/AAsn.pm +++ b/xCAT-server/lib/xcat/plugins/AAsn.pm @@ -152,6 +152,9 @@ sub init_plugin $rc = xCAT::Utils->setupAIXconserver(); } + } elsif ($servicelist->{"conserver"} == 2) + { + &setup_GOCONS(); } if (($servicelist->{"nameserver"} == 1) || ($servicelist->{"nameserver"} == 2)) { @@ -488,15 +491,17 @@ sub setup_CONS { my ($nodename) = @_; my $rc = 0; + my $cmdref; if (-x "/usr/bin/goconserver") { - my $cmd = "ps axf | grep -v grep | grep \/usr\/bin\/goconserver"; - xCAT::Utils->runcmd($cmd, 0); - if ($::RUNCMD_RC == 0) { - xCAT::MsgUtils->message("S", "INFO: goconserver was started, do nothing for conserver."); - return 0; + require xCAT::Goconserver; + if (xCAT::Goconserver::is_goconserver_running()) { + $rc = xCAT::Goconserver::stop_service(); + if($rc) { + xCAT::MsgUtils->message("S", "Error: Failed to stop goconserver service."); + return 1; + } } } - my $cmdref; $cmdref->{command}->[0] = "makeconservercf"; $cmdref->{arg}->[0] = "-l"; $cmdref->{cwd}->[0] = "/opt/xcat/sbin"; @@ -538,6 +543,55 @@ sub setup_CONS #----------------------------------------------------------------------------- +=head3 setup_GOCONS + + Sets up goconserver + +=cut + +#----------------------------------------------------------------------------- +sub setup_GOCONS +{ + my ($running, $ready, $ret); + unless (-x "/usr/bin/goconserver") { + xCAT::MsgUtils->message("S", "Error: goconserver is not installed."); + return 1; + } + require xCAT::Goconserver; + # if goconserver is installed, check the status of conserver service. + if (xCAT::Goconserver::is_conserver_running()) { + xCAT::MsgUtils->message("S", "conserver is started, stopping it."); + $ret = xCAT::Goconserver::stop_conserver_service(); + if ($ret) { + xCAT::MsgUtils->message("S", "Error: failed to stop conserver service."); + return 1; + } + } + $running = xCAT::Goconserver::is_goconserver_running(); + $ready = xCAT::Goconserver::is_xcat_conf_ready(); + if ( $running && $ready ) { + # Already started by xcat + return 0; + } + # user could customize the configuration, do not rewrite the configuration if this file has been + # generated by xcat + if (!$ready) { + $ret = xCAT::Goconserver::build_conf(); + if ($ret) { + xCAT::MsgUtils->message("S", "Error: failed to create configuration file for goconserver."); + return 1; + } + } + $ret = xCAT::Goconserver::restart_service(); + if ($ret) { + xCAT::MsgUtils->message("S", "Error: failed to start goconserver service."); + return 1; + } + return 0; +} + +#----------------------------------------------------------------------------- + =head3 setup_DHCP Sets up DHCP services diff --git a/xCAT-server/lib/xcat/plugins/conserver.pm b/xCAT-server/lib/xcat/plugins/conserver.pm index d54cbe10d..db0473f76 100644 --- a/xCAT-server/lib/xcat/plugins/conserver.pm +++ b/xCAT-server/lib/xcat/plugins/conserver.pm @@ -203,9 +203,8 @@ sub process_request { my $cb = shift; if ($req->{command}->[0] eq "makeconservercf") { if (-x "/usr/bin/goconserver") { - my $cmd = "ps axf | grep -v grep | grep \/usr\/bin\/goconserver"; - xCAT::Utils->runcmd($cmd, 0); - if ($::RUNCMD_RC == 0) { + require xCAT::Goconserver; + if (xCAT::Goconserver::is_goconserver_running()) { my $rsp->{data}->[0] = "goconserver is started, please stop it at first."; xCAT::MsgUtils->message("E", $rsp, $cb); return; diff --git a/xCAT-server/lib/xcat/plugins/goconserver.pm b/xCAT-server/lib/xcat/plugins/goconserver.pm index 0fcf0d141..2cc470b2e 100644 --- a/xCAT-server/lib/xcat/plugins/goconserver.pm +++ b/xCAT-server/lib/xcat/plugins/goconserver.pm @@ -17,8 +17,6 @@ use Data::Dumper; my $isSN; my $host; -my $go_api_port = 12429; -my $go_cons_port = 12430; my $bmc_cons_port = "2200"; my $usage_string =" makegocons [-V|--verbose] [-d|--delete] noderange -h|--help Display this usage statement. @@ -56,8 +54,6 @@ sub preprocess_request { #$Getopt::Long::pass_through=1; if (!GetOptions( - 'c|conserver' => \$::CONSERVER, - 'l|local' => \$::LOCAL, 'h|help' => \$::HELP, 'D|debug' => \$::DEBUG, 'v|version' => \$::VERSION, @@ -75,19 +71,6 @@ sub preprocess_request { $request = {}; return; } - if ($::LOCAL) { - if ($noderange && @$noderange > 0) { - $::callback->({ data => "Invalid option -l or --local when there are nodes specified." }); - $request = {}; - return; - } - } - if ($::CONSERVER && $::LOCAL) { - $::callback->({ data => "Can not specify -l or --local together with -c or --conserver." }); - $request = {}; - return; - } - # get site master my $master = xCAT::TableUtils->get_site_Master(); @@ -122,42 +105,14 @@ sub preprocess_request { push @nodes, $_->{node}; } - #send all nodes to the MN - if (!$isSN && !$::CONSERVER) { #If -c flag is set, do not add the all nodes to the management node - if ($::VERBOSE) { - my $rsp; - $rsp->{data}->[0] = "Setting the nodes into goconserver on the management node"; - xCAT::MsgUtils->message("I", $rsp, $::callback); - } - my $reqcopy = {%$request}; - $reqcopy->{'_xcatdest'} = $master; - $reqcopy->{_xcatpreprocessed}->[0] = 1; - $reqcopy->{'_allnodes'} = $allnodes; # the original command comes with nodes or not - if ($allnodes == 1) { @nodes = (); } - $reqcopy->{node} = \@nodes; - push @requests, $reqcopy; - if ($::LOCAL) { return \@requests; } - } - # send to conserver hosts - foreach my $cons (keys %cons_hash) { - - #print "cons=$cons\n"; - my $doit = 0; - if ($isSN) { - if (exists($iphash{$cons})) { $doit = 1; } - } else { - if (!exists($iphash{$cons}) || $::CONSERVER) { $doit = 1; } - } - - if ($doit) { - my $reqcopy = {%$request}; - $reqcopy->{'_xcatdest'} = $cons; - $reqcopy->{_xcatpreprocessed}->[0] = 1; - $reqcopy->{'_allnodes'} = [$allnodes]; # the original command comes with nodes or not - $reqcopy->{node} = $cons_hash{$cons}{nodes}; - push @requests, $reqcopy; - } #end if + foreach my $host (keys %cons_hash) { + my $reqcopy = {%$request}; + $reqcopy->{'_xcatdest'} = $host; + $reqcopy->{_xcatpreprocessed}->[0] = 1; + $reqcopy->{'_allnodes'} = [$allnodes]; # the original command comes with nodes or not + $reqcopy->{node} = $cons_hash{$host}{nodes}; + push @requests, $reqcopy; } #end foreach if ($::DEBUG) { @@ -308,54 +263,44 @@ sub gen_request_data { return $data; } - sub start_goconserver { - my $rsp; + my ($rsp, $running, $ready, $ret); unless (-x "/usr/bin/goconserver") { $rsp->{data}->[0] = "goconserver is not installed."; xCAT::MsgUtils->message("E", $rsp, $::callback); return 1; } - # As conserver is always installed, we check the existence of goconserver at first. # if goconserver is installed, check the status of conserver service. - my $cmd = "ps axf | grep -v grep | grep \/usr\/sbin\/conserver"; - xCAT::Utils->runcmd($cmd, 0); - if ($::RUNCMD_RC == 0) { + if (xCAT::Goconserver::is_conserver_running()) { $rsp->{data}->[0] = "conserver is started, please stop it at first."; xCAT::MsgUtils->message("E", $rsp, $::callback); return 1; } - $cmd = "ps axf | grep -v grep | grep \/usr\/bin\/goconserver"; - xCAT::Utils->runcmd($cmd, 0); - if ($::RUNCMD_RC != 0) { - my $config= "global:\n". - " host: 0.0.0.0\n". - " ssl_key_file: /etc/xcat/cert/server-key.pem\n". - " ssl_cert_file: /etc/xcat/cert/server-cert.pem\n". - " ssl_ca_cert_file: /etc/xcat/cert/ca.pem\n". - " logfile: /var/log/goconserver/server.log\n". - "api:\n". - " port: $go_api_port\n". - "console:\n". - " port: $go_cons_port\n"; - my $file; - my $ret = open ($file, '>', '/etc/goconserver/server.conf'); - if ($ret == 0) { - $rsp->{data}->[0] = "Could not open file /etc/goconserver/server.conf."; - xCAT::MsgUtils->message("E", $rsp, $::callback); - return 1; - } - print $file $config; - close $file; - my $cmd = "service goconserver start"; - xCAT::Utils->runcmd($cmd, 0); - if ($::RUNCMD_RC != 0) { - $rsp->{data}->[0] = "Could not start goconserver service."; - xCAT::MsgUtils->message("E", $rsp, $::callback); - return 1; - } - sleep(3); + $running = xCAT::Goconserver::is_goconserver_running(); + $ready = xCAT::Goconserver::is_xcat_conf_ready(); + if ( $running && $ready ) { + # Already started by xcat + return 0; } + # user could customize the configuration, do not rewrite the configuration if this file has been + # generated by xcat + if (!$ready) { + $ret = xCAT::Goconserver::build_conf(); + if ($ret) { + $rsp->{data}->[0] = "Failed to create configuration file for goconserver."; + xCAT::MsgUtils->message("E", $rsp, $::callback); + return 1; + } + } + $ret = xCAT::Goconserver::restart_service(); + if ($ret) { + $rsp->{data}->[0] = "Failed to start goconserver service."; + xCAT::MsgUtils->message("E", $rsp, $::callback); + return 1; + } + $rsp->{data}->[0] = "Starting goconserver service ..."; + xCAT::MsgUtils->message("I", $rsp, $::callback); + sleep(3); return 0; } @@ -406,7 +351,7 @@ sub makegocons { xCAT::SvrUtils::sendmsg([ 1, "Could not generate the request data" ], $::callback); return 1; } - my $api_url = "https://$host:$go_api_port"; + my $api_url = "https://$host:". xCAT::Goconserver::get_api_port(); $ret = xCAT::Goconserver::delete_nodes($api_url, $data, $delmode, $::callback); if ($delmode) { return $ret; From 5d4925c317ffe16f4e24c1bbc283a42f78bcd2a0 Mon Sep 17 00:00:00 2001 From: ladams00 Date: Fri, 29 Dec 2017 12:08:49 -0800 Subject: [PATCH 33/93] Add if/else statement to allow ipmi=on just for Intel S2600BP system boards --- xCAT-genesis-scripts/bin/bmcsetup | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/xCAT-genesis-scripts/bin/bmcsetup b/xCAT-genesis-scripts/bin/bmcsetup index 5a732b25f..61c861968 100755 --- a/xCAT-genesis-scripts/bin/bmcsetup +++ b/xCAT-genesis-scripts/bin/bmcsetup @@ -481,8 +481,13 @@ for user in $BMCUS; do fi TRIES=0 - # Enable the channel and ipmi link for the specified user - while ! ipmitool -d $idev channel setaccess $LANCHAN $USERSLOT link=on ipmi=on; do + # Enable the channel link for the specified user + if [ "$IPMIMFG" == 343 -a "$XPROD" == 124 ]; then # For Intel S2600BP system boards + cmd="ipmitool -d $idev channel setaccess $LANCHAN $USERSLOT link=on ipmi=on" + else + cmd="ipmitool -d $idev channel setaccess $LANCHAN $USERSLOT link=on" + fi + while ! eval $cmd; do sleep 1 let TRIES=TRIES+1 if [ $TRIES -gt $TIMEOUT ]; then break; fi From 83af42c103ba229bc81fc40fc52eb39be0c6d51c Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Wed, 3 Jan 2018 10:48:10 -0500 Subject: [PATCH 34/93] missed update to the rflash RST man page --- .../admin-guides/references/man1/rflash.1.rst | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/docs/source/guides/admin-guides/references/man1/rflash.1.rst b/docs/source/guides/admin-guides/references/man1/rflash.1.rst index abc48f8d7..09b72654f 100644 --- a/docs/source/guides/admin-guides/references/man1/rflash.1.rst +++ b/docs/source/guides/admin-guides/references/man1/rflash.1.rst @@ -199,21 +199,6 @@ To apply the firmware level, a reboot is required to BMC and HOST. -\ **-d**\ : - -.. code-block:: perl - - This option steamlines the update, activate, reboot BMC and reboot HOST procedure. It expects a directory containing both BMC and PNOR .tar files. When BMC and PNOR tar files are provided, the command will upload and activate firmware. After BMC becomes activate, it will reboot BMC. If BMC state is Ready, the command will reboot the HOST. If BMC state is NotReady, the command will exit. - -\ **Note:**\ When using \ **--no-host-reboot**\, it will not reboot the host after BMC is reboot. - - -\ **-**\ **-delete**\ : - -.. code-block:: perl - - The delete option will delete update image from BMC. It expects an ID as the input. - *************** \ **Options**\ From 4703e396d694fa449240c63cbad13b5a074f9675 Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Wed, 3 Jan 2018 10:48:32 -0500 Subject: [PATCH 35/93] Add man page and usage for LED support for OpenBMC rvitals --- docs/source/guides/admin-guides/references/man1/rvitals.1.rst | 2 +- perl-xCAT/xCAT/Usage.pm | 2 +- xCAT-client/pods/man1/rvitals.1.pod | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/source/guides/admin-guides/references/man1/rvitals.1.rst b/docs/source/guides/admin-guides/references/man1/rvitals.1.rst index 7fa7e62d6..f67fe481d 100644 --- a/docs/source/guides/admin-guides/references/man1/rvitals.1.rst +++ b/docs/source/guides/admin-guides/references/man1/rvitals.1.rst @@ -67,7 +67,7 @@ OpenPOWER (OpenBMC) specific: ============================= -\ **rvitals**\ \ *noderange*\ [\ **temp | voltage | wattage | fanspeed | power | altitude | all**\ ] +\ **rvitals**\ \ *noderange*\ [\ **temp | voltage | wattage | fanspeed | power | leds | altitude | all**\ ] diff --git a/perl-xCAT/xCAT/Usage.pm b/perl-xCAT/xCAT/Usage.pm index 454f8cbc1..9d0ecbf38 100755 --- a/perl-xCAT/xCAT/Usage.pm +++ b/perl-xCAT/xCAT/Usage.pm @@ -83,7 +83,7 @@ my %usage = ( OpenPOWER (IPMI) specific: rvitals noderange [temp|voltage|wattage|fanspeed|power|leds|chassis|all] OpenPOWER (OpenBMC) specific: - rvitals noderange [temp|voltage|wattage|fanspeed|power|altitude|all] + rvitals noderange [temp|voltage|wattage|fanspeed|power|leds|altitude|all] MIC specific: rvitals noderange {thermal|all} pdu specific: diff --git a/xCAT-client/pods/man1/rvitals.1.pod b/xCAT-client/pods/man1/rvitals.1.pod index fb246eb40..e588434f3 100644 --- a/xCAT-client/pods/man1/rvitals.1.pod +++ b/xCAT-client/pods/man1/rvitals.1.pod @@ -32,7 +32,7 @@ B I [B|B|B|B|B|B I [B|B|B|B|B|B|B] +B I [B|B|B|B|B|B|B|B] =head1 B From 34f8038da5ecbd32d9b118dab7365d7d3d4b5d58 Mon Sep 17 00:00:00 2001 From: Samveen Date: Thu, 4 Jan 2018 13:18:53 +0700 Subject: [PATCH 36/93] `Canada/East-Saskatchewan` obsoleted by tzdata-2017c (#4601) As per the The 2017c release announcement, the zone `Canada/East-Saskatchewan` is now obsolete: http://mm.icann.org/pipermail/tz-announce/2017-October/000047.html --- xCAT-genesis-builder/install | 1 - xCAT-genesis-builder/install.ubuntu | 1 - 2 files changed, 2 deletions(-) diff --git a/xCAT-genesis-builder/install b/xCAT-genesis-builder/install index e5dfbe0f0..f1042fe61 100755 --- a/xCAT-genesis-builder/install +++ b/xCAT-genesis-builder/install @@ -473,7 +473,6 @@ dracut_install /usr/share/zoneinfo/posix/Asia/Phnom_Penh dracut_install /usr/share/zoneinfo/posix/Asia/Ulan_Bator dracut_install /usr/share/zoneinfo/posix/Asia/Sakhalin dracut_install /usr/share/zoneinfo/posix/MST7MDT -dracut_install /usr/share/zoneinfo/posix/Canada/East-Saskatchewan dracut_install /usr/share/zoneinfo/posix/Canada/Atlantic dracut_install /usr/share/zoneinfo/posix/Canada/Central dracut_install /usr/share/zoneinfo/posix/Canada/Eastern diff --git a/xCAT-genesis-builder/install.ubuntu b/xCAT-genesis-builder/install.ubuntu index f073efff0..182763474 100755 --- a/xCAT-genesis-builder/install.ubuntu +++ b/xCAT-genesis-builder/install.ubuntu @@ -498,7 +498,6 @@ dracut_install /usr/share/zoneinfo/posix/Asia/Phnom_Penh dracut_install /usr/share/zoneinfo/posix/Asia/Ulan_Bator dracut_install /usr/share/zoneinfo/posix/Asia/Sakhalin dracut_install /usr/share/zoneinfo/posix/MST7MDT -dracut_install /usr/share/zoneinfo/posix/Canada/East-Saskatchewan dracut_install /usr/share/zoneinfo/posix/Canada/Atlantic dracut_install /usr/share/zoneinfo/posix/Canada/Central dracut_install /usr/share/zoneinfo/posix/Canada/Eastern From c2c3ca4096420b3265147f460aceaefd01835fc1 Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Thu, 4 Jan 2018 13:54:18 -0500 Subject: [PATCH 37/93] Accidently tabbed rflash man page option descriptions, causing RST to format as code blocks --- .../admin-guides/references/man1/rflash.1.rst | 34 ++++--------------- xCAT-client/pods/man1/rflash.1.pod | 14 ++++---- 2 files changed, 14 insertions(+), 34 deletions(-) diff --git a/docs/source/guides/admin-guides/references/man1/rflash.1.rst b/docs/source/guides/admin-guides/references/man1/rflash.1.rst index 09b72654f..4eb48fa80 100644 --- a/docs/source/guides/admin-guides/references/man1/rflash.1.rst +++ b/docs/source/guides/admin-guides/references/man1/rflash.1.rst @@ -150,31 +150,19 @@ The command will update firmware for OpenPOWER BMC when given an OpenPOWER node \ **-l|-**\ **-list**\ : +The list option will list out available firmware on the BMC. It provides an interface to display the ID of the various firmware levels. -.. code-block:: perl - - The list option will list out available firmware on the BMC. It provides an interface to display the ID of the various firmware levels. - - The (*) symbol indicates the active running firmware on the server. - - The (+) symbol indicates the firmware that is pending and a reboot is required to set it to be the active running firmware level. +The (\*) symbol indicates the active running firmware on the server. +The (+) symbol indicates the firmware that is pending and a reboot is required to set it to be the active running firmware level. \ **-u|-**\ **-upload**\ : - -.. code-block:: perl - - The upload option expects a .tar file as the input and will upload the file to the BMC. Use the list option to view the result. - +The upload option expects a .tar file as the input and will upload the file to the BMC. Use the list option to view the result. \ **-a|-**\ **-activate**\ : - -.. code-block:: perl - - The activate option expects either a .tar file or an ID as the input. If a .tar file is provided, it will upload and activate the firmware in a single step - +The activate option expects either a .tar file or an ID as the input. If a .tar file is provided, it will upload and activate the firmware in a single step To apply the firmware level, a reboot is required to BMC and HOST. @@ -182,21 +170,13 @@ To apply the firmware level, a reboot is required to BMC and HOST. \ **-d**\ : - -.. code-block:: perl - - This option steamlines the update, activate, reboot BMC and reboot HOST procedure. It expects a directory containing both BMC and PNOR .tar files. When BMC and PNOR tar files are provided, the command will upload and activate firmware. After BMC becomes activate, it will reboot BMC. If BMC state is Ready, the command will reboot the HOST. If BMC state is NotReady, the command will exit. - +This option steamlines the update, activate, reboot BMC and reboot HOST procedure. It expects a directory containing both BMC and PNOR .tar files. When BMC and PNOR tar files are provided, the command will upload and activate firmware. After BMC becomes activate, it will reboot BMC. If BMC state is Ready, the command will reboot the HOST. If BMC state is NotReady, the command will exit. \ **Note:**\ When using \ **-**\ **-no-host-reboot**\ , it will not reboot the host after BMC is reboot. \ **-**\ **-delete**\ : - -.. code-block:: perl - - This delete option will delete update image from BMC. It expects an ID as the input. - +This delete option will delete update image from BMC. It expects an ID as the input. diff --git a/xCAT-client/pods/man1/rflash.1.pod b/xCAT-client/pods/man1/rflash.1.pod index 447bdc332..f6985b970 100644 --- a/xCAT-client/pods/man1/rflash.1.pod +++ b/xCAT-client/pods/man1/rflash.1.pod @@ -103,19 +103,19 @@ The command will update firmware for OpenPOWER BMC when given an OpenPOWER node B<-l|--list>: - The list option will list out available firmware on the BMC. It provides an interface to display the ID of the various firmware levels. +The list option will list out available firmware on the BMC. It provides an interface to display the ID of the various firmware levels. - The (*) symbol indicates the active running firmware on the server. +The (*) symbol indicates the active running firmware on the server. - The (+) symbol indicates the firmware that is pending and a reboot is required to set it to be the active running firmware level. +The (+) symbol indicates the firmware that is pending and a reboot is required to set it to be the active running firmware level. B<-u|--upload>: - The upload option expects a .tar file as the input and will upload the file to the BMC. Use the list option to view the result. +The upload option expects a .tar file as the input and will upload the file to the BMC. Use the list option to view the result. B<-a|--activate>: - The activate option expects either a .tar file or an ID as the input. If a .tar file is provided, it will upload and activate the firmware in a single step +The activate option expects either a .tar file or an ID as the input. If a .tar file is provided, it will upload and activate the firmware in a single step To apply the firmware level, a reboot is required to BMC and HOST. @@ -123,13 +123,13 @@ B When using B in hierarchical environment, the .tar file must be B<-d>: - This option steamlines the update, activate, reboot BMC and reboot HOST procedure. It expects a directory containing both BMC and PNOR .tar files. When BMC and PNOR tar files are provided, the command will upload and activate firmware. After BMC becomes activate, it will reboot BMC. If BMC state is Ready, the command will reboot the HOST. If BMC state is NotReady, the command will exit. +This option steamlines the update, activate, reboot BMC and reboot HOST procedure. It expects a directory containing both BMC and PNOR .tar files. When BMC and PNOR tar files are provided, the command will upload and activate firmware. After BMC becomes activate, it will reboot BMC. If BMC state is Ready, the command will reboot the HOST. If BMC state is NotReady, the command will exit. B When using B<--no-host-reboot>, it will not reboot the host after BMC is reboot. B<--delete>: - This delete option will delete update image from BMC. It expects an ID as the input. +This delete option will delete update image from BMC. It expects an ID as the input. =head1 B From 34a4403efd515e82fb783360a44e1c518f0f9df4 Mon Sep 17 00:00:00 2001 From: Casandra Qiu Date: Fri, 5 Jan 2018 10:21:03 -0500 Subject: [PATCH 38/93] remove $line with "******" --- xCAT-server/lib/xcat/plugins/pdu.pm | 5 ----- 1 file changed, 5 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/pdu.pm b/xCAT-server/lib/xcat/plugins/pdu.pm index 363f61b4b..8d1b618c2 100644 --- a/xCAT-server/lib/xcat/plugins/pdu.pm +++ b/xCAT-server/lib/xcat/plugins/pdu.pm @@ -953,10 +953,6 @@ sub rinv_for_irpdu $callback->({ errorcode => [1],error => "Couldn't connect to $pdu"}); next; } - my $line = "**********************************************************"; - xCAT::SvrUtils::sendmsg("$line", $callback,$pdu); - xCAT::SvrUtils::sendmsg("MFR Info List", $callback,$pdu); - xCAT::SvrUtils::sendmsg("$line", $callback,$pdu); #ibmPduSoftwareVersion $output = $session->get(".1.3.6.1.4.1.2.6.223.7.3.0"); if ($output) { @@ -992,7 +988,6 @@ sub rinv_for_irpdu if ($output) { xCAT::SvrUtils::sendmsg("PDU Description: $output", $callback,$pdu); } - xCAT::SvrUtils::sendmsg("$line", $callback,$pdu); } From f438e1b43277417af9d4ba0d17a1300c1d26470b Mon Sep 17 00:00:00 2001 From: Casandra Qiu Date: Fri, 5 Jan 2018 13:29:37 -0500 Subject: [PATCH 39/93] Add rvitals support for Infrastructure PDUs --- xCAT-server/lib/xcat/plugins/pdu.pm | 54 +++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/pdu.pm b/xCAT-server/lib/xcat/plugins/pdu.pm index 8d1b618c2..e6003b073 100644 --- a/xCAT-server/lib/xcat/plugins/pdu.pm +++ b/xCAT-server/lib/xcat/plugins/pdu.pm @@ -988,7 +988,6 @@ sub rinv_for_irpdu if ($output) { xCAT::SvrUtils::sendmsg("PDU Description: $output", $callback,$pdu); } - } @@ -1021,7 +1020,16 @@ sub showMonitorData { foreach my $pdu (@$noderange) { unless ($pduhash->{$pdu}->[0]->{pdutype} eq "crpdu") { - xCAT::SvrUtils::sendmsg("This command only supports CONSTELLATION PDU with pdutype=crpdu", $callback,$pdu); + my $session = connectTopdu($pdu,$callback); + if (!$session) { + $callback->({ errorcode => [1],error => "Couldn't connect to $pdu"}); + next; + } + my $count = $pduhash->{$pdu}->[0]->{outlet}; + unless ($count) { + $count = fill_outletCount($session, $pdu, $callback); + } + rvitals_for_irpdu($pdu, $count, $session, $callback); next; } @@ -1050,6 +1058,48 @@ sub showMonitorData { } } + +sub rvitals_for_irpdu +{ + my $pdu = shift; + my $count = shift; + my $session = shift; + my $callback = shift; + my $output; + + + # get power info for each outlet + # starts oid .2.6.223.8.2.2.1.7 to .2.6.223.8.2.2.1.14 + my $oid; + #ibmPduVoltageWarning: (voltageNormal(0),voltageOutOfRange(1)) + $oid = ".1.3.6.1.4.1.2.6.223..0.1.1.7.0"; + $output = $session->get("$oid"); + xCAT::SvrUtils::sendmsg("ibmPduVoltageWarning: $output", $callback,$pdu); + for (my $outlet = 1; $outlet <= $count; $outlet++) { + #ibmPduOutletCurrent + $oid = ".1.3.6.1.4.1.2.6.223.8.2.2.1.7"; + $output = $session->get("$oid.$outlet"); + xCAT::SvrUtils::sendmsg("outlet $outlet ibmPduOutletCurrent: $output", $callback,$pdu); + #ibmPduOutletMaxCapacity + $oid = ".1.3.6.1.4.1.2.6.223.8.2.2.1.8"; + $output = $session->get("$oid.$outlet"); + xCAT::SvrUtils::sendmsg("outlet $outlet ibmPduOutletMaxCapacity: $output", $callback,$pdu); + #ibmPduOutletCurrentThresholdWarning + $oid = ".1.3.6.1.4.1.2.6.223.8.2.2.1.9"; + $output = $session->get("$oid.$outlet"); + xCAT::SvrUtils::sendmsg("outlet $outlet ibmPduOutletCurrentThresholdWarning: $output", $callback,$pdu); + #ibmPduOutletCurrentThresholdCritical + $oid = ".1.3.6.1.4.1.2.6.223.8.2.2.1.10"; + $output = $session->get("$oid.$outlet"); + xCAT::SvrUtils::sendmsg("outlet $outlet ibmPduOutletCurrentThresholdCritical: $output", $callback,$pdu); + #ibmPduOutletLastPowerReading + $oid = ".1.3.6.1.4.1.2.6.223.8.2.2.1.13"; + $output = $session->get("$oid.$outlet"); + xCAT::SvrUtils::sendmsg("outlet $outlet ibmPduOutletLastPowerReading: $output", $callback,$pdu); + } + +} + #------------------------------------------------------- =head3 relaystat From 96ff31599e4c3382b2e9ee652bbe7367a0a2c354 Mon Sep 17 00:00:00 2001 From: Casandra Qiu Date: Mon, 8 Jan 2018 14:16:10 -0500 Subject: [PATCH 40/93] pre-defined variables for the OIDs --- xCAT-server/lib/xcat/plugins/pdu.pm | 43 +++++++++++++++-------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/pdu.pm b/xCAT-server/lib/xcat/plugins/pdu.pm index e6003b073..a6d4c893c 100644 --- a/xCAT-server/lib/xcat/plugins/pdu.pm +++ b/xCAT-server/lib/xcat/plugins/pdu.pm @@ -1029,7 +1029,9 @@ sub showMonitorData { unless ($count) { $count = fill_outletCount($session, $pdu, $callback); } - rvitals_for_irpdu($pdu, $count, $session, $callback); + if ($count > 0) { + rvitals_for_irpdu($pdu, $count, $session, $callback); + } next; } @@ -1067,34 +1069,33 @@ sub rvitals_for_irpdu my $callback = shift; my $output; + #ibmPduVoltageWarning: (voltageNormal(0),voltageOutOfRange(1)) + my $voltagewarning = ".1.3.6.1.4.1.2.6.223.0.1.1.7.0"; + $output = $session->get("$voltagewarning"); + xCAT::SvrUtils::sendmsg("ibmPduVoltageWarning: $output", $callback,$pdu); # get power info for each outlet # starts oid .2.6.223.8.2.2.1.7 to .2.6.223.8.2.2.1.14 - my $oid; - #ibmPduVoltageWarning: (voltageNormal(0),voltageOutOfRange(1)) - $oid = ".1.3.6.1.4.1.2.6.223..0.1.1.7.0"; - $output = $session->get("$oid"); - xCAT::SvrUtils::sendmsg("ibmPduVoltageWarning: $output", $callback,$pdu); + #ibmPduOutletCurrent + my $outletcurrent = ".1.3.6.1.4.1.2.6.223.8.2.2.1.7"; + #ibmPduOutletMaxCapacity + my $outletmaxcap = ".1.3.6.1.4.1.2.6.223.8.2.2.1.8"; + #ibmPduOutletCurrentThresholdWarning + my $currentthrewarning = ".1.3.6.1.4.1.2.6.223.8.2.2.1.9"; + #ibmPduOutletCurrentThresholdCritical + my $currentthrecrit = ".1.3.6.1.4.1.2.6.223.8.2.2.1.10"; + #ibmPduOutletLastPowerReading + my $lastpowerreading = ".1.3.6.1.4.1.2.6.223.8.2.2.1.13"; for (my $outlet = 1; $outlet <= $count; $outlet++) { - #ibmPduOutletCurrent - $oid = ".1.3.6.1.4.1.2.6.223.8.2.2.1.7"; - $output = $session->get("$oid.$outlet"); + $output = $session->get("$outletcurrent.$outlet"); xCAT::SvrUtils::sendmsg("outlet $outlet ibmPduOutletCurrent: $output", $callback,$pdu); - #ibmPduOutletMaxCapacity - $oid = ".1.3.6.1.4.1.2.6.223.8.2.2.1.8"; - $output = $session->get("$oid.$outlet"); + $output = $session->get("$outletmaxcap.$outlet"); xCAT::SvrUtils::sendmsg("outlet $outlet ibmPduOutletMaxCapacity: $output", $callback,$pdu); - #ibmPduOutletCurrentThresholdWarning - $oid = ".1.3.6.1.4.1.2.6.223.8.2.2.1.9"; - $output = $session->get("$oid.$outlet"); + $output = $session->get("$currentthrewarning.$outlet"); xCAT::SvrUtils::sendmsg("outlet $outlet ibmPduOutletCurrentThresholdWarning: $output", $callback,$pdu); - #ibmPduOutletCurrentThresholdCritical - $oid = ".1.3.6.1.4.1.2.6.223.8.2.2.1.10"; - $output = $session->get("$oid.$outlet"); + $output = $session->get("$currentthrecrit.$outlet"); xCAT::SvrUtils::sendmsg("outlet $outlet ibmPduOutletCurrentThresholdCritical: $output", $callback,$pdu); - #ibmPduOutletLastPowerReading - $oid = ".1.3.6.1.4.1.2.6.223.8.2.2.1.13"; - $output = $session->get("$oid.$outlet"); + $output = $session->get("$lastpowerreading.$outlet"); xCAT::SvrUtils::sendmsg("outlet $outlet ibmPduOutletLastPowerReading: $output", $callback,$pdu); } From 13882e69ff8d42c528dc51ed46e70c506e58be45 Mon Sep 17 00:00:00 2001 From: Casandra Qiu Date: Tue, 9 Jan 2018 09:30:05 -0500 Subject: [PATCH 41/93] add message in the fill_outletCount --- xCAT-server/lib/xcat/plugins/pdu.pm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xCAT-server/lib/xcat/plugins/pdu.pm b/xCAT-server/lib/xcat/plugins/pdu.pm index a6d4c893c..c59d58579 100644 --- a/xCAT-server/lib/xcat/plugins/pdu.pm +++ b/xCAT-server/lib/xcat/plugins/pdu.pm @@ -251,6 +251,8 @@ sub fill_outletCount { my $count = $session->get("$outletoid"); if ($count) { $pdutab->setNodeAttribs($pdu, {outlet => $count}); + } else { + xCAT::SvrUtils::sendmsg("Invalid Outlet number ", $callback,$pdu); } return $count; From 423a1c913d77bc3e8ee6959946e4809f2438e47e Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Wed, 10 Jan 2018 11:46:25 -0500 Subject: [PATCH 42/93] Add resolved=LED option to reventlog --- .../references/man1/reventlog.1.rst | 40 ++++++++++++- perl-xCAT/xCAT/Usage.pm | 1 + xCAT-client/pods/man1/reventlog.1.pod | 25 +++++++- xCAT-server/lib/xcat/plugins/openbmc.pm | 60 ++++++++++++++++++- 4 files changed, 121 insertions(+), 5 deletions(-) diff --git a/docs/source/guides/admin-guides/references/man1/reventlog.1.rst b/docs/source/guides/admin-guides/references/man1/reventlog.1.rst index 8d5e4bff2..108ccbe9d 100644 --- a/docs/source/guides/admin-guides/references/man1/reventlog.1.rst +++ b/docs/source/guides/admin-guides/references/man1/reventlog.1.rst @@ -19,10 +19,17 @@ Name **************** -\ **reventlog**\ \ *noderange*\ {\ *number-of-entries*\ [\ **-s**\ ]|\ **all [-s] | clear**\ } +\ **reventlog**\ \ *noderange*\ [\ *number-of-entries*\ [\ **-s**\ ]|\ **all [-s] | clear**\ ] \ **reventlog**\ [\ **-h | -**\ **-help | -v | -**\ **-version**\ ] +OpenPOWER OpenBMC specific : +============================ + + +\ **reventlog**\ \ *noderange*\ [\ **resolved=**\ {\ *id-list*\ |\ **LED**\ }] + + ******************* \ **Description**\ @@ -64,6 +71,12 @@ logs are stored on each servers service processor. +\ **resolved=**\ {\ *id-list*\ |\ **LED**\ } + + Mark event log entries as resolved. Use comma separated list of entry ids to specify individual entries. Use \ **LED**\ to mark as resolved all event log entries that contribute to LED fault. + + + \ **-h | -**\ **-help**\ Print help. @@ -83,7 +96,7 @@ logs are stored on each servers service processor. -1. +1. List last 5 event log entries from node4 and node5 .. code-block:: perl @@ -110,7 +123,7 @@ logs are stored on each servers service processor. -2. +2. Clear all event log entries from node4 and node5 .. code-block:: perl @@ -129,6 +142,27 @@ logs are stored on each servers service processor. +3. Mark as resolved all event log entries from node4 that contribute to LED fault + + + .. code-block:: perl + + reventlog node4 resolved=LED + + + Output is similar to: + + + .. code-block:: perl + + Attempting to resolve the following log entries: LED... + node4: Resolved 51. + node4: Resolved 52. + node4: Resolved 58. + + + + ******** SEE ALSO diff --git a/perl-xCAT/xCAT/Usage.pm b/perl-xCAT/xCAT/Usage.pm index 9d0ecbf38..551cabd05 100755 --- a/perl-xCAT/xCAT/Usage.pm +++ b/perl-xCAT/xCAT/Usage.pm @@ -90,6 +90,7 @@ my %usage = ( rvitals noderange ", "reventlog" => "Usage: reventlog [all [-s]|clear| [-s]] [-V|--verbose] + reventlog [resolved={|LED}] reventlog [-h|--help|-v|--version]", "rinv" => "Usage: diff --git a/xCAT-client/pods/man1/reventlog.1.pod b/xCAT-client/pods/man1/reventlog.1.pod index b18de103d..2877a7b32 100644 --- a/xCAT-client/pods/man1/reventlog.1.pod +++ b/xCAT-client/pods/man1/reventlog.1.pod @@ -4,10 +4,15 @@ B - retrieve or clear remote hardware event logs =head1 B -B I {I [B<-s>]|B|B} +B I [I [B<-s>]|B|B] B [B<-h>|B<--help>|B<-v>|B<--version>] +=head2 OpenPOWER OpenBMC specific : + +B I [B{I|B}] + + =head1 B B can display any number of remote hardware event log entries @@ -34,6 +39,10 @@ To sort the entries from latest (always the last entry in event DB) to oldest (a Clear event logs. +=item B{I|B} + +Mark event log entries as resolved. Use comma separated list of entry ids to specify individual entries. Use B to mark as resolved all event log entries that contribute to LED fault. + =item B<-h>|B<--help> Print help. @@ -50,6 +59,7 @@ Print version. =over 2 =item 1. +List last 5 event log entries from node4 and node5 reventlog node4,node5 5 @@ -67,6 +77,7 @@ Output is similar to: node5: SERVPROC I 09/06/00 15:21:29 System spn1 started a RS485 connection with us[00] =item 2. +Clear all event log entries from node4 and node5 reventlog node4,node5 clear @@ -75,6 +86,18 @@ Output is similar to: node4: clear node5: clear +=item 3. +Mark as resolved all event log entries from node4 that contribute to LED fault + + reventlog node4 resolved=LED + +Output is similar to: + + Attempting to resolve the following log entries: LED... + node4: Resolved 51. + node4: Resolved 52. + node4: Resolved 58. + =back =head1 SEE ALSO diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index c70967595..825405ed7 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -211,6 +211,9 @@ my %status_info = ( REVENTLOG_RESOLVED_RESPONSE => { process => \&reventlog_response, }, + REVENTLOG_RESOLVED_RESPONSE_LED => { + process => \&reventlog_response, + }, RFLASH_LIST_REQUEST => { method => "GET", @@ -1084,7 +1087,7 @@ sub parse_args { my $nodes_num = @$noderange; if (@$noderange > 1) { - xCAT::SvrUtils::sendmsg("WARN: Resolving faults over a xCAT noderange is not recommended.", $callback); + return ([ 1, "Resolving faults over a xCAT noderange is not recommended." ]); } xCAT::SvrUtils::sendmsg("Attempting to resolve the following log entries: $value...", $callback); @@ -1471,6 +1474,9 @@ sub parse_command_status { if ($subcommand eq "clear") { $next_status{LOGIN_RESPONSE} = "REVENTLOG_CLEAR_REQUEST"; $next_status{REVENTLOG_CLEAR_REQUEST} = "REVENTLOG_CLEAR_RESPONSE"; + } elsif ($subcommand =~ /resolved=LED/) { + $next_status{LOGIN_RESPONSE} = "REVENTLOG_REQUEST"; + $next_status{REVENTLOG_REQUEST} = "REVENTLOG_RESOLVED_RESPONSE_LED"; } elsif ($subcommand =~ /resolved=(.+)/) { $next_status{LOGIN_RESPONSE} = "REVENTLOG_RESOLVED_REQUEST"; $next_status{REVENTLOG_RESOLVED_REQUEST} = "REVENTLOG_RESOLVED_RESPONSE"; @@ -2932,6 +2938,31 @@ sub reventlog_response { $wait_node_num--; return; } + } elsif ($node_info{$node}{cur_status} eq "REVENTLOG_RESOLVED_RESPONSE_LED") { + # Scan all event log entries and build an array of all that have callout data + my @entries; + foreach my $key_url (keys %{$response_info->{data}}) { + my %content = %{ ${ $response_info->{data} }{$key_url} }; + next unless ($content{Id}); + my $event_msg = is_callout_event_data(\%content); + push(@entries, $event_msg) if ($event_msg); # Add array entry of log event id + } + + # If some entries with callout data, send them off to be resolved + if (scalar(@entries) > 0) { + $next_status{"REVENTLOG_RESOLVED_RESPONSE_LED"} = "REVENTLOG_RESOLVED_REQUEST"; + $next_status{"REVENTLOG_RESOLVED_REQUEST"} = "REVENTLOG_RESOLVED_RESPONSE"; + + my $init_entry = shift @entries; + $status_info{REVENTLOG_RESOLVED_REQUEST}{init_url} =~ s/#ENTRY_ID#/$init_entry/g; + push @{ $status_info{REVENTLOG_RESOLVED_RESPONSE}{remain_entries} }, @entries; + } + else { + # Return if there are no entries with callout data + xCAT::SvrUtils::sendmsg("There are no event log entries contributing to LED fault", $callback, $node); + $wait_node_num--; + return; + } } else { my $entry_string = $status_info{REVENTLOG_RESPONSE}{argv}; my $content_info; @@ -2967,6 +2998,33 @@ sub reventlog_response { #------------------------------------------------------- +=head3 is_callout_event_data + + Parse reventlog data and return entry ID if it has + CALLOUT data + Input: + $content: data for single entry + +=cut + +#------------------------------------------------------- +sub is_callout_event_data { + my $content = shift; + my $id_num = $$content{Id}; + + if ($$content{Message}) { + if (defined $$content{AdditionalData} and $$content{AdditionalData}) { + foreach my $addition (@{ $$content{AdditionalData} }) { + if ($addition =~ /CALLOUT/) { + return $id_num; + } + } + } + } + return ""; +} +#------------------------------------------------------- + =head3 parse_event_data Parse reventlog data From 207e22c77280599c0a4d6fe4d9df6a8c46ef0fec Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Tue, 9 Jan 2018 11:08:35 -0500 Subject: [PATCH 43/93] Add LED tag to the output of reventlog --- xCAT-server/lib/xcat/plugins/openbmc.pm | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index c70967595..71fcb3f71 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -95,7 +95,7 @@ unless (-d $::XCAT_LOG_DUMP_DIR) { # Common logging messages: my $usage_errormsg = "Usage error."; -my $reventlog_no_id_resolved_errormsg = "Provide a comma separated list of IDs to resolved. Example: 'resolved=x,y,z'"; +my $reventlog_no_id_resolved_errormsg = "Provide a comma separated list of IDs to be resolved. Example: 'resolved=x,y,z'"; sub unsupported { @@ -2262,7 +2262,7 @@ sub deal_with_response { $cur_url = $status_info{REVENTLOG_RESOLVED_REQUEST}{init_url}; } my $log_id = (split ('/', $cur_url))[5]; - $error = "Invalid ID=$log_id provided to resolved. [$::RESPONSE_FORBIDDEN]"; + $error = "Invalid ID=$log_id provided to be resolved. [$::RESPONSE_FORBIDDEN]"; } else{ $error = "$::RESPONSE_FORBIDDEN - Requested endpoint does not exists and may indicate function is not yet supported by OpenBMC firmware."; } @@ -2979,6 +2979,7 @@ sub reventlog_response { sub parse_event_data { my $content = shift; my $content_info = ""; + my $LED_tag = " [LED]"; # Indicate that the entry contributes to LED fault my $timestamp = $$content{Timestamp}; my $id_num = $$content{Id}; @@ -2987,7 +2988,7 @@ sub parse_event_data { $mon += 1; $year += 1900; my $UTC_time = sprintf ("%02d/%02d/%04d %02d:%02d:%02d", $mon, $mday, $year, $hour, $min, $sec); - my $messgae = $$content{Message}; + my $message = $$content{Message}; my $callout; my $msg_pid; my $i2c_device; @@ -3021,21 +3022,22 @@ sub parse_event_data { } } - $messgae .= "||$callout" if ($callout); + $message .= "||$callout" if ($callout); if (ref($event_mapping) eq "HASH") { - if ($event_mapping->{$messgae}) { - my $event_type = $event_mapping->{$messgae}{EventType}; - my $event_message = $event_mapping->{$messgae}{Message}; - my $severity = $event_mapping->{$messgae}{Severity}; - my $affect = $event_mapping->{$messgae}{AffectedSubsystem}; + if ($event_mapping->{$message}) { + my $event_type = $event_mapping->{$message}{EventType}; + my $event_message = $event_mapping->{$message}{Message}; + my $severity = $event_mapping->{$message}{Severity}; + my $affect = $event_mapping->{$message}{AffectedSubsystem}; $content_info = "$UTC_time [$id_num]: $event_type, ($severity) $event_message (AffectedSubsystem: $affect, PID: $msg_pid), Resolved: $$content{Resolved}"; } else { - $content_info = "$UTC_time [$id_num]: Not found in policy table: $messgae (PID: $msg_pid), Resolved: $$content{Resolved}"; + $content_info = "$UTC_time [$id_num]: Not found in policy table: $message (PID: $msg_pid), Resolved: $$content{Resolved}"; } } else { - $content_info = "$UTC_time [$id_num]: $messgae (PID: $msg_pid), Resolved: $$content{Resolved}"; + $content_info = "$UTC_time [$id_num]: $message (PID: $msg_pid), Resolved: $$content{Resolved}"; } + $content_info .= $LED_tag if ($callout); } return $content_info; From d694ac96833926450a5ba41ab577de37efd2949c Mon Sep 17 00:00:00 2001 From: Casandra Qiu Date: Wed, 10 Jan 2018 15:27:53 -0500 Subject: [PATCH 44/93] Modify rvitals output --- xCAT-server/lib/xcat/plugins/pdu.pm | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/pdu.pm b/xCAT-server/lib/xcat/plugins/pdu.pm index c59d58579..eca4553bf 100644 --- a/xCAT-server/lib/xcat/plugins/pdu.pm +++ b/xCAT-server/lib/xcat/plugins/pdu.pm @@ -1074,7 +1074,7 @@ sub rvitals_for_irpdu #ibmPduVoltageWarning: (voltageNormal(0),voltageOutOfRange(1)) my $voltagewarning = ".1.3.6.1.4.1.2.6.223.0.1.1.7.0"; $output = $session->get("$voltagewarning"); - xCAT::SvrUtils::sendmsg("ibmPduVoltageWarning: $output", $callback,$pdu); + xCAT::SvrUtils::sendmsg("Voltage Warning: $output", $callback,$pdu); # get power info for each outlet # starts oid .2.6.223.8.2.2.1.7 to .2.6.223.8.2.2.1.14 @@ -1090,15 +1090,15 @@ sub rvitals_for_irpdu my $lastpowerreading = ".1.3.6.1.4.1.2.6.223.8.2.2.1.13"; for (my $outlet = 1; $outlet <= $count; $outlet++) { $output = $session->get("$outletcurrent.$outlet"); - xCAT::SvrUtils::sendmsg("outlet $outlet ibmPduOutletCurrent: $output", $callback,$pdu); + xCAT::SvrUtils::sendmsg("outlet $outlet Current: $output mA", $callback,$pdu); $output = $session->get("$outletmaxcap.$outlet"); - xCAT::SvrUtils::sendmsg("outlet $outlet ibmPduOutletMaxCapacity: $output", $callback,$pdu); + xCAT::SvrUtils::sendmsg("outlet $outlet Max Capacity of the current: $output mA", $callback,$pdu); $output = $session->get("$currentthrewarning.$outlet"); - xCAT::SvrUtils::sendmsg("outlet $outlet ibmPduOutletCurrentThresholdWarning: $output", $callback,$pdu); + xCAT::SvrUtils::sendmsg("outlet $outlet Current Threshold Warning: $output mA", $callback,$pdu); $output = $session->get("$currentthrecrit.$outlet"); - xCAT::SvrUtils::sendmsg("outlet $outlet ibmPduOutletCurrentThresholdCritical: $output", $callback,$pdu); + xCAT::SvrUtils::sendmsg("outlet $outlet Current Threshold Critical: $output mA", $callback,$pdu); $output = $session->get("$lastpowerreading.$outlet"); - xCAT::SvrUtils::sendmsg("outlet $outlet ibmPduOutletLastPowerReading: $output", $callback,$pdu); + xCAT::SvrUtils::sendmsg("outlet $outlet Last Power Reading: $output Watts", $callback,$pdu); } } From 2ac30e1ec4d4890b3bb90606a01a0b7cfe71992b Mon Sep 17 00:00:00 2001 From: hu-weihua Date: Wed, 10 Jan 2018 21:42:04 -0500 Subject: [PATCH 45/93] modify the output of reventlog depending on the latest code --- xCAT-test/autotest/testcase/reventlog/cases0 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/xCAT-test/autotest/testcase/reventlog/cases0 b/xCAT-test/autotest/testcase/reventlog/cases0 index 5e73493b7..7a1e7a1a1 100644 --- a/xCAT-test/autotest/testcase/reventlog/cases0 +++ b/xCAT-test/autotest/testcase/reventlog/cases0 @@ -3,16 +3,19 @@ cmd:reventlog check:rc==0 check:output=~Usage end + start:reventlog_all cmd:reventlog $$CN all check:rc==0 check:output=~$$CN\s*:\s*.*\d\d/\d\d/\d\d\s*\S+ end + start:reventlog_clear cmd:reventlog $$CN clear check:rc==0 -check:output=~$$CN\s*:\s*clear|SEL cleared +check:output=~$$CN\s*:\s*Logs cleared|SEL cleared end + start:reventlog_numofentries cmd:reventlog $$CN 5 check:rc==0 From fc58a8e87281f1f2400bcfad0b865f3801a80caa Mon Sep 17 00:00:00 2001 From: Sebastian Thorarensen Date: Thu, 11 Jan 2018 04:00:59 +0100 Subject: [PATCH 46/93] Do not comment out rsyslog /var/log/messages on MN (#4527) Since commit 1219fdd23fb8602bb1029b96bb69cf4d746f0029, the rsyslog rule "*.debug /var/log/messages" is no longer added to rsyslog.conf on the MN. However, any rule ending with "/var/log/messages" is still commented out. This leads to xCAT removing all output to /var/log/messages, except for the daemon and ftp facilities that are enabled by /etc/rsyslog.d/xcat-debug.conf! This commit - stops commenting out rules ending with "/var/log/messages" in rsyslog.conf - stops adding adding the comment "#*.debug /var/log/messages" to rsyslog.conf - changes "daemon.debug" to "daemon.=debug" in xcat-debug.conf to avoid duplicate daemon log lines with most Linux distributions' default rsyslog.conf. The 'ftp.* rule in xcat-debug.conf is possibly no longer needed, and will lead to duplicate ftp messages with most distributions, but it is left untouched in this commit. --- xCAT/etc/rsyslog.d/xcat-debug.conf | 6 +++--- xCAT/postscripts/syslog | 12 ++---------- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/xCAT/etc/rsyslog.d/xcat-debug.conf b/xCAT/etc/rsyslog.d/xcat-debug.conf index 4756b300d..555edf8e9 100644 --- a/xCAT/etc/rsyslog.d/xcat-debug.conf +++ b/xCAT/etc/rsyslog.d/xcat-debug.conf @@ -1,3 +1,3 @@ -# By default, dhcpd use the ``daemon'' facility. Thus dhcp logs will go here. -# ftp.* is for tftp log. -daemon.debug;ftp.* /var/log/messages +# Make sure dhcpd requests and responses (daemon.=debug) and +# tftp messages (ftp.*) are logged. +daemon.=debug;ftp.* /var/log/messages diff --git a/xCAT/postscripts/syslog b/xCAT/postscripts/syslog index e8286121f..6e5036dd7 100755 --- a/xCAT/postscripts/syslog +++ b/xCAT/postscripts/syslog @@ -117,11 +117,8 @@ config_Rsyslog_C3() #enable to send the logging to master if [ $isLocal -eq 1 ]; then - #enable the MN to log all the logs from CN and MN itself - sed -i 's/\(^[^\#].*\/var\/log\/messages\)/\#\1/g' $2 - echo "#*.debug /var/log/messages" >> $2 - touch /var/log/messages if ( pmatch $OSVER "ubuntu*" ) || ( is_lsb_ubuntu ) || ( pmatch $OSVER "debian*" ); then + touch /var/log/messages chown syslog:adm /var/log/messages sed -i 's/\$PrivDropToGroup syslog/\$PrivDropToGroup adm/' $2 chown syslog:adm /var/log/xcat @@ -200,7 +197,7 @@ config_rsyslog_V8() if [ $goLocal -eq 1 ]; then #logging is local, do not forward - #making sure all the messages goes to /var/log/messages + #making sure /var/log/messages is setup for xcat-debug touch /var/log/messages if ( pmatch $OSVER "ubuntu*" ) || ( is_lsb_ubuntu ) || ( pmatch $OSVER "debian*" ); then chown syslog:adm /var/log/messages @@ -208,14 +205,9 @@ config_rsyslog_V8() chown syslog:adm /var/log/xcat fi - #comment out the rules which will write logs to /var/log/messages - # to prevent duplicate logs after "syslog" script is run - sed -i '/^[^#].*\/var\/log\/messages/s/^/#/' $conf_file - # Mark the start of xCAT section echo "# $xCATSettingsSTART" >> $conf_file echo "# $xCATSettingsInfo" >> $conf_file - echo "#*.debug /var/log/messages" >> $conf_file # Need to uncomment the lines $ModLoad imudp.so and $UDPServerRun 514, # to make the MN be able to receive syslog from remote hosts if [ -f "$remoteconf" ]; then From 82e0e44f72a8a18856ce4e09c45744f1e8c5b130 Mon Sep 17 00:00:00 2001 From: bybai Date: Thu, 11 Jan 2018 04:20:53 -0500 Subject: [PATCH 47/93] update routes doc --- .../manage_clusters/common/deployment/network/cfg_routes.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/source/guides/admin-guides/manage_clusters/common/deployment/network/cfg_routes.rst b/docs/source/guides/admin-guides/manage_clusters/common/deployment/network/cfg_routes.rst index 836a8c55b..d9a4bcb70 100644 --- a/docs/source/guides/admin-guides/manage_clusters/common/deployment/network/cfg_routes.rst +++ b/docs/source/guides/admin-guides/manage_clusters/common/deployment/network/cfg_routes.rst @@ -85,4 +85,9 @@ Use ``setroute`` to configure OS route for compute node updatenode cn1 -P "setroute replace" +Check result +```````````` +#. Use ``route`` command in xCAT management node to check OS route table. + +#. Use ``xdsh cn1 route`` to check compute node OS route table. From c88042cb73290b44eb2faea498dd46c6240a1bf1 Mon Sep 17 00:00:00 2001 From: yangsong Date: Thu, 11 Jan 2018 04:49:16 -0600 Subject: [PATCH 48/93] fis issue [REST] xCAT restful API xcatws cannot work #4622 (#4623) --- xCAT-server/xCAT-wsapi/xcat-ws.conf.apache22 | 4 ++-- xCAT-server/xCAT-wsapi/xcat-ws.conf.apache24 | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/xCAT-server/xCAT-wsapi/xcat-ws.conf.apache22 b/xCAT-server/xCAT-wsapi/xcat-ws.conf.apache22 index 21ce5b943..a8432e979 100644 --- a/xCAT-server/xCAT-wsapi/xcat-ws.conf.apache22 +++ b/xCAT-server/xCAT-wsapi/xcat-ws.conf.apache22 @@ -7,8 +7,8 @@ RewriteCond %{HTTPS} !=on RewriteRule ^/?xcatws/(.*) https://%{SERVER_NAME}/xcatws/$1 [R,L] RewriteRule ^/?xcatwsv2/(.*) https://%{SERVER_NAME}/xcatwsv2/$1 [R,L] - + Order allow,deny Allow from all - + diff --git a/xCAT-server/xCAT-wsapi/xcat-ws.conf.apache24 b/xCAT-server/xCAT-wsapi/xcat-ws.conf.apache24 index 7fc48853c..7c54e25bc 100644 --- a/xCAT-server/xCAT-wsapi/xcat-ws.conf.apache24 +++ b/xCAT-server/xCAT-wsapi/xcat-ws.conf.apache24 @@ -5,7 +5,6 @@ RewriteCond %{HTTPS} !=on RewriteRule ^/?xcatws/(.*) https://%{SERVER_NAME}/xcatws/$1 [R,L] RewriteRule ^/?xcatwsv2/(.*) https://%{SERVER_NAME}/xcatwsv2/$1 [R,L] - + Require all granted - - + From c144069d774be7bd2634b85fa6ef71cd92423f11 Mon Sep 17 00:00:00 2001 From: GONG Jie Date: Thu, 11 Jan 2018 18:55:20 +0800 Subject: [PATCH 49/93] Add script to convert xCAT-genesis-base rpm package to deb package --- .../debuild-xcat-genesis-base | 39 +++++++++++++++++++ .../xCAT-genesis-builder.spec | 1 + 2 files changed, 40 insertions(+) create mode 100755 xCAT-genesis-builder/debuild-xcat-genesis-base diff --git a/xCAT-genesis-builder/debuild-xcat-genesis-base b/xCAT-genesis-builder/debuild-xcat-genesis-base new file mode 100755 index 000000000..1b952adc3 --- /dev/null +++ b/xCAT-genesis-builder/debuild-xcat-genesis-base @@ -0,0 +1,39 @@ +#!/bin/bash + +# xCAT-genesis-base-x86_64-2.13.10-snap201801090246.noarch.rpm +RPM_PACKAGE="$1" + +[ -n "${RPM_PACKAGE}" ] || exit 1 +[ -f "${RPM_PACKAGE}" ] || exit 1 + +EXTRACT_DIR="${RPM_PACKAGE##*/}" +EXTRACT_DIR="${EXTRACT_DIR%%-snap*}" + +rm -rf "${EXTRACT_DIR}" +rm -rf "${EXTRACT_DIR}.orig" +alien -d -g -c -k "${RPM_PACKAGE}" || exit 1 + +PACKAGE_ARCH="${EXTRACT_DIR%-*}" +PACKAGE_ARCH="${PACKAGE_ARCH##*-}" + +if [[ ${EXTRACT_DIR} =~ -x86_64- ]] +then + rm -rf "${EXTRACT_DIR//x86_64/amd64}" + mv "${EXTRACT_DIR}" "${EXTRACT_DIR//x86_64/amd64}" + EXTRACT_DIR="${EXTRACT_DIR//x86_64/amd64}" + + sed -i -e 's/x86-64/amd64/g' "${EXTRACT_DIR}/debian/control" + sed -i -e 's/x86-64/amd64/g' "${EXTRACT_DIR}/debian/changelog" +fi + +cat >"${EXTRACT_DIR}/debian/preinst" <<-EOF +#!/bin/bash + +rm -rf /opt/xcat/share/xcat/netboot/genesis/${PACKAGE_ARCH}/fs/bin +rm -rf /opt/xcat/share/xcat/netboot/genesis/${PACKAGE_ARCH}/fs/sbin +rm -rf /opt/xcat/share/xcat/netboot/genesis/${PACKAGE_ARCH}/fs/lib +rm -rf /opt/xcat/share/xcat/netboot/genesis/${PACKAGE_ARCH}/fs/lib64 +rm -rf /opt/xcat/share/xcat/netboot/genesis/${PACKAGE_ARCH}/fs/var/run +EOF + +( cd "${EXTRACT_DIR}" && debian/rules binary ) diff --git a/xCAT-genesis-builder/xCAT-genesis-builder.spec b/xCAT-genesis-builder/xCAT-genesis-builder.spec index e1704f8fc..8321f99e6 100644 --- a/xCAT-genesis-builder/xCAT-genesis-builder.spec +++ b/xCAT-genesis-builder/xCAT-genesis-builder.spec @@ -34,6 +34,7 @@ mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/xcat/netboot/genesis/builder cd $RPM_BUILD_ROOT/%{prefix}/share/xcat/netboot/genesis/builder tar jxvf %{SOURCE1} chmod +x $RPM_BUILD_ROOT/%{prefix}/share/xcat/netboot/genesis/builder/buildrpm +chmod +x $RPM_BUILD_ROOT/%{prefix}/share/xcat/netboot/genesis/builder/debuild-xcat-genesis-base cd - From 2ea43cc01b95632e5a44b8db1c907409de129f0e Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Thu, 11 Jan 2018 13:51:43 -0500 Subject: [PATCH 50/93] Enhance rflash -c output for ipmi controlled machines --- xCAT-server/lib/xcat/plugins/ipmi.pm | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/ipmi.pm b/xCAT-server/lib/xcat/plugins/ipmi.pm index 56db4df57..8cb56dfba 100644 --- a/xCAT-server/lib/xcat/plugins/ipmi.pm +++ b/xCAT-server/lib/xcat/plugins/ipmi.pm @@ -2427,9 +2427,9 @@ sub rflash { my $c_id = ${ $sessdata->{component_ids} }[$i]; my $version = $firmware_version{$c_id}; my $format_string = $comp_string{$c_id}; - my $format_ver = sprintf("%3d.%02x %02X%02X%02X%02X", - $version->[0], $version->[1], $version->[2], - $version->[3], $version->[4], $version->[5]); + my $format_ver = sprintf("%3d.%02x.%d%d%d%d", + $version->[0], $version->[1], $version->[5], + $version->[4], $version->[3], $version->[2]); $msg = $msg . $sessdata->{node} . ": " . "Node firmware version for $format_string component: $format_ver"; if ($i != scalar(@{ $sessdata->{component_ids} }) - 1) { @@ -8747,16 +8747,16 @@ sub hpm_action_version { return -1; } my $version = $hpm_data_hash{1}{action_version}; - my $ver = sprintf("%3d.%02x %02X%02X%02X%02X", $version->[0], $version->[1], $version->[2], - $version->[3], $version->[4], $version->[5]); + my $ver = sprintf("%3d.%02x.%d%d%d%d", $version->[0], $version->[1], $version->[5], + $version->[4], $version->[3], $version->[2]); $callback->({ data => "HPM firmware version for BOOT component:$ver" }); $version = $hpm_data_hash{2}{action_version}; - $ver = sprintf("%3d.%02x %02X%02X%02X%02X", $version->[0], $version->[1], $version->[2], - $version->[3], $version->[4], $version->[5]); + $ver = sprintf("%3d.%02x.%d%d%d%d", $version->[0], $version->[1], $version->[5], + $version->[4], $version->[3], $version->[2]); $callback->({ data => "HPM firmware version for APP component:$ver" }); $version = $hpm_data_hash{4}{action_version}; - $ver = sprintf("%3d.%02x %02X%02X%02X%02X", $version->[0], $version->[1], $version->[2], - $version->[3], $version->[4], $version->[5]); + $ver = sprintf("%3d.%02x.%d%d%d%d", $version->[0], $version->[1], $version->[5], + $version->[4], $version->[3], $version->[2]); $callback->({ data => "HPM firmware version for BIOS component:$ver" }); } From a2665fad519ce245b9b90226ac7b753616ae3f1a Mon Sep 17 00:00:00 2001 From: Samveen Date: Fri, 12 Jan 2018 09:18:45 +0700 Subject: [PATCH 51/93] Improvements to xcat init unit for dracut (#4609) Changes: - Explicit shebang (make it explicit). It not required but clarifies syntax used. - ShellCheck suggested fixes. - Correct mirroring of `doxcat` to first physical cons if serial cons is primary. - Add protection for accidental closure of primary screen. - Minor optimizations --- xCAT-genesis-builder/xcat-cmdline.sh | 37 ++++++++++++++-------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/xCAT-genesis-builder/xcat-cmdline.sh b/xCAT-genesis-builder/xcat-cmdline.sh index 67b08484e..6e824eb00 100755 --- a/xCAT-genesis-builder/xcat-cmdline.sh +++ b/xCAT-genesis-builder/xcat-cmdline.sh @@ -1,3 +1,4 @@ +#!/bin/bash root=1 rootok=1 netroot=xcat @@ -8,11 +9,13 @@ mkdir -p /etc/ssh mkdir -p /var/tmp/ mkdir -p /var/empty/sshd sed -i '/^root:x/d' /etc/passwd -echo root:x:0:0::/:/bin/bash >> /etc/passwd -echo sshd:x:30:30:SSH User:/var/empty/sshd:/sbin/nologin >> /etc/passwd -echo rpc:x:32:32:Rpcbind Daemon:/var/cache/rpcbind:/sbin/nologin >> /etc/passwd -echo rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin >> /etc/passwd -echo qemu:x:107:107:qemu user:/:/sbin/nologin >> /etc/passwd +cat >>/etc/passwd <<"__ENDL" +root:x:0:0::/:/bin/bash +sshd:x:30:30:SSH User:/var/empty/sshd:/sbin/nologin +rpc:x:32:32:Rpcbind Daemon:/var/cache/rpcbind:/sbin/nologin +rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin +qemu:x:107:107:qemu user:/:/sbin/nologin +__ENDL # Fedora 20 ppc64 uses /lib/dracut/hooks/initqueue/finished # CentOS 7 probably uses /lib/dracut/hooks/initqueue/finished also if [ -d "/initqueue-finished" ]; then @@ -35,34 +38,30 @@ mkdir -p /var/lib/dhclient/ mkdir -p /var/log ip link set lo up echo '127.0.0.1 localhost' >> /etc/hosts -if grep console=ttyS /proc/cmdline > /dev/null; then - while :; do sleep 1; screen -x console < /dev/tty1 > /dev/tty1 2>&1; clear; done & +if grep -q console=ttyS /proc/cmdline; then + while :; do sleep 1; screen -S console -ln screen -x doxcat /dev/tty1; clear &>/dev/tty1 ; done & fi -while :; do screen -ln < /dev/tty2 > /dev/tty2 2>&1; done & +while :; do screen -ln < /dev/tty2 &> /dev/tty2 ; done & # The section below is just for System P LE hardware discovery # Need to wait for NIC initialization sleep 20 -ARCH=`uname -m` -#For Openpower -if [ $ARCH = "ppc64le" ]; then - ARCH="ppc64" -fi +ARCH="$(uname -m)" -if [ $ARCH == 'ppc64' ]; then +if [[ ${ARCH} =~ ppc64 ]]; then waittime=2 - ALL_NICS=`ip link show | grep -v "^ " | awk '{print $2}' | sed -e 's/:$//' | grep -v lo` + ALL_NICS=$(ip link show | grep -v "^ " | awk '{print $2}' | sed -e 's/:$//' | grep -v lo) for tmp in $ALL_NICS; do - tmp_data=`ip link show $tmp | grep -v "^ " | grep "UP"` + tmp_data="$(ip link show "$tmp" | grep -v "^ " | grep "UP")" if [ "$tmp_data" == "" ]; then - ip link set $tmp up + ip link set "$tmp" up fi tmp_data="UP" - waittime=$(($waittime+1)) + waittime=$((waittime+1)) done # wait 2+number_of_nics seconds for all the LINKed NICs to be UP sleep $waittime fi -while :; do screen -L -ln doxcat; done +while :; do screen -dr doxcat || screen -S doxcat -L -ln doxcat; done From 63a3efe8bb87799c3ffb6804eb5bc2f3efbb4c2b Mon Sep 17 00:00:00 2001 From: Samveen Gulati Date: Wed, 10 Jan 2018 09:23:43 +0000 Subject: [PATCH 52/93] move `/*bin` to `/usr/` to fix path conflict of genesis `base` and `scripts` RH7/Centos7 and recent versions of fedora relocate `/*bin/*` into `/usr/*bin/`. This causes conflicts for upgrades against xCAT-genesis-scripts-* packages which expect the `/bin` a to be a directory while `xCAT-genesis-base-*` packages provide a link. Relocating all files into `/usr` fixes that conflict and allows a clean upgrade from all old versions. --- xCAT-genesis-scripts/debian/rules | 4 +- .../{ => usr}/bin/allowcred.awk | 0 xCAT-genesis-scripts/{ => usr}/bin/bmcsetup | 0 xCAT-genesis-scripts/{ => usr}/bin/configraid | 0 .../{ => usr}/bin/diskdiscover | 0 .../{ => usr}/bin/dodiscovery | 0 xCAT-genesis-scripts/{ => usr}/bin/dosysclone | 0 xCAT-genesis-scripts/{ => usr}/bin/doxcat | 0 xCAT-genesis-scripts/{ => usr}/bin/getadapter | 0 xCAT-genesis-scripts/{ => usr}/bin/getcert | 0 xCAT-genesis-scripts/{ => usr}/bin/getdestiny | 0 xCAT-genesis-scripts/{ => usr}/bin/getipmi | 0 xCAT-genesis-scripts/{ => usr}/bin/ifup | 0 .../{ => usr}/bin/minixcatd.awk | 0 .../{ => usr}/bin/nextdestiny | 0 .../{ => usr}/bin/pseries_platform | 0 xCAT-genesis-scripts/{ => usr}/bin/raidcmd | 0 xCAT-genesis-scripts/{ => usr}/bin/raidutils | 0 .../{ => usr}/bin/remoteimmsetup | 0 xCAT-genesis-scripts/{ => usr}/bin/restart | 0 xCAT-genesis-scripts/{ => usr}/bin/udpcat.awk | 0 .../{ => usr}/bin/update_flash | 0 .../{ => usr}/bin/update_flash_nv | 0 .../{ => usr}/bin/updateflag.awk | 0 .../{ => usr}/sbin/loadmlxeth | 0 .../{ => usr}/sbin/setupimmnic | 0 .../xCAT-genesis-scripts.spec | 50 +++++++++---------- 27 files changed, 27 insertions(+), 27 deletions(-) rename xCAT-genesis-scripts/{ => usr}/bin/allowcred.awk (100%) rename xCAT-genesis-scripts/{ => usr}/bin/bmcsetup (100%) rename xCAT-genesis-scripts/{ => usr}/bin/configraid (100%) rename xCAT-genesis-scripts/{ => usr}/bin/diskdiscover (100%) rename xCAT-genesis-scripts/{ => usr}/bin/dodiscovery (100%) rename xCAT-genesis-scripts/{ => usr}/bin/dosysclone (100%) rename xCAT-genesis-scripts/{ => usr}/bin/doxcat (100%) rename xCAT-genesis-scripts/{ => usr}/bin/getadapter (100%) rename xCAT-genesis-scripts/{ => usr}/bin/getcert (100%) rename xCAT-genesis-scripts/{ => usr}/bin/getdestiny (100%) rename xCAT-genesis-scripts/{ => usr}/bin/getipmi (100%) rename xCAT-genesis-scripts/{ => usr}/bin/ifup (100%) rename xCAT-genesis-scripts/{ => usr}/bin/minixcatd.awk (100%) rename xCAT-genesis-scripts/{ => usr}/bin/nextdestiny (100%) rename xCAT-genesis-scripts/{ => usr}/bin/pseries_platform (100%) rename xCAT-genesis-scripts/{ => usr}/bin/raidcmd (100%) rename xCAT-genesis-scripts/{ => usr}/bin/raidutils (100%) rename xCAT-genesis-scripts/{ => usr}/bin/remoteimmsetup (100%) rename xCAT-genesis-scripts/{ => usr}/bin/restart (100%) rename xCAT-genesis-scripts/{ => usr}/bin/udpcat.awk (100%) rename xCAT-genesis-scripts/{ => usr}/bin/update_flash (100%) rename xCAT-genesis-scripts/{ => usr}/bin/update_flash_nv (100%) rename xCAT-genesis-scripts/{ => usr}/bin/updateflag.awk (100%) rename xCAT-genesis-scripts/{ => usr}/sbin/loadmlxeth (100%) rename xCAT-genesis-scripts/{ => usr}/sbin/setupimmnic (100%) diff --git a/xCAT-genesis-scripts/debian/rules b/xCAT-genesis-scripts/debian/rules index adff007b4..6da840833 100755 --- a/xCAT-genesis-scripts/debian/rules +++ b/xCAT-genesis-scripts/debian/rules @@ -33,8 +33,8 @@ install: dh_installdirs $(installdir) dh_install -X".svn" dh_install ./etc/ $(installtodir) - dh_install ./bin/ $(installtodir) - dh_install ./sbin/ $(installtodir) + dh_install ./usr/bin/ $(installtodir) + dh_install ./usr/sbin/ $(installtodir) dh_compress dh_installdeb dh_gencontrol diff --git a/xCAT-genesis-scripts/bin/allowcred.awk b/xCAT-genesis-scripts/usr/bin/allowcred.awk similarity index 100% rename from xCAT-genesis-scripts/bin/allowcred.awk rename to xCAT-genesis-scripts/usr/bin/allowcred.awk diff --git a/xCAT-genesis-scripts/bin/bmcsetup b/xCAT-genesis-scripts/usr/bin/bmcsetup similarity index 100% rename from xCAT-genesis-scripts/bin/bmcsetup rename to xCAT-genesis-scripts/usr/bin/bmcsetup diff --git a/xCAT-genesis-scripts/bin/configraid b/xCAT-genesis-scripts/usr/bin/configraid similarity index 100% rename from xCAT-genesis-scripts/bin/configraid rename to xCAT-genesis-scripts/usr/bin/configraid diff --git a/xCAT-genesis-scripts/bin/diskdiscover b/xCAT-genesis-scripts/usr/bin/diskdiscover similarity index 100% rename from xCAT-genesis-scripts/bin/diskdiscover rename to xCAT-genesis-scripts/usr/bin/diskdiscover diff --git a/xCAT-genesis-scripts/bin/dodiscovery b/xCAT-genesis-scripts/usr/bin/dodiscovery similarity index 100% rename from xCAT-genesis-scripts/bin/dodiscovery rename to xCAT-genesis-scripts/usr/bin/dodiscovery diff --git a/xCAT-genesis-scripts/bin/dosysclone b/xCAT-genesis-scripts/usr/bin/dosysclone similarity index 100% rename from xCAT-genesis-scripts/bin/dosysclone rename to xCAT-genesis-scripts/usr/bin/dosysclone diff --git a/xCAT-genesis-scripts/bin/doxcat b/xCAT-genesis-scripts/usr/bin/doxcat similarity index 100% rename from xCAT-genesis-scripts/bin/doxcat rename to xCAT-genesis-scripts/usr/bin/doxcat diff --git a/xCAT-genesis-scripts/bin/getadapter b/xCAT-genesis-scripts/usr/bin/getadapter similarity index 100% rename from xCAT-genesis-scripts/bin/getadapter rename to xCAT-genesis-scripts/usr/bin/getadapter diff --git a/xCAT-genesis-scripts/bin/getcert b/xCAT-genesis-scripts/usr/bin/getcert similarity index 100% rename from xCAT-genesis-scripts/bin/getcert rename to xCAT-genesis-scripts/usr/bin/getcert diff --git a/xCAT-genesis-scripts/bin/getdestiny b/xCAT-genesis-scripts/usr/bin/getdestiny similarity index 100% rename from xCAT-genesis-scripts/bin/getdestiny rename to xCAT-genesis-scripts/usr/bin/getdestiny diff --git a/xCAT-genesis-scripts/bin/getipmi b/xCAT-genesis-scripts/usr/bin/getipmi similarity index 100% rename from xCAT-genesis-scripts/bin/getipmi rename to xCAT-genesis-scripts/usr/bin/getipmi diff --git a/xCAT-genesis-scripts/bin/ifup b/xCAT-genesis-scripts/usr/bin/ifup similarity index 100% rename from xCAT-genesis-scripts/bin/ifup rename to xCAT-genesis-scripts/usr/bin/ifup diff --git a/xCAT-genesis-scripts/bin/minixcatd.awk b/xCAT-genesis-scripts/usr/bin/minixcatd.awk similarity index 100% rename from xCAT-genesis-scripts/bin/minixcatd.awk rename to xCAT-genesis-scripts/usr/bin/minixcatd.awk diff --git a/xCAT-genesis-scripts/bin/nextdestiny b/xCAT-genesis-scripts/usr/bin/nextdestiny similarity index 100% rename from xCAT-genesis-scripts/bin/nextdestiny rename to xCAT-genesis-scripts/usr/bin/nextdestiny diff --git a/xCAT-genesis-scripts/bin/pseries_platform b/xCAT-genesis-scripts/usr/bin/pseries_platform similarity index 100% rename from xCAT-genesis-scripts/bin/pseries_platform rename to xCAT-genesis-scripts/usr/bin/pseries_platform diff --git a/xCAT-genesis-scripts/bin/raidcmd b/xCAT-genesis-scripts/usr/bin/raidcmd similarity index 100% rename from xCAT-genesis-scripts/bin/raidcmd rename to xCAT-genesis-scripts/usr/bin/raidcmd diff --git a/xCAT-genesis-scripts/bin/raidutils b/xCAT-genesis-scripts/usr/bin/raidutils similarity index 100% rename from xCAT-genesis-scripts/bin/raidutils rename to xCAT-genesis-scripts/usr/bin/raidutils diff --git a/xCAT-genesis-scripts/bin/remoteimmsetup b/xCAT-genesis-scripts/usr/bin/remoteimmsetup similarity index 100% rename from xCAT-genesis-scripts/bin/remoteimmsetup rename to xCAT-genesis-scripts/usr/bin/remoteimmsetup diff --git a/xCAT-genesis-scripts/bin/restart b/xCAT-genesis-scripts/usr/bin/restart similarity index 100% rename from xCAT-genesis-scripts/bin/restart rename to xCAT-genesis-scripts/usr/bin/restart diff --git a/xCAT-genesis-scripts/bin/udpcat.awk b/xCAT-genesis-scripts/usr/bin/udpcat.awk similarity index 100% rename from xCAT-genesis-scripts/bin/udpcat.awk rename to xCAT-genesis-scripts/usr/bin/udpcat.awk diff --git a/xCAT-genesis-scripts/bin/update_flash b/xCAT-genesis-scripts/usr/bin/update_flash similarity index 100% rename from xCAT-genesis-scripts/bin/update_flash rename to xCAT-genesis-scripts/usr/bin/update_flash diff --git a/xCAT-genesis-scripts/bin/update_flash_nv b/xCAT-genesis-scripts/usr/bin/update_flash_nv similarity index 100% rename from xCAT-genesis-scripts/bin/update_flash_nv rename to xCAT-genesis-scripts/usr/bin/update_flash_nv diff --git a/xCAT-genesis-scripts/bin/updateflag.awk b/xCAT-genesis-scripts/usr/bin/updateflag.awk similarity index 100% rename from xCAT-genesis-scripts/bin/updateflag.awk rename to xCAT-genesis-scripts/usr/bin/updateflag.awk diff --git a/xCAT-genesis-scripts/sbin/loadmlxeth b/xCAT-genesis-scripts/usr/sbin/loadmlxeth similarity index 100% rename from xCAT-genesis-scripts/sbin/loadmlxeth rename to xCAT-genesis-scripts/usr/sbin/loadmlxeth diff --git a/xCAT-genesis-scripts/sbin/setupimmnic b/xCAT-genesis-scripts/usr/sbin/setupimmnic similarity index 100% rename from xCAT-genesis-scripts/sbin/setupimmnic rename to xCAT-genesis-scripts/usr/sbin/setupimmnic diff --git a/xCAT-genesis-scripts/xCAT-genesis-scripts.spec b/xCAT-genesis-scripts/xCAT-genesis-scripts.spec index 2a35f23af..4fb917727 100755 --- a/xCAT-genesis-scripts/xCAT-genesis-scripts.spec +++ b/xCAT-genesis-scripts/xCAT-genesis-scripts.spec @@ -71,32 +71,32 @@ touch /etc/xcat/genesis-scripts-updated %Files %defattr(-,root,root) #%dir %attr(-,root,root) %{rpminstallroot} -%{rpminstallroot}/bin/allowcred.awk -%{rpminstallroot}/bin/bmcsetup -%{rpminstallroot}/bin/raidcmd -%{rpminstallroot}/bin/raidutils -%{rpminstallroot}/bin/diskdiscover -%{rpminstallroot}/bin/configraid -%{rpminstallroot}/bin/dodiscovery -%{rpminstallroot}/bin/dosysclone -%{rpminstallroot}/bin/doxcat -%{rpminstallroot}/bin/getadapter -%{rpminstallroot}/bin/getcert -%{rpminstallroot}/bin/getdestiny -%{rpminstallroot}/bin/getipmi -%{rpminstallroot}/bin/ifup -%{rpminstallroot}/bin/minixcatd.awk -%{rpminstallroot}/bin/nextdestiny -%{rpminstallroot}/bin/remoteimmsetup -%{rpminstallroot}/bin/udpcat.awk -%{rpminstallroot}/bin/updateflag.awk -%{rpminstallroot}/bin/pseries_platform -%{rpminstallroot}/bin/update_flash -%{rpminstallroot}/bin/update_flash_nv -%{rpminstallroot}/bin/restart +%{rpminstallroot}/usr/bin/allowcred.awk +%{rpminstallroot}/usr/bin/bmcsetup +%{rpminstallroot}/usr/bin/raidcmd +%{rpminstallroot}/usr/bin/raidutils +%{rpminstallroot}/usr/bin/diskdiscover +%{rpminstallroot}/usr/bin/configraid +%{rpminstallroot}/usr/bin/dodiscovery +%{rpminstallroot}/usr/bin/dosysclone +%{rpminstallroot}/usr/bin/doxcat +%{rpminstallroot}/usr/bin/getadapter +%{rpminstallroot}/usr/bin/getcert +%{rpminstallroot}/usr/bin/getdestiny +%{rpminstallroot}/usr/bin/getipmi +%{rpminstallroot}/usr/bin/ifup +%{rpminstallroot}/usr/bin/minixcatd.awk +%{rpminstallroot}/usr/bin/nextdestiny +%{rpminstallroot}/usr/bin/remoteimmsetup +%{rpminstallroot}/usr/bin/udpcat.awk +%{rpminstallroot}/usr/bin/updateflag.awk +%{rpminstallroot}/usr/bin/pseries_platform +%{rpminstallroot}/usr/bin/update_flash +%{rpminstallroot}/usr/bin/update_flash_nv +%{rpminstallroot}/usr/bin/restart %{rpminstallroot}/etc/init.d/functions %{rpminstallroot}/etc/udev/rules.d/99-imm.rules %{rpminstallroot}/etc/udev/rules.d/98-mlx.rules -%{rpminstallroot}/sbin/setupimmnic -%{rpminstallroot}/sbin/loadmlxeth +%{rpminstallroot}/usr/sbin/setupimmnic +%{rpminstallroot}/usr/sbin/loadmlxeth %exclude %{rpminstallroot}/debian/* From 03d6c72622d2df7e8ca54f634a66813f4e7623fd Mon Sep 17 00:00:00 2001 From: GONG Jie Date: Fri, 12 Jan 2018 16:17:54 +0800 Subject: [PATCH 53/93] Minor tweaks for the debian packaging script of xcat-genesis-base --- .../debuild-xcat-genesis-base | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/xCAT-genesis-builder/debuild-xcat-genesis-base b/xCAT-genesis-builder/debuild-xcat-genesis-base index 1b952adc3..d897039ee 100755 --- a/xCAT-genesis-builder/debuild-xcat-genesis-base +++ b/xCAT-genesis-builder/debuild-xcat-genesis-base @@ -1,7 +1,15 @@ #!/bin/bash +# +# This is a dirty script for convert an xCAT-genesis-base rpm package to +# a debian package. +# # xCAT-genesis-base-x86_64-2.13.10-snap201801090246.noarch.rpm RPM_PACKAGE="$1" +[ -n "${RPM_PACKAGE}" ] || + echo "Usage: ${0##*/} /path/to/xCAT-genesis-base.rpm" && exit 0 + +set -x [ -n "${RPM_PACKAGE}" ] || exit 1 [ -f "${RPM_PACKAGE}" ] || exit 1 @@ -29,11 +37,16 @@ fi cat >"${EXTRACT_DIR}/debian/preinst" <<-EOF #!/bin/bash -rm -rf /opt/xcat/share/xcat/netboot/genesis/${PACKAGE_ARCH}/fs/bin -rm -rf /opt/xcat/share/xcat/netboot/genesis/${PACKAGE_ARCH}/fs/sbin -rm -rf /opt/xcat/share/xcat/netboot/genesis/${PACKAGE_ARCH}/fs/lib -rm -rf /opt/xcat/share/xcat/netboot/genesis/${PACKAGE_ARCH}/fs/lib64 -rm -rf /opt/xcat/share/xcat/netboot/genesis/${PACKAGE_ARCH}/fs/var/run +[ -d /opt/xcat/share/xcat/netboot/genesis/${PACKAGE_ARCH}/fs/bin ] && + rm -rf /opt/xcat/share/xcat/netboot/genesis/${PACKAGE_ARCH}/fs/bin +[ -d /opt/xcat/share/xcat/netboot/genesis/${PACKAGE_ARCH}/fs/sbin ] && + rm -rf /opt/xcat/share/xcat/netboot/genesis/${PACKAGE_ARCH}/fs/sbin +[ -d /opt/xcat/share/xcat/netboot/genesis/${PACKAGE_ARCH}/fs/lib ] && + rm -rf /opt/xcat/share/xcat/netboot/genesis/${PACKAGE_ARCH}/fs/lib +[ -d /opt/xcat/share/xcat/netboot/genesis/${PACKAGE_ARCH}/fs/lib64 ] && + rm -rf /opt/xcat/share/xcat/netboot/genesis/${PACKAGE_ARCH}/fs/lib64 +[ -d /opt/xcat/share/xcat/netboot/genesis/${PACKAGE_ARCH}/fs/var/run ] && + rm -rf /opt/xcat/share/xcat/netboot/genesis/${PACKAGE_ARCH}/fs/var/run EOF ( cd "${EXTRACT_DIR}" && debian/rules binary ) From 0d515b9bf4016afe74a81f2a6eed5442ee37c843 Mon Sep 17 00:00:00 2001 From: chenglch Date: Mon, 15 Jan 2018 13:49:21 +0800 Subject: [PATCH 54/93] Modify the default configuration for gocons As output plugins are suported by goconserver, this patch modify the configuration file accordingly. partial: #4597 --- xCAT-server/lib/perl/xCAT/Goconserver.pm | 51 ++++++++++++++++-------- 1 file changed, 34 insertions(+), 17 deletions(-) diff --git a/xCAT-server/lib/perl/xCAT/Goconserver.pm b/xCAT-server/lib/perl/xCAT/Goconserver.pm index 7f281cde4..b6a55a390 100644 --- a/xCAT-server/lib/perl/xCAT/Goconserver.pm +++ b/xCAT-server/lib/perl/xCAT/Goconserver.pm @@ -218,23 +218,40 @@ sub is_conserver_running { #------------------------------------------------------------------------------- sub build_conf { - # TODO(chenglch): add -f options to support import the configuration file customized by the user, - # it would be friendly to the version control system. - my $config= "#generated by xcat ".xCAT::Utils->Version()."\n". - "global:\n". - " host: 0.0.0.0\n". - " ssl_key_file: /etc/xcat/cert/server-cred.pem\n". - " ssl_cert_file: /etc/xcat/cert/server-cred.pem\n". - " ssl_ca_cert_file: /etc/xcat/cert/ca.pem\n". - " logfile: /var/log/goconserver/server.log # the log for goconserver\n". - "api:\n". - " port: $go_api_port # the port for rest api\n". - "console:\n". - " datadir: /var/lib/goconserver/ # the data file to save the hosts\n". - " port: $go_cons_port # the port for console\n". - " logdir: ".CONSOLE_LOG_DIR." # log files for session nodes\n". - " log_timestamp: true # log the timestamp at the beginning of line\n". - " reconnect_interval: 10 # retry interval in second if console could not be connected\n"; + my $config = "#generated by xcat ".xCAT::Utils->Version()."\n". + "global:\n". + " host: 0.0.0.0\n". + " ssl_key_file: /etc/xcat/cert/server-cred.pem\n". + " ssl_cert_file: /etc/xcat/cert/server-cred.pem\n". + " ssl_ca_cert_file: /etc/xcat/cert/ca.pem\n". + " logfile: /var/log/goconserver/server.log # the log for goconserver\n". + "api:\n". + " port: $go_api_port # the port for rest api\n". + "console:\n". + " datadir: /var/lib/goconserver/ # the data file to save the hosts\n". + " port: $go_cons_port # the port for console\n". + " log_timestamp: true # log the timestamp at the beginning of line\n". + " reconnect_interval: 10 # retry interval in second if console could not be connected\n". + " logger: # multiple logger targets could be specified\n". + " file: # file logger, valid fields: name,logdir. Accept array in yaml format\n". + " - name: default # the identity name customized by user\n". + " logdir: ".CONSOLE_LOG_DIR." # default log directory of xcat\n". + " # - name: goconserver \n". + " # logdir: /var/log/goconserver/nodes \n". + " # tcp: # valied fields: name, host, port, timeout, ssl_key_file, ssl_cert_file, ssl_ca_cert_file, ssl_insecure\n". + " # - name: logstash \n". + " # host: 127.0.0.1 \n". + " # port: 9653 \n". + " # timeout: 3 # default 3 second\n". + " # - name: filebeat \n". + " # host: \n". + " # port: \n". + " # udp: # valid fiedls: name, host, port, timeout\n". + " # - name: rsyslog \n". + " # host: \n". + " # port: \n". + " # timeout: # default 3 second\n"; + my $file; my $ret = open ($file, '>', '/etc/goconserver/server.conf'); if ($ret == 0) { From a4e9fbf01fdf84b9e2b8f4c012203207f116c857 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Mon, 15 Jan 2018 09:44:47 -0500 Subject: [PATCH 55/93] Changes after review --- xCAT-server/lib/xcat/plugins/ipmi.pm | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/ipmi.pm b/xCAT-server/lib/xcat/plugins/ipmi.pm index 8cb56dfba..55eb9955c 100644 --- a/xCAT-server/lib/xcat/plugins/ipmi.pm +++ b/xCAT-server/lib/xcat/plugins/ipmi.pm @@ -2427,9 +2427,9 @@ sub rflash { my $c_id = ${ $sessdata->{component_ids} }[$i]; my $version = $firmware_version{$c_id}; my $format_string = $comp_string{$c_id}; - my $format_ver = sprintf("%3d.%02x.%d%d%d%d", - $version->[0], $version->[1], $version->[5], - $version->[4], $version->[3], $version->[2]); + my $format_ver = sprintf("%3d.%02x.%d", + $version->[0], $version->[1], + $version->[5]*0x1000000 +$version->[4]*0x10000+ $version->[3]*0x100+$version->[2]); $msg = $msg . $sessdata->{node} . ": " . "Node firmware version for $format_string component: $format_ver"; if ($i != scalar(@{ $sessdata->{component_ids} }) - 1) { @@ -8747,16 +8747,16 @@ sub hpm_action_version { return -1; } my $version = $hpm_data_hash{1}{action_version}; - my $ver = sprintf("%3d.%02x.%d%d%d%d", $version->[0], $version->[1], $version->[5], - $version->[4], $version->[3], $version->[2]); + my $ver = sprintf("%3d.%02x.%d", $version->[0], $version->[1], + $version->[5]*0x1000000+$version->[4]*0x10000+$version->[3]*0x100+$version->[2]); $callback->({ data => "HPM firmware version for BOOT component:$ver" }); $version = $hpm_data_hash{2}{action_version}; - $ver = sprintf("%3d.%02x.%d%d%d%d", $version->[0], $version->[1], $version->[5], - $version->[4], $version->[3], $version->[2]); + $ver = sprintf("%3d.%02x.%d", $version->[0], $version->[1], + $version->[5]*0x1000000+$version->[4]*0x10000+$version->[3]*0x100+$version->[2]); $callback->({ data => "HPM firmware version for APP component:$ver" }); $version = $hpm_data_hash{4}{action_version}; - $ver = sprintf("%3d.%02x.%d%d%d%d", $version->[0], $version->[1], $version->[5], - $version->[4], $version->[3], $version->[2]); + $ver = sprintf("%3d.%02x.%d", $version->[0], $version->[1], + $version->[5]*0x1000000+$version->[4]*0x10000+$version->[3]*0x100+$version->[2]); $callback->({ data => "HPM firmware version for BIOS component:$ver" }); } From 7b4af8f393ee28d0edb8a7ba4e3e574235556692 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Mon, 15 Jan 2018 11:49:29 -0500 Subject: [PATCH 56/93] Support for OpenBMC PowerRestorePolicy attribute --- xCAT-server/lib/xcat/plugins/openbmc.pm | 55 +++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 4 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index c70967595..cdde35141 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -539,6 +539,14 @@ my %status_info = ( RSPCONFIG_API_CONFIG_OFF_RESPONSE => { process => \&rspconfig_api_config_response, }, + RSPCONFIG_API_CONFIG_ATTR_REQUEST => { + method => "PUT", + init_url => "$openbmc_project_url", + data => "false", + }, + RSPCONFIG_API_CONFIG_ATTR_RESPONSE => { + process => \&rspconfig_api_config_response, + }, RSPCONFIG_API_CONFIG_QUERY_REQUEST => { method => "GET", init_url => "$openbmc_project_url", @@ -552,6 +560,7 @@ my %status_info = ( # For example: rspconfig # rspconfig =0 # rspconfig =1 +# rspconfig = # # my %api_config_info = ( @@ -571,6 +580,19 @@ my %api_config_info = ( type => "boolean", subcommand => "powersupplyredundency", }, + RSPCONFIG_POWERRESTORE_POLICY => { + command => "rspconfig", + url => "/control/host0/power_restore_policy", + attr_url => "PowerRestorePolicy", + display_name => "PowerRestorePolicy", + type => "attribute", + subcommand => "powerrestorepolicy", + attr_value => { + restore => "xyz.openbmc_project.Control.Power.RestorePolicy.Policy.Restore", + always_on => "xyz.openbmc_project.Control.Power.RestorePolicy.Policy.AlwaysOn", + always_off => "xyz.openbmc_project.Control.Power.RestorePolicy.Policy.AlwaysOff", + }, + }, ); $::RESPONSE_OK = "200 OK"; @@ -1508,18 +1530,25 @@ sub parse_command_status { my $subcommand_key = $1; my $subcommand_value = $2; - if ($subcommand_value eq "1") { + if (($subcommand_value eq "1") && ($api_config_info{$::RSPCONFIG_CONFIGURED_API_KEY}{type} eq "boolean")) { # Setup chain for subcommand=1 $next_status{LOGIN_RESPONSE} = "RSPCONFIG_API_CONFIG_ON_REQUEST"; $status_info{RSPCONFIG_API_CONFIG_ON_REQUEST}{init_url} = $status_info{RSPCONFIG_API_CONFIG_ON_REQUEST}{init_url} . $api_config_info{$::RSPCONFIG_CONFIGURED_API_KEY}{url} . "/attr/" . $api_config_info{$::RSPCONFIG_CONFIGURED_API_KEY}{attr_url}; $next_status{RSPCONFIG_API_CONFIG_ON_REQUEST} = "RSPCONFIG_API_CONFIG_ON_RESPONSE"; } - elsif ($subcommand_value eq "0") { + elsif (($subcommand_value eq "0") && ($api_config_info{$::RSPCONFIG_CONFIGURED_API_KEY}{type} eq "boolean")) { # Setup chain for subcommand=0 $next_status{LOGIN_RESPONSE} = "RSPCONFIG_API_CONFIG_OFF_REQUEST"; $status_info{RSPCONFIG_API_CONFIG_OFF_REQUEST}{init_url} = $status_info{RSPCONFIG_API_CONFIG_OFF_REQUEST}{init_url} . $api_config_info{$::RSPCONFIG_CONFIGURED_API_KEY}{url} . "/attr/" . $api_config_info{$::RSPCONFIG_CONFIGURED_API_KEY}{attr_url}; $next_status{RSPCONFIG_API_CONFIG_OFF_REQUEST} = "RSPCONFIG_API_CONFIG_OFF_RESPONSE"; } + elsif (($api_config_info{$::RSPCONFIG_CONFIGURED_API_KEY}{type} eq "attribute") && (exists $api_config_info{$::RSPCONFIG_CONFIGURED_API_KEY}{attr_value}{$subcommand_value})) { + # Setup chain for subcommand= + $next_status{LOGIN_RESPONSE} = "RSPCONFIG_API_CONFIG_ATTR_REQUEST"; + $status_info{RSPCONFIG_API_CONFIG_ATTR_REQUEST}{init_url} = $status_info{RSPCONFIG_API_CONFIG_ATTR_REQUEST}{init_url} . $api_config_info{$::RSPCONFIG_CONFIGURED_API_KEY}{url} . "/attr/" . $api_config_info{$::RSPCONFIG_CONFIGURED_API_KEY}{attr_url}; + $status_info{RSPCONFIG_API_CONFIG_ATTR_REQUEST}{data} = $api_config_info{$::RSPCONFIG_CONFIGURED_API_KEY}{attr_value}{$subcommand_value}; + $next_status{RSPCONFIG_API_CONFIG_ATTR_REQUEST} = "RSPCONFIG_API_CONFIG_ATTR_RESPONSE"; + } else { # Everything else is invalid xCAT::SvrUtils::sendmsg([1, "Invalid value $subcommand_value for 'rspconfig $subcommand_key=$subcommand_value' command"], $callback); @@ -3406,6 +3435,14 @@ sub rspconfig_api_config_response { xCAT::SvrUtils::sendmsg("Error unsetting RSPCONFIG_API_CONFIG_OFF_RESPONSE", $callback, $node); } } + elsif ($node_info{$node}{cur_status} eq "RSPCONFIG_API_CONFIG_ATTR_RESPONSE") { + if ($response_info->{'message'} eq $::RESPONSE_OK) { + xCAT::SvrUtils::sendmsg("BMC Setting ". $api_config_info{$::RSPCONFIG_CONFIGURED_API_KEY}{display_name} . "...", $callback, $node); + } + else { + xCAT::SvrUtils::sendmsg("Error unsetting RSPCONFIG_API_CONFIG_OFF_RESPONSE", $callback, $node); + } + } elsif ($node_info{$node}{cur_status} eq "RSPCONFIG_API_CONFIG_QUERY_RESPONSE") { if ($response_info->{'message'} eq $::RESPONSE_OK) { foreach my $key_url (keys %{$response_info->{data}}) { @@ -3415,11 +3452,21 @@ sub rspconfig_api_config_response { last; } } - if (scalar($value) >= 0) { + if (($value eq "0") || ($value eq "1")) { + # If 0 or 1 display as a boolean value xCAT::SvrUtils::sendmsg($api_config_info{$::RSPCONFIG_CONFIGURED_API_KEY}{display_name} . ": $value", $callback, $node); } else { - xCAT::SvrUtils::sendmsg("Unable to query value for " . $api_config_info{$::RSPCONFIG_CONFIGURED_API_KEY}{attr_url}, $callback, $node); + # If not a boolean value, display the last component of the attribute + # For example "xyz.openbmc_project.Control.Power.RestorePolicy.Policy.Restore" + # will be displayed as "Restore" + my @attr_value = split('\.', $value); + if (@attr_value[-1]) { + xCAT::SvrUtils::sendmsg($api_config_info{$::RSPCONFIG_CONFIGURED_API_KEY}{display_name} . ": @attr_value[-1]", $callback, $node); + } + else { + xCAT::SvrUtils::sendmsg("Unable to query value for " . $api_config_info{$::RSPCONFIG_CONFIGURED_API_KEY}{attr_url}, $callback, $node); + } } } else { From daae8eed58c24ce188af481bd8a5028f2db10ecf Mon Sep 17 00:00:00 2001 From: Casandra Qiu Date: Mon, 15 Jan 2018 15:28:57 -0500 Subject: [PATCH 57/93] Add documentation for PDU support. --- docs/source/advanced/pdu/crpdu.rst | 109 ++++++++++++++++++++ docs/source/advanced/pdu/index.rst | 4 +- docs/source/advanced/pdu/irpdu.rst | 151 +++++++++++++++++++++++++++ docs/source/advanced/pdu/pdu.rst | 157 +++++------------------------ 4 files changed, 291 insertions(+), 130 deletions(-) create mode 100644 docs/source/advanced/pdu/crpdu.rst create mode 100644 docs/source/advanced/pdu/irpdu.rst diff --git a/docs/source/advanced/pdu/crpdu.rst b/docs/source/advanced/pdu/crpdu.rst new file mode 100644 index 000000000..eea318d72 --- /dev/null +++ b/docs/source/advanced/pdu/crpdu.rst @@ -0,0 +1,109 @@ +Collaborative PDU +================= + +Collaborative PDU is also refer as Coral PDU, it controls power for compute Rack. + + +Pre-Defined PDU Objects +----------------------- + +User needs to pre-defined PDU node object if want to run pdudiscover command. :: + + mkdef coralpdu groups=pdu mgt=pdu nodetype=pdu (required) + +all other attributes can be set by chdef command or pdudisocover command. :: + + --switch required for pdudiscover command to do mapping + --switchport required for pdudiscover command to do mapping + --ip ip address of the pdu. + --mac can be filled in by pdudiscover command + --pdutype crpdu(for coral pdu) or irpdu(for infrastructure PDUs) + + +If user want to configure snmp other than default value, the following attributes need to be set. :: + + --community community string for coral pdu + --snmpversion snmp version number, required if configure snmpv3 for coral pdu + --snmpuser snmpv3 user name, required if configure snmpv3 for coral pdu + --authkey auth passphrase for snmpv3 configuration + --authtype auth protocol (MD5|SHA) for snmpv3 configuration + --privkey priv passphrase for snmpv3 configuration + --privtype priv protocol (AES|DES) for snmpv3 configuration + --seclevel security level (noAuthNoPriv|authNoPriv|authPriv) for snmpv3 configuration + +Make sure run makehosts after pre-defined PDU. :: + + makehosts coralpdu + + +Configure PDUs +-------------- + +After pre-defined PDUs, user can use **pdudisocver --range ip_range --setup** to configure the PDUs, it covers following commands: + + * To configure passwordless of Coral PDU: :: + + # rspconfig coralpdu sshcfg + + * To change hostname of Coral PDU: :: + + # rspconfig coralpdu hosname=f5pdu3 + + * To change ip address of PDU: :: + + # rsconfig coralpdu ip=x.x.x.x netmaks=255.x.x.x + + * To configure SNMP community string or snmpv3 of PDU (the attribute needs to pre-defined): :: + + # rspconfig coralpdu snmpcfg + + +Remote Power Control of PDU +--------------------------- + +Use the rpower command to remotely power on and off of PDU. + + * To check power stat of PDU: :: + + # rpower coralpdu stat + + * To power off the PDU: :: + + # rpower coralpdu off + + * To power on the PDU: :: + + # rpower coralpdu on + +Coral PDUs have three relays, the following commands are for individual relay support of PDU: + + * To check power stat of relay: :: + + # rpower coralpdu relay=1 stat + + * To power off the relay: :: + + # rpower coralpdu relay=2 off + + * To power on the relay: :: + + # rpower coralpdu relay=3 on + + +Show Monitor Data +----------------- + +Use the rvitals command to show realtime monitor data(inpute voltage, current, power) of PDU. :: + + # rvitals coralpdu + + +Show manufacture information +----------------------------- + +Use the rinv command to show MFR information of PDU :: + + # rinv coralpdu + + + diff --git a/docs/source/advanced/pdu/index.rst b/docs/source/advanced/pdu/index.rst index 5141a09f5..b27f754f2 100644 --- a/docs/source/advanced/pdu/index.rst +++ b/docs/source/advanced/pdu/index.rst @@ -1,10 +1,12 @@ PDUs ==== -Power Distribution Units (PDUs) are devices that distribute power to servers in a frame. Intelligent PDUs have the capability of monitoring the amount of power that is being used by devices plugged into it. +Power Distribution Units (PDUs) are devices that distribute power to servers in a frame. It has the capability of monitoring the amount of power that is being used by devices plugged into it and cycle power to individual receptacles. xCAT can support two kinds of PDUs on the fields, infrastructure PDU (irpdu) and collaborative PDU (crpdu). These two types of PDU have different design and implementation. xCAT has different code path to maintains PDU commands via **pdutype**. .. toctree:: :maxdepth: 2 pdu.rst + irpdu.rst + crpdu.rst diff --git a/docs/source/advanced/pdu/irpdu.rst b/docs/source/advanced/pdu/irpdu.rst new file mode 100644 index 000000000..08c779154 --- /dev/null +++ b/docs/source/advanced/pdu/irpdu.rst @@ -0,0 +1,151 @@ +Infrastructure PDU +================== + + +PDU Commands +------------ + +Administrators will need to know the exact mapping of the outlets to each server in the frame. xCAT cannot validate the physical cable is connected to the correct server. + +Add a ``pdu`` attribute to the compute node definition in the form "PDU_Name:outlet": :: + + # + # Compute server cn01 has two power supplies + # connected to outlet 6 and 7 on pdu=f5pdu3 + # + chdef cn01 pdu=f5pdu3:6,f5pdu3:7 + + +The following commands are supported against a compute node: + + * Check the pdu status for a compute node: :: + + # rpower cn01 pdustat + cn01: f5pdu3 outlet 6 is on + cn01: f5pdu3 outlet 7 is on + + + * Power off the PDU outlets on a compute node: :: + + # rpower cn01 pduoff + cn01: f5pdu3 outlet 6 is off + cn01: f5pdu3 outlet 7 is off + + * Power on the PDU outlets on a compute node: :: + + # rpower cn01 pduon + cn01: f5pdu3 outlet 6 is on + cn01: f5pdu3 outlet 7 is on + + * Power cycling the PDU outlets on a compute node: :: + + # rpower cn01 pdureset + cn01: f5pdu3 outlet 6 is reset + cn01: f5pdu3 outlet 7 is reset + +The following commands are supported against a PDU: + + * Check the status of the full PDU: :: + + # rpower f5pdu3 stat + f5pdu3: outlet 1 is on + f5pdu3: outlet 2 is on + f5pdu3: outlet 3 is on + f5pdu3: outlet 4 is on + f5pdu3: outlet 5 is on + f5pdu3: outlet 6 is off + f5pdu3: outlet 7 is off + f5pdu3: outlet 8 is on + f5pdu3: outlet 9 is on + f5pdu3: outlet 10 is on + f5pdu3: outlet 11 is on + f5pdu3: outlet 12 is on + + * Power off the full PDU: :: + + # rpower f5pdu3 off + f5pdu3: outlet 1 is off + f5pdu3: outlet 2 is off + f5pdu3: outlet 3 is off + f5pdu3: outlet 4 is off + f5pdu3: outlet 5 is off + f5pdu3: outlet 6 is off + f5pdu3: outlet 7 is off + f5pdu3: outlet 8 is off + f5pdu3: outlet 9 is off + f5pdu3: outlet 10 is off + f5pdu3: outlet 11 is off + f5pdu3: outlet 12 is off + + * Power on the full PDU: :: + + # rpower f5pdu3 on + f5pdu3: outlet 1 is on + f5pdu3: outlet 2 is on + f5pdu3: outlet 3 is on + f5pdu3: outlet 4 is on + f5pdu3: outlet 5 is on + f5pdu3: outlet 6 is on + f5pdu3: outlet 7 is on + f5pdu3: outlet 8 is on + f5pdu3: outlet 9 is on + f5pdu3: outlet 10 is on + f5pdu3: outlet 11 is on + f5pdu3: outlet 12 is on + + * Power reset the full PDU: :: + + # rpower f5pdu3 reset + f5pdu3: outlet 1 is reset + f5pdu3: outlet 2 is reset + f5pdu3: outlet 3 is reset + f5pdu3: outlet 4 is reset + f5pdu3: outlet 5 is reset + f5pdu3: outlet 6 is reset + f5pdu3: outlet 7 is reset + f5pdu3: outlet 8 is reset + f5pdu3: outlet 9 is reset + f5pdu3: outlet 10 is reset + f5pdu3: outlet 11 is reset + f5pdu3: outlet 12 is reset + + * PDU inventory information: :: + + # rinv f6pdu16 + f6pdu16: PDU Software Version: "OPDP_sIBM_v01.3_2" + f6pdu16: PDU Machine Type: "1U" + f6pdu16: PDU Model Number: "dPDU4230" + f6pdu16: PDU Part Number: "46W1608" + f6pdu16: PDU Name: "IBM PDU" + f6pdu16: PDU Serial Number: "4571S9" + f6pdu16: PDU Description: "description" + + * PDU and outlet power information: :: + + # rvitals f6pdu15 + f6pdu15: Voltage Warning: 0 + f6pdu15: outlet 1 Current: 0 mA + f6pdu15: outlet 1 Max Capacity of the current: 16000 mA + f6pdu15: outlet 1 Current Threshold Warning: 9600 mA + f6pdu15: outlet 1 Current Threshold Critical: 12800 mA + f6pdu15: outlet 1 Last Power Reading: 0 Watts + f6pdu15: outlet 2 Current: 0 mA + f6pdu15: outlet 2 Max Capacity of the current: 16000 mA + f6pdu15: outlet 2 Current Threshold Warning: 9600 mA + f6pdu15: outlet 2 Current Threshold Critical: 12800 mA + f6pdu15: outlet 2 Last Power Reading: 0 Watts + f6pdu15: outlet 3 Current: 1130 mA + f6pdu15: outlet 3 Max Capacity of the current: 16000 mA + f6pdu15: outlet 3 Current Threshold Warning: 9600 mA + f6pdu15: outlet 3 Current Threshold Critical: 12800 mA + f6pdu15: outlet 3 Last Power Reading: 217 Wattsv + +**Note:** For BMC based compute nodes, turning the PDU outlet power on does not automatically power on the compute side. Users will need to issue ``rpower on`` to power on the compute node after the BMC boots. + + + + + + + + diff --git a/docs/source/advanced/pdu/pdu.rst b/docs/source/advanced/pdu/pdu.rst index a8566b5f8..64de43178 100644 --- a/docs/source/advanced/pdu/pdu.rst +++ b/docs/source/advanced/pdu/pdu.rst @@ -1,17 +1,39 @@ -PDU -=== +Discovering PDUs +================ -xCAT provides basic remote management for each power outlet plugged into the PDUs using SNMP communication. This documentation will focus on configuration of the PDU and Node objects to allow xCAT to control power at the PDU outlet level. +xCAT provides `pdudiscover` command to discover the PDUs that are attached to the neighboring subnets on xCAT management node. :: + + pdudiscover [|--range ipranges] [-r|-x|-z] [-w] [-V|--verbose] [--setup] + +xCAT uses snmp scan method to discover PDU. Make sure net-snmp-utils package is installed on xCAT MN in order to use snmpwalk command. :: + + Options: + --range Specify one or more IP ranges. Each can be an ip address (10.1.2.3) or an ip range + (10.1.2.0/24). If the range is huge, for example, 192.168.1.1/8, the pdu + discover may take a very long time to scan. So the range should be exactly + specified. It accepts multiple formats. For example: + 192.168.1.1/24, 40-41.1-2.3-4.1-100. + + If the range is not specified, the command scans all the subnets that the active + network interfaces (eth0, eth1) are on where this command is issued. + -r Display Raw responses. + -x XML formatted output. + -z Stanza formatted output. + -w Writes output to xCAT database. + --setup Process switch-based pdu discovery and configure the PDUs(it included passwordless , change ip address from dhcp to static and snmp configuration). It required predefined PDU node definition with switch name and switch port attributes for mapping. (Notes: only support for crpdu for now for this options) Define PDU Objects ------------------ - #. Define pdu object :: - mkdef f5pdu3 groups=pdu ip=50.0.0.8 mgt=pdu nodetype=pdu + mkdef f5pdu3 groups=pdu ip=50.0.0.8 mgt=pdu nodetype=pdu pdutype=irpdu + +#. Define switch attribute for pdu object will use for pdudiscover **--setup** options. :: + + chdef f5pdu3 switch=mid08 switchport=3 #. Add hostname to /etc/hosts:: @@ -19,129 +41,6 @@ Define PDU Objects #. Verify the SNMP command responds against the PDU: :: - snmpwalk -v1 -cpublic -mALL f5pdu3 .1.3.6.1.2.1.1 - - -Define PDU Attribute --------------------- - -Administrators will need to know the exact mapping of the outlets to each server in the frame. xCAT cannot validate the physical cable is connected to the correct server. - -Add a ``pdu`` attribute to the compute node definition in the form "PDU_Name:outlet": :: - - # - # Compute server cn01 has two power supplies - # connected to outlet 6 and 7 on pdu=f5pdu3 - # - chdef cn01 pdu=f5pdu3:6,f5pdu3:7 - - -Verify the setting: ``lsdef cn01 -i pdu`` - - -PDU Commands ------------- - -The following commands are supported against a compute node: - - * Check the pdu status for a compute node: :: - - # rpower cn01 pdustat - cn01: f5pdu3 outlet 6 is on - cn01: f5pdu3 outlet 7 is on - - - * Power off the PDU outlets on a compute node: :: - - # rpower cn01 pduoff - cn01: f5pdu3 outlet 6 is off - cn01: f5pdu3 outlet 7 is off - - * Power on the PDU outlets on a compute node: :: - - # rpower cn01 pduon - cn01: f5pdu3 outlet 6 is on - cn01: f5pdu3 outlet 7 is on - - * Power cycling the PDU outlets on a compute node: :: - - # rpower cn01 pdureset - cn01: f5pdu3 outlet 6 is reset - cn01: f5pdu3 outlet 7 is reset - -The following commands are supported against a PDU: - - * Check the status of the full PDU: :: - - # rinv f5pdu3 - f5pdu3: outlet 1 is on - f5pdu3: outlet 2 is on - f5pdu3: outlet 3 is on - f5pdu3: outlet 4 is on - f5pdu3: outlet 5 is on - f5pdu3: outlet 6 is off - f5pdu3: outlet 7 is off - f5pdu3: outlet 8 is on - f5pdu3: outlet 9 is on - f5pdu3: outlet 10 is on - f5pdu3: outlet 11 is on - f5pdu3: outlet 12 is on - - * Power off the full PDU: :: - - # rpower f5pdu3 off - f5pdu3: outlet 1 is off - f5pdu3: outlet 2 is off - f5pdu3: outlet 3 is off - f5pdu3: outlet 4 is off - f5pdu3: outlet 5 is off - f5pdu3: outlet 6 is off - f5pdu3: outlet 7 is off - f5pdu3: outlet 8 is off - f5pdu3: outlet 9 is off - f5pdu3: outlet 10 is off - f5pdu3: outlet 11 is off - f5pdu3: outlet 12 is off - - * Power on the full PDU: :: - - # rpower f5pdu3 on - f5pdu3: outlet 1 is on - f5pdu3: outlet 2 is on - f5pdu3: outlet 3 is on - f5pdu3: outlet 4 is on - f5pdu3: outlet 5 is on - f5pdu3: outlet 6 is on - f5pdu3: outlet 7 is on - f5pdu3: outlet 8 is on - f5pdu3: outlet 9 is on - f5pdu3: outlet 10 is on - f5pdu3: outlet 11 is on - f5pdu3: outlet 12 is on - - * Power reset the full PDU: :: - - # rpower f5pdu3 reset - f5pdu3: outlet 1 is reset - f5pdu3: outlet 2 is reset - f5pdu3: outlet 3 is reset - f5pdu3: outlet 4 is reset - f5pdu3: outlet 5 is reset - f5pdu3: outlet 6 is reset - f5pdu3: outlet 7 is reset - f5pdu3: outlet 8 is reset - f5pdu3: outlet 9 is reset - f5pdu3: outlet 10 is reset - f5pdu3: outlet 11 is reset - f5pdu3: outlet 12 is reset - - -**Note:** For BMC based compute nodes, turning the PDU outlet power on does not automatically power on the compute side. Users will need to issue ``rpower on`` to power on the compute node after the BMC boots. - - - - - - + snmpwalk -v1 -cpublic -mALL f5pdu3 system From 26ccc9fabd355a893cb6a1a1901033e021f70f06 Mon Sep 17 00:00:00 2001 From: XuWei Date: Tue, 16 Jan 2018 01:03:10 -0500 Subject: [PATCH 58/93] Add perl files of openbmc2 --- xCAT-server/lib/perl/xCAT/OPENBMC.pm | 150 +++++++++++++++ xCAT-server/lib/xcat/plugins/openbmc.pm | 15 ++ xCAT-server/lib/xcat/plugins/openbmc2.pm | 229 +++++++++++++++++++++++ 3 files changed, 394 insertions(+) create mode 100644 xCAT-server/lib/xcat/plugins/openbmc2.pm diff --git a/xCAT-server/lib/perl/xCAT/OPENBMC.pm b/xCAT-server/lib/perl/xCAT/OPENBMC.pm index 424f83c36..225d73216 100644 --- a/xCAT-server/lib/perl/xCAT/OPENBMC.pm +++ b/xCAT-server/lib/perl/xCAT/OPENBMC.pm @@ -16,6 +16,20 @@ use HTTP::Request; use HTTP::Headers; use HTTP::Cookies; use Data::Dumper; +use Time::HiRes qw(sleep time); +use JSON; +use File::Path; +use Fcntl ":flock"; +use IO::Socket::UNIX qw( SOCK_STREAM ); +use xCAT_monitoring::monitorctrl; + +my $LOCK_DIR = "/var/lock/xcat/"; +my $LOCK_PATH = "/var/lock/xcat/agent.lock"; +my $AGENT_SOCK_PATH = "/var/run/xcat/agent.sock"; +my $PYTHON_LOG_PATH = "/var/log/xcat/agent.log"; +my $MSG_TYPE = "message"; +my $DB_TYPE = "db"; +my $lock_fd; my $header = HTTP::Headers->new('Content-Type' => 'application/json'); @@ -43,4 +57,140 @@ sub send_request { return $id; } +# if lock is released unexpectedly, python side would aware of the error after +# getting this lock +sub acquire_lock { + mkpath($LOCK_DIR); + # always create a new lock file + unlink($LOCK_PATH); + open($lock_fd, ">>", $LOCK_PATH) or return undef; + flock($lock_fd, LOCK_EX) or return undef; + return $lock_fd; +} +sub start_python_agent { + my $agent_file = "/opt/xcat/lib/python/agent/agent.py"; + if (! -e $agent_file) { + xCAT::MsgUtils->message("S", "Error: '/opt/xcat/lib/python/agent/agent.py' does not exist"); + return undef; + } + + if (!defined(acquire_lock())) { + xCAT::MsgUtils->message("S", "Error: Faild to require lock"); + return undef; + } + my $fd; + open($fd, '>', $AGENT_SOCK_PATH) && close($fd); + my $pid = fork; + if (!defined $pid) { + xCAT::MsgUtils->message("S", "Error: Unable to fork process"); + return undef; + } + $SIG{CHLD} = 'DEFAULT'; + if (!$pid) { + # child + open($fd, ">>", $PYTHON_LOG_PATH) && close($fd); + open(STDOUT, '>>', $PYTHON_LOG_PATH) or die("open: $!"); + open(STDERR, '>>&', \*STDOUT) or die("open: $!"); + my $ret = exec ("/opt/xcat/lib/python/agent/agent.py"); + if (!defined($ret)) { + xCAT::MsgUtils->message("S", "Error: Failed to start python agent"); + } + } + return $pid; +} + +sub handle_message { + my ($data, $callback) = @_; + if($data->{type} eq $MSG_TYPE) { + my $msg = $data->{msg}; + if ($msg->{type} eq 'info') { + xCAT::MsgUtils->message("I", { data => [$msg->{data}] }, $callback); + } elsif ($msg->{type} eq 'warning') { + xCAT::MsgUtils->message("W", { data => [$msg->{data}] }, $callback); + } elsif ($msg->{type} eq 'error'){ + xCAT::MsgUtils->message("E", { data => [$msg->{data}] }, $callback); + } elsif ($msg->{type} eq 'syslog'){ + xCAT::MsgUtils->message("S", $msg->{data}); + } + } elsif ($data->{type} eq $DB_TYPE) { + my $attribute = $data->{attribute}; + if ($attribute->{name} eq 'status' and $attribute->{method} eq 'set' and $attribute->{type} eq 'node') { + my %new_status = ($attribute->{value} => [$attribute->{node}]); + xCAT_monitoring::monitorctrl::setNodeStatusAttributes(\%new_status, 1) + } + } +} + +sub submit_agent_request { + my ($pid, $req, $nodeinfo, $callback) = @_; + my $sock; + my $retry = 0; + while($retry < 30) { + $sock = IO::Socket::UNIX->new(Peer => $AGENT_SOCK_PATH, Type => SOCK_STREAM, Timeout => 10, Blocking => 1); + if (!defined($sock)) { + sleep(0.1); + } else { + last; + } + $retry++; + } + if (!defined($sock)) { + xCAT::MsgUtils->message("E", { data => ["Failed to connect to the agent"] }, $callback); + kill('TERM', $pid); + return; + } + my $xcatdebugmode = 0; + if ($::XCATSITEVALS{xcatdebugmode}) { $xcatdebugmode = $::XCATSITEVALS{xcatdebugmode} } + my %env_hash = (); + $env_hash{debugmode} = $xcatdebugmode; + my ($data, $sz, $ret, $buf); + $data->{module} = 'openbmc'; + $data->{command} = $req->{command}->[0]; + $data->{args} = $req->{arg}; + $data->{cwd} = $req->{cwd}; + $data->{nodes} = $req->{node}; + $data->{nodeinfo} = $nodeinfo; + $data->{envs} = \%env_hash; + $buf = encode_json($data); + $sz = pack('i', length($buf)); + $ret = $sock->send($sz); + if (!$ret) { + xCAT::MsgUtils->message("E", { data => ["Failed to send message to the agent"] }, $callback); + $sock->close(); + kill('TERM', $pid); + return; + } + $ret = $sock->send($buf); + if (!$ret) { + xCAT::MsgUtils->message("E", { data => ["Failed to send message to the agent"] }, $callback); + $sock->close(); + kill('TERM', $pid); + return; + } + while(1) { + $ret = $sock->recv($buf, 4); + if (!$ret) { + last; + } + $sz = unpack('i', $buf); + $ret = $sock->recv($buf, $sz); + if (!$ret) { + xCAT::MsgUtils->message("E", { data => ["receive data from python agent unexpectedly"] }, $callback); + last; + } + $data = decode_json($buf); + handle_message($data, $callback); + } + # no message received, the socket on the agent side should be closed. + $sock->close(); +} + +sub wait_agent { + my ($pid, $callback) = @_; + waitpid($pid, 0); + if ($? >> 8 != 0) { + xCAT::MsgUtils->message("E", { data => ["python agent exited unexpectedly"] }, $callback); + } +} + 1; diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index c101c570f..e087ed0bd 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -679,6 +679,21 @@ sub preprocess_request { } ############################################## + # Provide a way to change to python code before formal release + if (ref($request->{environment}) eq 'ARRAY' and ref($request->{environment}->[0]->{XCAT_OPENBMC_PYTHON}) eq 'ARRAY') { + $::OPENBMC_PYTHON = $request->{environment}->[0]->{XCAT_OPENBMC_PYTHON}->[0]; + } elsif (ref($request->{environment}) eq 'ARRAY') { + $::OPENBMC_PYTHON = $request->{environment}->[0]->{XCAT_OPENBMC_PYTHON}; + } else { + $::OPENBMC_PYTHON = $request->{environment}->{XCAT_OPENBMC_PYTHON}; + } + ############################################## + + if (defined($::OPENBMC_PYTHON) and $::OPENBMC_PYTHON eq "YES") { + $request = {}; + return; + } + $callback = shift; if ($::XCATSITEVALS{xcatdebugmode}) { $xcatdebugmode = $::XCATSITEVALS{xcatdebugmode} } diff --git a/xCAT-server/lib/xcat/plugins/openbmc2.pm b/xCAT-server/lib/xcat/plugins/openbmc2.pm new file mode 100644 index 000000000..97c16c794 --- /dev/null +++ b/xCAT-server/lib/xcat/plugins/openbmc2.pm @@ -0,0 +1,229 @@ +#!/usr/bin/perl +### IBM(c) 2017 EPL license http://www.eclipse.org/legal/epl-v10.html + +package xCAT_plugin::openbmc2; + +BEGIN + { + $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat'; + } +use lib "$::XCATROOT/lib/perl"; +use strict; +use warnings "all"; + +use JSON; +use Getopt::Long; +use xCAT::Utils; +use xCAT::Usage; +use xCAT::SvrUtils; +use xCAT::OPENBMC; + +#------------------------------------------------------- + +=head3 handled_commands + + Return list of commands handled by this plugin + +=cut + +#------------------------------------------------------- + +sub handled_commands { + return { + rpower => 'nodehm:mgt=openbmc', + }; +} + +my %node_info = (); +my $callback; + +#------------------------------------------------------- + +=head3 preprocess_request + + preprocess the command + +=cut + +#------------------------------------------------------- +sub preprocess_request { + my $request = shift; + $callback = shift; + + # if $::OPENBMC_PYTHON is 'YES', will run this script + if (ref($request->{environment}) eq 'ARRAY' and ref($request->{environment}->[0]->{XCAT_OPENBMC_PYTHON}) eq 'ARRAY') { + $::OPENBMC_PYTHON = $request->{environment}->[0]->{XCAT_OPENBMC_PYTHON}->[0]; + } elsif (ref($request->{environment}) eq 'ARRAY') { + $::OPENBMC_PYTHON = $request->{environment}->[0]->{XCAT_OPENBMC_PYTHON}; + } else { + $::OPENBMC_PYTHON = $request->{environment}->{XCAT_OPENBMC_PYTHON}; + } + + if (! (defined($::OPENBMC_PYTHON) and $::OPENBMC_PYTHON eq "YES")) { + $request = {}; + return; + } + + my $command = $request->{command}->[0]; + my $noderange = $request->{node}; + my $extrargs = $request->{arg}; + my @exargs = ($request->{arg}); + my @requests; + + if (ref($extrargs)) { + @exargs = @$extrargs; + } + my $usage_string = xCAT::Usage->parseCommand($command, @exargs); + if ($usage_string) { + $callback->({ data => [$usage_string] }); + $request = {}; + return; + } + + my $parse_result = parse_args($command, $extrargs, $noderange); + if (ref($parse_result) eq 'ARRAY') { + my $error_data; + foreach my $node (@$noderange) { + $error_data .= "\n" if ($error_data); + $error_data .= "$node: Error: " . "$parse_result->[1]"; + } + $callback->({ errorcode => [$parse_result->[0]], data => [$error_data] }); + $request = {}; + return; + } + + my $sn = xCAT::ServiceNodeUtils->get_ServiceNode($noderange, "xcat", "MN"); + foreach my $snkey (keys %$sn) { + my $reqcopy = {%$request}; + $reqcopy->{node} = $sn->{$snkey}; + $reqcopy->{'_xcatdest'} = $snkey; + $reqcopy->{_xcatpreprocessed}->[0] = 1; + push @requests, $reqcopy; + } + + return \@requests; +} + +#------------------------------------------------------- + +=head3 process_request + + Process the command + +=cut + +#------------------------------------------------------- +sub process_request { + my $request = shift; + $callback = shift; + my $noderange = $request->{node}; + my $check = parse_node_info($noderange); + $callback->({ errorcode => [$check] }) if ($check); + my $pid = xCAT::OPENBMC::start_python_agent(); + if (!defined($pid)) { + xCAT::MsgUtils->message("E", { data => ["Failed to start python agent"] }, $callback); + return; + } + + xCAT::OPENBMC::submit_agent_request($pid, $request, \%node_info, $callback); + xCAT::OPENBMC::wait_agent($pid, $callback); +} + +#------------------------------------------------------- + +=head3 parse_args + + Parse the command line options and operands + +=cut + +#------------------------------------------------------- +sub parse_args { + my $command = shift; + my $extrargs = shift; + my $noderange = shift; + my $subcommand = undef; + + if (scalar(@ARGV) != 2 and ($command =~ /rpower/)) { + return ([ 1, "Only one option is supported at the same time for $command" ]); + } else { + $subcommand = $ARGV[0]; + } + + if ($command eq "rpower") { + unless ($subcommand =~ /^on$|^off$|^softoff$|^reset$|^boot$|^bmcreboot$|^bmcstate$|^status$|^stat$|^state$/) { + return ([ 1, "Unsupported command: $command $subcommand" ]); + } + } else { + return ([ 1, "Unsupported command: $command" ]); + } +} + +#------------------------------------------------------- + +=head3 parse_node_info + + Parse the node information: bmc, bmcip, username, password + +=cut + +#------------------------------------------------------- +sub parse_node_info { + my $noderange = shift; + my $rst = 0; + + my $passwd_table = xCAT::Table->new('passwd'); + my $passwd_hash = $passwd_table->getAttribs({ 'key' => 'openbmc' }, qw(username password)); + + my $openbmc_table = xCAT::Table->new('openbmc'); + my $openbmc_hash = $openbmc_table->getNodesAttribs(\@$noderange, ['bmc', 'username', 'password']); + + foreach my $node (@$noderange) { + if (defined($openbmc_hash->{$node}->[0])) { + if ($openbmc_hash->{$node}->[0]->{'bmc'}) { + $node_info{$node}{bmc} = $openbmc_hash->{$node}->[0]->{'bmc'}; + $node_info{$node}{bmcip} = xCAT::NetworkUtils::getNodeIPaddress($openbmc_hash->{$node}->[0]->{'bmc'}); + } + unless($node_info{$node}{bmc}) { + xCAT::SvrUtils::sendmsg("Error: Unable to get attribute bmc", $callback, $node); + $rst = 1; + next; + } + unless($node_info{$node}{bmcip}) { + xCAT::SvrUtils::sendmsg("Error: Unable to resolve ip address for bmc: $node_info{$node}{bmc}", $callback, $node); + delete $node_info{$node}; + $rst = 1; + next; + } + if ($openbmc_hash->{$node}->[0]->{'username'}) { + $node_info{$node}{username} = $openbmc_hash->{$node}->[0]->{'username'}; + } elsif ($passwd_hash and $passwd_hash->{username}) { + $node_info{$node}{username} = $passwd_hash->{username}; + } else { + xCAT::SvrUtils::sendmsg("Error: Unable to get attribute username", $callback, $node); + delete $node_info{$node}; + $rst = 1; + next; + } + + if ($openbmc_hash->{$node}->[0]->{'password'}) { + $node_info{$node}{password} = $openbmc_hash->{$node}->[0]->{'password'}; + } elsif ($passwd_hash and $passwd_hash->{password}) { + $node_info{$node}{password} = $passwd_hash->{password}; + } else { + xCAT::SvrUtils::sendmsg("Error: Unable to get attribute password", $callback, $node); + delete $node_info{$node}; + $rst = 1; + next; + } + } else { + xCAT::SvrUtils::sendmsg("Error: Unable to get information from openbmc table", $callback, $node); + $rst = 1; + next; + } + } + + return $rst; +} + +1; From 3f0a152acc2905860e1ac30a4ac0cb09a29fe304 Mon Sep 17 00:00:00 2001 From: bybai Date: Tue, 16 Jan 2018 03:41:20 -0500 Subject: [PATCH 59/93] packaging xCAT-openbmc-py method --- makepythonrpm | 38 +++ xCAT-openbmc-py/lib/python/agent/agent.py | 52 ++++ xCAT-openbmc-py/lib/python/agent/client.py | 76 ++++++ .../lib/python/agent/xcatagent/__init__.py | 2 + .../lib/python/agent/xcatagent/base.py | 47 ++++ .../lib/python/agent/xcatagent/openbmc.py | 242 ++++++++++++++++++ .../lib/python/agent/xcatagent/rest.py | 84 ++++++ .../lib/python/agent/xcatagent/server.py | 123 +++++++++ .../lib/python/agent/xcatagent/utils.py | 41 +++ .../python/agent/xcatagent/xcat_exception.py | 7 + xCAT-openbmc-py/xCAT-openbmc-py.spec | 54 ++++ 11 files changed, 766 insertions(+) create mode 100755 makepythonrpm create mode 100755 xCAT-openbmc-py/lib/python/agent/agent.py create mode 100755 xCAT-openbmc-py/lib/python/agent/client.py create mode 100644 xCAT-openbmc-py/lib/python/agent/xcatagent/__init__.py create mode 100644 xCAT-openbmc-py/lib/python/agent/xcatagent/base.py create mode 100644 xCAT-openbmc-py/lib/python/agent/xcatagent/openbmc.py create mode 100644 xCAT-openbmc-py/lib/python/agent/xcatagent/rest.py create mode 100644 xCAT-openbmc-py/lib/python/agent/xcatagent/server.py create mode 100644 xCAT-openbmc-py/lib/python/agent/xcatagent/utils.py create mode 100644 xCAT-openbmc-py/lib/python/agent/xcatagent/xcat_exception.py create mode 100644 xCAT-openbmc-py/xCAT-openbmc-py.spec diff --git a/makepythonrpm b/makepythonrpm new file mode 100755 index 000000000..72527f512 --- /dev/null +++ b/makepythonrpm @@ -0,0 +1,38 @@ +#!/bin/bash + +# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html + +function makepythonrpm { + RPMNAME="$1" + SPEC_FILE="$RPMNAME.spec" + tar --exclude .svn -czvf $RPMROOT/SOURCES/$RPMNAME-${VER}.tar.gz $RPMNAME + rm -f $RPMROOT/SRPMS/$RPMNAME-$VER*rpm $RPMROOT/RPMS/noarch/$RPMNAME-$VER*rpm + echo "Building $RPMROOT/RPMS/noarch/$RPMNAME-$VER-snap*.noarch.rpm $EMBEDTXT..." + rpmbuild --quiet -ta $RPMROOT/SOURCES/$RPMNAME-${VER}.tar.gz --define "version $VER" $REL "$EASE" + if [ $? -eq 0 ]; then + exit 0 + else + exit 1 + fi +} + +# Main code.... +OSNAME=$(uname) +VER=`cat Version` +REL="--define" +EASE='usedate 1' +RPMROOT=/root/rpmbuild + +rpmbuild --version > /dev/null +if [ $? -gt 0 ]; then + echo "Error: rpmbuild does not appear to be installed or working." + exit 2 +fi + +if [ -n "$1" -a "$1" = "xCAT-openbmc-py" ]; then + makepythonrpm $1 +else + echo 'Usage: makepythonrpm xCAT-openbmc-py' + exit 1 +fi + diff --git a/xCAT-openbmc-py/lib/python/agent/agent.py b/xCAT-openbmc-py/lib/python/agent/agent.py new file mode 100755 index 000000000..b7a1827bc --- /dev/null +++ b/xCAT-openbmc-py/lib/python/agent/agent.py @@ -0,0 +1,52 @@ +#!/usr/bin/env python +# -*- encoding: utf-8 -*- +from __future__ import print_function +import argparse +import sys +from xcatagent import server + + +class AgentShell(object): + def get_base_parser(self): + parser = argparse.ArgumentParser( + prog='xcatagent', + add_help=False, + formatter_class=HelpFormatter, + ) + parser.add_argument('-h', '--help', + action='store_true', + help=argparse.SUPPRESS, + ) + parser.add_argument('--standalone', + help="Start xcat agent as a standalone service, " + "mostly work for test purpose. ", + action='store_true') + parser.add_argument('--sock', + help="The unix domain sock file to communicate " + "with the client", + default='/var/run/xcat/agent.sock', + type=str) + return parser + + def do_help(self, args): + self.parser.print_help() + + def main(self, argv): + self.parser = self.get_base_parser() + (options, args) = self.parser.parse_known_args(argv) + + if options.help: + self.do_help(options) + return 0 + s = server.Server(options.sock, options.standalone) + s.start() + +class HelpFormatter(argparse.HelpFormatter): + def start_section(self, heading): + # Title-case the headings + heading = '%s%s' % (heading[0].upper(), heading[1:]) + super(HelpFormatter, self).start_section(heading) + + +if __name__ == '__main__': + AgentShell().main(sys.argv[1:]) diff --git a/xCAT-openbmc-py/lib/python/agent/client.py b/xCAT-openbmc-py/lib/python/agent/client.py new file mode 100755 index 000000000..ed5bd3e84 --- /dev/null +++ b/xCAT-openbmc-py/lib/python/agent/client.py @@ -0,0 +1,76 @@ +#!/usr/bin/env python +# -*- encoding: utf-8 -*- +# just for test +from __future__ import print_function + +import argparse +import json +import os +import socket +import sys +from xcatagent import utils + +class ClientShell(object): + def get_base_parser(self): + parser = argparse.ArgumentParser( + prog='agentclient', + add_help=False, + formatter_class=HelpFormatter, + ) + parser.add_argument('-h', '--help', + action='store_true', + help=argparse.SUPPRESS, + ) + parser.add_argument('--sock', + help="The unix domain sock file to communicate " + "with the server", + default='/var/run/xcat/agent.sock', + type=str) + return parser + + def do_help(self, args): + self.parser.print_help() + + def main(self, argv): + self.parser = self.get_base_parser() + (options, args) = self.parser.parse_known_args(argv) + + if options.help: + self.do_help(options) + return 0 + + s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) + nodes = ['node1', 'node2'] + nodeinfo = {'node1':{'bmc':'10.0.0.1', 'bmcip':'10.0.0.1', 'username':'root', 'password': 'xxxxxx'}, + 'node2':{'bmc':'10.0.0.2', 'bmcip':'10.0.0.2', 'username':'root', 'password': 'xxxxxx'}} + + s.connect(options.sock) + req = {'module': 'openbmc', + 'command': 'rpower', + 'args': ['state'], + 'cwd': os.getcwd(), + 'nodes': nodes, + 'nodeinfo': nodeinfo, + 'envs': {'debugmode': 1}} + + buf = json.dumps(req) + s.send(utils.int2bytes(len(buf))) + s.send(buf) + while True: + sz = s.recv(4) + if len(sz) == 0: + break + sz = utils.bytes2int(sz) + data = s.recv(sz) + print(data) + + +class HelpFormatter(argparse.HelpFormatter): + def start_section(self, heading): + # Title-case the headings + heading = '%s%s' % (heading[0].upper(), heading[1:]) + super(HelpFormatter, self).start_section(heading) + + +if __name__ == '__main__': + ClientShell().main(sys.argv[1:]) diff --git a/xCAT-openbmc-py/lib/python/agent/xcatagent/__init__.py b/xCAT-openbmc-py/lib/python/agent/xcatagent/__init__.py new file mode 100644 index 000000000..a9ad45f68 --- /dev/null +++ b/xCAT-openbmc-py/lib/python/agent/xcatagent/__init__.py @@ -0,0 +1,2 @@ +from gevent import monkey +monkey.patch_all(thread=False) diff --git a/xCAT-openbmc-py/lib/python/agent/xcatagent/base.py b/xCAT-openbmc-py/lib/python/agent/xcatagent/base.py new file mode 100644 index 000000000..b1ebb6aac --- /dev/null +++ b/xCAT-openbmc-py/lib/python/agent/xcatagent/base.py @@ -0,0 +1,47 @@ +from xcatagent import utils +import gevent +from gevent.pool import Pool + +MODULE_MAP = {"openbmc": "OpenBMCManager"} + + +class BaseManager(object): + def __init__(self, messager, cwd): + self.messager = messager + self.cwd = cwd + + @classmethod + def get_manager_func(self, name): + module_name = 'xcatagent.%s' % name + try: + __import__(module_name) + except ImportError: + return None + + class_name = MODULE_MAP[name] + return utils.class_func(module_name, class_name) + + def process_nodes_worker(self, name, classname, nodes, nodeinfo, command, args): + + module_name = 'xcatagent.%s' % name + obj_func = utils.class_func(module_name, classname) + + gevent_pool = Pool(1000) + + for node in nodes: + obj = obj_func(self.messager, node, nodeinfo[node]) + if not hasattr(obj, command): + self.messager.error('%s: command %s is not supported for %s' % (node, command, classname)) + func = getattr(obj, command) + try: + gevent_pool.add( gevent.spawn(func, args) ) + except Exception: + error = '%s: Internel Error occured in gevent' % node + self.messager.error(error) + + gevent_pool.join() + + +class BaseDriver(object): + def __init__(self, messager): + self.messager = messager diff --git a/xCAT-openbmc-py/lib/python/agent/xcatagent/openbmc.py b/xCAT-openbmc-py/lib/python/agent/xcatagent/openbmc.py new file mode 100644 index 000000000..1276bc85b --- /dev/null +++ b/xCAT-openbmc-py/lib/python/agent/xcatagent/openbmc.py @@ -0,0 +1,242 @@ +from xcatagent import base +import time +import sys +import gevent + +import xcat_exception +import rest + +HTTP_PROTOCOL = "https://" +PROJECT_URL = "/xyz/openbmc_project" + +RESULT_OK = 'ok' + +DEBUGMODE = False + +POWER_SET_OPTIONS = ('on', 'off', 'bmcreboot', 'softoff') +POWER_GET_OPTIONS = ('bmcstate', 'state', 'stat', 'status') + +RPOWER_URLS = { + "on" : { + "url" : PROJECT_URL + "/state/host0/attr/RequestedHostTransition", + "field" : "xyz.openbmc_project.State.Host.Transition.On", + }, + "off" : { + "url" : PROJECT_URL + "/state/chassis0/attr/RequestedPowerTransition", + "field" : "xyz.openbmc_project.State.Chassis.Transition.Off", + }, + "softoff" : { + "url" : PROJECT_URL + "/state/host0/attr/RequestedHostTransition", + "field" : "xyz.openbmc_project.State.Host.Transition.Off", + }, + "bmcreboot" : { + "url" : PROJECT_URL + "/state/bmc0/attr/RequestedBMCTransition", + "field" : "xyz.openbmc_project.State.BMC.Transition.Reboot", + }, + "state" : { + "url" : PROJECT_URL + "/state/enumerate", + }, +} + +RPOWER_STATE = { + "on" : "on", + "off" : "off", + "Off" : "off", + "softoff" : "softoff", + "boot" : "reset", + "reset" : "reset", + "bmcreboot" : "BMC reboot", + "Ready" : "BMC Ready", + "NotReady" : "BMC NotReady", + "chassison" : "on (Chassis)", + "Running" : "on", + "Quiesced" : "quiesced", +} + +POWER_STATE_DB = { + "on" : "powering-on", + "off" : "powering-off", + "softoff" : "powering-off", + "boot" : "powering-on", + "reset" : "powering-on", +} + +class OpenBMC(base.BaseDriver): + + headers = {'Content-Type': 'application/json'} + + def __init__(self, messager, name, node_info): + super(OpenBMC, self).__init__(messager) + self.node = name + for key, value in node_info.items() : + setattr(self, key, value) + global DEBUGMODE + self.client = rest.RestSession(messager, DEBUGMODE) + + def _login(self) : + """ Login + :raise: error message if failed + """ + url = HTTP_PROTOCOL + self.bmcip + '/login' + data = { "data": [ self.username, self.password ] } + self.client.request('POST', url, OpenBMC.headers, data, self.node, 'login') + return RESULT_OK + + def _set_power_onoff(self, subcommand) : + """ Set power on/off/softoff/bmcreboot + :param subcommand: subcommand for rpower + :returns: ok if success + :raise: error message if failed + """ + url = HTTP_PROTOCOL + self.bmcip + RPOWER_URLS[subcommand]['url'] + data = { "data": RPOWER_URLS[subcommand]['field'] } + try : + response = self.client.request('PUT', url, OpenBMC.headers, data, self.node, 'rpower_' + subcommand) + except (xcat_exception.SelfServerException, + xcat_exception.SelfClientException) as e : + if subcommand != 'bmcreboot': + result = e.message + return result + + return RESULT_OK + + def _get_power_state(self, subcommand) : + """ Get power current state + :param subcommand: state/stat/status/bmcstate + :returns: current state if success + :raise: error message if failed + """ + result = '' + bmc_not_ready = 'NotReady' + url = HTTP_PROTOCOL + self.bmcip + RPOWER_URLS['state']['url'] + try : + response = self.client.request('GET', url, OpenBMC.headers, '', self.node, 'rpower_' + subcommand) + except xcat_exception.SelfServerException, e : + if subcommand == 'bmcstate': + result = bmc_not_ready + else : + result = e.message + except xcat_exception.SelfClientException, e : + result = e.message + + if result : + return result + + for key in response['data'] : + key_type = key.split('/')[-1] + if key_type == 'bmc0' : + bmc_current_state = response['data'][key]['CurrentBMCState'].split('.')[-1] + if key_type == 'chassis0' : + chassis_current_state = response['data'][key]['CurrentPowerState'].split('.')[-1] + if key_type == 'host0' : + host_current_state = response['data'][key]['CurrentHostState'].split('.')[-1] + + if subcommand == 'bmcstate' : + if bmc_current_state == 'Ready' : + return bmc_current_state + else : + return bmc_not_ready + + if chassis_current_state == 'Off' : + return chassis_current_state + elif chassis_current_state == 'On' : + if host_current_state == 'Off' : + return 'chassison' + elif host_current_state == 'Quiesced' : + return host_current_state + elif host_current_state == 'Running' : + return host_current_state + else : + return 'Unexpected chassis state=' + host_current_state + else : + return 'Unexpected chassis state=' + chassis_current_state + + + def _rpower_boot(self) : + """Power boot + :returns: 'reset' if success + :raise: error message if failed + """ + result = self._set_power_onoff('off') + if result != RESULT_OK : + return result + self.messager.update_node_attributes('status', self.node, POWER_STATE_DB['off']) + + start_timeStamp = int(time.time()) + for i in range (0,30) : + status = self._get_power_state('state') + if status in RPOWER_STATE and RPOWER_STATE[status] == 'off': + break + gevent.sleep( 2 ) + + end_timeStamp = int(time.time()) + + if status not in RPOWER_STATE or RPOWER_STATE[status] != 'off': + wait_time = str(end_timeStamp - start_timeStamp) + result = 'Error: Sent power-off command but state did not change to off after waiting ' + wait_time + ' seconds. (State=' + status + ').' + return result + + result = self._set_power_onoff('on') + return result + + + def rpower(self, args) : + """handle rpower command + :param args: subcommands for rpower + """ + subcommand = args[0] + try : + result = self._login() + except xcat_exception.SelfServerException as e : + if subcommand == 'bmcstate' : + result = '%s: %s' % (self.node, RPOWER_STATE['NotReady']) + else : + result = '%s: %s' % (self.node, e.message) + except xcat_exception.SelfClientException as e : + result = '%s: %s' % (self.node, e.message) + + if result != RESULT_OK : + self.messager.info(result) + self._update2Ddict(node_rst, self.node, 'rst', result) + return + new_status = '' + if subcommand in POWER_SET_OPTIONS : + result = self._set_power_onoff(subcommand) + if result == RESULT_OK : + result = RPOWER_STATE[subcommand] + new_status = POWER_STATE_DB.get(subcommand, '') + + if subcommand in POWER_GET_OPTIONS : + tmp_result = self._get_power_state(subcommand) + result = RPOWER_STATE.get(tmp_result, tmp_result) + + if subcommand == 'boot' : + result = self._rpower_boot() + if result == RESULT_OK : + result = RPOWER_STATE[subcommand] + new_status = POWER_STATE_DB.get(subcommand, '') + + if subcommand == 'reset' : + status = self._get_power_state('state') + if status == 'Off' or status == 'chassison': + result = RPOWER_STATE['Off'] + else : + result = self._rpower_boot() + if result == RESULT_OK : + result = RPOWER_STATE[subcommand] + new_status = POWER_STATE_DB.get(subcommand, '') + + message = '%s: %s' % (self.node, result) + self.messager.info(message) + if new_status : + self.messager.update_node_attributes('status', self.node, new_status) + +class OpenBMCManager(base.BaseManager): + def __init__(self, messager, cwd, nodes, envs): + super(OpenBMCManager, self).__init__(messager, cwd) + self.nodes = nodes + global DEBUGMODE + DEBUGMODE = envs['debugmode'] + + def rpower(self, nodeinfo, args): + super(OpenBMCManager, self).process_nodes_worker('openbmc', 'OpenBMC', self.nodes, nodeinfo, 'rpower', args) diff --git a/xCAT-openbmc-py/lib/python/agent/xcatagent/rest.py b/xCAT-openbmc-py/lib/python/agent/xcatagent/rest.py new file mode 100644 index 000000000..c3057ddb3 --- /dev/null +++ b/xCAT-openbmc-py/lib/python/agent/xcatagent/rest.py @@ -0,0 +1,84 @@ +#!/usr/bin/env python +import requests +import json +import time +import urllib3 +urllib3.disable_warnings() + +import xcat_exception + +class RestSession : + + def __init__(self, messager, debugmode) : + self.session = requests.Session() + self.messager = messager + self.debugmode = debugmode + + def _print_record_log (self, node, log_string, status) : + if self.debugmode : + localtime = time.asctime( time.localtime(time.time()) ) + log = node + ': [openbmc_debug] ' + status + ' ' + log_string + self.messager.info(localtime + ' ' + log) + self.messager.syslog(log) + + def _request_log (self, method, url, headers, data): + log_string = 'curl -k -c cjar' + log_string += ' -X %s' % method + for key,value in headers.items() : + header_data = key + ": " + value + log_string += ' -H "' + header_data + '"' + log_string += ' %s' % url + + if data : + log_string += ' -d \'%s\'' % data + + return log_string + + def request (self, method, url, headers, in_data, node, status) : + if in_data : + data = json.dumps(in_data) + else : + data = '' + + if status == 'login' : + in_data['data'][1] = 'xxxxxx' + log_data = json.dumps(in_data) + else : + log_data = data + + log_string = self._request_log(method, url, headers, log_data) + self._print_record_log(node, log_string, status) + + response = '' + error = '' + try : + response = self.session.request(method, url, + data=data, + headers=headers, + verify=False, + timeout=30) + except requests.exceptions.ConnectionError : + error = 'Error: BMC did not respond. Validate BMC configuration and retry the command.' + except requests.exceptions.Timeout : + error = 'Error: Timeout to connect to server' + + if error : + self._print_record_log(node, error, status) + raise xcat_exception.SelfServerException(error) + + try : + response_dict = response.json() + except ValueError : + error = 'Error: Received wrong format response:' + response_dict + self._print_record_log(node, error, status) + raise xcat_exception.SelfServerException(error) + + if response.status_code != requests.codes.ok : + description = ''.join(response_dict['data']['description']) + error = 'Error: [%d] %s' % (response.status_code, description) + self._print_record_log(node, error, status) + raise xcat_exception.SelfClientException(error) + else : + self._print_record_log(node, response_dict['message'], status) + + return response_dict diff --git a/xCAT-openbmc-py/lib/python/agent/xcatagent/server.py b/xCAT-openbmc-py/lib/python/agent/xcatagent/server.py new file mode 100644 index 000000000..a0b242356 --- /dev/null +++ b/xCAT-openbmc-py/lib/python/agent/xcatagent/server.py @@ -0,0 +1,123 @@ +# -*- encoding: utf-8 -*- +from __future__ import print_function +import json +import sys +import os +import threading +import fcntl +import traceback +from gevent import socket +from gevent.server import StreamServer +from gevent.lock import BoundedSemaphore +from xcatagent import utils +from xcatagent import base as xcat_manager + +MSG_TYPE = 'message' +DB_TYPE = 'db' +LOCK_FILE = '/var/lock/xcat/agent.lock' + + +class Messager(object): + def __init__(self, sock): + self.sock = sock + self.sem = BoundedSemaphore(1) + + def _send(self, d): + buf = json.dumps(d) + self.sem.acquire() + self.sock.sendall(utils.int2bytes(len(buf)) + buf) + self.sem.release() + + def info(self, msg): + d = {'type': MSG_TYPE, 'msg': {'type': 'info', 'data': msg}} + self._send(d) + + def warn(self, msg): + d = {'type': MSG_TYPE, 'msg': {'type': 'warning', 'data': msg}} + self._send(d) + + def error(self, msg): + d = {'type': MSG_TYPE, 'msg': {'type': 'error', 'data': msg}} + self._send(d) + + def syslog(self, msg): + d = {'type': MSG_TYPE, 'msg': {'type': 'syslog', 'data': msg}} + self._send(d) + + def update_node_attributes(self, attribute, node, data): + d = {'type': DB_TYPE, 'attribute': {'name': attribute, 'method': 'set', 'type': 'node', 'node': node, 'value': data}} + self._send(d) + + +class Server(object): + def __init__(self, address, standalone): + try: + os.unlink(address) + except OSError: + if os.path.exists(address): + raise + self.address = address + self.standalone = standalone + self.server = StreamServer(self._serve(), self._handle) + + def _serve(self): + listener = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) + listener.bind(self.address) + listener.listen(1) + return listener + + def _handle(self, sock, address): + try: + messager = Messager(sock) + buf = sock.recv(4) + sz = utils.bytes2int(buf) + buf = utils.recv_all(sock, sz) + req = json.loads(buf) + if not 'command' in req: + messager.error("Could not find command") + return + if not 'module' in req: + messager.error("Please specify the request module") + return + if not 'cwd' in req: + messager.error("Please specify the cwd parameter") + return + manager_func = xcat_manager.BaseManager.get_manager_func( + req['module']) + if manager_func is None: + messager.error("Could not find manager for %s" % req['module']) + return + nodes = req.get("nodes", None) + manager = manager_func(messager, req['cwd'], nodes, req['envs']) + if not hasattr(manager, req['command']): + messager.error("command %s is not supported" % req['command']) + func = getattr(manager, req['command']) + # call the function in the specified manager + func(req['nodeinfo'], req['args']) + # after the method returns, the request should be handled + # completely, close the socket for client + if not self.standalone: + sock.close() + self.server.stop() + os._exit(0) + except Exception: + print(traceback.format_exc(), file=sys.stderr) + self.server.stop() + os._exit(1) + + def keep_peer_alive(self): + def acquire(): + fd = open(LOCK_FILE, "r+") + fcntl.flock(fd.fileno(), fcntl.LOCK_EX) + # if reach here, parent process may exit + print("xcat process exit unexpectedly.", file=sys.stderr) + self.server.stop() + os._exit(1) + + t = threading.Thread(target=acquire) + t.start() + + def start(self): + if not self.standalone: + self.keep_peer_alive() + self.server.serve_forever() diff --git a/xCAT-openbmc-py/lib/python/agent/xcatagent/utils.py b/xCAT-openbmc-py/lib/python/agent/xcatagent/utils.py new file mode 100644 index 000000000..8fff2403a --- /dev/null +++ b/xCAT-openbmc-py/lib/python/agent/xcatagent/utils.py @@ -0,0 +1,41 @@ +import struct +import sys +import inspect + + +def int2bytes(num): + return struct.pack('i', num) + + +def bytes2int(buf): + return struct.unpack('i', buf)[0] + + +def get_classes(module_name): + ret = [] + for name, obj in inspect.getmembers(sys.modules[module_name]): + if inspect.isclass(obj): + ret.append(obj) + + return ret + + +def class_func(module_name, class_name): + func = getattr(sys.modules[module_name], class_name) + return func + + +def recv_all(sock, size): + recv_size = 4096 + buf_size = 0 + buf_parts = [] + while buf_size < size: + tmp_size = recv_size + left_size = size - buf_size + if left_size < recv_size: + tmp_size = left_size + buf_part = sock.recv(tmp_size) + buf_parts.append(buf_part) + buf_size += len(buf_part) + buf = ''.join(buf_parts) + return buf diff --git a/xCAT-openbmc-py/lib/python/agent/xcatagent/xcat_exception.py b/xCAT-openbmc-py/lib/python/agent/xcatagent/xcat_exception.py new file mode 100644 index 000000000..f544cf2c8 --- /dev/null +++ b/xCAT-openbmc-py/lib/python/agent/xcatagent/xcat_exception.py @@ -0,0 +1,7 @@ +#!/usr/bin/env python + +class SelfServerException(Exception) : + pass + +class SelfClientException(Exception) : + pass diff --git a/xCAT-openbmc-py/xCAT-openbmc-py.spec b/xCAT-openbmc-py/xCAT-openbmc-py.spec new file mode 100644 index 000000000..70776df50 --- /dev/null +++ b/xCAT-openbmc-py/xCAT-openbmc-py.spec @@ -0,0 +1,54 @@ +Summary: xCAT openbmc python +Name: xCAT-openbmc-py +Version: %{?version:%{version}}%{!?version:%(cat Version)} +Release: %{?release:%{release}}%{!?release:snap%(date +"%Y%m%d%H%M")} +Epoch: 4 +License: EPL +Group: Applications/System +Source: xCAT-openbmc-py-%{version}.tar.gz +Packager: IBM Corp. +Vendor: IBM Corp. +Distribution: %{?_distribution:%{_distribution}}%{!?_distribution:%{_vendor}} +Prefix: /opt/xcat +BuildRoot: /var/tmp/%{name}-%{version}-%{release}-root + +%ifnos linux +AutoReqProv: no +%endif + +BuildArch: noarch +Requires: xCAT-server, python-requests + +%description +xCAT-openbmc-py provides openbmc related functions. + +%prep +%setup -q -n xCAT-openbmc-py +%build + +%install +rm -rf $RPM_BUILD_ROOT +install -d $RPM_BUILD_ROOT/%{prefix}/lib/python/agent +install -d $RPM_BUILD_ROOT/%{prefix}/lib/python/agent/xcatagent +install -m644 lib/python/agent/*.py $RPM_BUILD_ROOT/%{prefix}/lib/python/agent +install -m644 lib/python/agent/xcatagent/*.py $RPM_BUILD_ROOT/%{prefix}/lib/python/agent/xcatagent + +%ifnos linux +rm -rf $RPM_BUILD_ROOT/%{prefix}/lib/python +%endif + +%clean +rm -rf $RPM_BUILD_ROOT + +%files +%defattr(-,root,root) +%{prefix} + +%changelog + +%pre + +%post + +%preun + From e718235ae2a2be33a0fdbe3748178e29913cb426 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 4 Apr 2017 09:50:05 -0400 Subject: [PATCH 60/93] macdata can be a string, ignore that as well --- 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 55eb9955c..112f51390 100644 --- a/xCAT-server/lib/xcat/plugins/ipmi.pm +++ b/xCAT-server/lib/xcat/plugins/ipmi.pm @@ -4696,7 +4696,7 @@ sub parseboard { my $macdata = $boardinf{extra}->[6]->{value}; my $macstring = "1"; my $macprefix; - while ($macdata and $macstring !~ /00:00:00:00:00:00/ and not ref $global_sessdata->{currmacs}) { + while ($macdata and ref $macdata and $macstring !~ /00:00:00:00:00:00/ and not ref $global_sessdata->{currmacs}) { my @currmac = splice @$macdata, 0, 6; unless ((scalar @currmac) == 6) { last; From ec7a7fc325e80ac9faf73b992c60829011618201 Mon Sep 17 00:00:00 2001 From: Casandra Qiu Date: Tue, 16 Jan 2018 13:46:43 -0500 Subject: [PATCH 61/93] modify changes from Mark's review --- docs/source/advanced/pdu/crpdu.rst | 14 +++---- docs/source/advanced/pdu/index.rst | 2 +- docs/source/advanced/pdu/irpdu.rst | 62 +++++++++++++++--------------- docs/source/advanced/pdu/pdu.rst | 2 +- 4 files changed, 40 insertions(+), 40 deletions(-) diff --git a/docs/source/advanced/pdu/crpdu.rst b/docs/source/advanced/pdu/crpdu.rst index eea318d72..e527c0169 100644 --- a/docs/source/advanced/pdu/crpdu.rst +++ b/docs/source/advanced/pdu/crpdu.rst @@ -1,13 +1,13 @@ Collaborative PDU ================= -Collaborative PDU is also refer as Coral PDU, it controls power for compute Rack. +Collaborative PDU is also referred as Coral PDU, it controls power for compute Rack. Pre-Defined PDU Objects ----------------------- -User needs to pre-defined PDU node object if want to run pdudiscover command. :: +A pre-defined PDU node object is required before running pdudiscover command. :: mkdef coralpdu groups=pdu mgt=pdu nodetype=pdu (required) @@ -20,7 +20,7 @@ all other attributes can be set by chdef command or pdudisocover command. :: --pdutype crpdu(for coral pdu) or irpdu(for infrastructure PDUs) -If user want to configure snmp other than default value, the following attributes need to be set. :: +The following attributes need to be set in order to configure snmp with non-default values. :: --community community string for coral pdu --snmpversion snmp version number, required if configure snmpv3 for coral pdu @@ -31,7 +31,7 @@ If user want to configure snmp other than default value, the following attribute --privtype priv protocol (AES|DES) for snmpv3 configuration --seclevel security level (noAuthNoPriv|authNoPriv|authPriv) for snmpv3 configuration -Make sure run makehosts after pre-defined PDU. :: +Make sure to run makehosts after pre-defined PDU. :: makehosts coralpdu @@ -39,7 +39,7 @@ Make sure run makehosts after pre-defined PDU. :: Configure PDUs -------------- -After pre-defined PDUs, user can use **pdudisocver --range ip_range --setup** to configure the PDUs, it covers following commands: +After pre-defining PDUs, user can use **pdudisocver --range ip_range --setup** to configure the PDUs, or following commands can be used: * To configure passwordless of Coral PDU: :: @@ -61,7 +61,7 @@ After pre-defined PDUs, user can use **pdudisocver --range ip_range --setup** to Remote Power Control of PDU --------------------------- -Use the rpower command to remotely power on and off of PDU. +Use the rpower command to remotely power on and off PDU. * To check power stat of PDU: :: @@ -93,7 +93,7 @@ Coral PDUs have three relays, the following commands are for individual relay su Show Monitor Data ----------------- -Use the rvitals command to show realtime monitor data(inpute voltage, current, power) of PDU. :: +Use the rvitals command to show realtime monitor data(input voltage, current, power) of PDU. :: # rvitals coralpdu diff --git a/docs/source/advanced/pdu/index.rst b/docs/source/advanced/pdu/index.rst index b27f754f2..42b371ae7 100644 --- a/docs/source/advanced/pdu/index.rst +++ b/docs/source/advanced/pdu/index.rst @@ -1,7 +1,7 @@ PDUs ==== -Power Distribution Units (PDUs) are devices that distribute power to servers in a frame. It has the capability of monitoring the amount of power that is being used by devices plugged into it and cycle power to individual receptacles. xCAT can support two kinds of PDUs on the fields, infrastructure PDU (irpdu) and collaborative PDU (crpdu). These two types of PDU have different design and implementation. xCAT has different code path to maintains PDU commands via **pdutype**. +Power Distribution Units (PDUs) are devices that distribute power to servers in a frame. They have the capability of monitoring the amount of power that is being used by devices plugged into it and cycle power to individual receptacles. xCAT can support two kinds of PDUs, infrastructure PDU (irpdu) and collaborative PDU (crpdu). These two types of PDU have different design and implementation. xCAT has different code path to maintains PDU commands via **pdutype**. .. toctree:: diff --git a/docs/source/advanced/pdu/irpdu.rst b/docs/source/advanced/pdu/irpdu.rst index 08c779154..b35193b50 100644 --- a/docs/source/advanced/pdu/irpdu.rst +++ b/docs/source/advanced/pdu/irpdu.rst @@ -25,19 +25,19 @@ The following commands are supported against a compute node: cn01: f5pdu3 outlet 7 is on - * Power off the PDU outlets on a compute node: :: + * Power off the PDU outlets for a compute node: :: # rpower cn01 pduoff cn01: f5pdu3 outlet 6 is off cn01: f5pdu3 outlet 7 is off - * Power on the PDU outlets on a compute node: :: + * Power on the PDU outlets for a compute node: :: # rpower cn01 pduon cn01: f5pdu3 outlet 6 is on cn01: f5pdu3 outlet 7 is on - * Power cycling the PDU outlets on a compute node: :: + * Power cycling the PDU outlets for a compute node: :: # rpower cn01 pdureset cn01: f5pdu3 outlet 6 is reset @@ -109,38 +109,38 @@ The following commands are supported against a PDU: f5pdu3: outlet 11 is reset f5pdu3: outlet 12 is reset - * PDU inventory information: :: + * PDU inventory information: :: - # rinv f6pdu16 - f6pdu16: PDU Software Version: "OPDP_sIBM_v01.3_2" - f6pdu16: PDU Machine Type: "1U" - f6pdu16: PDU Model Number: "dPDU4230" - f6pdu16: PDU Part Number: "46W1608" - f6pdu16: PDU Name: "IBM PDU" - f6pdu16: PDU Serial Number: "4571S9" - f6pdu16: PDU Description: "description" + # rinv f6pdu16 + f6pdu16: PDU Software Version: "OPDP_sIBM_v01.3_2" + f6pdu16: PDU Machine Type: "1U" + f6pdu16: PDU Model Number: "dPDU4230" + f6pdu16: PDU Part Number: "46W1608" + f6pdu16: PDU Name: "IBM PDU" + f6pdu16: PDU Serial Number: "4571S9" + f6pdu16: PDU Description: "description" - * PDU and outlet power information: :: + * PDU and outlet power information: :: - # rvitals f6pdu15 - f6pdu15: Voltage Warning: 0 - f6pdu15: outlet 1 Current: 0 mA - f6pdu15: outlet 1 Max Capacity of the current: 16000 mA - f6pdu15: outlet 1 Current Threshold Warning: 9600 mA - f6pdu15: outlet 1 Current Threshold Critical: 12800 mA - f6pdu15: outlet 1 Last Power Reading: 0 Watts - f6pdu15: outlet 2 Current: 0 mA - f6pdu15: outlet 2 Max Capacity of the current: 16000 mA - f6pdu15: outlet 2 Current Threshold Warning: 9600 mA - f6pdu15: outlet 2 Current Threshold Critical: 12800 mA - f6pdu15: outlet 2 Last Power Reading: 0 Watts - f6pdu15: outlet 3 Current: 1130 mA - f6pdu15: outlet 3 Max Capacity of the current: 16000 mA - f6pdu15: outlet 3 Current Threshold Warning: 9600 mA - f6pdu15: outlet 3 Current Threshold Critical: 12800 mA - f6pdu15: outlet 3 Last Power Reading: 217 Wattsv + # rvitals f6pdu15 + f6pdu15: Voltage Warning: 0 + f6pdu15: outlet 1 Current: 0 mA + f6pdu15: outlet 1 Max Capacity of the current: 16000 mA + f6pdu15: outlet 1 Current Threshold Warning: 9600 mA + f6pdu15: outlet 1 Current Threshold Critical: 12800 mA + f6pdu15: outlet 1 Last Power Reading: 0 Watts + f6pdu15: outlet 2 Current: 0 mA + f6pdu15: outlet 2 Max Capacity of the current: 16000 mA + f6pdu15: outlet 2 Current Threshold Warning: 9600 mA + f6pdu15: outlet 2 Current Threshold Critical: 12800 mA + f6pdu15: outlet 2 Last Power Reading: 0 Watts + f6pdu15: outlet 3 Current: 1130 mA + f6pdu15: outlet 3 Max Capacity of the current: 16000 mA + f6pdu15: outlet 3 Current Threshold Warning: 9600 mA + f6pdu15: outlet 3 Current Threshold Critical: 12800 mA + f6pdu15: outlet 3 Last Power Reading: 217 Wattsv -**Note:** For BMC based compute nodes, turning the PDU outlet power on does not automatically power on the compute side. Users will need to issue ``rpower on`` to power on the compute node after the BMC boots. +**Note:** For BMC based compute nodes, turning the PDU outlet power on does not automatically power on the compute side. Users will need to issue ``rpower on`` to power on the compute side after the BMC boots. diff --git a/docs/source/advanced/pdu/pdu.rst b/docs/source/advanced/pdu/pdu.rst index 64de43178..0157ee8da 100644 --- a/docs/source/advanced/pdu/pdu.rst +++ b/docs/source/advanced/pdu/pdu.rst @@ -31,7 +31,7 @@ Define PDU Objects mkdef f5pdu3 groups=pdu ip=50.0.0.8 mgt=pdu nodetype=pdu pdutype=irpdu -#. Define switch attribute for pdu object will use for pdudiscover **--setup** options. :: +#. Define switch attribute for pdu object which will be used for pdudiscover **--setup** options. :: chdef f5pdu3 switch=mid08 switchport=3 From c381d31b798ef70a531ddd6838a5cb80edcf53c3 Mon Sep 17 00:00:00 2001 From: bybai Date: Tue, 16 Jan 2018 21:43:58 -0500 Subject: [PATCH 62/93] update Epoch --- xCAT-openbmc-py/xCAT-openbmc-py.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-openbmc-py/xCAT-openbmc-py.spec b/xCAT-openbmc-py/xCAT-openbmc-py.spec index 70776df50..ef722b043 100644 --- a/xCAT-openbmc-py/xCAT-openbmc-py.spec +++ b/xCAT-openbmc-py/xCAT-openbmc-py.spec @@ -2,7 +2,7 @@ Summary: xCAT openbmc python Name: xCAT-openbmc-py Version: %{?version:%{version}}%{!?version:%(cat Version)} Release: %{?release:%{release}}%{!?release:snap%(date +"%Y%m%d%H%M")} -Epoch: 4 +Epoch: 1 License: EPL Group: Applications/System Source: xCAT-openbmc-py-%{version}.tar.gz From 858270e66657c95ef58b776b7e900f6ffd9c72e8 Mon Sep 17 00:00:00 2001 From: GONG Jie Date: Wed, 17 Jan 2018 13:03:42 +0800 Subject: [PATCH 63/93] Fix the error handling of command line argument checking --- xCAT-genesis-builder/debuild-xcat-genesis-base | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/xCAT-genesis-builder/debuild-xcat-genesis-base b/xCAT-genesis-builder/debuild-xcat-genesis-base index d897039ee..2dc9e9066 100755 --- a/xCAT-genesis-builder/debuild-xcat-genesis-base +++ b/xCAT-genesis-builder/debuild-xcat-genesis-base @@ -6,8 +6,11 @@ # xCAT-genesis-base-x86_64-2.13.10-snap201801090246.noarch.rpm RPM_PACKAGE="$1" -[ -n "${RPM_PACKAGE}" ] || - echo "Usage: ${0##*/} /path/to/xCAT-genesis-base.rpm" && exit 0 +if [ -z "${RPM_PACKAGE}" ] +then + echo "Usage: ${0##*/} /path/to/xCAT-genesis-base.rpm" + exit 0 +fi set -x From 7e286494c0864667e44e72773b64884968050b2a Mon Sep 17 00:00:00 2001 From: XuWei Date: Tue, 16 Jan 2018 04:10:30 -0500 Subject: [PATCH 64/93] modified depending on comments --- xCAT-server/lib/perl/xCAT/OPENBMC.pm | 31 +++++++++++++++++++++--- xCAT-server/lib/xcat/plugins/openbmc.pm | 12 +-------- xCAT-server/lib/xcat/plugins/openbmc2.pm | 13 +++------- 3 files changed, 31 insertions(+), 25 deletions(-) diff --git a/xCAT-server/lib/perl/xCAT/OPENBMC.pm b/xCAT-server/lib/perl/xCAT/OPENBMC.pm index 225d73216..64fd999d5 100644 --- a/xCAT-server/lib/perl/xCAT/OPENBMC.pm +++ b/xCAT-server/lib/perl/xCAT/OPENBMC.pm @@ -27,6 +27,7 @@ my $LOCK_DIR = "/var/lock/xcat/"; my $LOCK_PATH = "/var/lock/xcat/agent.lock"; my $AGENT_SOCK_PATH = "/var/run/xcat/agent.sock"; my $PYTHON_LOG_PATH = "/var/log/xcat/agent.log"; +my $PYTHON_AGENT_FILE = "/opt/xcat/lib/python/agent/agent.py"; my $MSG_TYPE = "message"; my $DB_TYPE = "db"; my $lock_fd; @@ -68,9 +69,8 @@ sub acquire_lock { return $lock_fd; } sub start_python_agent { - my $agent_file = "/opt/xcat/lib/python/agent/agent.py"; - if (! -e $agent_file) { - xCAT::MsgUtils->message("S", "Error: '/opt/xcat/lib/python/agent/agent.py' does not exist"); + if (! -e $PYTHON_AGENT_FILE) { + xCAT::MsgUtils->message("S", "'$PYTHON_AGENT_FILE' does not exist"); return undef; } @@ -91,9 +91,10 @@ sub start_python_agent { open($fd, ">>", $PYTHON_LOG_PATH) && close($fd); open(STDOUT, '>>', $PYTHON_LOG_PATH) or die("open: $!"); open(STDERR, '>>&', \*STDOUT) or die("open: $!"); - my $ret = exec ("/opt/xcat/lib/python/agent/agent.py"); + my $ret = exec ($PYTHON_AGENT_FILE); if (!defined($ret)) { xCAT::MsgUtils->message("S", "Error: Failed to start python agent"); + exit(1); } } return $pid; @@ -153,6 +154,7 @@ sub submit_agent_request { $data->{envs} = \%env_hash; $buf = encode_json($data); $sz = pack('i', length($buf)); + # send length of data first $ret = $sock->send($sz); if (!$ret) { xCAT::MsgUtils->message("E", { data => ["Failed to send message to the agent"] }, $callback); @@ -160,6 +162,7 @@ sub submit_agent_request { kill('TERM', $pid); return; } + # send data $ret = $sock->send($buf); if (!$ret) { xCAT::MsgUtils->message("E", { data => ["Failed to send message to the agent"] }, $callback); @@ -172,7 +175,9 @@ sub submit_agent_request { if (!$ret) { last; } + # receive the length of data $sz = unpack('i', $buf); + # read data with length is $sz $ret = $sock->recv($buf, $sz); if (!$ret) { xCAT::MsgUtils->message("E", { data => ["receive data from python agent unexpectedly"] }, $callback); @@ -193,4 +198,22 @@ sub wait_agent { } } +sub is_openbmc_python { + my $environment = shift; + $environment = shift if (($environment) && ($environment =~ /OPENBMC/)); + # If XCAT_OPENBMC_PYTHON is YES, will run openbmc2.pm. If not, run openbmc.pm + if (ref($environment) eq 'ARRAY' and ref($environment->[0]->{XCAT_OPENBMC_PYTHON}) eq 'ARRAY') { + $::OPENBMC_PYTHON = $environment->[0]->{XCAT_OPENBMC_PYTHON}->[0]; + } elsif (ref($environment) eq 'ARRAY') { + $::OPENBMC_PYTHON = $environment->[0]->{XCAT_OPENBMC_PYTHON}; + } else { + $::OPENBMC_PYTHON = $environment->{XCAT_OPENBMC_PYTHON}; + } + if (defined($::OPENBMC_PYTHON) and $::OPENBMC_PYTHON eq "YES") { + return 1; + } + + return 0; +} + 1; diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index e087ed0bd..dd0d6fba1 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -679,17 +679,7 @@ sub preprocess_request { } ############################################## - # Provide a way to change to python code before formal release - if (ref($request->{environment}) eq 'ARRAY' and ref($request->{environment}->[0]->{XCAT_OPENBMC_PYTHON}) eq 'ARRAY') { - $::OPENBMC_PYTHON = $request->{environment}->[0]->{XCAT_OPENBMC_PYTHON}->[0]; - } elsif (ref($request->{environment}) eq 'ARRAY') { - $::OPENBMC_PYTHON = $request->{environment}->[0]->{XCAT_OPENBMC_PYTHON}; - } else { - $::OPENBMC_PYTHON = $request->{environment}->{XCAT_OPENBMC_PYTHON}; - } - ############################################## - - if (defined($::OPENBMC_PYTHON) and $::OPENBMC_PYTHON eq "YES") { + if (xCAT::OPENBMC->is_openbmc_python($request->{environment})) { $request = {}; return; } diff --git a/xCAT-server/lib/xcat/plugins/openbmc2.pm b/xCAT-server/lib/xcat/plugins/openbmc2.pm index 97c16c794..6f1bfaf99 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc2.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc2.pm @@ -50,16 +50,7 @@ sub preprocess_request { my $request = shift; $callback = shift; - # if $::OPENBMC_PYTHON is 'YES', will run this script - if (ref($request->{environment}) eq 'ARRAY' and ref($request->{environment}->[0]->{XCAT_OPENBMC_PYTHON}) eq 'ARRAY') { - $::OPENBMC_PYTHON = $request->{environment}->[0]->{XCAT_OPENBMC_PYTHON}->[0]; - } elsif (ref($request->{environment}) eq 'ARRAY') { - $::OPENBMC_PYTHON = $request->{environment}->[0]->{XCAT_OPENBMC_PYTHON}; - } else { - $::OPENBMC_PYTHON = $request->{environment}->{XCAT_OPENBMC_PYTHON}; - } - - if (! (defined($::OPENBMC_PYTHON) and $::OPENBMC_PYTHON eq "YES")) { + if (!xCAT::OPENBMC->is_openbmc_python($request->{environment})) { $request = {}; return; } @@ -119,6 +110,7 @@ sub process_request { my $noderange = $request->{node}; my $check = parse_node_info($noderange); $callback->({ errorcode => [$check] }) if ($check); + return unless(%node_info); my $pid = xCAT::OPENBMC::start_python_agent(); if (!defined($pid)) { xCAT::MsgUtils->message("E", { data => ["Failed to start python agent"] }, $callback); @@ -186,6 +178,7 @@ sub parse_node_info { } unless($node_info{$node}{bmc}) { xCAT::SvrUtils::sendmsg("Error: Unable to get attribute bmc", $callback, $node); + delete $node_info{$node}; $rst = 1; next; } From 66c190d6123c556a49db178adc1210e26241d2b5 Mon Sep 17 00:00:00 2001 From: GONG Jie Date: Wed, 17 Jan 2018 13:52:32 +0800 Subject: [PATCH 65/93] Add dependency for xcat-genesis-base on Debian/Ubuntu --- xCAT-genesis-builder/debuild-xcat-genesis-base | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xCAT-genesis-builder/debuild-xcat-genesis-base b/xCAT-genesis-builder/debuild-xcat-genesis-base index 2dc9e9066..d6e029345 100755 --- a/xCAT-genesis-builder/debuild-xcat-genesis-base +++ b/xCAT-genesis-builder/debuild-xcat-genesis-base @@ -37,6 +37,8 @@ then sed -i -e 's/x86-64/amd64/g' "${EXTRACT_DIR}/debian/changelog" fi +sed -i -e "/^Description:/i Breaks: xcat-genesis-scripts-${PACKAGE_ARCH//x86_64/amd64} (<< 2.13.10)" "${EXTRACT_DIR}/debian/control" + cat >"${EXTRACT_DIR}/debian/preinst" <<-EOF #!/bin/bash From 0ce225b33932b2b3652a182ffec2efaa6ff42d69 Mon Sep 17 00:00:00 2001 From: GONG Jie Date: Wed, 17 Jan 2018 13:54:12 +0800 Subject: [PATCH 66/93] Update dependency for xCAT-genesis-base on Red Hat --- xCAT-genesis-builder/xCAT-genesis-base.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-genesis-builder/xCAT-genesis-base.spec b/xCAT-genesis-builder/xCAT-genesis-base.spec index 1b9cb3e46..76bd5644b 100644 --- a/xCAT-genesis-builder/xCAT-genesis-base.spec +++ b/xCAT-genesis-builder/xCAT-genesis-base.spec @@ -29,7 +29,7 @@ Vendor: IBM Corp. Summary: xCAT Genesis netboot image URL: https://xcat.org/ Source1: xCAT-genesis-base-%{tarch}.tar.bz2 -Conflicts: xCAT-genesis-scripts-%{tarch} < 1:2.13.9 +Conflicts: xCAT-genesis-scripts-%{tarch} < 1:2.13.10 Buildroot: %{_localstatedir}/tmp/xCAT-genesis BuildRequires: /usr/sbin/ntp-wait From 3461396e9ca27da8783371f157a8d304b3334dbe Mon Sep 17 00:00:00 2001 From: GONG Jie Date: Wed, 17 Jan 2018 14:02:54 +0800 Subject: [PATCH 67/93] Fix permission in xCAT-genesis-builder.spec --- xCAT-genesis-builder/xCAT-genesis-builder.spec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xCAT-genesis-builder/xCAT-genesis-builder.spec b/xCAT-genesis-builder/xCAT-genesis-builder.spec index 8321f99e6..3a9b428a1 100644 --- a/xCAT-genesis-builder/xCAT-genesis-builder.spec +++ b/xCAT-genesis-builder/xCAT-genesis-builder.spec @@ -33,8 +33,8 @@ rm -rf $RPM_BUILD_ROOT mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/xcat/netboot/genesis/builder cd $RPM_BUILD_ROOT/%{prefix}/share/xcat/netboot/genesis/builder tar jxvf %{SOURCE1} -chmod +x $RPM_BUILD_ROOT/%{prefix}/share/xcat/netboot/genesis/builder/buildrpm -chmod +x $RPM_BUILD_ROOT/%{prefix}/share/xcat/netboot/genesis/builder/debuild-xcat-genesis-base +chmod 0755 $RPM_BUILD_ROOT/%{prefix}/share/xcat/netboot/genesis/builder/buildrpm +chmod 0755 $RPM_BUILD_ROOT/%{prefix}/share/xcat/netboot/genesis/builder/debuild-xcat-genesis-base cd - From a2d2ed1d344cc2837ce6789e835c30f6939aba2d Mon Sep 17 00:00:00 2001 From: ertaozh Date: Wed, 17 Jan 2018 03:36:40 -0500 Subject: [PATCH 68/93] From 2.13.10, the genesis scripts is moved to usr/bin or usr/sbin --- xCAT-genesis-scripts/debian/control-amd64 | 2 +- xCAT-genesis-scripts/debian/control-ppc64el | 2 +- xCAT-genesis-scripts/xCAT-genesis-scripts.spec | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/xCAT-genesis-scripts/debian/control-amd64 b/xCAT-genesis-scripts/debian/control-amd64 index 01223cc6f..38992a3c9 100644 --- a/xCAT-genesis-scripts/debian/control-amd64 +++ b/xCAT-genesis-scripts/debian/control-amd64 @@ -7,7 +7,7 @@ Standards-Version: 3.9.4 Package: xcat-genesis-scripts-amd64 Architecture: all -Depends: xcat-genesis-base-amd64 (>=2.13.2) +Depends: xcat-genesis-base-amd64 (>= 2.13.10) Conflicts: xcat-genesis-scripts, xcat-genesis-scripts-x86-64 Replaces: xcat-genesis-scripts, xcat-genesis-scripts-x86-64 Description: xCAT genesis diff --git a/xCAT-genesis-scripts/debian/control-ppc64el b/xCAT-genesis-scripts/debian/control-ppc64el index af9ad5ed8..53200fc05 100644 --- a/xCAT-genesis-scripts/debian/control-ppc64el +++ b/xCAT-genesis-scripts/debian/control-ppc64el @@ -7,7 +7,7 @@ Standards-Version: 3.9.4 Package: xcat-genesis-scripts-ppc64 Architecture: all -Depends: xcat-genesis-base-ppc64 (>=2.13.2) +Depends: xcat-genesis-base-ppc64 (>= 2.13.10) Conflicts: xcat-genesis-scripts Replaces: xcat-genesis-scripts Description: xCAT genesis diff --git a/xCAT-genesis-scripts/xCAT-genesis-scripts.spec b/xCAT-genesis-scripts/xCAT-genesis-scripts.spec index 4fb917727..bab373378 100755 --- a/xCAT-genesis-scripts/xCAT-genesis-scripts.spec +++ b/xCAT-genesis-scripts/xCAT-genesis-scripts.spec @@ -29,7 +29,7 @@ Vendor: IBM Corp. Summary: xCAT Genesis netboot image - Core content URL: https://xcat.org/ Source1: xCAT-genesis-scripts.tar.bz2 -Requires: xCAT-genesis-base-%{tarch} >= 2:2.13.2 +Requires: xCAT-genesis-base-%{tarch} >= 2:2.13.10 Buildroot: %{_localstatedir}/tmp/xCAT-genesis Packager: IBM Corp. From 1f069848685411be2026f1ddc21c9d9afbd0918b Mon Sep 17 00:00:00 2001 From: Casandra Qiu Date: Wed, 17 Jan 2018 21:06:48 -0500 Subject: [PATCH 69/93] types of PDUs --- docs/source/advanced/pdu/crpdu.rst | 2 +- docs/source/advanced/pdu/index.rst | 4 +++- docs/source/advanced/pdu/irpdu.rst | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/source/advanced/pdu/crpdu.rst b/docs/source/advanced/pdu/crpdu.rst index e527c0169..9933a80bc 100644 --- a/docs/source/advanced/pdu/crpdu.rst +++ b/docs/source/advanced/pdu/crpdu.rst @@ -1,7 +1,7 @@ Collaborative PDU ================= -Collaborative PDU is also referred as Coral PDU, it controls power for compute Rack. +Collaborative PDU is also referred as Coral PDU, it controls power for compute Rack. User can access PDU via SSH and can use the **PduManager** command to configure and manage the PDU product. Pre-Defined PDU Objects diff --git a/docs/source/advanced/pdu/index.rst b/docs/source/advanced/pdu/index.rst index 42b371ae7..625bfb269 100644 --- a/docs/source/advanced/pdu/index.rst +++ b/docs/source/advanced/pdu/index.rst @@ -1,7 +1,9 @@ PDUs ==== -Power Distribution Units (PDUs) are devices that distribute power to servers in a frame. They have the capability of monitoring the amount of power that is being used by devices plugged into it and cycle power to individual receptacles. xCAT can support two kinds of PDUs, infrastructure PDU (irpdu) and collaborative PDU (crpdu). These two types of PDU have different design and implementation. xCAT has different code path to maintains PDU commands via **pdutype**. +Power Distribution Units (PDUs) are devices that distribute power to servers in a frame. They have the capability of monitoring the amount of power that is being used by devices plugged into it and cycle power to individual receptacles. xCAT can support two kinds of PDUs, infrastructure PDU (irpdu) and collaborative PDU (crpdu). + +The Infrastructure rack PDUs are switched and monitored 1U PDU products which can connect up to nine C19 devices or up to 12 C13 devices and an additional three C13 peripheral devices to a signle dedicated power source. The Collaborative PDU is on the compute rack and has the 6x IEC 320-C13 receptacles that feed the rack switches. These two types of PDU have different design and implementation. xCAT has different code path to maintains PDU commands via **pdutype**. .. toctree:: diff --git a/docs/source/advanced/pdu/irpdu.rst b/docs/source/advanced/pdu/irpdu.rst index b35193b50..c7a557ed7 100644 --- a/docs/source/advanced/pdu/irpdu.rst +++ b/docs/source/advanced/pdu/irpdu.rst @@ -1,6 +1,8 @@ Infrastructure PDU ================== +Users can access Infrastructure PDU via telnet and use the **IBM PDU Configuration Utility** to set up and configure the PDU. xCAT supports PDU commands for power management and monitoring through SNMP. + PDU Commands ------------ From 179b1cdf6c9a642eafc2d53e3f9b92d7fb559ecb Mon Sep 17 00:00:00 2001 From: zet809 Date: Thu, 18 Jan 2018 13:48:13 +0800 Subject: [PATCH 70/93] modify directory to copy bmcsetup/getipmi scripts (#4649) --- build-ubunturepo | 2 +- makerpm | 2 +- xCAT-genesis-scripts/debian/rules | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/build-ubunturepo b/build-ubunturepo index 729067680..2f9457727 100755 --- a/build-ubunturepo +++ b/build-ubunturepo @@ -250,7 +250,7 @@ then # shipping bmcsetup and getipmi scripts as part of postscripts files=("bmcsetup" "getipmi") for f in "${files[@]}"; do - cp ${CURDIR}/../xCAT-genesis-scripts/bin/$f ${CURDIR}/postscripts/$f + cp ${CURDIR}/../xCAT-genesis-scripts/usr/bin/$f ${CURDIR}/postscripts/$f sed -i "s/xcat.genesis.$f/$f/g" ${CURDIR}/postscripts/$f done fi diff --git a/makerpm b/makerpm index b093e116d..1e874662f 100755 --- a/makerpm +++ b/makerpm @@ -126,7 +126,7 @@ function makexcat { # shipping bmcsetup and getipmi scripts as part of postscripts files=("bmcsetup" "getipmi") for f in "${files[@]}"; do - cp "xCAT-genesis-scripts/bin/"$f ${RPMNAME}/postscripts/$f + cp "xCAT-genesis-scripts/usr/bin/"$f ${RPMNAME}/postscripts/$f sed -i "s/xcat.genesis.$f/$f/g" ${RPMNAME}/postscripts/$f done cd `dirname $0`/$RPMNAME diff --git a/xCAT-genesis-scripts/debian/rules b/xCAT-genesis-scripts/debian/rules index 6da840833..16d3fc804 100755 --- a/xCAT-genesis-scripts/debian/rules +++ b/xCAT-genesis-scripts/debian/rules @@ -33,8 +33,7 @@ install: dh_installdirs $(installdir) dh_install -X".svn" dh_install ./etc/ $(installtodir) - dh_install ./usr/bin/ $(installtodir) - dh_install ./usr/sbin/ $(installtodir) + dh_install ./usr/ $(installtodir) dh_compress dh_installdeb dh_gencontrol From df3eb6c4f48b9dd7ddc911e50065ea6df533ae11 Mon Sep 17 00:00:00 2001 From: bybai Date: Thu, 18 Jan 2018 01:44:29 -0500 Subject: [PATCH 71/93] change empty_zones_enable in named.conf --- perl-xCAT/xCAT/Schema.pm | 1 + xCAT-server/lib/xcat/plugins/ddns.pm | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/perl-xCAT/xCAT/Schema.pm b/perl-xCAT/xCAT/Schema.pm index 02760f105..42b309c6e 100755 --- a/perl-xCAT/xCAT/Schema.pm +++ b/perl-xCAT/xCAT/Schema.pm @@ -1057,6 +1057,7 @@ passed as argument rather than by table value', " requests it does not know to these servers. Note that the DNS servers on the\n" . " service nodes will ignore this value and always be configured to forward \n" . " to the management node.\n\n" . +" emptyzonesenable: (yes or no). This is to set empty-zones-enable value in named.conf options section. The default is yes. \n\n" " master: The hostname of the xCAT management node, as known by the nodes.\n\n" . " nameservers: A comma delimited list of DNS servers that each node in the cluster should\n" . " use. This value will end up in the nameserver settings of the\n" . diff --git a/xCAT-server/lib/xcat/plugins/ddns.pm b/xCAT-server/lib/xcat/plugins/ddns.pm index 026e55bd8..f59fb1f04 100644 --- a/xCAT-server/lib/xcat/plugins/ddns.pm +++ b/xCAT-server/lib/xcat/plugins/ddns.pm @@ -587,6 +587,11 @@ sub process_request { $ctx->{forwarders} = \@forwarders; } + my @options = xCAT::TableUtils->get_site_attribute("emptyzonesenable"); + my $empty_zones = $options[0]; + if (defined($empty_zones) and $empty_zones =~ /^yes$|^no$/) { + $ctx->{empty_zones_enable} = $empty_zones; + } my @slave_ips; my $dns_slaves = get_dns_slave(); if (scalar @$dns_slaves) { @@ -1098,6 +1103,9 @@ sub update_namedconf { push @newnamed, "\t\t" . $_ . ";\n"; } push @newnamed, "\t};\n"; + } elsif ($ctx->{empty_zones_enable} and $line =~ /empty-zones-enable/) { + push @newnamed, "\tempty-zones-enable " . $_ . ";\n"; + $skip = 1; } elsif ($ctx->{slaves} and $line =~ /allow-transfer \{/) { push @newnamed, "\tallow-transfer \{\n"; $skip = 1; @@ -1237,6 +1245,10 @@ sub update_namedconf { push @newnamed, "\t};\n"; } + if ($ctx->{empty_zones_enable}){ + push @newnamed, "\tempty-zones-enable " . $ctx->{empty_zones_enable} . ";\n"; + } + if ($slave) { push @newnamed, "\tallow-transfer { any; };\n"; } else { From fe63484909afb7d7e49cb2c9335ba62bb08fd910 Mon Sep 17 00:00:00 2001 From: XuWei Date: Wed, 17 Jan 2018 00:51:06 -0500 Subject: [PATCH 72/93] rflash for openbmc on python, including options a|c|l|delete|u --- .../lib/python/agent/xcatagent/openbmc.py | 662 ++++++++++++++++-- .../lib/python/agent/xcatagent/rest.py | 121 +++- .../lib/python/agent/xcatagent/utils.py | 8 + .../python/agent/xcatagent/xcat_exception.py | 4 +- xCAT-server/lib/xcat/plugins/openbmc2.pm | 53 +- 5 files changed, 760 insertions(+), 88 deletions(-) diff --git a/xCAT-openbmc-py/lib/python/agent/xcatagent/openbmc.py b/xCAT-openbmc-py/lib/python/agent/xcatagent/openbmc.py index 1276bc85b..d8be9aea4 100644 --- a/xCAT-openbmc-py/lib/python/agent/xcatagent/openbmc.py +++ b/xCAT-openbmc-py/lib/python/agent/xcatagent/openbmc.py @@ -1,8 +1,10 @@ from xcatagent import base +import os import time import sys import gevent +import utils import xcat_exception import rest @@ -10,9 +12,52 @@ HTTP_PROTOCOL = "https://" PROJECT_URL = "/xyz/openbmc_project" RESULT_OK = 'ok' +RESULT_FAIL = 'fail' DEBUGMODE = False +VERBOSE = False +ALL_NODES_RESULT = {} + +# global variables of rflash +RFLASH_OPTIONS = { + "-a" : "activate", + "--activate" : "activate", + "-c" : "check", + "--check" : "check", + "-d" : "direcory", + "--delete" : "delete", + "-l" : "list", + "--list" : "list", + "-u" : "upload", + "--upload" : "upload", +} + +RFLASH_URLS = { + "activate" : { + "url" : PROJECT_URL + "/software/#ACTIVATE_ID#/attr/RequestedActivation", + "field" : "xyz.openbmc_project.Software.Activation.RequestedActivations.Active", + }, + "delete" : { + "url" : PROJECT_URL + "/software/#DELETE_ID#/action/Delete", + "field" : [], + }, + "upload" : { + "url" : "/upload/image/", + }, + "priority" : { + "url" : PROJECT_URL + "/software/#PRIORITY_ID#/attr/Priority", + "field" : "false", + } +} + +XCAT_LOG_DIR = "/var/log/xcat" +XCAT_LOG_RFLASH_DIR = XCAT_LOG_DIR + "/rflash/" + +# global variable of firmware information +FIRM_URL = PROJECT_URL + "/software/enumerate" + +# global variables of rpower POWER_SET_OPTIONS = ('on', 'off', 'bmcreboot', 'softoff') POWER_GET_OPTIONS = ('bmcstate', 'state', 'stat', 'status') @@ -68,12 +113,13 @@ class OpenBMC(base.BaseDriver): def __init__(self, messager, name, node_info): super(OpenBMC, self).__init__(messager) self.node = name - for key, value in node_info.items() : + for key, value in node_info.items(): setattr(self, key, value) global DEBUGMODE self.client = rest.RestSession(messager, DEBUGMODE) + self.rflash_log_file = XCAT_LOG_RFLASH_DIR + '/' + self.node + '.log' - def _login(self) : + def _login(self): """ Login :raise: error message if failed """ @@ -82,7 +128,363 @@ class OpenBMC(base.BaseDriver): self.client.request('POST', url, OpenBMC.headers, data, self.node, 'login') return RESULT_OK - def _set_power_onoff(self, subcommand) : + def _msg_process_rflash (self, msg, update_dict, checkv): + """deal with msg during rflash + :param msg: the msg want to process + """ + if not checkv: + self.messager.info('%s: %s' % (self.node, msg)) + elif VERBOSE: + self.messager.info('%s: %s' % (self.node, msg)) + self.rflash_log_handle.writelines(msg + '\n') + self.rflash_log_handle.flush() + if update_dict: + utils.update2Ddict(update_dict, self.node, 'rst', [msg]) + + def _firm_info(self, status): + """List firmware information including additional + called by rflash check and rinv firm + :returns: firmware information + """ + firm_output = [] + try: + (has_functional, firm_info) = self._get_firm_info(status) + except (xcat_exception.SelfServerException, + xcat_exception.SelfClientException) as e: + firm_output.append(e.message) + return firm_output + + keys = firm_info.keys() + keys.sort() + for key in keys: + flag = '' + if 'is_functional' in firm_info[key]: + flag = '*' + elif 'Priority' in firm_info[key] and + firm_info[key]['Priority'] == '0': + if not has_functional: + flag = '*' + else: + flag = '+' + + if not flag and not VERBOSE: + continue + + firm_output.append('%s Firmware Product: %s (%s)%s' % + (firm_info[key]['Purpose'], + firm_info[key]['Version'], + firm_info[key]['Activation'], flag)) + if 'ExtendedVersion' in firm_info[key]: + extendeds = firm_info[key]['ExtendedVersion'].split(',') + extendeds.sort() + for extended in extendeds: + firm_output.append('%s Firmware Product: ' \ + '-- additional info: %s' % \ + (firm_info[key]['Purpose'], extended)) + + return firm_output + + def _get_firm_info(self, status): + """get firmware information + :param status: current status + :returns: firmware version information + """ + firm_info = {} + has_functional = False + url = HTTP_PROTOCOL + self.bmcip + FIRM_URL + response = self.client.request('GET', url, OpenBMC.headers, '', self.node, status) + functional_url = PROJECT_URL + '/software/functional' + + for key in response['data']: + key_id = key.split('/')[-1] + if key_id == 'functional': + for endpoint in response['data'][key]['endpoints']: + purpose = response['data'][endpoint]['Purpose'].split('.')[-1] + key_sort = purpose + '-' + endpoint.split('/')[-1] + + utils.update2Ddict(firm_info, key_sort, 'is_functional', True) + has_functional = True + + if 'Version' in response['data'][key]: + purpose = response['data'][key]['Purpose'].split('.')[-1] + key_sort = purpose + '-' + key_id + if functional_url in response['data'] and + key in response['data'][functional_url]['endpoints']: + utils.update2Ddict(firm_info, key_sort, 'is_functional', True) + utils.update2Ddict(firm_info, key_sort, 'Version', + response['data'][key]['Version']) + utils.update2Ddict(firm_info, key_sort, 'Purpose', purpose) + utils.update2Ddict(firm_info, key_sort, 'Activation', + response['data'][key]['Activation'].split('.')[-1]) + if 'Priority' in response['data'][key]: + utils.update2Ddict(firm_info, key_sort, 'Priority', + str(response['data'][key]['Priority'])) + if 'ExtendedVersion' in response['data'][key]: + utils.update2Ddict(firm_info, key_sort, 'ExtendedVersion', + response['data'][key]['ExtendedVersion']) + if 'Progress' in response['data'][key]: + utils.update2Ddict(firm_info, key_sort, 'Progress', + response['data'][key]['Progress']) + + return (has_functional, firm_info) + + def _get_firm_id(self, firm_list): + """get firmware id + :param firm_list: the list of firmware versions + :return: result and info list + """ + firm_ids = [] + url = HTTP_PROTOCOL + self.bmcip + FIRM_URL + + for i in range(6): + try: + response = self.client.request('GET', url, OpenBMC.headers, + '', self.node, 'rflash_check_id') + except (xcat_exception.SelfServerException, + xcat_exception.SelfClientException) as e: + self._msg_process_rflash(e.message, ALL_NODES_RESULT, False) + return (RESULT_FAIL, []) + + for key in response['data']: + if 'Version' in response['data'][key]: + if response['data'][key]['Version'] in firm_list: + firm_id = key.split('/')[-1] + upload_msg = 'Firmware upload successful. ' \ + 'Attempting to activate firmware: ' \ + '%s (ID: %s)' % \ + (response['data'][key]['Version'], firm_id) + self._msg_process_rflash(upload_msg, {}, False) + firm_ids.append(firm_id) + firm_list.remove(response['data'][key]['Version']) + + if firm_list: + for firm_ver in firm_list: + retry_msg = 'Could not find ID for firmware %s to '\ + 'activate, waiting %d seconds and retry...' \ + % (firm_ver, 10) + self._msg_process_rflash(upload_msg, {}, True) + gevent.sleep( 10 ) + else: + break + + if firm_list: + for firm_ver in firm_list: + error = 'Could not find firmware %s after waiting %d seconds.' \ + % (firm_ver, 10*6) + self._msg_process_rflash(upload_msg, {}, False) + error_list.append(error) + utils.update2Ddict(ALL_NODES_RESULT, self.node, 'rst', error_list) + return (RESULT_FAIL, []) + + return (RESULT_OK, firm_ids) + + def _check_id_status(self, firm_id_list): + """check firm id status + :param firm_id_list: list of firm ids want to check + :return: result + """ + result = RESULT_OK + set_priority_ids = [] + process_status = {} + for i in range(80): + try: + (has_functional, firm_info) = self._get_firm_info('rflash_check_status') + except (xcat_exception.SelfServerException, + xcat_exception.SelfClientException) as e: + self._msg_process_rflash(e.message, ALL_NODES_RESULT, False) + return (RESULT_FAIL, set_priority_ids) + + activation_num = 0 + for key in firm_info: + firm_id = key.split('-')[-1] + if firm_id in firm_id_list: + activation_state = firm_info[key]['Activation'] + firm_version = firm_info[key]['Version'] + if activation_state == 'Failed': + activation_msg = 'Firmware %s activation failed.' % (firm_version) + self._msg_process_rflash(activation_msg, {}, False) + result = RESULT_FAIL + firm_id_list.rempove(firm_id) + if activation_state == 'Active': + activation_msg = 'Firmware %s activation successful.' % (firm_version) + self._msg_process_rflash(activation_msg, {}, False) + firm_id_list.remove(firm_id) + priority = firm_info[key]['Priority'] + if priority != '0': + set_priority_ids.append(firm_id) + if activation_state == 'Activating': + activating_progress_msg = 'Activating %s ... %s%%' \ + % (firm_version, firm_info[key]['Progress']) + self._msg_process_rflash(activating_progress_msg, {}, True) + process_status[firm_id] = activating_progress_msg + + if not firm_id_list: + break + gevent.sleep( 15 ) + + if firm_id_list: + result = RESULT_FAIL + for firm_id in firm_id_list: + if firm_id in process_status: + warn_msg = 'After %d seconds check the current status is %s' \ + % (80*15, process_status[firm_id]) + self._msg_process_rflash(warn_msg, ALL_NODES_RESULT, False) + + return (result, set_priority_ids) + + def _set_priority(self, priority_ids): + """set firmware priority to 0 + :param priority_ids: list of firmware ids + :return ok if success + :return error msg if failed + """ + for priority_id in priority_ids: + url = HTTP_PROTOCOL + self.bmcip + + RFLASH_URLS['priority']['url'].replace('#PRIORITY_ID#', priority_id) + data = { "data": RFLASH_URLS['priority']['field'] } + try: + response = self.client.request('PUT', url, OpenBMC.headers, + data, self.node, 'rflash_set_priority') + except (xcat_exception.SelfServerException, + xcat_exception.SelfClientException) as e: + return e.message + + return RESULT_OK + + def _rflash_activate_id(self, activate_id): + """rflash activate id + :param activate_id: the id want to activate + :raise: error message if failed + """ + url = HTTP_PROTOCOL + self.bmcip + + RFLASH_URLS['activate']['url'].replace('#ACTIVATE_ID#', activate_id) + data = { "data": RFLASH_URLS['activate']['field'] } + try: + response = self.client.request('PUT', url, OpenBMC.headers, + data, self.node, 'rflash_activate') + except xcat_exception.SelfServerException as e: + return e.message + except xcat_exception.SelfClientException as e: + code = e.code + if code == 403: + return 'Error: Invalid ID provided to activate. ' \ + 'Use the -l option to view valid firmware IDs.' + return e.message + + return RESULT_OK + + def _rflash_activate(self, activate_arg): + """ACTIVATE firmware + called by rflash activate + :param activate_arg: firmware tar ball or firmware id + :return: ok if success + :raise: error message if failed + """ + activate_id = activate_version = '' + if 'activate_id' in activate_arg: + activate_id = activate_arg['activate_id'] + if 'activate_version' in activate_arg: + activate_version = activate_arg['activate_version'] + if 'update_file' in activate_arg: + result = self._rflash_upload(activate_arg['update_file']) + if result != RESULT_OK: + self._msg_process_rflash(result, ALL_NODES_RESULT, False) + + (result, info) = self._get_firm_id([activate_version]) + if result == RESULT_OK: + activate_id = info.pop(0) + + result = self._rflash_activate_id(activate_id) + if result != RESULT_OK: + self._msg_process_rflash(result, ALL_NODES_RESULT, False) + return + else: + flash_started_msg = 'rflash %s started, please wait...' % activate_version + self._msg_process_rflash(flash_started_msg, {}, False) + + firm_id_list = [activate_id] + (result, priority_ids) = self._check_id_status(firm_id_list) + if result == RESULT_OK: + utils.update2Ddict(ALL_NODES_RESULT, self.node, 'rst', 'OK') + if priority_ids: + self._set_priority(priority_ids) + + def _rflash_delete(self, delete_id): + """Delete firmware on OpenBMC + called by rflash delete + :param delete_id: firmware id want to delete + :returns: ok if success + :raise: error message if failed + """ + url = HTTP_PROTOCOL + self.bmcip + + RFLASH_URLS['delete']['url'].replace('#DELETE_ID#', delete_id) + data = { "data": RFLASH_URLS['delete']['field'] } + try: + response = self.client.request('POST', url, OpenBMC.headers, + data, self.node, 'rflash_delete') + except xcat_exception.SelfServerException as e: + return e.message + except xcat_exception.SelfClientException as e: + code = e.code + if code == 404: + return 'Error: Invalid ID provided to delete. ' \ + 'Use the -l option to view valid firmware IDs.' + return e.message + + return RESULT_OK + + + def _rflash_list(self): + """List firmware information + called by rflash list + :returns: firmware version if success + :raise: error message if failed + """ + firm_output = [] + try: + (has_functional, firm_info) = self._get_firm_info('rflash_list') + except (xcat_exception.SelfServerException, + xcat_exception.SelfClientException) as e: + firm_output.append(e.message) + return firm_output + + firm_output.append('%-8s %-7s %-10s %-s' % ('ID', 'Purpose', 'State', 'Version')) + firm_output.append('-' * 55) + + for key in firm_info: + status = firm_info[key]['Activation'] + if 'is_functional' in firm_info[key]: + status += '(*)' + elif 'Priority' in firm_info[key] and firm_info[key]['Priority'] == '0': + if not has_functional: + status += '(*)' + else: + status += '(+)' + + firm_output.append('%-8s %-7s %-10s %-s' % (key.split('-')[-1], + firm_info[key]['Purpose'], status, firm_info[key]['Version'])) + + return firm_output + + def _rflash_upload(self, upload_file): + """ Upload *.tar file to OpenBMC server + :param upload_file: file to upload + """ + url = HTTP_PROTOCOL + self.bmcip + RFLASH_URLS['upload']['url'] + headers = {'Content-Type': 'application/octet-stream'} + uploading_msg = 'Uploading %s ...' % upload_file + self._msg_process_rflash(uploading_msg, {}, True) + try: + self.client.request_upload_curl('PUT', url, headers, upload_file, + self.node, 'rflash_upload') + except (xcat_exception.SelfServerException, + xcat_exception.SelfClientException) as e: + result = e.message + return result + + return RESULT_OK + + def _set_power_onoff(self, subcommand): """ Set power on/off/softoff/bmcreboot :param subcommand: subcommand for rpower :returns: ok if success @@ -90,17 +492,19 @@ class OpenBMC(base.BaseDriver): """ url = HTTP_PROTOCOL + self.bmcip + RPOWER_URLS[subcommand]['url'] data = { "data": RPOWER_URLS[subcommand]['field'] } - try : - response = self.client.request('PUT', url, OpenBMC.headers, data, self.node, 'rpower_' + subcommand) + try: + response = self.client.request('PUT', url, OpenBMC.headers, data, + self.node, 'rpower_' + subcommand) except (xcat_exception.SelfServerException, - xcat_exception.SelfClientException) as e : + xcat_exception.SelfClientException) as e: if subcommand != 'bmcreboot': result = e.message return result return RESULT_OK - def _get_power_state(self, subcommand) : + + def _get_power_state(self, subcommand): """ Get power current state :param subcommand: state/stat/status/bmcstate :returns: current state if success @@ -109,61 +513,62 @@ class OpenBMC(base.BaseDriver): result = '' bmc_not_ready = 'NotReady' url = HTTP_PROTOCOL + self.bmcip + RPOWER_URLS['state']['url'] - try : - response = self.client.request('GET', url, OpenBMC.headers, '', self.node, 'rpower_' + subcommand) - except xcat_exception.SelfServerException, e : + try: + response = self.client.request('GET', url, OpenBMC.headers, '', + self.node, 'rpower_' + subcommand) + except xcat_exception.SelfServerException, e: if subcommand == 'bmcstate': result = bmc_not_ready - else : + else: result = e.message - except xcat_exception.SelfClientException, e : + except xcat_exception.SelfClientException, e: result = e.message - if result : + if result: return result - for key in response['data'] : + for key in response['data']: key_type = key.split('/')[-1] - if key_type == 'bmc0' : + if key_type == 'bmc0': bmc_current_state = response['data'][key]['CurrentBMCState'].split('.')[-1] - if key_type == 'chassis0' : + if key_type == 'chassis0': chassis_current_state = response['data'][key]['CurrentPowerState'].split('.')[-1] - if key_type == 'host0' : + if key_type == 'host0': host_current_state = response['data'][key]['CurrentHostState'].split('.')[-1] - if subcommand == 'bmcstate' : - if bmc_current_state == 'Ready' : + if subcommand == 'bmcstate': + if bmc_current_state == 'Ready': return bmc_current_state - else : + else: return bmc_not_ready - if chassis_current_state == 'Off' : + if chassis_current_state == 'Off': return chassis_current_state - elif chassis_current_state == 'On' : - if host_current_state == 'Off' : + elif chassis_current_state == 'On': + if host_current_state == 'Off': return 'chassison' - elif host_current_state == 'Quiesced' : + elif host_current_state == 'Quiesced': return host_current_state - elif host_current_state == 'Running' : + elif host_current_state == 'Running': return host_current_state - else : + else: return 'Unexpected chassis state=' + host_current_state - else : + else: return 'Unexpected chassis state=' + chassis_current_state - def _rpower_boot(self) : + def _rpower_boot(self): """Power boot :returns: 'reset' if success :raise: error message if failed """ result = self._set_power_onoff('off') - if result != RESULT_OK : + if result != RESULT_OK: return result self.messager.update_node_attributes('status', self.node, POWER_STATE_DB['off']) start_timeStamp = int(time.time()) - for i in range (0,30) : + for i in range (0,30): status = self._get_power_state('state') if status in RPOWER_STATE and RPOWER_STATE[status] == 'off': break @@ -173,64 +578,126 @@ class OpenBMC(base.BaseDriver): if status not in RPOWER_STATE or RPOWER_STATE[status] != 'off': wait_time = str(end_timeStamp - start_timeStamp) - result = 'Error: Sent power-off command but state did not change to off after waiting ' + wait_time + ' seconds. (State=' + status + ').' + result = 'Error: Sent power-off command but state did not change ' \ + 'to off after waiting %s seconds. (State= %s).' % (wait_time, status) return result result = self._set_power_onoff('on') return result + def rflash(self, args): + """handle rflash command + :param args: subcommands and parameters for rflash + """ + subcommand = args[0] + if subcommand == 'activate' or subcommand == 'upload': + self.rflash_log_handle = open(self.rflash_log_file, 'a') - def rpower(self, args) : + try: + result = self._login() + except (xcat_exception.SelfServerException, + xcat_exception.SelfClientException) as e: + result = e.message + + if result != RESULT_OK: + self.messager.info('%s: %s'% (self.node,result)) + if subcommand == 'activate' or subcommand == 'upload': + self.rflash_log_handle.writelines(result + '\n') + self.rflash_log_handle.flush() + if subcommand == 'activate': + utils.update2Ddict(ALL_NODES_RESULT, self.node, 'rst', error_list) + return + + if subcommand == 'activate': + activate_arg = args[1] + self._rflash_activate(activate_arg) + + if subcommand == 'check': + firm_info = self._firm_info('rflash_check') + for i in firm_info: + result = '%s: %s' % (self.node, i) + self.messager.info(result) + + if subcommand == 'delete': + firmware_id = args[1] + result = self._rflash_delete(firmware_id) + if result == RESULT_OK: + result = '%s: [%s] Firmware removed' % (self.node, firmware_id) + self.messager.info(result) + else: + result = '%s: %s' % (self.node, result) + self.messager.info(result) + + if subcommand == 'list': + firm_info = self._rflash_list() + for i in firm_info: + result = '%s: %s' % (self.node, i) + self.messager.info(result) + + if subcommand == 'upload': + upload_file = args[1] + result = self._rflash_upload(upload_file) + if result == RESULT_OK: + result = 'Firmware upload successful. Use -l option to list.' + self._msg_process_rflash(result, {}, False) + else: + self._msg_process_rflash(result, {}, False) + + if subcommand == 'activate' or subcommand == 'upload': + self.rflash_log_handle.close() + + + def rpower(self, args): """handle rpower command :param args: subcommands for rpower """ subcommand = args[0] - try : + try: result = self._login() - except xcat_exception.SelfServerException as e : - if subcommand == 'bmcstate' : + except xcat_exception.SelfServerException as e: + if subcommand == 'bmcstate': result = '%s: %s' % (self.node, RPOWER_STATE['NotReady']) - else : + else: result = '%s: %s' % (self.node, e.message) - except xcat_exception.SelfClientException as e : + except xcat_exception.SelfClientException as e: result = '%s: %s' % (self.node, e.message) - if result != RESULT_OK : + if result != RESULT_OK: self.messager.info(result) - self._update2Ddict(node_rst, self.node, 'rst', result) return - new_status = '' - if subcommand in POWER_SET_OPTIONS : + + if subcommand in POWER_SET_OPTIONS: result = self._set_power_onoff(subcommand) - if result == RESULT_OK : + if result == RESULT_OK: result = RPOWER_STATE[subcommand] new_status = POWER_STATE_DB.get(subcommand, '') - if subcommand in POWER_GET_OPTIONS : + if subcommand in POWER_GET_OPTIONS: tmp_result = self._get_power_state(subcommand) result = RPOWER_STATE.get(tmp_result, tmp_result) - if subcommand == 'boot' : + if subcommand == 'boot': result = self._rpower_boot() - if result == RESULT_OK : + if result == RESULT_OK: result = RPOWER_STATE[subcommand] new_status = POWER_STATE_DB.get(subcommand, '') - if subcommand == 'reset' : + if subcommand == 'reset': status = self._get_power_state('state') if status == 'Off' or status == 'chassison': result = RPOWER_STATE['Off'] - else : + else: result = self._rpower_boot() - if result == RESULT_OK : + if result == RESULT_OK: result = RPOWER_STATE[subcommand] new_status = POWER_STATE_DB.get(subcommand, '') message = '%s: %s' % (self.node, result) self.messager.info(message) - if new_status : + if new_status: self.messager.update_node_attributes('status', self.node, new_status) + class OpenBMCManager(base.BaseManager): def __init__(self, messager, cwd, nodes, envs): super(OpenBMCManager, self).__init__(messager, cwd) @@ -238,5 +705,100 @@ class OpenBMCManager(base.BaseManager): global DEBUGMODE DEBUGMODE = envs['debugmode'] + def _get_full_path(self,file_path): + if type(self.cwd) == 'unicode': + dir_path = self.cwd + else: + dir_path = self.cwd[0] + return '%s/%s' % (dir_path,file_path) + + def _check_verbose(self, args): + verbose_list = ('-V', '--verbose') + for i in verbose_list: + if i in args: + global VERBOSE + VERBOSE = True + args.remove(i) + + def _summary(self, nodes_num, title): + if ALL_NODES_RESULT: + success_num = failed_num = 0 + failed_list = [] + for key in ALL_NODES_RESULT: + if ALL_NODES_RESULT[key]['rst'] == 'OK': + success_num += 1 + else: + failed_num += 1 + for error in ALL_NODES_RESULT[key]['rst']: + failed_list.append(error) + self.messager.info('-' * 55) + self.messager.info('%s complete: Total=%d Success=%d Failed=%d' % \ + (title, nodes_num, success_num, failed_num)) + if failed_list: + for i in failed_list: + self.messager.info(i) + self.messager.info('-' * 55) + + def rflash(self, nodeinfo, args): + if not os.path.exists(XCAT_LOG_RFLASH_DIR): + os.makedirs(XCAT_LOG_RFLASH_DIR) + nodes_num = len(self.nodes) + self._check_verbose(args) + + for key,value in RFLASH_OPTIONS.items(): + if key in args: + args.remove(key) + args.insert(0, value) + break + + upload_file = None + activate_arg = {} + args_num = len(args) + subcommand = args[0] + if subcommand == 'upload' or subcommand == 'activate' or + (subcommand == 'check' and args_num > 1): + arg_type = args[1].split('.')[-1] + if arg_type == 'tar': + upload_file = args[1] + if not os.path.isabs(upload_file): + upload_file = self._get_full_path(upload_file) + + if not os.access(upload_file, os.F_OK) or + not os.access(upload_file, os.R_OK): + error = 'Error: Cannot access %s. Check the management ' \ + 'node and/or service nodes.' % upload_file + self.messager.error(error) + return + activate_arg['update_file'] = upload_file + else: + activate_arg['activate_id'] = args[1] + + if (subcommand == 'check' or subcommand == 'activate') and upload_file: + grep_cmd = '/usr/bin/grep -a' + version_cmd = grep_cmd + ' ^version= ' + upload_file + purpose_cmd = grep_cmd + ' purpose= ' + upload_file + firmware_ver = os.popen(version_cmd).readlines()[0].split('=')[-1].strip() + purpose_ver = os.popen(purpose_cmd).readlines()[0].split('=')[-1].strip() + if subcommand == 'check': + self.messager.info('TAR %s Firmware Product Version: %s' \ + % (purpose_ver,firmware_ver)) + else: + activate_arg['activate_version'] = firmware_ver + activate_arg['purpose'] = purpose_ver.split('.')[-1] + + if subcommand == 'activate': + args[1] = activate_arg + + if subcommand == 'upload': + args[1] = upload_file + + if subcommand == 'upload' or subcommand == 'activate' and upload_file: + self.messager.info('Attempting to upload %s, please wait...' % upload_file) + + super(OpenBMCManager, self).process_nodes_worker('openbmc', 'OpenBMC', + self.nodes, nodeinfo, 'rflash', args) + self._summary(nodes_num, 'Firmware update') + def rpower(self, nodeinfo, args): - super(OpenBMCManager, self).process_nodes_worker('openbmc', 'OpenBMC', self.nodes, nodeinfo, 'rpower', args) + super(OpenBMCManager, self).process_nodes_worker('openbmc', 'OpenBMC', + self.nodes, nodeinfo, 'rpower', args) diff --git a/xCAT-openbmc-py/lib/python/agent/xcatagent/rest.py b/xCAT-openbmc-py/lib/python/agent/xcatagent/rest.py index c3057ddb3..00b3f5e40 100644 --- a/xCAT-openbmc-py/lib/python/agent/xcatagent/rest.py +++ b/xCAT-openbmc-py/lib/python/agent/xcatagent/rest.py @@ -2,6 +2,7 @@ import requests import json import time +from gevent.subprocess import Popen, PIPE import urllib3 urllib3.disable_warnings() @@ -9,76 +10,126 @@ import xcat_exception class RestSession : - def __init__(self, messager, debugmode) : + def __init__(self, messager, debugmode): self.session = requests.Session() + self.cookies = None self.messager = messager self.debugmode = debugmode - def _print_record_log (self, node, log_string, status) : + def _print_record_log (self, node, log_string, status): if self.debugmode : localtime = time.asctime( time.localtime(time.time()) ) log = node + ': [openbmc_debug] ' + status + ' ' + log_string self.messager.info(localtime + ' ' + log) self.messager.syslog(log) - def _request_log (self, method, url, headers, data): - log_string = 'curl -k -c cjar' + def _request_log (self, method, url, headers, data, files): + log_string = 'curl -k -c cjar -b cjar' log_string += ' -X %s' % method - for key,value in headers.items() : + for key,value in headers.items(): header_data = key + ": " + value log_string += ' -H "' + header_data + '"' log_string += ' %s' % url - if data : + if data: log_string += ' -d \'%s\'' % data + if files: + log_string += ' -T \'%s\'' % files return log_string - def request (self, method, url, headers, in_data, node, status) : - if in_data : + + def _response_check (self, response, response_dict, node, status): + if response.status_code != requests.codes.ok: + description = ''.join(response_dict['data']['description']) + error = 'Error: [%d] %s' % (response.status_code, description) + self._print_record_log(node, error, status) + code = response.status_code + raise xcat_exception.SelfClientException(error, code) + else: + self._print_record_log(node, response_dict['message'], status) + + if status == 'login': + self.cookies = requests.utils.dict_from_cookiejar(self.session.cookies) + + + def request (self, method, url, headers, in_data, node, status): + data = log_data = '' + + if in_data: data = json.dumps(in_data) - else : - data = '' - - if status == 'login' : - in_data['data'][1] = 'xxxxxx' - log_data = json.dumps(in_data) - else : log_data = data + if status == 'login': + in_data['data'][1] = 'xxxxxx' + log_data = json.dumps(in_data) - log_string = self._request_log(method, url, headers, log_data) + log_string = self._request_log(method, url, headers, log_data, '') self._print_record_log(node, log_string, status) response = '' error = '' - try : + try: response = self.session.request(method, url, - data=data, - headers=headers, - verify=False, - timeout=30) - except requests.exceptions.ConnectionError : - error = 'Error: BMC did not respond. Validate BMC configuration and retry the command.' - except requests.exceptions.Timeout : + data=data, + headers=headers, + verify=False, + timeout=30) + except requests.exceptions.ConnectionError: + error = 'Error: BMC did not respond. ' \ + 'Validate BMC configuration and retry the command.' + except requests.exceptions.Timeout: error = 'Error: Timeout to connect to server' - if error : + if error: self._print_record_log(node, error, status) raise xcat_exception.SelfServerException(error) - try : + try: response_dict = response.json() - except ValueError : - error = 'Error: Received wrong format response:' + response_dict + except ValueError: + error = 'Error: Received wrong format response: %s' % response self._print_record_log(node, error, status) raise xcat_exception.SelfServerException(error) - if response.status_code != requests.codes.ok : - description = ''.join(response_dict['data']['description']) - error = 'Error: [%d] %s' % (response.status_code, description) - self._print_record_log(node, error, status) - raise xcat_exception.SelfClientException(error) - else : - self._print_record_log(node, response_dict['message'], status) + self._response_check(response, response_dict, node, status) return response_dict + + + def request_upload_curl (self, method, url, headers, files, node, status): + for key,value in headers.items(): + header_data = key + ': ' + value + request_cmd = 'curl -k -b sid=%s -H "%s" -X %s -T %s %s -s' % \ + (self.cookies['sid'], header_data, method, files, url) + request_cmd_log = 'curl -k -c cjar -b cjar -H "%s" -X %s -T %s %s -s' \ + % (header_data, method, files, url) + + log_string = self._request_log(method, url, headers, '', files) + self._print_record_log(node, log_string, status) + + sub = Popen(request_cmd, stdout=PIPE, shell=True) + response, err = sub.communicate() + + if not response: + error = 'Error: Did not receive response from OpenBMC after ' \ + 'running command form \'%s\'' % request_cmd_log + raise xcat_exception.SelfServerException(error) + + try: + response_dict = json.loads(response) + except ValueError: + error = 'Error: Received wrong format response: %s: %s' % \ + (request_cmd_log, response) + self._print_record_log(node, error, status) + raise xcat_exception.SelfServerException(error) + + if response_dict['message'] != '200 OK': + error = 'Error: Failed to upload update file %s : %s-%s' % \ + (files, response_dict['message'], \ + ''.join(response_dict['data']['description'])) + self._print_record_log(node, error, status) + raise xcat_exception.SelfClientException(error, code) + + self._print_record_log(node, response_dict['message'], status) + + return diff --git a/xCAT-openbmc-py/lib/python/agent/xcatagent/utils.py b/xCAT-openbmc-py/lib/python/agent/xcatagent/utils.py index 8fff2403a..b2d475cea 100644 --- a/xCAT-openbmc-py/lib/python/agent/xcatagent/utils.py +++ b/xCAT-openbmc-py/lib/python/agent/xcatagent/utils.py @@ -39,3 +39,11 @@ def recv_all(sock, size): buf_size += len(buf_part) buf = ''.join(buf_parts) return buf + + +def update2Ddict(the_dict, key_a, key_b, value): + if key_a in the_dict : + the_dict[key_a].update({key_b: value}) + else : + the_dict.update({key_a: {key_b: value}}) + diff --git a/xCAT-openbmc-py/lib/python/agent/xcatagent/xcat_exception.py b/xCAT-openbmc-py/lib/python/agent/xcatagent/xcat_exception.py index f544cf2c8..15af285c4 100644 --- a/xCAT-openbmc-py/lib/python/agent/xcatagent/xcat_exception.py +++ b/xCAT-openbmc-py/lib/python/agent/xcatagent/xcat_exception.py @@ -4,4 +4,6 @@ class SelfServerException(Exception) : pass class SelfClientException(Exception) : - pass + def __init__(self, message, code) : + super(Exception, self).__init__(message) + self.code = code diff --git a/xCAT-server/lib/xcat/plugins/openbmc2.pm b/xCAT-server/lib/xcat/plugins/openbmc2.pm index 6f1bfaf99..766791242 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc2.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc2.pm @@ -30,6 +30,7 @@ use xCAT::OPENBMC; sub handled_commands { return { + rflash => 'nodehm:mgt=openbmc', rpower => 'nodehm:mgt=openbmc', }; } @@ -136,13 +137,61 @@ sub parse_args { my $noderange = shift; my $subcommand = undef; - if (scalar(@ARGV) != 2 and ($command =~ /rpower/)) { + if (scalar(@ARGV) >= 2 and ($command =~ /rpower/)) { return ([ 1, "Only one option is supported at the same time for $command" ]); + } elsif (scalar(@ARGV) == 0 and $command =~ /rpower|rflash/) { + return ([ 1, "No option specified for $command" ]); } else { $subcommand = $ARGV[0]; } - if ($command eq "rpower") { + if ($command eq "rflash") { + my $verbose; + my ($activate, $check, $delete, $directory, $list, $upload) = (0) x 6; + my $no_host_reboot; + GetOptions( + 'a|activate' => \$activate, + 'c|check' => \$check, + 'delete' => \$delete, + 'd' => \$directory, + 'l|list' => \$list, + 'u|upload' => \$upload, + 'V|verbose' => \$verbose, + 'no-host-reboot' => \$no_host_reboot, + ); + my $option_num = $activate+$check+$delete+$directory+$list+$upload; + if ($option_num >= 2) { + return ([ 1, "Multiple options are not supported."]); + } elsif ($option_num == 0) { + return ([ 1, "No options specified."]); + } + if ($activate or $check or $delete or $upload) { + return ([ 1, "More than one firmware specified is not supported."]) if ($#ARGV >= 1); + if ($check) { + return ([ 1, "Invalid firmware specified with '-c|--check'."]) if (@ARGV and ($ARGV[0] !~ /.*\.tar$/i or $#ARGV >= 1)); + } + if ($activate or $delete or $upload) { + my $option = "-a|--activate"; + if ($upload) { + $option = "-u|--upload"; + } elsif ($delete) { + $option = "--delete" + } + return ([ 1, "Invalid firmware specified with '$option'"]) if (!@ARGV); + my $param = $ARGV[0]; + return ([ 1, "Invalid firmware specified with '$option': $param"]) if (($delete and $param !~ /^[[:xdigit:]]+$/i) + or ($activate and $param !~ /^[[:xdigit:]]+$/i and $param !~ /.*\.tar$/i) or ($upload and $param !~ /.*\.tar$/i)); + } + } + if ($directory) { + return ([ 1, "Unsupported command: $command '-d'" ]); + return ([ 1, "More than one directory specified is not supported."]) if ($#ARGV >= 1); + return ([ 1, "Invalid option specified with '-d'."]) if (!@ARGV); + } + if ($list) { + return ([ 1, "Invalid option specified with '-l|--list'."]) if (@ARGV); + } + } elsif ($command eq "rpower") { unless ($subcommand =~ /^on$|^off$|^softoff$|^reset$|^boot$|^bmcreboot$|^bmcstate$|^status$|^stat$|^state$/) { return ([ 1, "Unsupported command: $command $subcommand" ]); } From 7f7c4e4deaf28ed31f834882146ae30169af3470 Mon Sep 17 00:00:00 2001 From: bybai Date: Thu, 18 Jan 2018 02:36:31 -0500 Subject: [PATCH 73/93] enhance print error message --- xCAT-server/lib/xcat/plugins/ddns.pm | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/ddns.pm b/xCAT-server/lib/xcat/plugins/ddns.pm index f59fb1f04..d2b5a9812 100644 --- a/xCAT-server/lib/xcat/plugins/ddns.pm +++ b/xCAT-server/lib/xcat/plugins/ddns.pm @@ -589,8 +589,14 @@ sub process_request { my @options = xCAT::TableUtils->get_site_attribute("emptyzonesenable"); my $empty_zones = $options[0]; - if (defined($empty_zones) and $empty_zones =~ /^yes$|^no$/) { - $ctx->{empty_zones_enable} = $empty_zones; + if (defined($empty_zones)) { + if ($empty_zones =~ /^yes$|^no$/) { + $ctx->{empty_zones_enable} = $empty_zones; + } else { + my $rsp; + push @{ $rsp->{data} }, "emptyzonesenable from xCAT site table should be yes or no."; + xCAT::MsgUtils->message("E", $rsp, $callback); + } } my @slave_ips; my $dns_slaves = get_dns_slave(); @@ -1104,8 +1110,7 @@ sub update_namedconf { } push @newnamed, "\t};\n"; } elsif ($ctx->{empty_zones_enable} and $line =~ /empty-zones-enable/) { - push @newnamed, "\tempty-zones-enable " . $_ . ";\n"; - $skip = 1; + push @newnamed, "\tempty-zones-enable " . $ctx->{empty_zones_enable} . ";\n"; } elsif ($ctx->{slaves} and $line =~ /allow-transfer \{/) { push @newnamed, "\tallow-transfer \{\n"; $skip = 1; From 988898dde1ee5d951fa9181e4634766194dee7e7 Mon Sep 17 00:00:00 2001 From: bybai Date: Thu, 18 Jan 2018 02:58:30 -0500 Subject: [PATCH 74/93] enhance emptyzonesenable description --- perl-xCAT/xCAT/Schema.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/perl-xCAT/xCAT/Schema.pm b/perl-xCAT/xCAT/Schema.pm index 42b309c6e..0bb0b52d9 100755 --- a/perl-xCAT/xCAT/Schema.pm +++ b/perl-xCAT/xCAT/Schema.pm @@ -1057,7 +1057,7 @@ passed as argument rather than by table value', " requests it does not know to these servers. Note that the DNS servers on the\n" . " service nodes will ignore this value and always be configured to forward \n" . " to the management node.\n\n" . -" emptyzonesenable: (yes or no). This is to set empty-zones-enable value in named.conf options section. The default is yes. \n\n" +" emptyzonesenable: (yes or no). This is to set empty-zones-enable value in named.conf options section. \n\n" " master: The hostname of the xCAT management node, as known by the nodes.\n\n" . " nameservers: A comma delimited list of DNS servers that each node in the cluster should\n" . " use. This value will end up in the nameserver settings of the\n" . From 55fed03a8166a33458d3e9f549960fe62341192c Mon Sep 17 00:00:00 2001 From: bybai Date: Thu, 18 Jan 2018 03:01:45 -0500 Subject: [PATCH 75/93] handle error --- xCAT-server/lib/xcat/plugins/ddns.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/xCAT-server/lib/xcat/plugins/ddns.pm b/xCAT-server/lib/xcat/plugins/ddns.pm index d2b5a9812..903c3aea5 100644 --- a/xCAT-server/lib/xcat/plugins/ddns.pm +++ b/xCAT-server/lib/xcat/plugins/ddns.pm @@ -595,7 +595,8 @@ sub process_request { } else { my $rsp; push @{ $rsp->{data} }, "emptyzonesenable from xCAT site table should be yes or no."; - xCAT::MsgUtils->message("E", $rsp, $callback); + xCAT::MsgUtils->message("E", $rsp, $callback); + return; } } my @slave_ips; From 956719b53e3dca8d33018aa894bcecd8063a94e6 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Thu, 18 Jan 2018 11:35:23 -0500 Subject: [PATCH 76/93] Add rspconfig dump download all function --- .../references/man1/rspconfig.1.rst | 4 +- perl-xCAT/xCAT/Usage.pm | 2 +- xCAT-client/pods/man1/rspconfig.1.pod | 4 +- xCAT-server/lib/xcat/plugins/openbmc.pm | 68 ++++++++++++++++--- 4 files changed, 65 insertions(+), 13 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 b6956de5d..c9278d2f7 100644 --- a/docs/source/guides/admin-guides/references/man1/rspconfig.1.rst +++ b/docs/source/guides/admin-guides/references/man1/rspconfig.1.rst @@ -49,7 +49,7 @@ OpenBMC specific: \ **rspconfig**\ \ *noderange*\ {\ **ipsrc | ip | netmask | gateway | hostname | vlan | sshcfg**\ } -\ **rspconfig**\ \ *noderange*\ \ **dump**\ [\ **-l | -**\ **-list**\ ] [\ **-g | -**\ **-generate**\ ] [\ **-c | -**\ **-clear**\ {\ *id*\ |\ **all**\ }] [\ **-d | -**\ **-download**\ \ *id*\ ] +\ **rspconfig**\ \ *noderange*\ \ **dump**\ [\ **-l | -**\ **-list**\ ] [\ **-g | -**\ **-generate**\ ] [\ **-c | -**\ **-clear**\ {\ *id*\ | \ **all**\ }] [\ **-d | -**\ **-download**\ {\ *id*\ | \ **all**\ }] MPA specific: @@ -449,7 +449,7 @@ OPTIONS - \ **-d**\ will download a single dump from the BMC to /var/log/xcat/dump on management or service node. + \ **-d**\ will download a single dump or all generated dumps from the BMC to /var/log/xcat/dump on management or service node. diff --git a/perl-xCAT/xCAT/Usage.pm b/perl-xCAT/xCAT/Usage.pm index 551cabd05..d28130199 100755 --- a/perl-xCAT/xCAT/Usage.pm +++ b/perl-xCAT/xCAT/Usage.pm @@ -147,7 +147,7 @@ my %usage = ( rspconfig [userid= username= password=] OpenBMC specific: rspconfig [ipsrc|ip|netmask|gateway|hostname|vlan] - rspconfig dump [-l|--list] [-g|--generate] [-c|--clear {|all}] [-d|--download ] + rspconfig dump [-l|--list] [-g|--generate] [-c|--clear {|all}] [-d|--download {|all}] 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 fbd1fa6f0..9088188f7 100644 --- a/xCAT-client/pods/man1/rspconfig.1.pod +++ b/xCAT-client/pods/man1/rspconfig.1.pod @@ -26,7 +26,7 @@ B I B=I