Merge branch 'master' of ssh://git.code.sf.net/p/xcat/xcat-core
This commit is contained in:
commit
3757a0aeec
@ -59,8 +59,13 @@ sub addKernelParms {
|
||||
|
||||
# replace <nodename> with the nodename
|
||||
my $nodename = $ENV{NODE}; # this env var is set by xdsh
|
||||
if (!$nodename){
|
||||
my $tmpstr=$args->{kernelparms};
|
||||
my @strhost=split(' ',$tmpstr);
|
||||
my @tempname=split('=',$strhost[7]);
|
||||
$nodename=$tempname[1];
|
||||
}
|
||||
$args->{kernelparms} =~ s/<nodename>/$nodename/g;
|
||||
|
||||
# get node ip and add it to the kernel parms
|
||||
my ($nic, $ip, $netmask, $network, $broadcast, $gateway, $mac) = getNodeIpInfo($args);
|
||||
if (!$ip) { die "Error: could not find the NIC that would connect to the xCAT mgmt node's IP (".$args->{mnip}.").\n"; }
|
||||
@ -83,6 +88,7 @@ sub addKernelParms {
|
||||
else { # scripted install
|
||||
#todo: the parameters for kickstart are likely different
|
||||
$args->{kernelparms} .= " $bootif hostip=$ip netmask=$netmask gateway=$gateway dns=$mnip hostname=$nodename netdevice=$nic netwait=$WAITTIME textmode=1";
|
||||
# print Dumper($args->{kernelparms})
|
||||
}
|
||||
}
|
||||
|
||||
@ -94,7 +100,7 @@ sub getNodeIpInfo {
|
||||
verbose("using IP prefix $ipprefix");
|
||||
|
||||
# parse ip addr show output, looking for ipprefix, to determine nic, ip, mac
|
||||
my @output = runcmd("ip addr show");
|
||||
my @output = runcmd("/sbin/ip addr show");
|
||||
my ($nic, $mac, $ipandmask);
|
||||
foreach my $line (@output) {
|
||||
my ($nictmp, $mactmp, $iptmp);
|
||||
@ -148,7 +154,7 @@ sub getNodeIpInfo {
|
||||
|
||||
# finally, find the gateway
|
||||
my $gateway;
|
||||
my @output = runcmd("ip route");
|
||||
my @output = runcmd("/sbin/ip route");
|
||||
# we are looking for a line like: 10.0.0.0/8 via 10.54.51.1 dev bond0
|
||||
my @networks = grep(m/ via .* $nic\s*$/, @output);
|
||||
if (scalar(@networks)) { ($gateway) = $networks[0]=~m/ via\s+(\S+)/; }
|
||||
|
@ -54,6 +54,7 @@ if ($bootparms{osimageprovmethod} eq 'sysclone') { copySyscloneFiles(); }
|
||||
|
||||
exit(0);
|
||||
|
||||
sub isRedhat { return (-e '/etc/redhat-release' || -e '/etc/centos-release' || -e '/etc/fedora-release'); }
|
||||
|
||||
# Query the db for the kernel, initrd, and kcmdline attributes of the 1st node in the noderange
|
||||
sub getBootParms {
|
||||
@ -132,7 +133,17 @@ sub updateGrubOnNodes {
|
||||
my @output = runcmd('which modifygrub');
|
||||
my $modifygrub = $output[0];
|
||||
chomp($modifygrub);
|
||||
my $cmd = "xdsh $nr -e $modifygrub $vtxt $dtxt -w $WAITTIME -p " . $bootparms->{osimageprovmethod} . ' ' . remoteFilename($bootparms->{kernel}) . ' ' . remoteFilename($bootparms->{initrd}) . ' ';
|
||||
my @auser = runcmd('whoami');
|
||||
chop(@auser);
|
||||
my $cmd;
|
||||
if($auser[0] eq "root")
|
||||
{
|
||||
$cmd = "xdsh $nr -e $modifygrub $vtxt $dtxt -w $WAITTIME -p " . $bootparms->{osimageprovmethod} . ' ' . remoteFilename($bootparms->{kernel}) . ' ' . remoteFilename($bootparms->{initrd}) . ' ';
|
||||
}
|
||||
else
|
||||
{
|
||||
$cmd = "xdsh $nr -l $auser[0] --sudo -e $modifygrub $vtxt $dtxt -w $WAITTIME -p " . $bootparms->{osimageprovmethod} . ' ' . remoteFilename($bootparms->{kernel}) . ' ' . remoteFilename($bootparms->{initrd}) . ' ';
|
||||
}
|
||||
# we need to quote the kernel parms, both here when passing it to xdsh, and on the node
|
||||
# when xdsh is passing it to modifygrub. The way to get single quotes inside single quotes
|
||||
# is to quote each of the outer single quotes with double quotes.
|
||||
@ -216,8 +227,16 @@ sub modifyAutoinstFiles {
|
||||
foreach my $n (@nodes) {
|
||||
my $f = "/install/autoinst/$n";
|
||||
my ($ip, $netmask, $gateway) = getNodeIpInfo($n);
|
||||
runcmd("sed -i 's/#NODEIPADDR#/$ip/;s/#NODENETMASK#/$netmask/;s/#NODEGATEWAY#/$gateway/' $f");
|
||||
|
||||
my @auser = runcmd('whoami');
|
||||
chop(@auser);
|
||||
if($auser[0] eq "root")
|
||||
{
|
||||
runcmd("sed -i 's/#NODEIPADDR#/$ip/;s/#NODENETMASK#/$netmask/;s/#NODEGATEWAY#/$gateway/' $f");
|
||||
}
|
||||
else
|
||||
{
|
||||
runcmd("sudo sed -i 's/#NODEIPADDR#/$ip/;s/#NODENETMASK#/$netmask/;s/#NODEGATEWAY#/$gateway/' $f");
|
||||
}
|
||||
my $matches = sed($f, $search, $replace, mode=>'insertbefore');
|
||||
if (!$matches) { die "Error: could not find the right place in $f to insert the sed of the network wait.\n"; }
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user