diff --git a/perl-xCAT/xCAT/NetworkUtils.pm b/perl-xCAT/xCAT/NetworkUtils.pm index 79caf98d4..d6116d783 100755 --- a/perl-xCAT/xCAT/NetworkUtils.pm +++ b/perl-xCAT/xCAT/NetworkUtils.pm @@ -2502,9 +2502,12 @@ sub gen_net_boot_params } elsif ($installnic =~ /^[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}$/) { $mac = $installnic; $net_params->{mac} = $mac; + $net_params->{setmac} = $mac; } else { + $mac = $macmac; $nicname = $installnic; $net_params->{nicname} = $nicname; + $net_params->{mac} = $mac; } if ($nicname) { @@ -2512,6 +2515,7 @@ sub gen_net_boot_params $net_params->{ip} = "ip=$nicname:dhcp"; $net_params->{netdev} = "netdev=$nicname"; $net_params->{netdevice} = "netdevice=$nicname"; + $net_params->{ifname} = "ifname=$nodebootif:$mac"; } elsif ($mac) { $net_params->{ksdevice} = "ksdevice=$mac"; $net_params->{BOOTIF} = "BOOTIF=$mac"; diff --git a/perl-xCAT/xCAT/Utils.pm b/perl-xCAT/xCAT/Utils.pm index 8a9e5e8fc..549ab8618 100755 --- a/perl-xCAT/xCAT/Utils.pm +++ b/perl-xCAT/xCAT/Utils.pm @@ -4468,29 +4468,32 @@ sub cleanup_for_powerLE_hardware_discovery { #This may also be a "|" delimited string of "mac address!hostname" format (such as "01:02:03:04:05:0E!node5|01:02:03:05:0F!node6-eth1"). sub parseMacTabEntry{ - my $macString=shift; - if( $macString =~ /xCAT::Utils/) - { - $macString=shift; + my $macString=shift; + if( $macString =~ /xCAT::Utils/) { + $macString=shift; + } + my $HostName=shift; + + my $mac_ret; + my @macEntry=split(/\|/,$macString); + + foreach my $mac_t (@macEntry){ + if($mac_t =~ /!/){ + if($mac_t =~ /(.+)!$HostName$/){ + $mac_ret=$1; + } + }else{ + $mac_ret=$mac_t; + } + } - } - my $HostName=shift; - - my $mac_ret; - my @macEntry=split(/\|/,$macString); - - foreach my $mac_t (@macEntry){ - if($mac_t =~ /!/){ - if($mac_t =~ /(.+)!$HostName$/){ - $mac_ret=$1; - } - }else{ - $mac_ret=$mac_t; - } - } - - - return $mac_ret; + if ($mac_ret) { + if ($mac_ret !~ /:/) { + $mac_ret =~ s/(..)(..)(..)(..)(..)(..)/$1:$2:$3:$4:$5:$6/; + } + } + + return $mac_ret; } diff --git a/xCAT-server/lib/xcat/plugins/anaconda.pm b/xCAT-server/lib/xcat/plugins/anaconda.pm index 3ff436b20..1861ae340 100755 --- a/xCAT-server/lib/xcat/plugins/anaconda.pm +++ b/xCAT-server/lib/xcat/plugins/anaconda.pm @@ -750,7 +750,7 @@ sub mknetboot my $primarynic; my $mac; if (defined ($reshash->{$node}->[0]) && $reshash->{$node}->[0]->{installnic}) { - $installnic = $reshash->{$node}->[0] and $reshash->{$node}->[0]->{installnic}; + $installnic = $reshash->{$node}->[0]->{installnic}; } if (defined ($reshash->{$node}->[0]) and $reshash->{$node}->[0]->{primarynic}) { $primarynic = $reshash->{$node}->[0]->{primarynic}; @@ -762,8 +762,13 @@ sub mknetboot my $net_params = xCAT::NetworkUtils->gen_net_boot_params($installnic, $primarynic, $mac, $nodebootif); if (defined ($net_params->{ifname}) || defined ($net_params->{netdev})) { - $kcmdline .= "$net_params->{ifname} $net_params->{netdev} "; - } elsif (defined ($net_params->{BOOTIF}) && $arch=~ /ppc/) { + if (defined ($net_params->{ifname})) { + $kcmdline .= "$net_params->{ifname} "; + } + if ( defined ($net_params->{netdev})) { + $kcmdline .= "$net_params->{netdev} "; + } + } elsif (defined ($net_params->{BOOTIF}) && ($net_params->{setmac} || $arch=~ /ppc/)) { $kcmdline .= "$net_params->{BOOTIF} "; } @@ -1386,11 +1391,11 @@ sub mkinstall $ent->{installnic} =~ s/eth/vmnic/g; $ent->{primarynic} =~ s/eth/vmnic/g; } - my $net_params = xCAT::NetworkUtils->gen_net_boot_params($ent->{installnic}, $ent->{primarynic}, $macent->{mac}); -print "ori par: $ent->{installnic}, $ent->{primarynic}, $macent->{mac}\n"; -foreach (keys %{$net_params}) { - print "key[$_} = $net_params->{$_}\n"; -} + my $mac; + if ($macent->{mac}) { + $mac = xCAT::Utils->parseMacTabEntry($macent->{mac}, $node); + } + my $net_params = xCAT::NetworkUtils->gen_net_boot_params($ent->{installnic}, $ent->{primarynic}, $mac); my $nicname = $net_params->{nicname}; @@ -1863,7 +1868,11 @@ sub mksysclone my $kcmdline = "ramdisk_size=$ramdisk_size"; # Add kernel parameters to specify the boot network interface - my $net_params = xCAT::NetworkUtils->gen_net_boot_params($ent->{installnic}, $ent->{primarynic}, $macent->{mac}); + my $mac; + if ($macent->{mac}) { + $mac = xCAT::Utils->parseMacTabEntry($macent->{mac}, $node); + } + my $net_params = xCAT::NetworkUtils->gen_net_boot_params($ent->{installnic}, $ent->{primarynic}, $mac); $kcmdline .= " $net_params->{ksdevice} "; if ($arch =~ /ppc/) { $kcmdline .= " $net_params->{BOOTIF} "; diff --git a/xCAT-server/lib/xcat/plugins/debian.pm b/xCAT-server/lib/xcat/plugins/debian.pm index 3adf885d0..3daa675e9 100755 --- a/xCAT-server/lib/xcat/plugins/debian.pm +++ b/xCAT-server/lib/xcat/plugins/debian.pm @@ -1452,9 +1452,6 @@ sub mknetboot if( $machash->{$node}->[0] && $machash->{$node}->[0]->{'mac'}) { # TODO: currently, only "mac" attribute with classic style is used, the "|" delimited string of "macaddress!hostname" format is not used $mac = xCAT::Utils->parseMacTabEntry($machash->{$node}->[0]->{'mac'},$node); - if ($mac !~ /:/) { - $mac =~s/(..)(..)(..)(..)(..)(..)/$1:$2:$3:$4:$5:$6/; - } } my $net_params = xCAT::NetworkUtils->gen_net_boot_params($installnic, $primarynic, $mac, $nodebootif); if (defined($net_params->{ifname})) { @@ -1462,7 +1459,7 @@ sub mknetboot } if (defined($net_params->{netdev})) { $kcmdline .= "$net_params->{netdev} "; - } elsif (defined($net_params->{BOOTIF})) { + } elsif (defined($net_params->{BOOTIF}) && ($net_params->{setmac} || $arch=~ /ppc/)) { $kcmdline .= "$net_params->{BOOTIF} "; } diff --git a/xCAT-server/lib/xcat/plugins/sles.pm b/xCAT-server/lib/xcat/plugins/sles.pm index bdadc2d48..5ebf2ca38 100755 --- a/xCAT-server/lib/xcat/plugins/sles.pm +++ b/xCAT-server/lib/xcat/plugins/sles.pm @@ -583,30 +583,6 @@ sub mknetboot # add dhcp for ip $kcmdline .= "ip=dhcp "; - # add the kernel-booting parameter: netdev=, or BOOTIF= - #my $netdev = ""; - #my $mac = xCAT::Utils->parseMacTabEntry($machash->{$node}->[0]->{mac},$node); - - #if ($reshash->{$node}->[0] and $reshash->{$node}->[0]->{installnic} and ($reshash->{$node}->[0]->{installnic} ne "mac")) { - # $kcmdline .= "netdev=" . $reshash->{$node}->[0]->{installnic} . " "; - #} elsif ($nodebootif) { - # $kcmdline .= "netdev=" . $nodebootif . " "; - #} elsif ($reshash->{$node}->[0] and $reshash->{$node}->[0]->{primarynic} and ($reshash->{$node}->[0]->{primarynic} ne "mac")) { - # $kcmdline .= "netdev=" . $reshash->{$node}->[0]->{primarynic} . " "; - #} else { - # if ($arch =~ /x86/) { - # #do nothing, we'll let pxe/xnba work their magic - # } elsif ($mac) { - # $kcmdline .= "BOOTIF=" . $mac . " "; - # } else { - # $callback->({ - # error=>[qq{"cannot get the mac address for $node in mac table"}], - # errorcode=>[1] - # }); - # } - #} - - # add the kernel-booting parameter: netdev=, or BOOTIF= my $mac; my $installnic; my $primarynic; @@ -627,7 +603,7 @@ sub mknetboot if (defined ($net_params->{ifname}) || defined ($net_params->{netdev})) { $kcmdline .= " $net_params->{ifname} $net_params->{netdev} "; - } elsif (defined ($net_params->{BOOTIF}) && $arch=~ /ppc/) { + } elsif (defined ($net_params->{BOOTIF}) && ($net_params->{setmac} || $arch=~ /ppc/)) { $kcmdline .= " $net_params->{BOOTIF} "; } @@ -1142,50 +1118,6 @@ sub mkinstall . $netserver . ":" . $httpport . "$httpprefix/1"; - #my $netdev = ""; - #if ($ent->{installnic}) - #{ - # if ($ent->{installnic} eq "mac") - # { - # my $mactab = xCAT::Table->new("mac"); - # my $macref = $mactab->getNodeAttribs($node, ['mac']); - # $netdev = xCAT::Utils->parseMacTabEntry($macref->{mac},$node); - # } - # else - # { - # $netdev = $ent->{installnic}; - # } - #} - #elsif ($ent->{primarynic}) - #{ - # if ($ent->{primarynic} eq "mac") - # { - # my $mactab = xCAT::Table->new("mac"); - # my $macref = $mactab->getNodeAttribs($node, ['mac']); - # $netdev = xCAT::Utils->parseMacTabEntry($macref->{mac},$node); - # } - # else - # { - # $netdev = $ent->{primarynic}; - # } - #} - #else - #{ - # $netdev = "bootif"; - #} - #if ($netdev eq "") #why it is blank, no mac defined? - #{ - # $callback->( - # { - # error => ["No mac.mac for $node defined"], - # errorcode => [1] - # } - # ); - #} - #unless ($netdev eq "bootif") { #if going by bootif, BOOTIF will suffice - # $kcmdline .= " netdevice=" . $netdev; - #} - my $installnic; my $primarynic; my $mac; @@ -1518,30 +1450,6 @@ sub mksysclone my $sent = $hents{$node}->[0]; my $kcmdline = "ramdisk_size=$ramdisk_size"; - #my $ksdev = ""; - #if ($ent->{installnic}) - #{ - # $ksdev = $ent->{installnic}; - #} - #elsif ($ent->{primarynic}) - #{ - # $ksdev = $ent->{primarynic}; - #} - #else - #{ - # $ksdev = "bootif"; #if not specified, fall back to bootif - #} - - #if ($ksdev eq "mac") - #{ - # my $mactab = xCAT::Table->new("mac"); - # my $macref = $mactab->getNodeAttribs($node, ['mac']); - # $ksdev = xCAT::Utils->parseMacTabEntry($macref->{mac},$node); - #} - - #unless ( $ksdev eq "bootif" ) { - # $kcmdline .= " netdevice=" . $ksdev; - #} my $installnic; my $primarynic; @@ -1565,6 +1473,7 @@ sub mksysclone if ($arch =~ /ppc/) { $kcmdline .= " dhcptimeout=150"; + $kcmdline .= " $net_params->{BOOTIF} "; } if (defined($sent->{serialport})) @@ -1586,18 +1495,6 @@ sub mksysclone } $kcmdline .= " XCAT=$xcatmaster:$xcatdport xcatd=$xcatmaster:$xcatdport SCRIPTNAME=$imagename"; - #my $nodetab = xCAT::Table->new('nodetype'); - #my $archref = $nodetab->getNodeAttribs($node, ['arch']); - #if ($archref->{arch} eq "ppc64"){ - # my $mactab = xCAT::Table->new('mac'); - # my $macref = $mactab->getNodeAttribs($node, ['mac']); - # my $formatmac = xCAT::Utils->parseMacTabEntry($macref->{mac},$node); - # $formatmac =~ s/:/-/g; - # $formatmac = "01-".$formatmac; - # $kcmdline .= " BOOTIF=$formatmac "; - #} - $kcmdline .= " $net_params->{BOOTIF} "; - my $i = "xcat/genesis.fs.$arch.gz"; if ( -r "$tftpdir/xcat/genesis.fs.$arch.lzma" ){ $i = "xcat/genesis.fs.$arch.lzma"; diff --git a/xCAT-server/share/xcat/netboot/ubuntu/genimage b/xCAT-server/share/xcat/netboot/ubuntu/genimage index 9c5533159..4ae2c2f19 100755 --- a/xCAT-server/share/xcat/netboot/ubuntu/genimage +++ b/xCAT-server/share/xcat/netboot/ubuntu/genimage @@ -449,7 +449,7 @@ unless ($onlyinitrd) { my %extrapkgnames; if (keys(%extra_hash) > 0) { - open ($aptconfig,">>","$rootimg_dir/etc/apt/sources.list.d/genimage.apt.list"); + open ($aptconfig,">","$rootimg_dir/etc/apt/sources.list.d/genimage1.apt.list"); my $index=1; foreach $pass (sort {$a <=> $b} (keys(%extra_hash))) { foreach (keys(%{$extra_hash{$pass}})) { @@ -558,8 +558,9 @@ unless ($onlyinitrd) { # Add the local repo from MN my $master = xCAT::TableUtils->get_site_Master(); open($aptconfig,">","$rootimg_dir/etc/apt/sources.list"); - print $aptconfig "deb http://$master$installroot/$osver/$arch/ $dist main\n"; + print $aptconfig "deb http://$master$srcdir $dist main\n"; close($aptconfig); + `rm -fr $rootimg_dir/etc/apt/sources.list.d/genimage1.apt.list`; #recover the /etc/hosts & /etc/reslov.conf `cd $rootimg_dir/etc/;mv -f hosts.bak hosts;mv -f resolv.conf.bak resolv.conf`;