From a2d89b5d69667811fb47fd1c01538a2a3e296970 Mon Sep 17 00:00:00 2001 From: daniceexi Date: Wed, 11 Feb 2015 02:30:36 -0500 Subject: [PATCH 1/5] Continue the change to refine installnic and primarynic code --- perl-xCAT/xCAT/NetworkUtils.pm | 4 ++ perl-xCAT/xCAT/Utils.pm | 47 +++++++++++++----------- xCAT-server/lib/xcat/plugins/anaconda.pm | 27 +++++++++----- xCAT-server/lib/xcat/plugins/debian.pm | 5 +-- 4 files changed, 48 insertions(+), 35 deletions(-) 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} "; } From 860600e782adeee614645139add5bbc740727410 Mon Sep 17 00:00:00 2001 From: ertaozh Date: Wed, 11 Feb 2015 02:36:36 -0500 Subject: [PATCH 2/5] fix bug 4556: There are some failed message during Ubuntu ppc64le stateless provision --- xCAT-server/share/xcat/netboot/ubuntu/genimage | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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`; From 35e6a500a898e21f977cc1f45b0f4027c53db7fd Mon Sep 17 00:00:00 2001 From: daniceexi Date: Wed, 11 Feb 2015 02:51:18 -0500 Subject: [PATCH 3/5] sles.pm, more code change for installnic/primarynic code refine --- xCAT-server/lib/xcat/plugins/sles.pm | 107 +-------------------------- 1 file changed, 2 insertions(+), 105 deletions(-) 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"; From 3faba40ece6eee8d2ba305dcdee67cafc6ed5ccb Mon Sep 17 00:00:00 2001 From: immarvin Date: Wed, 11 Feb 2015 01:19:56 -0800 Subject: [PATCH 4/5] uncomment the updates/security/src entries and correct some entries in source.list --- xCAT-server/share/xcat/install/scripts/post.ubuntu | 6 +++--- xCAT-server/share/xcat/install/ubuntu/compute.tmpl | 2 +- xCAT-server/share/xcat/install/ubuntu/service.tmpl | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/xCAT-server/share/xcat/install/scripts/post.ubuntu b/xCAT-server/share/xcat/install/scripts/post.ubuntu index d8f948fe7..80a6ea669 100755 --- a/xCAT-server/share/xcat/install/scripts/post.ubuntu +++ b/xCAT-server/share/xcat/install/scripts/post.ubuntu @@ -32,7 +32,7 @@ done >>/etc/resolv.conf ln -sf /bin/bash /bin/sh # #delete the useless apt repo -sed -i 's/^deb.*updates.*$/#&/g' /etc/apt/sources.list +#sed -i 's/^deb.*updates.*$/#&/g' /etc/apt/sources.list # Run xCAT post install # export MASTER_IP="#XCATVAR:XCATMASTER#" @@ -230,9 +230,9 @@ script end script EOF fi -sed -i 's/\(deb.*security.*\)/#\1/' /etc/apt/sources.list +#sed -i 's/\(deb.*security.*\)/#\1/' /etc/apt/sources.list #iso does not contains source deb packages -sed -i 's/^\(\s*deb-src.*install.*\)$/#\1/g' /etc/apt/sources.list +#sed -i 's/^\(\s*deb-src.*install.*\)$/#\1/g' /etc/apt/sources.list #delete the 127.0.1.1 line from /etc/hosts sed -i '/127.0.1.1/d' /etc/hosts updateflag.awk $MASTER 3002 diff --git a/xCAT-server/share/xcat/install/ubuntu/compute.tmpl b/xCAT-server/share/xcat/install/ubuntu/compute.tmpl index 7f12d69cd..a0d3fa0cc 100644 --- a/xCAT-server/share/xcat/install/ubuntu/compute.tmpl +++ b/xCAT-server/share/xcat/install/ubuntu/compute.tmpl @@ -100,7 +100,7 @@ tasksel tasksel/first multiselect standard d-i pkgsel/include string #INCLUDE_DEFAULT_PKGLIST_PRESEED# -d-i debian-installer/allow_unauthenticated string true +d-i debian-installer/allow_unauthenticated boolean true d-i pkgsel/update-policy select none d-i pkgsel/updatedb boolean false diff --git a/xCAT-server/share/xcat/install/ubuntu/service.tmpl b/xCAT-server/share/xcat/install/ubuntu/service.tmpl index 8e7cbac67..ca87469ee 100644 --- a/xCAT-server/share/xcat/install/ubuntu/service.tmpl +++ b/xCAT-server/share/xcat/install/ubuntu/service.tmpl @@ -100,7 +100,7 @@ tasksel tasksel/first multiselect standard d-i pkgsel/include string #INCLUDE_DEFAULT_PKGLIST_PRESEED# -d-i debian-installer/allow_unauthenticated string true +d-i debian-installer/allow_unauthenticated boolean true d-i pkgsel/update-policy select none d-i pkgsel/updatedb boolean false From 9598c45746d7d1e64a2648edddf06f373dc6d9f9 Mon Sep 17 00:00:00 2001 From: immarvin Date: Wed, 11 Feb 2015 03:12:38 -0800 Subject: [PATCH 5/5] add support for online mirrors in pkgdir during provision --- xCAT-server/lib/xcat/plugins/debian.pm | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/debian.pm b/xCAT-server/lib/xcat/plugins/debian.pm index 3daa675e9..199e99ca6 100755 --- a/xCAT-server/lib/xcat/plugins/debian.pm +++ b/xCAT-server/lib/xcat/plugins/debian.pm @@ -506,6 +506,8 @@ sub mkinstall my $profile; my $tmplfile; my $pkgdir; + my $pkgdirval; + my @mirrors; my $pkglistfile; my $imagename; # set it if running of 'nodeset osimage=xxx' my $platform; @@ -580,13 +582,23 @@ sub mkinstall $arch = $ph->{osarch}; $profile = $ph->{profile}; $platform=xCAT_plugin::debian::getplatform($os); + + $tmplfile=$ph->{template}; + $pkgdirval=$ph->{pkgdir}; + my @pkgdirlist=split(/,/,$pkgdirval); + foreach (@pkgdirlist){ + if($_ =~ /^http|ssh/){ + push @mirrors,$_; + }else{ + $pkgdir=$_; + } + + } - $tmplfile=$ph->{template}; - $pkgdir=$ph->{pkgdir}; if (!$pkgdir) { $pkgdir="$installroot/$os/$arch"; } - $pkglistfile=$ph->{pkglist}; + $pkglistfile=$ph->{pkglist}; } else { $os = $ent->{os};