From 1d8a1ff27c88cd24c42caf2e7401f0a65c75742f Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Tue, 13 Sep 2016 16:57:46 -0400 Subject: [PATCH 1/4] Probe to catch duplicate MTM+SERIAL node definitions --- xCAT-probe/subcmds/uniq_definitions | 180 ++++++++++++++++++++++++++++ 1 file changed, 180 insertions(+) create mode 100755 xCAT-probe/subcmds/uniq_definitions diff --git a/xCAT-probe/subcmds/uniq_definitions b/xCAT-probe/subcmds/uniq_definitions new file mode 100755 index 000000000..1311ce583 --- /dev/null +++ b/xCAT-probe/subcmds/uniq_definitions @@ -0,0 +1,180 @@ +#! /usr/bin/perl +# IBM(c) 2016 EPL license http://www.eclipse.org/legal/epl-v10.html + +BEGIN { $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : -d '/opt/xcat' ? '/opt/xcat' : '/usr'; } + +use lib "$::XCATROOT/probe/lib/perl"; +use probe_utils; +use File::Basename; +use Net::Ping; +use Getopt::Long qw(:config no_ignore_case); + +use Data::Dumper; +use warnings; + +my $program_name = basename("$0"); +my $help; +my $noderange = ""; +my $test; +my $output = "stdout"; +my $verbose = 0; +my $rst = 0; +# Match pattern for discovered nodes: node-1234-ABCDE-123456 +# node- d+ -[a-z]- d+ +my $discovered_node_pattern = '^node-\d+-[a-zA-Z]+-\d+'; + +$::USAGE = "Usage: + $program_name -h + $program_name [-d] [-n noderange] [-V] + +Description: + Use this command to check if any node defintions in xCAT DB have duplicate model type and serial numbers. + +Options: + -h : Get usage information of $program_name + -n : Range of nodes to check + -d : Remode duplicate model type and serial number node definition from xCAT DB + -V : To print additional debug information. +"; + +#------------------------------------- +# main process +#------------------------------------- +if ( + !GetOptions("--help|h" => \$help, + "T" => \$test, + "V" => \$VERBOSE, + "n=s" => \$noderange, + "d" => \$DELETE_DUPLICATE)) +{ + probe_utils->send_msg("$output", "f", "Invalid parameter for $program_name"); + probe_utils->send_msg("$output", "d", "$::USAGE"); + exit 1; +} + +if ($help) { + if ($output ne "stdout") { + probe_utils->send_msg("$output", "d", "$::USAGE"); + } else { + print "$::USAGE"; + } + exit 0; +} + +if ($test) { + probe_utils->send_msg("$output", "o", "Use this command to check if any node defintions in xCAT DB have duplicate model type and serial numbers."); + exit 0; +} + +if (scalar(@ARGV) >= 1) { + + # After processing all the expected flags and arguments, + # there is still left over stuff on the command line + probe_utils->send_msg("$output", "f", "Invalid flag or parameter: @ARGV"); + probe_utils->send_msg("$output", "d", "$::USAGE"); + exit 1; +} + +my $na = "N/A"; + +my %node_mtm_serial_hash; +my %mtm_serial_node_hash; +my %waiting_to_be_discovered; + +my $all_nodes_mtm_serial = `lsdef -i mtm,serial -c $noderange`; +chomp($all_nodes_mtm_serial); +my @all_nodes_mtm_serial_lines = split("[\n\r]", $all_nodes_mtm_serial); + +if ($all_nodes_mtm_serial =~ /Usage:/) { + + # lsdef command displayed a Usage message. Must be some noderange formatting problem. + # Issue a warning and exit. + probe_utils->send_msg("$output", "w", "Can not get a list of nodes from specified noderange."); + exit 1; +} + +if (scalar(@all_nodes_mtm_serial_lines) <= 0) { + + # There were no nodes matching the noderange. Issue a warning and exit. + probe_utils->send_msg("$output", "w", "No nodes matching the noderange were found."); + exit 1; +} + +# Build a hash of key="nodename" value="mtm+serial" +foreach (@all_nodes_mtm_serial_lines) { + probe_utils->send_msg("$output", "d", "Processing $_.") if ($VERBOSE); + my ($node_name, $value) = split ":", $_; + if (exists($node_mtm_serial_hash{$node_name})) { + # already have an entry for this node with mtm, concat the serial + $value = $node_mtm_serial_hash{$node_name} . $value; + } + $node_mtm_serial_hash{$node_name} = $value; +} + +#print Dumper(\%node_mtm_serial_hash) if ($VERBOSE); + +# Build a hash of key="mtm+serial" value = "nodename" for all non-empty mtm+serial +my $any_dups = 0; +while (($node_name, $mtm_serial) = each %node_mtm_serial_hash) { + # Check if hash already has the same key indicating another node definition has the same mtm+serial + if (exists($mtm_serial_node_hash{$mtm_serial})) { + if ($mtm_serial eq " mtm= serial=") { + # Exclude entries that do not have mtm+serial set + probe_utils->send_msg("$output", "d", "No mtm and no serial for node $node_name") if ($VERBOSE); + next; + } + probe_utils->send_msg("$output", "f", "Duplicate node definition for $mtm_serial : $node_name and $mtm_serial_node_hash{$mtm_serial}."); + + # Remove entries from waiting_to_be_discovered hash if duplicate entry is detected + if ($node_name =~ /$discovered_node_pattern/) { + #probe_utils->send_msg("$output", "d", "Pattern match discovered node: $node_name") if ($VERBOSE); + if (exists($waiting_to_be_discovered{$node_name})) { + delete $waiting_to_be_discovered{$node_name}; + if ($DELETE_DUPLICATE) { + # Removing duplicat node entry + probe_utils->send_msg("$output", "d", "Removing node definition: $node_name") if ($VERBOSE); + my $remove_result = `rmdef $node_name`; + } + } + } + else { + if ($mtm_serial_node_hash{$mtm_serial} =~ /$discovered_node_pattern/) { + #probe_utils->send_msg("$output", "d", "Pattern match discovered node: $mtm_serial_node_hash{$mtm_serial}") if ($VERBOSE); + $node_name = $mtm_serial_node_hash{$mtm_serial}; + if (exists($waiting_to_be_discovered{$node_name})) { + delete $waiting_to_be_discovered{$node_name}; + if ($DELETE_DUPLICATE) { + # Removing duplicat node entry + probe_utils->send_msg("$output", "d", "Removing node definition: $node_name") if ($VERBOSE); + my $remove_result = `rmdef $node_name`; + } + } + } + } + $any_dups = 1; + } + else { + $mtm_serial_node_hash{$mtm_serial} = $node_name; + if ($node_name =~ /$discovered_node_pattern/) { + # probe_utils->send_msg("$output", "d", "Pattern match discovered node: $node_name") if ($VERBOSE); + # Add node to waiting_to_be_discovered hash, if later duplicate is found, this entry will be deleted + $waiting_to_be_discovered{$node_name} = 1; + } + } +} + +#print Dumper(\%mtm_serial_node_hash) if ($VERBOSE); +#print Dumper(\%waiting_to_be_discovered) if ($VERBOSE); + +unless ($any_dups) { + probe_utils->send_msg("$output", "o", "No nodes with duplicate mtm and serial numbers were found."); +} + + +# Display all discovered nodes (starting with "node-" that do not have a corresponding predefined node +foreach (keys %waiting_to_be_discovered) { + probe_utils->send_msg("$output", "o", "$_: Waiting to be discovered"); +} + + +exit 0; From f7a1fed233d1e78fcb8dab1ba85e20f037fc6372 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Tue, 20 Sep 2016 14:41:27 -0400 Subject: [PATCH 2/4] Rework probe based on code review --- xCAT-probe/subcmds/nodecheck | 218 ++++++++++++++++++++++++++++ xCAT-probe/subcmds/uniq_definitions | 180 ----------------------- 2 files changed, 218 insertions(+), 180 deletions(-) create mode 100755 xCAT-probe/subcmds/nodecheck delete mode 100755 xCAT-probe/subcmds/uniq_definitions diff --git a/xCAT-probe/subcmds/nodecheck b/xCAT-probe/subcmds/nodecheck new file mode 100755 index 000000000..d025b53a9 --- /dev/null +++ b/xCAT-probe/subcmds/nodecheck @@ -0,0 +1,218 @@ +#! /usr/bin/perl +# IBM(c) 2016 EPL license http://www.eclipse.org/legal/epl-v10.html + +BEGIN { $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : -d '/opt/xcat' ? '/opt/xcat' : '/usr'; } + +use lib "$::XCATROOT/probe/lib/perl"; +use probe_utils; +use File::Basename; +use Net::Ping; +use Getopt::Long qw(:config no_ignore_case); + +use Data::Dumper; +use warnings; + +my $program_name = basename("$0"); +my $help; +my $noderange = ""; +my $test; +my $output = "stdout"; +my $verbose = 0; +my $rst = 0; + +# Match pattern for discovered nodes: node-1234-ABCDE-123456 +# node- d+ -[a-z]- d+ +#my $discovered_node_pattern = '^node-\d+-[a-zA-Z]+-\d+'; +my $discovered_node_pattern = '^node-*'; + +$::USAGE = "Usage: + $program_name -h + $program_name -c {duplicate_mtm|valid_node_attributes} [-d|delete_duplicate] [-n noderange] [-V|--verbose] + +Description: + Use this command to check node defintions in xCAT DB. + +Options: + -h : Get usage information of $program_name + -n : Range of nodes to check + -c : Check node definitions in xCAT DB + duplicate_mtm : Check for node definitions with duplicate model type and serial numbers + valid_node_attributes : Check for validity of attributes in node definitions + -d : Remove duplicate model type and serial number node definition from xCAT DB + -V : To print additional debug information. +"; + +#------------------------------------- +# main process +#------------------------------------- +if ( + !GetOptions("--help|h" => \$help, + "T" => \$test, + "V|verbose" => \$VERBOSE, + "n=s" => \$noderange, + "c=s" => \$what_to_check, + "d|delete_duplicate" => \$DELETE_DUPLICATE)) +{ + probe_utils->send_msg("$output", "f", "Invalid parameter for $program_name"); + probe_utils->send_msg("$output", "d", "$::USAGE"); + exit 1; +} + +if ($help) { + if ($output ne "stdout") { + probe_utils->send_msg("$output", "d", "$::USAGE"); + } else { + print "$::USAGE"; + } + exit 0; +} + +if ($what_to_check) { + if ($what_to_check eq "duplicate_mtm") { + $CHECK_MTM_SN = 1; + } + + if ($what_to_check eq "valid_node_attributes") { + $VALID_NODE_ATTRIBUTES = 1; + } +} + +if ($DELETE_DUPLICATE) { + unless ($CHECK_MTM_SN) { + probe_utils->send_msg("$output", "f", "delete_duplicate parameter can only be used with duplicate_mtm parameter."); + probe_utils->send_msg("$output", "d", "$::USAGE"); + exit 1; + } +} + +if ($test) { + probe_utils->send_msg("$output", "o", "Use this command to check node defintions in xCAT DB."); + exit 0; +} + +if (scalar(@ARGV) >= 1) { + + # After processing all the expected flags and arguments, + # there is still left over stuff on the command line + probe_utils->send_msg("$output", "f", "Invalid flag or parameter: @ARGV"); + probe_utils->send_msg("$output", "d", "$::USAGE"); + exit 1; +} + +if ($CHECK_MTM_SN) { + my $rc = check_for_duplicate_mtms_sn(); + exit $rc; +} elsif ($VALID_NODE_ATTRIBUTES) { + my $rc = check_for_valid_node_attributes(); + exit $rc; +} else { + probe_utils->send_msg("$output", "d", "Unknown type of node checking to perform: $what_to_check"); + probe_utils->send_msg("$output", "d", "$::USAGE"); + exit 1; +} + +# Check for node definitions with duplicate MTM+SERIAL +sub check_for_duplicate_mtms_sn { + my $na = "N/A"; + + my %node_mtm_serial_hash; + my %mtm_serial_node_hash; + my %waiting_to_be_discovered; + + my $all_nodes_mtm_serial = `lsdef -i mtm,serial -c $noderange 2> /dev/null`; + chomp($all_nodes_mtm_serial); + my @all_nodes_mtm_serial_lines = split("[\n\r]", $all_nodes_mtm_serial); + + if ($all_nodes_mtm_serial =~ /Usage:/) { + + # lsdef command displayed a Usage message. Must be some noderange formatting problem. + # Issue a warning and exit. + probe_utils->send_msg("$output", "w", "Can not get a list of nodes from specified noderange."); + return 1; + } + + if (scalar(@all_nodes_mtm_serial_lines) <= 0) { + + # There were no nodes matching the noderange. Issue a warning and exit. + probe_utils->send_msg("$output", "w", "No nodes matching the noderange were found."); + return 1; + } + + # Build a hash of key="nodename" value="mtm+serial" + foreach (@all_nodes_mtm_serial_lines) { + probe_utils->send_msg("$output", "d", "Processing $_.") if ($VERBOSE); + my ($node_name, $value) = split ":", $_; + if (exists($node_mtm_serial_hash{$node_name})) { + + # already have an entry for this node with mtm, concat the serial + $value = $node_mtm_serial_hash{$node_name} . $value; + if ($node_name =~ /$discovered_node_pattern/) { + probe_utils->send_msg("$output", "d", "Pattern match discovered for node: $node_name") if ($VERBOSE); + + # Build a hash of key="mtm+serial" and value="nodename". Later entry will be removed if + # predefined node found with the same mtm + serial found + $waiting_to_be_discovered{$value} = $node_name; + } + } + $node_mtm_serial_hash{$node_name} = $value; + + } + + #print Dumper(\%node_mtm_serial_hash) if ($VERBOSE); + + # Build a hash of key="mtm+serial" value = "nodename" for all non-empty mtm+serial + my $any_dups = 0; + while (($node_name, $mtm_serial) = each %node_mtm_serial_hash) { + + # Check if hash already has the same key indicating another node definition has the same mtm+serial + if (exists($mtm_serial_node_hash{$mtm_serial})) { + if ($mtm_serial eq " mtm= serial=") { + + # Exclude entries that do not have mtm+serial set + probe_utils->send_msg("$output", "d", "No mtm and no serial for node $node_name") if ($VERBOSE); + next; + } + probe_utils->send_msg("$output", "f", "Duplicate found for machine with $mtm_serial : $node_name and $mtm_serial_node_hash{$mtm_serial}"); + if ($DELETE_DUPLICATE) { + + # Removing node definition of the duplicate node entry + probe_utils->send_msg("$output", "d", "Removing node definition: $mtm_serial_node_hash{$mtm_serial}") if ($VERBOSE); + my $remove_result = `rmdef $mtm_serial_node_hash{$mtm_serial}`; + } + + # Remove entries from waiting_to_be_discovered hash if duplicate entry is detected + delete $waiting_to_be_discovered{$mtm_serial}; + $any_dups = 1; + } + else { + $mtm_serial_node_hash{$mtm_serial} = $node_name; + } + } + + #print Dumper(\%mtm_serial_node_hash) if ($VERBOSE); + #print Dumper(\%waiting_to_be_discovered) if ($VERBOSE); + + my $rc = 1; + unless ($any_dups) { + probe_utils->send_msg("$output", "o", "No nodes with duplicate mtm and serial numbers were found."); + $rc = 0; + } + + + # Display all discovered nodes (starting with "node-" that do not have a corresponding predefined node + foreach (values %waiting_to_be_discovered) { + probe_utils->send_msg("$output", "o", "$_: Waiting to be discovered"); + } + return $rc; +} + +# Check attributes in node definitions for valid format +sub check_for_valid_node_attributes { + my $na = "N/A"; + + my $rc = 1; + + probe_utils->send_msg("$output", "d", "Probe to check for valid node attributes is not yet implemented."); + + return $rc; +} diff --git a/xCAT-probe/subcmds/uniq_definitions b/xCAT-probe/subcmds/uniq_definitions deleted file mode 100755 index 1311ce583..000000000 --- a/xCAT-probe/subcmds/uniq_definitions +++ /dev/null @@ -1,180 +0,0 @@ -#! /usr/bin/perl -# IBM(c) 2016 EPL license http://www.eclipse.org/legal/epl-v10.html - -BEGIN { $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : -d '/opt/xcat' ? '/opt/xcat' : '/usr'; } - -use lib "$::XCATROOT/probe/lib/perl"; -use probe_utils; -use File::Basename; -use Net::Ping; -use Getopt::Long qw(:config no_ignore_case); - -use Data::Dumper; -use warnings; - -my $program_name = basename("$0"); -my $help; -my $noderange = ""; -my $test; -my $output = "stdout"; -my $verbose = 0; -my $rst = 0; -# Match pattern for discovered nodes: node-1234-ABCDE-123456 -# node- d+ -[a-z]- d+ -my $discovered_node_pattern = '^node-\d+-[a-zA-Z]+-\d+'; - -$::USAGE = "Usage: - $program_name -h - $program_name [-d] [-n noderange] [-V] - -Description: - Use this command to check if any node defintions in xCAT DB have duplicate model type and serial numbers. - -Options: - -h : Get usage information of $program_name - -n : Range of nodes to check - -d : Remode duplicate model type and serial number node definition from xCAT DB - -V : To print additional debug information. -"; - -#------------------------------------- -# main process -#------------------------------------- -if ( - !GetOptions("--help|h" => \$help, - "T" => \$test, - "V" => \$VERBOSE, - "n=s" => \$noderange, - "d" => \$DELETE_DUPLICATE)) -{ - probe_utils->send_msg("$output", "f", "Invalid parameter for $program_name"); - probe_utils->send_msg("$output", "d", "$::USAGE"); - exit 1; -} - -if ($help) { - if ($output ne "stdout") { - probe_utils->send_msg("$output", "d", "$::USAGE"); - } else { - print "$::USAGE"; - } - exit 0; -} - -if ($test) { - probe_utils->send_msg("$output", "o", "Use this command to check if any node defintions in xCAT DB have duplicate model type and serial numbers."); - exit 0; -} - -if (scalar(@ARGV) >= 1) { - - # After processing all the expected flags and arguments, - # there is still left over stuff on the command line - probe_utils->send_msg("$output", "f", "Invalid flag or parameter: @ARGV"); - probe_utils->send_msg("$output", "d", "$::USAGE"); - exit 1; -} - -my $na = "N/A"; - -my %node_mtm_serial_hash; -my %mtm_serial_node_hash; -my %waiting_to_be_discovered; - -my $all_nodes_mtm_serial = `lsdef -i mtm,serial -c $noderange`; -chomp($all_nodes_mtm_serial); -my @all_nodes_mtm_serial_lines = split("[\n\r]", $all_nodes_mtm_serial); - -if ($all_nodes_mtm_serial =~ /Usage:/) { - - # lsdef command displayed a Usage message. Must be some noderange formatting problem. - # Issue a warning and exit. - probe_utils->send_msg("$output", "w", "Can not get a list of nodes from specified noderange."); - exit 1; -} - -if (scalar(@all_nodes_mtm_serial_lines) <= 0) { - - # There were no nodes matching the noderange. Issue a warning and exit. - probe_utils->send_msg("$output", "w", "No nodes matching the noderange were found."); - exit 1; -} - -# Build a hash of key="nodename" value="mtm+serial" -foreach (@all_nodes_mtm_serial_lines) { - probe_utils->send_msg("$output", "d", "Processing $_.") if ($VERBOSE); - my ($node_name, $value) = split ":", $_; - if (exists($node_mtm_serial_hash{$node_name})) { - # already have an entry for this node with mtm, concat the serial - $value = $node_mtm_serial_hash{$node_name} . $value; - } - $node_mtm_serial_hash{$node_name} = $value; -} - -#print Dumper(\%node_mtm_serial_hash) if ($VERBOSE); - -# Build a hash of key="mtm+serial" value = "nodename" for all non-empty mtm+serial -my $any_dups = 0; -while (($node_name, $mtm_serial) = each %node_mtm_serial_hash) { - # Check if hash already has the same key indicating another node definition has the same mtm+serial - if (exists($mtm_serial_node_hash{$mtm_serial})) { - if ($mtm_serial eq " mtm= serial=") { - # Exclude entries that do not have mtm+serial set - probe_utils->send_msg("$output", "d", "No mtm and no serial for node $node_name") if ($VERBOSE); - next; - } - probe_utils->send_msg("$output", "f", "Duplicate node definition for $mtm_serial : $node_name and $mtm_serial_node_hash{$mtm_serial}."); - - # Remove entries from waiting_to_be_discovered hash if duplicate entry is detected - if ($node_name =~ /$discovered_node_pattern/) { - #probe_utils->send_msg("$output", "d", "Pattern match discovered node: $node_name") if ($VERBOSE); - if (exists($waiting_to_be_discovered{$node_name})) { - delete $waiting_to_be_discovered{$node_name}; - if ($DELETE_DUPLICATE) { - # Removing duplicat node entry - probe_utils->send_msg("$output", "d", "Removing node definition: $node_name") if ($VERBOSE); - my $remove_result = `rmdef $node_name`; - } - } - } - else { - if ($mtm_serial_node_hash{$mtm_serial} =~ /$discovered_node_pattern/) { - #probe_utils->send_msg("$output", "d", "Pattern match discovered node: $mtm_serial_node_hash{$mtm_serial}") if ($VERBOSE); - $node_name = $mtm_serial_node_hash{$mtm_serial}; - if (exists($waiting_to_be_discovered{$node_name})) { - delete $waiting_to_be_discovered{$node_name}; - if ($DELETE_DUPLICATE) { - # Removing duplicat node entry - probe_utils->send_msg("$output", "d", "Removing node definition: $node_name") if ($VERBOSE); - my $remove_result = `rmdef $node_name`; - } - } - } - } - $any_dups = 1; - } - else { - $mtm_serial_node_hash{$mtm_serial} = $node_name; - if ($node_name =~ /$discovered_node_pattern/) { - # probe_utils->send_msg("$output", "d", "Pattern match discovered node: $node_name") if ($VERBOSE); - # Add node to waiting_to_be_discovered hash, if later duplicate is found, this entry will be deleted - $waiting_to_be_discovered{$node_name} = 1; - } - } -} - -#print Dumper(\%mtm_serial_node_hash) if ($VERBOSE); -#print Dumper(\%waiting_to_be_discovered) if ($VERBOSE); - -unless ($any_dups) { - probe_utils->send_msg("$output", "o", "No nodes with duplicate mtm and serial numbers were found."); -} - - -# Display all discovered nodes (starting with "node-" that do not have a corresponding predefined node -foreach (keys %waiting_to_be_discovered) { - probe_utils->send_msg("$output", "o", "$_: Waiting to be discovered"); -} - - -exit 0; From e6b6bbe08132fc445593cd4fc7b2a896bb53c571 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Mon, 26 Sep 2016 14:08:17 -0400 Subject: [PATCH 3/4] Remove flag for a specific check. The probe will do all the verifications it can. --- xCAT-probe/subcmds/nodecheck | 43 +++++------------------------------- 1 file changed, 6 insertions(+), 37 deletions(-) diff --git a/xCAT-probe/subcmds/nodecheck b/xCAT-probe/subcmds/nodecheck index d025b53a9..f763530c1 100755 --- a/xCAT-probe/subcmds/nodecheck +++ b/xCAT-probe/subcmds/nodecheck @@ -19,6 +19,7 @@ my $test; my $output = "stdout"; my $verbose = 0; my $rst = 0; +my $rc = 0; # Match pattern for discovered nodes: node-1234-ABCDE-123456 # node- d+ -[a-z]- d+ @@ -27,7 +28,7 @@ my $discovered_node_pattern = '^node-*'; $::USAGE = "Usage: $program_name -h - $program_name -c {duplicate_mtm|valid_node_attributes} [-d|delete_duplicate] [-n noderange] [-V|--verbose] + $program_name [-d|delete_duplicate] [-n noderange] [-V|--verbose] Description: Use this command to check node defintions in xCAT DB. @@ -35,9 +36,6 @@ Description: Options: -h : Get usage information of $program_name -n : Range of nodes to check - -c : Check node definitions in xCAT DB - duplicate_mtm : Check for node definitions with duplicate model type and serial numbers - valid_node_attributes : Check for validity of attributes in node definitions -d : Remove duplicate model type and serial number node definition from xCAT DB -V : To print additional debug information. "; @@ -50,7 +48,6 @@ if ( "T" => \$test, "V|verbose" => \$VERBOSE, "n=s" => \$noderange, - "c=s" => \$what_to_check, "d|delete_duplicate" => \$DELETE_DUPLICATE)) { probe_utils->send_msg("$output", "f", "Invalid parameter for $program_name"); @@ -67,24 +64,6 @@ if ($help) { exit 0; } -if ($what_to_check) { - if ($what_to_check eq "duplicate_mtm") { - $CHECK_MTM_SN = 1; - } - - if ($what_to_check eq "valid_node_attributes") { - $VALID_NODE_ATTRIBUTES = 1; - } -} - -if ($DELETE_DUPLICATE) { - unless ($CHECK_MTM_SN) { - probe_utils->send_msg("$output", "f", "delete_duplicate parameter can only be used with duplicate_mtm parameter."); - probe_utils->send_msg("$output", "d", "$::USAGE"); - exit 1; - } -} - if ($test) { probe_utils->send_msg("$output", "o", "Use this command to check node defintions in xCAT DB."); exit 0; @@ -99,17 +78,9 @@ if (scalar(@ARGV) >= 1) { exit 1; } -if ($CHECK_MTM_SN) { - my $rc = check_for_duplicate_mtms_sn(); - exit $rc; -} elsif ($VALID_NODE_ATTRIBUTES) { - my $rc = check_for_valid_node_attributes(); - exit $rc; -} else { - probe_utils->send_msg("$output", "d", "Unknown type of node checking to perform: $what_to_check"); - probe_utils->send_msg("$output", "d", "$::USAGE"); - exit 1; -} +$rc = check_for_duplicate_mtms_sn(); +$rc = check_for_valid_node_attributes(); +exit $rc; # Check for node definitions with duplicate MTM+SERIAL sub check_for_duplicate_mtms_sn { @@ -210,9 +181,7 @@ sub check_for_duplicate_mtms_sn { sub check_for_valid_node_attributes { my $na = "N/A"; - my $rc = 1; - - probe_utils->send_msg("$output", "d", "Probe to check for valid node attributes is not yet implemented."); + my $rc = 0; return $rc; } From a04b973af7ed88bd05730574be9cdc45351b89b0 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Mon, 26 Sep 2016 15:33:47 -0400 Subject: [PATCH 4/4] Remove RC for each probe step --- xCAT-probe/subcmds/nodecheck | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/xCAT-probe/subcmds/nodecheck b/xCAT-probe/subcmds/nodecheck index f763530c1..bd198b4d0 100755 --- a/xCAT-probe/subcmds/nodecheck +++ b/xCAT-probe/subcmds/nodecheck @@ -19,7 +19,6 @@ my $test; my $output = "stdout"; my $verbose = 0; my $rst = 0; -my $rc = 0; # Match pattern for discovered nodes: node-1234-ABCDE-123456 # node- d+ -[a-z]- d+ @@ -78,9 +77,8 @@ if (scalar(@ARGV) >= 1) { exit 1; } -$rc = check_for_duplicate_mtms_sn(); -$rc = check_for_valid_node_attributes(); -exit $rc; +check_for_duplicate_mtms_sn(); +check_for_valid_node_attributes(); # Check for node definitions with duplicate MTM+SERIAL sub check_for_duplicate_mtms_sn {