From 27a2292995de8e3261e6804a4c1a6727a7c902fb Mon Sep 17 00:00:00 2001 From: ertaozh Date: Thu, 30 Aug 2018 06:17:10 -0400 Subject: [PATCH 1/3] To have bmcdiscover matching pre-defined node with lc(mtm)*lc(serial)-ip --- xCAT-server/lib/xcat/plugins/bmcdiscover.pm | 30 +++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/xCAT-server/lib/xcat/plugins/bmcdiscover.pm b/xCAT-server/lib/xcat/plugins/bmcdiscover.pm index 291ded928..aa00efa2f 100644 --- a/xCAT-server/lib/xcat/plugins/bmcdiscover.pm +++ b/xCAT-server/lib/xcat/plugins/bmcdiscover.pm @@ -540,6 +540,35 @@ sub check_auth_process { } } +sub buildup_mtms_hash { + xCAT::MsgUtils->trace(0, "I", "Establish hash for vpd table with key=mtm*serial, value=node"); + my %nodehash = (); + if (my $vpdtab = xCAT::Table->new("vpd")) { + my @entries = $vpdtab->getAllAttribs(qw/node serial mtm/); + foreach (@entries) { + unless ($_->{mtm} and $_->{serial}) { next; } + my $mtms = lc($_->{mtm}) . "*" . lc($_->{serial}); + $nodehash{$_->{node}} = $mtms; + } + } + foreach my $tab (qw/ipmi openbmc/) { + my $tabfd = xCAT::Table->new($tab); + my $entries = $tabfd->getAllAttribs(qw/node bmc/); + foreach (@entries) { + unless($_->{bmc}) { next; } + my $node = $_->{node}; + if (exists($nodehash{$node})) { + my $mtmsip = $nodehash{$node}."-".$_->{bmc}; + $nodehash{$node} = $mtmsip; + } + } + } + foreach my $node (keys %nodehash) { + my $mtmsip = $nodehash{$node}; + push @{ $::VPDHASH{$mtmsip} }, $node; + } +} + #---------------------------------------------------------------------------- =head3 scan_process @@ -619,6 +648,7 @@ sub scan_process { my $live_mac = split_comma_delim_str($mac_list); my %pipe_map; if (scalar(@{$live_ip}) > 0) { + xCAT::MsgUtils->trace(0, "I", "$log_label Scaned live IPs " . scalar(@{$live_ip}) . " with mac " . scalar(@{$live_mac})); foreach (@{$live_ip}) { my $new_mac = lc(shift @{$live_mac}); From 7f379abeb4963d880e77b91f82787933a6322787 Mon Sep 17 00:00:00 2001 From: ertaozh Date: Fri, 31 Aug 2018 05:39:47 -0400 Subject: [PATCH 2/3] Enhance bmcdiscover to match nodes with mtm,serial,bmcip before creating new nodes --- xCAT-server/lib/xcat/plugins/bmcdiscover.pm | 46 +++++++++++++++++---- 1 file changed, 38 insertions(+), 8 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/bmcdiscover.pm b/xCAT-server/lib/xcat/plugins/bmcdiscover.pm index aa00efa2f..02dec2a6b 100644 --- a/xCAT-server/lib/xcat/plugins/bmcdiscover.pm +++ b/xCAT-server/lib/xcat/plugins/bmcdiscover.pm @@ -51,7 +51,7 @@ my $openbmc_pass; my $done_num = 0; $::P9_WITHERSPOON_MFG_ID = "42817"; $::P9_WITHERSPOON_PRODUCT_ID = "16975"; - +%::VPDHASH = (); my %node_in_list = (); #------------------------------------------------------- @@ -551,21 +551,39 @@ sub buildup_mtms_hash { $nodehash{$_->{node}} = $mtms; } } + my @nodes = keys %nodehash; foreach my $tab (qw/ipmi openbmc/) { my $tabfd = xCAT::Table->new($tab); - my $entries = $tabfd->getAllAttribs(qw/node bmc/); - foreach (@entries) { - unless($_->{bmc}) { next; } - my $node = $_->{node}; + my $entries = $tabfd->getNodesAttribs(\@nodes,qw/bmc/); + foreach my $node (@nodes) { + my $bmc = $entries->{$node}->[0]->{bmc}; + unless($bmc) { next; } if (exists($nodehash{$node})) { - my $mtmsip = $nodehash{$node}."-".$_->{bmc}; + my $mtmsip = $nodehash{$node}."-".$bmc; $nodehash{$node} = $mtmsip; } } } + my @tmp_bmc_nodes = (); foreach my $node (keys %nodehash) { my $mtmsip = $nodehash{$node}; - push @{ $::VPDHASH{$mtmsip} }, $node; + if (exists($::VPDHASH{$mtmsip})) { + my $tmp_node = $::VPDHASH{$mtmsip}; + if ($tmp_node =~ /node-.+/) { + push @tmp_bmc_nodes, $tmp_node; + } elsif ($node =~ /node-.+/) { + $::VPDHASH{$mtmsip} = $node; + push @tmp_bmc_nodes, $node; + } else { + xCAT::MsgUtils->message("W", { data => ["Node $node and $tmp_node have the same mtms-ip keys: $mtmsip"] }, $::CALLBACK); + } + next; + } + $::VPDHASH{$mtmsip} = $node; + } + if ($#tmp_bmc_nodes > 0) { + my $useless_nodes = join(',', @tmp_bmc_nodes); + xCAT::MsgUtils->message("W", { data => ["The nodes: $useless_nodes have normal nodes defined, please remove them"] }, $::CALLBACK); } } @@ -698,7 +716,7 @@ sub scan_process { } } }; - + buildup_mtms_hash(); for (my $i = 0 ; $i < scalar(@{$live_ip}) ; $i++) { # fork a sub process to handle the communication with service processor @@ -1153,6 +1171,12 @@ sub bmcdiscovery_ipmi { } $node_data .= ",mp,bmc"; if ($mtm and $serial) { + my $mtmsip = lc($mtm)."*".lc($serial)."-".$ip; + if (exists($::VPDHASH{$mtmsip})) { + my $pre_node = $::VPDHASH{$mtmsip}; + xCAT::MsgUtils->message("I", { data => ["Match node $pre_node with bmc ip address: $ip"] }, $::CALLBACK); + return; + } $mtms_node = "node-$mtm-$serial"; $mtms_node =~ s/(.*)/\L$1/g; $mtms_node =~ s/[\s:\._]/-/g; @@ -1276,6 +1300,12 @@ sub bmcdiscovery_openbmc{ } $node_data .= ",mp,bmc"; if ($mtm and $serial) { + my $mtmsip = lc($mtm)."*".lc($serial)."-".$ip; + if (exists($::VPDHASH{$mtmsip})) { + my $pre_node = $::VPDHASH{$mtmsip}; + xCAT::MsgUtils->message("I", { data => ["Match node $pre_node with bmc ip address: $ip"] }, $::CALLBACK); + return; + } $mtms_node = "node-$mtm-$serial"; $mtms_node =~ s/(.*)/\L$1/g; $mtms_node =~ s/[\s:\._]/-/g; From 7e4c3f4eff96e150ade8a653c3bc4a63ab3909c1 Mon Sep 17 00:00:00 2001 From: ertaozh Date: Tue, 4 Sep 2018 22:21:05 -0400 Subject: [PATCH 3/3] Update output message if bmcdiscover matching a pre-defined node --- xCAT-server/lib/xcat/plugins/bmcdiscover.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/bmcdiscover.pm b/xCAT-server/lib/xcat/plugins/bmcdiscover.pm index 02dec2a6b..d77639548 100644 --- a/xCAT-server/lib/xcat/plugins/bmcdiscover.pm +++ b/xCAT-server/lib/xcat/plugins/bmcdiscover.pm @@ -1174,7 +1174,7 @@ sub bmcdiscovery_ipmi { my $mtmsip = lc($mtm)."*".lc($serial)."-".$ip; if (exists($::VPDHASH{$mtmsip})) { my $pre_node = $::VPDHASH{$mtmsip}; - xCAT::MsgUtils->message("I", { data => ["Match node $pre_node with bmc ip address: $ip"] }, $::CALLBACK); + xCAT::MsgUtils->message("I", { data => ["Found match node $pre_node with bmc ip address: $ip, rsetboot/rpower $pre_node to continue hardware discovery."] }, $::CALLBACK); return; } $mtms_node = "node-$mtm-$serial"; @@ -1303,7 +1303,7 @@ sub bmcdiscovery_openbmc{ my $mtmsip = lc($mtm)."*".lc($serial)."-".$ip; if (exists($::VPDHASH{$mtmsip})) { my $pre_node = $::VPDHASH{$mtmsip}; - xCAT::MsgUtils->message("I", { data => ["Match node $pre_node with bmc ip address: $ip"] }, $::CALLBACK); + xCAT::MsgUtils->message("I", { data => ["Found match node $pre_node with bmc ip address: $ip, rsetboot/rpower $pre_node to continue hardware discovery."] }, $::CALLBACK); return; } $mtms_node = "node-$mtm-$serial";