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} "; }