From 868d3229a333b43c18c5a3fb56bcd4c2e252fc61 Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Fri, 6 May 2011 20:11:07 +0000 Subject: [PATCH] Have getbmcconfig work with multi-chassis bmc config git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@9509 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/bmcconfig.pm | 26 ++++++++++++++--------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/bmcconfig.pm b/xCAT-server/lib/xcat/plugins/bmcconfig.pm index f478aa09a..a94eae565 100644 --- a/xCAT-server/lib/xcat/plugins/bmcconfig.pm +++ b/xCAT-server/lib/xcat/plugins/bmcconfig.pm @@ -3,6 +3,7 @@ package xCAT_plugin::bmcconfig; use Data::Dumper; use xCAT::Table; use xCAT::MsgUtils; +use xCAT::Utils; use IO::Select; use Socket; @@ -44,6 +45,9 @@ sub net_parms { my $masknum = ($1<<24)+($2<<16)+($3<<8)+$4; $net =~ /([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)/; my $netnum = ($1<<24)+($2<<16)+($3<<8)+$4; + if ($gw eq '') { + $gw=xCAT::Utils->my_ip_facing($ip); + } if (($ipnum & $masknum)==$netnum) { return ($ip,$mask,$gw); } @@ -131,17 +135,19 @@ sub process_request { $callback->({error=>["Invalid table configuration for bmcconfig"],errorcode=>[1]}); return 1; } - (my $ip,my $mask,my $gw) = net_parms($bmc); - unless ($ip and $mask and $username and $password) { - xCAT::MsgUtils->message('S',"Unable to determine IP, netmask, username, and/or pasword for $bmc, ensure that host resolution is working. Best guess parameters would have been: IP: '$ip', netmask: '$netmask', username: '$username', password: '$password'", ); - $callback->({error=>["Invalid table configuration for bmcconfig"],errorcode=>[1]}); - return 1; + foreach my $sbmc (split /,/,$bmc) { + (my $ip,my $mask,my $gw) = net_parms($sbmc); + unless ($ip and $mask and $username and $password) { + xCAT::MsgUtils->message('S',"Unable to determine IP, netmask, username, and/or pasword for $sbmc, ensure that host resolution is working. Best guess parameters would have been: IP: '$ip', netmask: '$netmask', username: '$username', password: '$password'", ); + $callback->({error=>["Invalid table configuration for bmcconfig"],errorcode=>[1]}); + return 1; + } + my $response={bmcip=>$ip,netmask=>$mask,gateway=>$gw,username=>$username,password=>$password}; + if (defined $bmcport) { + $response->{bmcport}=$bmcport; + } + $callback->($response); } - my $response={bmcip=>$ip,netmask=>$mask,gateway=>$gw,username=>$username,password=>$password}; - if (defined $bmcport) { - $response->{bmcport}=$bmcport; - } - $callback->($response); if ($gennedpassword) { # save generated password $ipmitable->setNodeAttribs($node,{password=>$password}); }