snmove command honor the <xcatmaster> keyword in the networks table

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@9319 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
linggao 2011-04-14 19:34:11 +00:00
parent dc0f504997
commit 7b8875ea77

View File

@ -306,6 +306,7 @@ sub process_request
# get the network info for each node
# $nethash{nodename}{networks attr name} = value
my %nethash = xCAT::DBobjUtils->getNetwkInfo(\@nodes);
#print Dumper(%nethash);
# determine the xcatmaster value for the new SN
foreach my $node (@nodes)
@ -593,6 +594,103 @@ sub process_request
#
# for both AIX and Linux systems
#
# setup the default gateway if the network.gateway=xcatmaster for the node
my %nethash;
my %ipmap=();
my %gwhash=();
my $nwtab=xCAT::Table->new("networks");
if ($nwtab) {
my @tmp1=$nwtab->getAllAttribs(('net','mask','gateway','mgtifname'));
if (@tmp1 && (@tmp1 > 0)) {
foreach my $nwitem (@tmp1) {
my $gw=$nwitem->{'gateway'};
if (!$gw) {
next;
}
chomp $gw;
if ($gw ne '<xcatmaster>') {
next;
}
#now only handle the networks that has <xcatmaster> as the gateway
my $NM = $nwitem->{'mask'};
my $net=$nwitem->{'net'};
my $ifname=$nwitem->{'mgtifname'};
chomp $NM;
chomp $net;
chomp $ifname;
#print "NM=$NM, net=$net, ifname=$ifname, nodes=@nodes\n";
# for each node - get the network info
foreach my $node (@nodes)
{
# get, check, split the node IP
my $IP = xCAT::NetworkUtils->getipaddr($node);
chomp $IP;
# check the entries of the networks table
# - if the bitwise AND of the IP and the netmask gives you
# the "net" name then that is the entry you want.
if(xCAT::NetworkUtils->ishostinsubnet($IP, $NM, $net))
{
my $newmaster=$newxcatmaster{$node};
my $newmasterIP;
if (exists($ipmap{$newmaster})) {
$newmasterIP=$ipmap{$newmaster};
} else {
$newmasterIP = xCAT::NetworkUtils->getipaddr($newmaster);
chomp($newmasterIP);
$ipmap{$newmaster}=$newmasterIP;
}
$nethash{$node}{'gateway'}=$newmasterIP;
$nethash{$node}{'net'} = $net;
$nethash{$node}{'mask'} = $NM;
$nethash{$node}{'mgtifname'} = $ifname;
if ($newmasterIP) {
if (exists($gwhash{$newmasterIP})) {
my $pa=$gwhash{$newmasterIP};
push (@$pa, $node);
} else {
$gwhash{$newmasterIP}=[$node];
}
}
}
}
}
}
}
if (keys(%gwhash) > 0) {
my $rsp;
$rsp->{data}->[0]="Setting up the default routes on the nodes.";
xCAT::MsgUtils->message("I", $rsp, $callback);
}
foreach my $gw (keys %gwhash) {
my $cmd="route add default gw"; #this is temporary,TODO, set perminant route on the nodes.
if (xCAT::Utils->isAIX()) {
$cmd="route add default";
}
my $ret =
xCAT::Utils->runxcmd(
{
command => ['xdsh'],
node => $gwhash{$gw},
arg => ["-v", "$cmd $gw"],
},
$sub_req, -1, 1
);
if ($::RUNCMD_RC != 0)
{
$error++;
}
my $rsp;
$rsp->{data}=$ret;
xCAT::MsgUtils->message("I", $rsp, $callback);
}
# run postscripts to take care of syslog, ntp, and mkresolvconf
# - if they are included in the postscripts table
if (!$::IGNORE) # unless the user does not want us to touch the node
@ -751,7 +849,7 @@ sub process_request
return $retcode;
}
}
#----------------------------------------------------------------------------
@ -891,3 +989,4 @@ sub usage
return 0;
}