mirror of
https://github.com/xcat2/xcat-core.git
synced 2025-07-16 17:41:09 +00:00
Merge pull request #5582 from zet809/matching_for_bmcdiscovery
Matching for bmcdiscovery
This commit is contained in:
@@ -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 = ();
|
||||
|
||||
#-------------------------------------------------------
|
||||
@@ -540,6 +540,53 @@ 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;
|
||||
}
|
||||
}
|
||||
my @nodes = keys %nodehash;
|
||||
foreach my $tab (qw/ipmi openbmc/) {
|
||||
my $tabfd = xCAT::Table->new($tab);
|
||||
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;
|
||||
$nodehash{$node} = $mtmsip;
|
||||
}
|
||||
}
|
||||
}
|
||||
my @tmp_bmc_nodes = ();
|
||||
foreach my $node (keys %nodehash) {
|
||||
my $mtmsip = $nodehash{$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);
|
||||
}
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head3 scan_process
|
||||
@@ -619,6 +666,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});
|
||||
@@ -668,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
|
||||
@@ -1123,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 => ["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";
|
||||
$mtms_node =~ s/(.*)/\L$1/g;
|
||||
$mtms_node =~ s/[\s:\._]/-/g;
|
||||
@@ -1246,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 => ["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";
|
||||
$mtms_node =~ s/(.*)/\L$1/g;
|
||||
$mtms_node =~ s/[\s:\._]/-/g;
|
||||
|
Reference in New Issue
Block a user