From cef55779ce2fe3ba49b2fc52a70d42f433917e8c Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Wed, 12 Oct 2016 10:46:52 -0400 Subject: [PATCH 1/3] Suppress some messages to be only in verbose mode and skip node objects of type switch --- xCAT-probe/subcmds/image | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/xCAT-probe/subcmds/image b/xCAT-probe/subcmds/image index f7a26745a..b1df32420 100755 --- a/xCAT-probe/subcmds/image +++ b/xCAT-probe/subcmds/image @@ -153,11 +153,16 @@ foreach (@all_nodes_provmethod_lines) { print "Node $node_name has defined image $node_osimage_name at $rootimagedir with UUID $defined_UUID\n" if ($VERBOSE); } else { - probe_utils->send_msg("$output", "w", "$node_name is not diskless. No image consistency verification will be performed."); + probe_utils->send_msg("$output", "w", "$node_name is not diskless. No image consistency verification will be performed.") if ($VERBOSE); } } else { - probe_utils->send_msg("$output", "w", "$node_name has no provision method defined. No image consistency verification will be performed."); + my $nodetype = `lsdef -i nodetype -c $node_name`; + my ($node, $type) = split "=", $nodetype; + # If node object happens to be switch, do not display this warning message + unless ($type =~ /switch/) { + probe_utils->send_msg("$output", "w", "$node_name has no provision method defined. No image consistency verification will be performed.") if ($VERBOSE); + } } } @@ -204,7 +209,7 @@ if ((scalar(@pingable_nodes) == 1) && ($CONSISTENCY_CHECK)) { # There was only one node in noderange and comparison check was requested. # Nothing to compare the single node to. - probe_utils->send_msg("$output", "w", "Comparison check for a single diskless pingable node will not be performed. Minimum of 2 nodes are needed for that."); + probe_utils->send_msg("$output", "w", "Comparison check for a single diskless pingable node $pingable_nodes[0] will not be performed.\nMinimum of 2 nodes are needed for that."); exit 1; } From daf37fc180341bbd9c935d45fe6af5a7ffe4393a Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Wed, 12 Oct 2016 15:43:12 -0400 Subject: [PATCH 2/3] add support for summary and specific UUID display --- xCAT-probe/subcmds/image | 66 ++++++++++++++++++++++++++++++++++------ 1 file changed, 56 insertions(+), 10 deletions(-) diff --git a/xCAT-probe/subcmds/image b/xCAT-probe/subcmds/image index b1df32420..82ca762fb 100755 --- a/xCAT-probe/subcmds/image +++ b/xCAT-probe/subcmds/image @@ -19,10 +19,11 @@ my $test; my $output = "stdout"; my $verbose = 0; my $rst = 0; +my $large_system = 20; # Number of compute nodes to treat as a large system $::USAGE = "Usage: $program_name -h - $program_name {-c|-d} [-n noderange] [-V] + $program_name {-c|-d|-u uuid} [-n noderange] [-V] Description: Use this command to check if diskless, pingable compute nodes have the same images installed as defines in xCAT DB. @@ -33,6 +34,7 @@ Options: -n : Range of nodes to check -d : To verify diskless, pingable compute nodes have the same images installed as defines in xCAT DB. -c : To verify all diskless, pingable compute nodes have the identical images installed. + -u : To display a list of pingable compute nodes running an OS with the specified UUID -V : To print additional debug information. "; @@ -45,7 +47,8 @@ if ( "V" => \$VERBOSE, "n=s" => \$noderange, "c" => \$CONSISTENCY_CHECK, - "d" => \$DEFINITION_CHECK)) + "d" => \$DEFINITION_CHECK, + "u=s" => \$UUID_specified)) { probe_utils->send_msg("$output", "f", "Invalid parameter for $program_name"); probe_utils->send_msg("$output", "d", "$::USAGE"); @@ -66,12 +69,17 @@ if ($test) { exit 0; } -unless (defined($CONSISTENCY_CHECK) || defined($DEFINITION_CHECK)) { - probe_utils->send_msg("$output", "f", "At least one of -c or -d flags is required"); +unless (defined($CONSISTENCY_CHECK) || defined($DEFINITION_CHECK) || defined($UUID_specified)) { + probe_utils->send_msg("$output", "f", "At least one of -c or -d or -u flags is required"); probe_utils->send_msg("$output", "d", "$::USAGE"); exit 1; } +if ($UUID_specified) { + #Looking for compute nodes running with specific UUID. Do consistency check processing first to get the data + $CONSISTENCY_CHECK = 1; +} + if (scalar(@ARGV) >= 1) { # After processing all the expected flags and arguments, @@ -316,11 +324,15 @@ if ($CONSISTENCY_CHECK) { my $image_name_and_uuid; my $image_uuid; my %unique_image_hash; + - # Go throug the nodes and build a hash of key=image_name+image_uuid and value of nodename + # Go through the nodes and build a hash of key=image_name+image_uuid and value of nodename foreach (@pingable_nodes) { $image_name_and_uuid = $node_running_image_name_hash{$_} . ":" . $node_running_image_uuid_hash{$_}; - unless (exists $unique_image_hash{$image_name_and_uuid}) { + if (exists $unique_image_hash{$image_name_and_uuid}) { + $unique_image_hash{$image_name_and_uuid} = $unique_image_hash{$image_name_and_uuid} . "," . $_; + } + else { $unique_image_hash{$image_name_and_uuid} = $_; } } @@ -341,11 +353,45 @@ if ($CONSISTENCY_CHECK) { } else { my $node_image_table; - foreach $compute_node (keys %node_running_image_name_hash) { - $node_image_table .= sprintf(" %-15s %-30s : %-20s\n", $compute_node, $node_running_image_name_hash{$compute_node}, $node_running_image_uuid_hash{$compute_node}); + if ($UUID_specified) { + # Produce list of compute nodes running with a specified UUID + foreach $os_uuid (sort keys %unique_image_hash) { + my ($os_name, $uuid) = split(":", $os_uuid); + if ($uuid eq $UUID_specified) { + # Found UUID match + foreach my $node_name (split(",",$unique_image_hash{$os_uuid})) { + $node_image_table .= sprintf("$node_name\n"); + } + $msg = "Compute nodes running OS=>$os_name UUID=>$uuid:\n" . $node_image_table; + $status = "d"; + last; + } + } + if (length($node_image_table) < 1) { + # At the end of the loop, no UUID match found + $msg = "No compute nodes running UUID $UUID_specified were found."; + $status = "d"; + } + } + else { + if (scalar(@pingable_nodes) > $large_system) { + #Produce summary output for a large system + foreach $os_uuid (sort keys %unique_image_hash) { + my ($os_name, $uuid) = split(":", $os_uuid); + my $count = scalar(split(",",$unique_image_hash{$os_uuid})); + $node_image_table .= sprintf(" $count compute nodes running OS=>$os_name UUID=>$uuid\n"); + } + $node_image_table .= "Run 'xcatprobe image -u UUID' to display a list of compute nodes that have installed OS with specified UUID"; + } + else { + #Produce list output for small system + foreach $compute_node (sort keys %node_running_image_name_hash) { + $node_image_table .= sprintf(" %-15s %-30s : %-20s\n", $compute_node, $node_running_image_name_hash{$compute_node}, $node_running_image_uuid_hash{$compute_node}); + } + } + $msg = "Not all diskless pingable compute nodes are installed with the same os image.\n" . $node_image_table; + $status = "f"; } - $msg = "Not all compute nodes are installed with the same os image.\n" . $node_image_table; - $status = "f"; } probe_utils->send_msg("$output", "$status", "$msg"); From 9abe939c8c594b291ac4c876e8df0252a32307b9 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Tue, 18 Oct 2016 11:23:02 -0400 Subject: [PATCH 3/3] Fixed message wording --- xCAT-probe/subcmds/image | 58 ++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/xCAT-probe/subcmds/image b/xCAT-probe/subcmds/image index 82ca762fb..406668ab6 100755 --- a/xCAT-probe/subcmds/image +++ b/xCAT-probe/subcmds/image @@ -19,22 +19,22 @@ my $test; my $output = "stdout"; my $verbose = 0; my $rst = 0; -my $large_system = 20; # Number of compute nodes to treat as a large system +my $large_system = 20; # Number of nodes to treat as a large system $::USAGE = "Usage: $program_name -h $program_name {-c|-d|-u uuid} [-n noderange] [-V] Description: - Use this command to check if diskless, pingable compute nodes have the same images installed as defines in xCAT DB. - Use this command to check if all diskless, pingable compute nodes have the same identical installed. + Use this command to check if diskless nodes have the same images installed as defines in xCAT DB. + Use this command to check if all diskless nodes have the identical images installed. Options: -h : Get usage information of $program_name -n : Range of nodes to check - -d : To verify diskless, pingable compute nodes have the same images installed as defines in xCAT DB. - -c : To verify all diskless, pingable compute nodes have the identical images installed. - -u : To display a list of pingable compute nodes running an OS with the specified UUID + -d : To verify diskless nodes have the same images installed as defines in xCAT DB. + -c : To verify all diskless nodes have the identical images installed. + -u : To display a list of diskless nodes running an OS with the specified UUID -V : To print additional debug information. "; @@ -65,7 +65,7 @@ if ($help) { } if ($test) { - probe_utils->send_msg("$output", "o", "Use this command to check if specified compute nodes have the same images installed or if compute nodes are installed with the same image as defined on MN."); + probe_utils->send_msg("$output", "o", "Use this command to check if specified diskless nodes have the same images installed or if nodes are installed with the same image as defined on the management node."); exit 0; } @@ -76,7 +76,7 @@ unless (defined($CONSISTENCY_CHECK) || defined($DEFINITION_CHECK) || defined($UU } if ($UUID_specified) { - #Looking for compute nodes running with specific UUID. Do consistency check processing first to get the data + # Looking for nodes running with specific UUID. Do consistency check processing first to get the data $CONSISTENCY_CHECK = 1; } @@ -177,14 +177,14 @@ foreach (@all_nodes_provmethod_lines) { if (scalar(@diskless_nodes) <= 0) { # There were no diskless nodes found. Issue a warning and exit. - probe_utils->send_msg("$output", "w", "No diskless compute nodes were found."); + probe_utils->send_msg("$output", "w", "No diskless nodes were found."); exit 1; } if (scalar(@diskless_nodes) <= 0) { # There were no diskless nodes found. Issue a warning and exit. - probe_utils->send_msg("$output", "w", "No diskless compute nodes were found"); + probe_utils->send_msg("$output", "w", "No diskless nodes were found"); exit 1; } @@ -209,7 +209,7 @@ foreach (@pping_lines) { if (scalar(@pingable_nodes) <= 0) { # There were no pingable, diskless nodes found. Issue a warning and exit. - probe_utils->send_msg("$output", "w", "No diskless, pingable compute nodes were found"); + probe_utils->send_msg("$output", "w", "No diskless, pingable nodes were found"); exit 1; } @@ -217,12 +217,12 @@ if ((scalar(@pingable_nodes) == 1) && ($CONSISTENCY_CHECK)) { # There was only one node in noderange and comparison check was requested. # Nothing to compare the single node to. - probe_utils->send_msg("$output", "w", "Comparison check for a single diskless pingable node $pingable_nodes[0] will not be performed.\nMinimum of 2 nodes are needed for that."); + probe_utils->send_msg("$output", "w", "Comparison check for a single diskless node $pingable_nodes[0] will not be performed.\nMinimum of 2 nodes are needed for that."); exit 1; } # Next, from all pingable nodes get the IMAGENAME and IMAGEUUID entries from xcatinfo file -probe_utils->send_msg("$output", "d", "---- Gathering information from all diskless pingable compute nodes ----"); +probe_utils->send_msg("$output", "d", "---- Gathering information from all diskless nodes (pingable) ----"); my $pingable_hostname_list = join ",", @pingable_nodes; my $all_xdsh_output = `xdsh $pingable_hostname_list "cat /opt/xcat/xcatinfo"`; @@ -230,7 +230,7 @@ my $xcatinfo_image_UUID = ` echo "$all_xdsh_output" | awk -F"=" '/IMAGEUUID/ {gs # Check to verify xdsh worked and returned some usefull information if (length($xcatinfo_image_UUID) <= 1) { - probe_utils->send_msg("$output", "w", "Unable to extract image UUID information from compute nodes using xdsh command. No image consistency verification will be performed."); + probe_utils->send_msg("$output", "w", "Unable to extract image UUID information from nodes using xdsh command. No image consistency verification will be performed."); exit 1; } my @xdsh_UUID_lines = split("[\n\r]", $xcatinfo_image_UUID); @@ -239,7 +239,7 @@ my $xcatinfo_image_name = ` echo "$all_xdsh_output" | awk -F"=" '/IMAGENAME/ {gs # Check to verify xdsh worked and returned some usefull information if (length($xcatinfo_image_name) <= 1) { - probe_utils->send_msg("$output", "w", "Unable to extract image name information from compute nodes using xdsh command. No image consistency verification will be performed."); + probe_utils->send_msg("$output", "w", "Unable to extract image name information from nodes using xdsh command. No image consistency verification will be performed."); exit 1; } my @xdsh_name_lines = split("[\n\r]", $xcatinfo_image_name); @@ -260,7 +260,7 @@ foreach (@xdsh_UUID_lines) { } } -# It is possible that some older version xCAT compute nodes will not have an IMAGEUUID line in +# It is possible that some older version xCAT nodes will not have an IMAGEUUID line in # the xcatinfo file, for those nodes insert $na as the running UUID value foreach (@pingable_nodes) { unless (exists($node_running_image_uuid_hash{$_})) { @@ -294,17 +294,17 @@ if ($DEFINITION_CHECK) { if (($node_running_image_name_hash{$_} eq $node_defined_image_name_hash{$_}) && ($node_running_image_uuid_hash{$_} eq $node_defined_image_uuid_hash{$_})) { if ($node_running_image_uuid_hash{$_} eq $na) { - $msg = "$_: Not able to determine installed os image name or uuid"; + $msg = "$_: Not able to determine installed os image name or UUID"; } else { - $msg = "OS image installed on compute node $_ matches the image defined for it on management node"; + $msg = "OS image installed on diskless node $_ matches its image definition on the management node"; probe_utils->send_msg("$output", "o", "$msg") if ($VERBOSE); $success_nodes++; next; } } else { - $msg = "$_: Unmatched os image name or image UUID.\n Defined: name = $node_defined_image_name_hash{$_}" . + $msg = "$_: Unmatched OS image name or image UUID.\n Defined: name = $node_defined_image_name_hash{$_}" . " uuid = $node_defined_image_uuid_hash{$_}\n Installed: name = $node_running_image_name_hash{$_}" . " uuid = $node_running_image_uuid_hash{$_}"; } @@ -313,7 +313,7 @@ if ($DEFINITION_CHECK) { if (scalar(@pingable_nodes) eq $success_nodes) { # All pingable nodes were tested with success - probe_utils->send_msg("$output", "o", "OS image installed on each diskless compute node matches the image defined for it on management node"); + probe_utils->send_msg("$output", "o", "OS image installed on each diskless node matches its image definition on the management node"); } } @@ -343,18 +343,18 @@ if ($CONSISTENCY_CHECK) { if ($number_of_keys == 1) { my @image_names = keys %unique_image_hash; if ($image_names[0] =~ /$na/) { - $msg = "Not able to determine os image name or uuid of the image installed on any compute node."; + $msg = "Not able to determine OS image name or UUID of the image installed on any diskless node."; $status = "f"; } else { - $msg = "All compute nodes have the same os image installed: @image_names."; + $msg = "All diskless nodes have the same OS image installed: @image_names."; $status = "o"; } } else { my $node_image_table; if ($UUID_specified) { - # Produce list of compute nodes running with a specified UUID + # Produce list of nodes running with a specified UUID foreach $os_uuid (sort keys %unique_image_hash) { my ($os_name, $uuid) = split(":", $os_uuid); if ($uuid eq $UUID_specified) { @@ -369,27 +369,27 @@ if ($CONSISTENCY_CHECK) { } if (length($node_image_table) < 1) { # At the end of the loop, no UUID match found - $msg = "No compute nodes running UUID $UUID_specified were found."; + $msg = "No diskless nodes running UUID $UUID_specified were found."; $status = "d"; } } else { if (scalar(@pingable_nodes) > $large_system) { - #Produce summary output for a large system + # Produce summary output for a large system foreach $os_uuid (sort keys %unique_image_hash) { my ($os_name, $uuid) = split(":", $os_uuid); my $count = scalar(split(",",$unique_image_hash{$os_uuid})); - $node_image_table .= sprintf(" $count compute nodes running OS=>$os_name UUID=>$uuid\n"); + $node_image_table .= sprintf(" $count diskless nodes running OS=>$os_name UUID=>$uuid\n"); } - $node_image_table .= "Run 'xcatprobe image -u UUID' to display a list of compute nodes that have installed OS with specified UUID"; + $node_image_table .= "Run 'xcatprobe image -u UUID' to display a list of diskless nodes that have OS installed with the specified UUID"; } else { - #Produce list output for small system + # Produce list output for small system foreach $compute_node (sort keys %node_running_image_name_hash) { $node_image_table .= sprintf(" %-15s %-30s : %-20s\n", $compute_node, $node_running_image_name_hash{$compute_node}, $node_running_image_uuid_hash{$compute_node}); } } - $msg = "Not all diskless pingable compute nodes are installed with the same os image.\n" . $node_image_table; + $msg = "Not all diskless nodes are installed with the same OS image.\n" . $node_image_table; $status = "f"; } }