diff --git a/xCAT-server/lib/xcat/plugins/blade.pm b/xCAT-server/lib/xcat/plugins/blade.pm index 418d0e4bf..1dcbc75c2 100644 --- a/xCAT-server/lib/xcat/plugins/blade.pm +++ b/xCAT-server/lib/xcat/plugins/blade.pm @@ -928,6 +928,7 @@ sub rscan_stanza { sub getmacs { (my $code,my @macs)=inv('mac'); my $midx=0; + my @midxary; my $nrtab = xCAT::Table->new('noderes'); if ($nrtab) { my $nent = $nrtab->getNodeAttribs($curn,['primarynic','installnic']); @@ -939,24 +940,36 @@ sub getmacs { $mkey="primarynic"; } if ($mkey) { - $nent->{$mkey} =~ /(\d+)/; - $midx=$1; + while ( $nent->{$mkey} =~ /(\d+)/g ) { + push @midxary,$1; + } } } } if ($code==0) { #my @macs = split /\n/,$macs; - (my $macd,my $mac) = split (/:/,$macs[$midx],2); - $mac =~ s/\s+//g; - if ($macd =~ /mac address \d/i) { - $mac =~ s/\s*->.*$//; - my $mactab = xCAT::Table->new('mac',-create=>1); - $mactab->setNodeAttribs($curn,{mac=>$mac}); - $mactab->close; - return 0,":mac.mac set to $mac"; - } else { - return 1,"Unable to retrieve MAC address from Management Module"; - } + my @allmacs; + foreach my $midx ( @midxary) { + (my $macd,my $mac) = split (/:/,$macs[$midx],2); + $mac =~ s/\s+//g; + if ($macd =~ /mac address \d/i) { + $mac =~ s/\s*->.*$//; + } else { + return 1,"Unable to retrieve MAC address for interface $midx from Management Module"; + } + + if ( $#midxary == 0 ) { #-- backward compatibility mode - do not add host name to mac.mac if only one iface is used + push @allmacs,$mac; + } else { + push @allmacs,$mac."!".$curn."e".$midx; + } + } + + my $macstring = join("|",@allmacs); + my $mactab = xCAT::Table->new('mac',-create=>1); + $mactab->setNodeAttribs($curn,{mac=>$macstring}); + $mactab->close; + return 0,":mac.mac set to $macstring"; } else { return $code,$macs[0]; } diff --git a/xCAT-server/share/xcat/netboot/sles/genimage b/xCAT-server/share/xcat/netboot/sles/genimage index ad1a4cf1b..7f9023e3d 100755 --- a/xCAT-server/share/xcat/netboot/sles/genimage +++ b/xCAT-server/share/xcat/netboot/sles/genimage @@ -388,12 +388,20 @@ EOMS open($inifile,">"."/tmp/xcatinitrd.$$/bin/netstart"); print $inifile "#!/bin/bash\n"; print $inifile "dhcpcd $prinic\n"; - print $inifile "echo -n 'search '> /etc/resolv.conf\n"; - print $inifile "grep DOMAIN /var/lib/dhcpcd/*info|awk -F= '{print \$2}'|awk -F\\' '{print \$2}' >> /etc/resolv.conf\n"; - print $inifile "grep HOSTNAME /var/lib/dhcpcd/*info|awk -F= '{print \$2}'|awk -F\\' '{print \$2}' >> /etc/HOSTNAME\n"; - print $inifile "for names in `grep DNS /var/lib/dhcpcd/*info|awk -F= '{print \$2}'`; do\n"; - print $inifile ' echo nameserver $names >> /etc/resolv.conf'."\n"; - print $inifile "done\n"; + + #-- Bring other NICs up in /bin/netstart in initrd for NIC failover + foreach (split /,/,$othernics) { + if (/^$/) { next; } + print $inifile "dhcpcd $_\n"; + } + + print $inifile <> /etc/resolv.conf +cat /var/lib/dhcpcd/*info | grep HOSTNAME | uniq | awk -F= '{print \$2}'| sed \"s/'//g\" >> /etc/HOSTNAME +for names in \$(cat /var/lib/dhcpcd/*info | grep DNS | uniq | awk -F= '{print \$2}' | sed 's/,/\\n/'); do + echo nameserver \$names >> /etc/resolv.conf +done +END close($inifile); chmod(0755,"/tmp/xcatinitrd.$$/init"); @@ -404,7 +412,7 @@ EOMS push @filestoadd,[$_,"lib/$_"]; } } - foreach ("usr/bin/grep","bin/cpio","bin/sleep","bin/mount","sbin/dhcpcd","bin/bash","sbin/insmod","bin/mkdir","bin/mknod","sbin/ip","bin/cat","usr/bin/awk","usr/bin/wget","bin/cp","usr/bin/cpio","usr/bin/zcat","lib/mkinitrd/bin/run-init") { + foreach ("usr/bin/grep","bin/cpio","bin/sleep","bin/mount","sbin/dhcpcd","bin/bash","sbin/insmod","bin/mkdir","bin/mknod","sbin/ip","bin/cat","usr/bin/awk","usr/bin/wget","bin/cp","usr/bin/cpio","usr/bin/zcat","lib/mkinitrd/bin/run-init","usr/bin/uniq","usr/bin/sed") { getlibs($_); push @filestoadd,$_; }