diff --git a/xCAT-SoftLayer/bin/getslnodes b/xCAT-SoftLayer/bin/getslnodes index ae02b6642..d5549ad1c 100755 --- a/xCAT-SoftLayer/bin/getslnodes +++ b/xCAT-SoftLayer/bin/getslnodes @@ -38,8 +38,6 @@ if (scalar(@ARGV)>1) { $usage->(1); } my $hnmatch = $ARGV[0]; # if they specified a hostname match, only show svrs that start with that readconf("$ENV{HOME}/.slconfig"); # get the userid and api key from the config file -#my $api_username = 'SL276540'; -#my $api_key = '799d5d9267a927a330ec016f00bfe17e6fc532d203cf68b3b0d997b2d27a3ce1'; my $slinstalled = eval { push @INC, $CONFIG{apidir}; require SoftLayer::API::SOAP; }; if (!$slinstalled) { die "Error: the SoftLayer::API::SOAP perl module is not installed. Download it using 'git clone https://github.com/softlayer/softlayer-api-perl-client' and put the directory in ~/.slconfig ."; } @@ -64,12 +62,23 @@ foreach my $server (@$servers) { print "\tbmc=".$server->{remoteManagementComponent}->{ipmiIpAddress}."\n"; print "\tbmcusername=".$server->{remoteManagementAccounts}->[0]->{username}."\n"; print "\tbmcpassword=".$server->{remoteManagementAccounts}->[0]->{password}."\n"; - print "\tmac=".$server->{backendNetworkComponents}->[0]->{macAddress}."\n"; - print "\tip=".$server->{privateIpAddress}."\n"; + + # find the 1st active private nic that is not the bmc + foreach my $nic (@{$server->{backendNetworkComponents}}) { + #print "nic:\n"; foreach my $key (keys(%$nic)) { print " $key = ", $nic->{$key}, "\n"; } + if ($nic->{status} eq 'ACTIVE' && $nic->{name} eq 'eth' && $nic->{macAddress} && $nic->{primaryIpAddress}) { + # found it + print "\tmac=".$nic->{macAddress}."\n"; + print "\tip=".$nic->{primaryIpAddress}."\n"; + } + } + #print "\tip=".$server->{privateIpAddress}."\n"; # getting this from the backendNetworkComponents instead + print "\tserial=".$server->{manufacturerSerialNumber}."\n"; print "\tnetboot=xnba\n"; print "\tarch=x86_64\n"; print "\tusercomment=hostname:".$server->{fullyQualifiedDomainName}.", user:".$server->{operatingSystem}->{passwords}->[0]->{username}.", pw:".$server->{operatingSystem}->{passwords}->[0]->{password}."\n"; + verbose('SoftLayer API bare metal server entry: ' . Dumper($server)); #print Dumper($server->{remoteManagementAccounts}); #print "#Softlayer_account_info_for ".$server->{fullyQualifiedDomainName} . " Username: "; #print $server->{operatingSystem}->{passwords}->[0]->{username} . " Password: "; diff --git a/xCAT-SoftLayer/bin/modifygrub b/xCAT-SoftLayer/bin/modifygrub index a6d28407f..07ce948a9 100755 --- a/xCAT-SoftLayer/bin/modifygrub +++ b/xCAT-SoftLayer/bin/modifygrub @@ -60,13 +60,20 @@ sub addKernelParms { $args->{kernelparms} =~ s//$nodename/g; # get node ip and add it to the kernel parms - my ($nic, $ip, $netmask, $gateway) = getNodeIpInfo($args); + my ($nic, $ip, $netmask, $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"; } - $args->{kernelparms} .= " hostip=$ip netmask=$netmask gateway=$gateway dns=$mnip hostname=$nodename netdevice=$nic netwait=$WAITTIME textmode=1"; + # if we are booting genesis, need to add the BOOTIF parm + my $bootif; + if ($args->{kernelpath} =~ m/genesis\.kernel\.x86_64/) { + $bootif = $mac; + $bootif =~ s/:/-/g; + $bootif = "BOOTIF=01-$bootif"; + } + $args->{kernelparms} .= " $bootif hostip=$ip netmask=$netmask gateway=$gateway dns=$mnip hostname=$nodename netdevice=$nic netwait=$WAITTIME textmode=1"; } -# get this nodes nic, ip, netmask, and gateway. Returns them in a 4 element array. +# get this nodes nic, ip, netmask, gateway, and mac. Returns them in a 5 element array. sub getNodeIpInfo { my $args = shift @_; my ($ipprefix) = $args->{mnip}=~m/^(\d+\.\d+)\./; #todo: this is a hack, just using the 1st 2 octets of the mn ip addr @@ -74,10 +81,11 @@ sub getNodeIpInfo { # parse ip addr show output, looking for ipprefix, to determine nic and ip my @output = runcmd("ip addr show"); - my ($nic, $ipandmask); + my ($nic, $mac, $ipandmask); foreach my $line (@output) { - my ($nictmp, $iptmp); + my ($nictmp, $mactmp, $iptmp); if (($nictmp) = $line=~m/^\d+:\s+(\S+): /) { $nic = $nictmp; } # new stanza, remember it + if (($mactmp) = $line=~m|^\s+link/ether\s+(\S+) |) { $mac = $mactmp; } # got mac, remember it if (($iptmp) = $line=~m/^\s+inet\s+($ipprefix\S+) /) { $ipandmask = $iptmp; last; } # got ip, we are done } my ($ip, $netmask) = convertIpAndMask($ipandmask); @@ -88,6 +96,12 @@ sub getNodeIpInfo { my @nics = grep(m/\s+master\s+$nic\s+/, @output); if (!scalar(@nics)) { die "Error: can't find the NICs that are part of $nic.\n"; } ($realnic) = $nics[0]=~m/^\d+:\s+(\S+): /; + # go back thru the ip add show output and find the mac of this nic + foreach my $line (@output) { + my ($nictmp, $mactmp, $foundnic); + if (($nictmp) = $line=~m/^\d+:\s+(\S+): / && $nictmp eq $realnic) { $foundnic = 1; } + if (($mactmp) = $line=~m|^\s+link/ether\s+(\S+) | && $foundnic) { $mac = $mactmp; last; } # got mac, we are done + } } # finally, find the gateway @@ -102,8 +116,8 @@ sub getNodeIpInfo { verbose("using xCAT mgmt node IP as the fall back gateway."); } - verbose("IP info: realnic=$realnic, ip=$ip, netmask=$netmask, gateway=$gateway"); - return ($realnic, $ip, $netmask, $gateway); + verbose("IP info: realnic=$realnic, ip=$ip, netmask=$netmask, gateway=$gateway, mac=$mac"); + return ($realnic, $ip, $netmask, $gateway, $mac); } diff --git a/xCAT-SoftLayer/bin/pushinitrd b/xCAT-SoftLayer/bin/pushinitrd index 7e3cd5a7e..b454a1f77 100755 --- a/xCAT-SoftLayer/bin/pushinitrd +++ b/xCAT-SoftLayer/bin/pushinitrd @@ -45,7 +45,7 @@ copyFilesToNodes($noderange, \%bootparms); updateGrubOnNodes($noderange, \%bootparms); -if (!$NOAUTOINST) { modifyAutoinstFiles($noderange, \%bootparms); } +if ($bootparms{osimageprovmethod} eq 'install' && !$NOAUTOINST) { modifyAutoinstFiles($noderange, \%bootparms); } exit(0); @@ -54,23 +54,28 @@ exit(0); sub getBootParms { my $nr = shift @_; my %bootparms; - my @output = runcmd("nodels $nr bootparams.kernel bootparams.initrd bootparams.kcmdline"); + my @output = runcmd("nodels $nr bootparams.kernel bootparams.initrd bootparams.kcmdline nodetype.provmethod"); # the attributes can be displayed in a different order than requested, so need to grep for them - my @gresults; - foreach my $a (qw(kernel initrd kcmdline)) { - my $attr = "bootparams.$a"; - @gresults = grep(/^\S+:\s+$attr:/, @output); + foreach my $attr (qw(bootparams.kernel bootparams.initrd bootparams.kcmdline nodetype.provmethod)) { + my ($a) = $attr =~ m/\.(.*)$/; + my @gresults = grep(/^\S+:\s+$attr:/, @output); if (!scalar(@gresults)) { die "Error: attribute $attr not defined for the noderange. Did you run 'nodeset osimage=' ?\n"; } # for now just pick the 1st one. They should all be the same, except for the node name in kcmdline chomp($gresults[0]); $gresults[0] =~ s/^\S+:\s+$attr:\s*//; $bootparms{$a} = $gresults[0]; - if ($a eq 'kcmdline') { $bootparms{$a} =~ s|/install/autoinst/\S+|/install/autoinst/|; } } + $bootparms{kcmdline} =~ s|/install/autoinst/\S+|/install/autoinst/|; + + # from the nodes provmethod, get the osimage provmethod, so we know the type of install + @output = runcmd("lsdef -t osimage $bootparms{provmethod} -ci provmethod"); + chomp($output[0]); + my ($junk, $provmethod) = split(/=/, $output[0]); + $bootparms{osimageprovmethod} = $provmethod; # get the mgmt node cluster-facing ip addr - @output = runcmd('lsdef -t site -i master -c'); + @output = runcmd('lsdef -t site -ci master'); chomp($output[0]); my ($junk, $ip) = split(/=/, $output[0]); $bootparms{mnip} = $ip; @@ -99,7 +104,7 @@ sub copyFilesToNodes { # Form the remote file name, using the last 2 parts of the path, separated by "-" sub remoteFilename { my $f = shift @_; - $f =~ s|^.*/([^/]+)/([^/]+)$|$1-$2|; + $f =~ s|^.*?([^/]+)/([^/]+)$|$1-$2|; return $f; }