From 8e90e30bac13413997764fc927665a30b4951062 Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Wed, 21 Jun 2017 12:39:53 -0400 Subject: [PATCH 1/4] Add verbose option to be parsed by rinv [openbmc] --- xCAT-server/lib/xcat/plugins/openbmc.pm | 26 ++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index cf9b9cc60..1fca69eb0 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -29,6 +29,7 @@ use xCAT::SvrUtils; use xCAT::GlobalDef; use xCAT_monitoring::monitorctrl; +$::VERBOSE = 0; # String constants for rpower states $::POWER_STATE_OFF="off"; $::POWER_STATE_ON="on"; @@ -409,16 +410,27 @@ sub parse_args { my $extrargs = shift; my $noderange = shift; my $check = undef; - + if (!defined($extrargs) and $command =~ /rpower|rsetboot|rspconfig|rflash/) { return ([ 1, "No option specified for $command" ]); } - if (scalar(@ARGV) > 1 and ($command =~ /rpower|rinv|rsetboot|rvitals/)) { + my $subcommand = undef; + if (scalar(@ARGV) > 2 and ($command =~ /rpower|rinv|rsetboot|rvitals/)) { return ([ 1, "Only one option is supported at the same time" ]); + } elsif (scalar(@ARGV) == 2) { + # Check if one is calling for Verbose output + foreach (@ARGV) { + if ($_ =~ /V|verbose/) { + $::VERBOSE=1; + } else { + $subcommand = $_ + } + } + } else { + $subcommand = $ARGV[0] } - my $subcommand = $ARGV[0]; if ($command eq "rpower") { unless ($subcommand =~ /^on$|^off$|^reset$|^boot$|^status$|^stat$|^state$/) { return ([ 1, "Unsupported command: $command $subcommand" ]); @@ -526,6 +538,14 @@ sub parse_command_status { $next_status{LOGIN_REQUEST} = "LOGIN_RESPONSE"; + my $verbose = undef; + unless (GetOptions( + 'V|verbose' => \$verbose, + )) { + xCAT::SvrUtils::sendmsg("Error parsing arguments.", $callback); + return 1; + } + if ($command eq "rpower") { $subcommand = $ARGV[0]; From b658a17af30ddc67c18bc64c7985fddee5e40ade Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Wed, 21 Jun 2017 13:23:24 -0400 Subject: [PATCH 2/4] Change the output of firm [openbmc] to more closely match the output of OPAL P8 machines when displaying the firmware. Use the ID to sort, but remove it when printing out the messages to the user --- xCAT-server/lib/xcat/plugins/openbmc.pm | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index 1fca69eb0..3c30b1407 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -1083,30 +1083,27 @@ sub rinv_response { if ($grep_string eq "firm") { # This handles the data from the /xyz/openbmc_project/Software endpoint. - # - # Handle printing out all posssible Software values in a generic format: - # node: Software: () - # my $sw_id = (split(/\//, $key_url))[-1]; if (defined($content{Version}) and $content{Version}) { my $purpose_value = uc ((split(/\./, $content{Purpose}))[-1]); + $purpose_value = "[$sw_id]$purpose_value"; my $activation_value = (split(/\./, $content{Activation}))[-1]; # - # For 'rinv firm', only print Active software. 'rflash list' will handle others + # For 'rinv firm', only print Active software, unless verbose is specified # - if ($activation_value =~ "Active") { + if ($activation_value =~ "Active" or $::VERBOSE) { # - # The space below between "SOFTWARE:" and $content{Version} is intentional + # The space below between "Firmware Product Version:" and $content{Version} is intentional # to cause the sorting of this line before any additional info lines # - $content_info = "$purpose_value SOFTWARE[$sw_id]: $content{Version} ($activation_value)"; + $content_info = "$purpose_value Firmware Product: $content{Version} ($activation_value)"; push (@sorted_output, $content_info); if (defined($content{ExtendedVersion}) and $content{ExtendedVersion} ne "") { # ExtendedVersion is going to be a comma separated list of additional software my @versions = split(',', $content{ExtendedVersion}); foreach my $ver (@versions) { - $content_info = "$purpose_value SOFTWARE[$sw_id]: -- additional info: $ver"; + $content_info = "$purpose_value Firmware Product: -- additional info: $ver"; push (@sorted_output, $content_info); } } @@ -1149,7 +1146,14 @@ sub rinv_response { # sort alpha, then numeric my @sorted_output = grep {s/(^|\D)0+(\d)/$1$2/g,1} sort grep {s/(\d+)/sprintf"%06.6d",$1/ge,1} @sorted_output; - xCAT::SvrUtils::sendmsg("$_", $callback, $node) foreach (@sorted_output); + foreach (@sorted_output) { + # + # The firmware output requires the ID to be part of the string to sort correctly. + # Remove this ID from the output to the user + # + $_ =~ s/\[.*?\]//; + xCAT::SvrUtils::sendmsg("$_", $callback, $node); + } } else { xCAT::SvrUtils::sendmsg("$::NO_ATTRIBUTES_RETURNED", $callback, $node); } From 27607d7495382713bc2f57a14ad16613fc4fee6a Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Thu, 22 Jun 2017 20:55:52 -0400 Subject: [PATCH 3/4] Add verbose option to rinv for OpenBMC supported machines --- .../source/guides/admin-guides/references/man1/rinv.1.rst | 8 +++++++- perl-xCAT/xCAT/Usage.pm | 2 +- xCAT-client/pods/man1/rinv.1.pod | 6 +++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/docs/source/guides/admin-guides/references/man1/rinv.1.rst b/docs/source/guides/admin-guides/references/man1/rinv.1.rst index 214b06e13..045866ae0 100644 --- a/docs/source/guides/admin-guides/references/man1/rinv.1.rst +++ b/docs/source/guides/admin-guides/references/man1/rinv.1.rst @@ -39,7 +39,7 @@ OpenPOWER (OpenBMC) server specific: ==================================== -\ **rinv**\ \ *noderange*\ [\ **model | serial | firm | cpu | dimm | all**\ ] +\ **rinv**\ \ *noderange*\ [\ **model | serial | firm | cpu | dimm | all**\ ] [\ **-V | -**\ **-verbose**\ ] PPC (with HMC) specific: @@ -234,6 +234,12 @@ Calling \ **rinv**\ for VMware will display the UUID/GUID, number of CPUs, amou +\ **-V | -**\ **-verbose**\ + + Not supported for all managed machines. Prints verbose output. + + + \ **-t**\ Set the values in the vm table to what vCenter has for the indicated nodes. diff --git a/perl-xCAT/xCAT/Usage.pm b/perl-xCAT/xCAT/Usage.pm index b733daca9..b0348dd53 100755 --- a/perl-xCAT/xCAT/Usage.pm +++ b/perl-xCAT/xCAT/Usage.pm @@ -100,7 +100,7 @@ my %usage = ( OpenPOWER (IPMI) server specific: rinv [model|serial|deviceid|uuid|guid|vpd|mprom|firm|all] OpenPOWER (OpenBMC) server specific: - rinv [model|serial|firm|cpu|dimm|all] + rinv [model|serial|firm|cpu|dimm|all] [-V|--verbose] PPC specific(with HMC): rinv [all|bus|config|serial|model|firm] PPC specific(using Direct FSP Management): diff --git a/xCAT-client/pods/man1/rinv.1.pod b/xCAT-client/pods/man1/rinv.1.pod index 090194df1..5b3e92665 100644 --- a/xCAT-client/pods/man1/rinv.1.pod +++ b/xCAT-client/pods/man1/rinv.1.pod @@ -16,7 +16,7 @@ B I [B|B|B|B|B|B|B I [B|B|B|B|B|B] +B I [B|B|B|B|B|B] [B<-V>|B<--verbose>] =head2 PPC (with HMC) specific: @@ -149,6 +149,10 @@ Print help. Print version. +=item B<-V>|B<--verbose> + +Not supported for all managed machines. Prints verbose output. + =item B<-t> Set the values in the vm table to what vCenter has for the indicated nodes. From c7aff42ca27605fdbd652db79183e67508a1e5a6 Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Thu, 22 Jun 2017 21:00:43 -0400 Subject: [PATCH 4/4] Modify the description for verbose option in rinv --- docs/source/guides/admin-guides/references/man1/rinv.1.rst | 2 +- xCAT-client/pods/man1/rinv.1.pod | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/guides/admin-guides/references/man1/rinv.1.rst b/docs/source/guides/admin-guides/references/man1/rinv.1.rst index 045866ae0..d760fc576 100644 --- a/docs/source/guides/admin-guides/references/man1/rinv.1.rst +++ b/docs/source/guides/admin-guides/references/man1/rinv.1.rst @@ -236,7 +236,7 @@ Calling \ **rinv**\ for VMware will display the UUID/GUID, number of CPUs, amou \ **-V | -**\ **-verbose**\ - Not supported for all managed machines. Prints verbose output. + Prints verbose output, if available. diff --git a/xCAT-client/pods/man1/rinv.1.pod b/xCAT-client/pods/man1/rinv.1.pod index 5b3e92665..52ed22ccc 100644 --- a/xCAT-client/pods/man1/rinv.1.pod +++ b/xCAT-client/pods/man1/rinv.1.pod @@ -151,7 +151,7 @@ Print version. =item B<-V>|B<--verbose> -Not supported for all managed machines. Prints verbose output. +Prints verbose output, if available. =item B<-t>