From 1407d0044ef8a16ed9d81f79a556c0d19fe7e354 Mon Sep 17 00:00:00 2001 From: mellor Date: Fri, 19 Sep 2014 08:00:13 -0700 Subject: [PATCH] Do clean up things for Power LE hardware discovery --- xCAT-server/lib/perl/xCAT/PPC.pm | 63 ++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/xCAT-server/lib/perl/xCAT/PPC.pm b/xCAT-server/lib/perl/xCAT/PPC.pm index e32ac42c9..8699034a0 100644 --- a/xCAT-server/lib/perl/xCAT/PPC.pm +++ b/xCAT-server/lib/perl/xCAT/PPC.pm @@ -2157,6 +2157,7 @@ sub findme { my @tmp_nodes = $vpdtab->getAllAttribsWhere(\@attr_array, 'node'); my @nodes = (); + my $pbmc_node; my %nodes_hash = (); foreach (@tmp_nodes) { $nodes_hash{$_->{node}} = '1'; @@ -2169,6 +2170,7 @@ sub findme { foreach (@nodes) { if (defined($ppchash->{$_}->[0]) && defined($ppchash->{$_}->[0]->{'nodetype'}) && $ppchash->{$_}->[0]->{'nodetype'} eq 'pbmc') { delete $nodes_hash{$_}; + $pbmc_node = $_; } } @nodes = keys (%nodes_hash); @@ -2181,6 +2183,67 @@ sub findme { $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