diff --git a/perl-xCAT/xCAT/Utils.pm b/perl-xCAT/xCAT/Utils.pm index a284eb806..f8efb5dd0 100755 --- a/perl-xCAT/xCAT/Utils.pm +++ b/perl-xCAT/xCAT/Utils.pm @@ -4232,4 +4232,68 @@ sub disableservice{ xCAT::Utils->runcmd($cmd, -1); return $::RUNCMD_RC; } + +sub cleanup_for_powerLE_hardware_discovery { + my $host_node = shift; + if( $host_node =~ /xCAT::Utils/) + { + $host_node=shift; + } + my $pbmc_node = shift; + my $subreq = shift; + my $ipmitab = xCAT::Table->new("ipmi"); + unless($ipmitab) { + xCAT::MsgUtils->message("S", "Discovery Error: can not open ipmi table."); + return; + } + my @nodes = ($host_node, $pbmc_node); + my $ipmihash = $ipmitab->getNodesAttribs(\@nodes, ['node', 'bmc', 'username', 'password']); + if ($ipmihash) { + my $new_bmc_ip = $ipmihash->{$host_node}->[0]->{bmc}; + my $new_bmc_password = $ipmihash->{$host_node}->[0]->{password}; + + xCAT::MsgUtils->message("S", "Discovery info: configure password for pbmc_node:$pbmc_node."); + `rspconfig $pbmc_node password=$new_bmc_password`; + #if ($new_bmc_password) { + # xCAT::Utils->runxcmd( + # { + # command => ["rspconfig"], + # node => ["$pbmc_node"], + # arg => [ "password=$new_bmc_password" ], + # }, + # $subreq, 0,1); + # if ($::RUNCMD_RC != 0) { + # xCAT::MsgUtils->message("S", "Discovery Error: configure password failed for FSP."); + # return; + # } + #} + + xCAT::MsgUtils->message("S", "Discover info: configure ip:$new_bmc_ip for pbmc_node:$pbmc_node."); + `rspconfig $pbmc_node ip=$new_bmc_ip`; + #if($new_bmc_ip) { + # xCAT::Utils->runxcmd( + # { + # command => ["rspconfig"], + # node => ["$pbmc_node"], + # arg => [ "ip=$new_bmc_ip" ], + # }, + # $subreq, 0,1); + # if ($::RUNCMD_RC != 0) { + # xCAT::MsgUtils->message("S", "Discovery Error: configure IP address failed for FSP."); + # return; + # } + #} + xCAT::MsgUtils->message("S", "Discovery info: remove pbmc_node:$pbmc_node."); + `rmdef $pbmc_node`; + #xCAT::Utils->runxcmd( + # { + # command => ["rmdef"], + # node => ["$pbmc_node"], + # }, + # $subreq, 0,1); + } +} + + + 1; diff --git a/xCAT-server/lib/perl/xCAT/PPC.pm b/xCAT-server/lib/perl/xCAT/PPC.pm index 8699034a0..95063a76c 100644 --- a/xCAT-server/lib/perl/xCAT/PPC.pm +++ b/xCAT-server/lib/perl/xCAT/PPC.pm @@ -2175,76 +2175,25 @@ sub findme { } @nodes = keys (%nodes_hash); } - foreach (@nodes) { + my $nodenum = $#nodes; + if ($nodenum < 0) { + xCAT::MsgUtils->message("S", "Discovery Error: Could not find any node."); + return; + } elsif ($nodenum > 0) { + xCAT::MsgUtils->message("S", "Discovery Error: More than one node were found."); + return; + } + { my $req = {%$request}; $req->{command} = ['discovered']; - $req->{noderange} = [$_]; + $req->{noderange} = [$nodes[0]]; + $req->{pbmc_node} = [$pbmc_node]; $req->{discoverymethod} = ['mtms']; $subreq->($req); %{$req} = (); } - &cleanup_for_powerLE_hardware_discovery($nodes[-1], $pbmc_node, $subreq); } -sub cleanup_for_powerLE_hardware_discovery { - my $host_node = shift; - my $pbmc_node = shift; - my $subreq = shift; - my $ipmitab = xCAT::Table->new("ipmi"); - unless($ipmitab) { - xCAT::MsgUtils->message("S", "Discovery Error: can not open ipmi table."); - return; - } - my @nodes = ($host_node, $pbmc_node); - my $ipmihash = $ipmitab->getNodesAttribs(\@nodes, ['node', 'bmc', 'username', 'password']); - if ($ipmihash) { - my $new_bmc_ip = $ipmihash->{$host_node}->[0]->{bmc}; - my $new_bmc_password = $ipmihash->{$host_node}->[0]->{password}; - - xCAT::MsgUtils->message("S", "Discover info: configure ip:$new_bmc_ip for pbmc_node:$pbmc_node."); - if($new_bmc_ip) { - xCAT::Utils->runxcmd( - { - command => ["rspconfig"], - node => ["$pbmc_node"], - arg => [ "ip=$new_bmc_ip" ], - }, - $subreq, 0,1); - if ($::RUNCMD_RC != 0) { - xCAT::MsgUtils->message("S", "Discovery Error: configure IP address failed for FSP."); - return; - } - xCAT::Utils->runxcmd( - { - command => ["chdef"], - node => ["$pbmc_node"], - arg => [ "bmc=$new_bmc_ip" ], - }, - $subreq, 0,1); - } - xCAT::MsgUtils->message("S", "Discovery info: configure password:$new_bmc_password for pbmc_node:$pbmc_node."); - if ($new_bmc_password) { - xCAT::Utils->runxcmd( - { - command => ["rspconfig"], - node => ["$pbmc_node"], - arg => [ "password=$new_bmc_password" ], - }, - $subreq, 0,1); - if ($::RUNCMD_RC != 0) { - xCAT::MsgUtils->message("S", "Discovery Error: configure password failed for FSP."); - return; - } - } - xCAT::MsgUtils->message("S", "Discovery info: remove pbmc_node:$pbmc_node."); - xCAT::Utils->runxcmd( - { - command => ["rmdef"], - node => ["$pbmc_node"], - }, - $subreq, 0,1); - } -} ########################################################################## # Process request from xCat daemon ########################################################################## diff --git a/xCAT-server/lib/xcat/plugins/nodediscover.pm b/xCAT-server/lib/xcat/plugins/nodediscover.pm index f5a8e88ea..d8b3c1c32 100644 --- a/xCAT-server/lib/xcat/plugins/nodediscover.pm +++ b/xCAT-server/lib/xcat/plugins/nodediscover.pm @@ -353,6 +353,10 @@ sub process_request { $callback->({error=> ["The node [$node] should have a correct IP address which belongs to the management network."], errorcode=>["1"]}); return; } + if (defined ($request->{pbmc_node})) { + my $pbmc_node = $request->{pbmc_node}->[0]; + xCAT::Utils->cleanup_for_powerLE_hardware_discovery($node, $pbmc_node, $doreq); + } my $restartstring = "restart"; if (scalar @forcenics > 0) {