From 13d8331ff727ca32bd5c206c0b8dd07e7a8a1e9a Mon Sep 17 00:00:00 2001 From: daniceexi Date: Mon, 9 Feb 2015 07:02:19 -0500 Subject: [PATCH 01/12] refine the code to use installnic and primarynic to generate network boot kernel parameters. All the logic to use installnic/primarynic have been put in NetworkUtils->gen_net_boot_params --- perl-xCAT/xCAT/NetworkUtils.pm | 96 ++++++++ xCAT-server/lib/xcat/plugins/anaconda.pm | 283 +++++------------------ 2 files changed, 160 insertions(+), 219 deletions(-) diff --git a/perl-xCAT/xCAT/NetworkUtils.pm b/perl-xCAT/xCAT/NetworkUtils.pm index 5b138bd31..79caf98d4 100755 --- a/perl-xCAT/xCAT/NetworkUtils.pm +++ b/perl-xCAT/xCAT/NetworkUtils.pm @@ -2428,6 +2428,102 @@ sub get_all_nicips{ } } +#------------------------------------------------------------------------------- +=head3 gen_net_boot_params + + Description: + This subroutine is used to generate all possible kernel parameters for network boot (rh/sles/ubuntu + diskfull/diskless) + The supported network boot parameters: + ksdevice - Specify network device for Anaconda. For rh6 and earlier. Format: 'ksdevice={$mac|$nicname}' + BOOTIF - Specify network device for Anaconda. The boot device which set by pxe. xCAT also set it if the bootload is not pxe. Format 'BOOTIF={$mac}' + ifname - Specify a interfacename<->mac pair, it will set the interfacename to the interface which has the . Format 'ifname=$ifname:$mac' + # This will only be generated when linuximage.nodebootif is set. + bootdev - Specify the boot device. Mostly it's used with parameter and when there are multiple params. Format 'bootdev={$mac|$ifname} + ip - Specify the network configuration for an interface. Format: 'ip=dhcp', 'ip=$ifname:dhcp' + + netdevice - Specify network device for Linuxrc (Suse bootloader). Format: 'netdevice={$mac|$nicname}' + + netdev - Specify the interfacename which is used by xCAT diskless boot script to select the network interface. Format: 'netdev=$nicname' + + Reference: + Redhat anaconda doc: https://github.com/rhinstaller/anaconda/blob/master/docs/boot-options.txt + Suse Linuxrc do: https://en.opensuse.org/SDB:Linuxrc + + Arguments: + $installnic <- node.installnic + $primarynic <- node.primarynic + $macmac <- node.mac + $nodebootif <- linuximage.nodebootif + + Returns: + $net_params - The key will be the parameter name, the value for the key will be the parameter value. + Valid Parameter Name: + ksdevice + netdev + netdevice + ip + ifname + BOOTIF + + And following two keys also will be returned for reference + mac + nicname + + Example: + my $netparams = xCAT::NetworkUtils->gen_net_boot_params($installnic, $primmarynic, $macmac, $nodebootif); + +=cut + +#------------------------------------------------------------------------------- + +sub gen_net_boot_params +{ + my $class = shift; + my $installnic = shift; + my $primarynic = shift; + my $macmac = shift; + my $nodebootif = shift; + + my $net_params; + + # arbitrary use primarynic if installnic is not set + unless ($installnic) { + $installnic = $primarynic; + } + + # just use the installnic to generate the nic related kernel parameters + my $mac; + my $nicname; + + if ((! defined ($installnic)) || ($installnic eq "") || ($installnic =~ /^mac$/i)) { + $mac = $macmac; + $net_params->{mac} = $mac; + } 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; + } else { + $nicname = $installnic; + $net_params->{nicname} = $nicname; + } + + if ($nicname) { + $net_params->{ksdevice} = "ksdevice=$nicname"; + $net_params->{ip} = "ip=$nicname:dhcp"; + $net_params->{netdev} = "netdev=$nicname"; + $net_params->{netdevice} = "netdevice=$nicname"; + } elsif ($mac) { + $net_params->{ksdevice} = "ksdevice=$mac"; + $net_params->{BOOTIF} = "BOOTIF=$mac"; + $net_params->{bootdev} = "bootdev=$mac"; + $net_params->{ip} = "ip=dhcp"; + if ($nodebootif) { + $net_params->{ifname} = "ifname=$nodebootif:$mac"; + } + $net_params->{netdevice} = "netdevice=$mac"; + } + + return $net_params; +} 1; diff --git a/xCAT-server/lib/xcat/plugins/anaconda.pm b/xCAT-server/lib/xcat/plugins/anaconda.pm index b38dd3cb0..3ff436b20 100755 --- a/xCAT-server/lib/xcat/plugins/anaconda.pm +++ b/xCAT-server/lib/xcat/plugins/anaconda.pm @@ -745,81 +745,27 @@ sub mknetboot $kcmdline .= " nonodestatus "; } - - # add one parameter: ifname=: - # which is used for dracut - # the redhat5.x os will ignore it - my $useifname=0; - #for rhels5.x-ppc64, if installnic="mac", BOOTIF= should be appended - my $usemac=0; - my $nicname=""; - if ($reshash->{$node}->[0] and $reshash->{$node}->[0]->{installnic} and $reshash->{$node}->[0]->{installnic} ne "mac") { - $useifname=1; - #$kcmdline .= "ifname=".$reshash->{$node}->[0]->{installnic} . ":"; - $nicname=$reshash->{$node}->[0]->{installnic}; - } elsif ($nodebootif) { - $useifname=1; - #$kcmdline .= "ifname=$nodebootif:"; - $nicname=$nodebootif; - } elsif ($reshash->{$node}->[0] and $reshash->{$node}->[0]->{primarynic} and $reshash->{$node}->[0]->{primarynic} ne "mac") { - $useifname=1; - #$kcmdline .= "ifname=".$reshash->{$node}->[0]->{primarynic}.":"; - $nicname=$reshash->{$node}->[0]->{primarynic}; - }else{ - if($arch=~ /ppc/) - { - $usemac=1; - } - } - #else { #no, we autodetect and don't presume anything - # $kcmdline .="eth0:"; - # print "eth0 is used as the default booting network devices...\n"; - #} - # append the mac address + # Add kernel parameters to specify the boot network interface + my $installnic; + my $primarynic; my $mac; - - if( ($usemac || $useifname) && $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 = $machash->{$node}->[0]->{'mac'}; -# if ( (index($mac, "|") eq -1) and (index($mac, "!") eq -1) ) { - #convert to linux format - if ($mac !~ /:/) { - $mac =~s/(..)(..)(..)(..)(..)(..)/$1:$2:$3:$4:$5:$6/; - } - $mac =~ s/!.*//; #remove multi-interface mac information - $mac =~ s/\|.*//; -# } else { -# $callback->({ error=>[ qq{In the "mac" table, the "|" delimited string of "macaddress!hostname" format is not supported by "nodeset netboot|statelite if installnic/primarynic is set".}], errorcode=>[1]}); -# return; -# } + if (defined ($reshash->{$node}->[0]) && $reshash->{$node}->[0]->{installnic}) { + $installnic = $reshash->{$node}->[0] and $reshash->{$node}->[0]->{installnic}; } - - if( ($nicname ne "") and (not xCAT::NetworkUtils->isValidMAC($nicname) )){ - if ($useifname && $mac) { - $kcmdline .= "ifname=$nicname:$mac "; - } - $kcmdline .= "netdev=$nicname "; - }else { - if($mac){ - $kcmdline .= "BOOTIF=$mac "; - } + if (defined ($reshash->{$node}->[0]) and $reshash->{$node}->[0]->{primarynic}) { + $primarynic = $reshash->{$node}->[0]->{primarynic}; } + if (defined ($machash->{$node}->[0]) && $machash->{$node}->[0]->{'mac'}) { + $mac = xCAT::Utils->parseMacTabEntry($machash->{$node}->[0]->{'mac'}, $node); + } + + my $net_params = xCAT::NetworkUtils->gen_net_boot_params($installnic, $primarynic, $mac, $nodebootif); - - # add "netdev=" or "BOOTIF=" - # which are used for other scenarios - #my $netdev = ""; - #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 ( ($usemac || $useifname) && $mac) { - # $kcmdline .= "BOOTIF=" . $mac . " "; - # } - #} + if (defined ($net_params->{ifname}) || defined ($net_params->{netdev})) { + $kcmdline .= "$net_params->{ifname} $net_params->{netdev} "; + } elsif (defined ($net_params->{BOOTIF}) && $arch=~ /ppc/) { + $kcmdline .= "$net_params->{BOOTIF} "; + } my %client_nethash = xCAT::DBobjUtils->getNetwkInfo( [$node] ); if ( $client_nethash{$node}{mgtifname} =~ /hf/ ) @@ -998,13 +944,13 @@ sub mkinstall my $restab = xCAT::Table->new('noderes'); my $bptab = xCAT::Table->new('bootparams',-create=>1); my $hmtab = xCAT::Table->new('nodehm'); + my $mactab = xCAT::Table->new('mac'); my %osents = %{$ostab->getNodesAttribs(\@nodes, ['profile', 'os', 'arch', 'provmethod'])}; - my %rents = - %{$restab->getNodesAttribs(\@nodes, + my %rents = %{$restab->getNodesAttribs(\@nodes, ['xcatmaster', 'nfsserver', 'tftpdir', 'primarynic', 'installnic'])}; - my %hents = - %{$hmtab->getNodesAttribs(\@nodes, + my %hents = %{$hmtab->getNodesAttribs(\@nodes, ['serialport', 'serialspeed', 'serialflow'])}; + my %macents = %{$mactab->getNodesAttribs(\@nodes, ['mac'])}; #my $addkcmdhash = # $bptab->getNodesAttribs(\@nodes, ['addkcmdline']); require xCAT::Template; @@ -1388,15 +1334,8 @@ sub mkinstall #We have a shot... my $ent = $rents{$node}->[0]; -# $restab->getNodeAttribs($node, -# ['nfsserver', 'primarynic', 'installnic']); my $sent = $hents{$node}->[0]; -# $hmtab->getNodeAttribs( -# $node, -# [ -# 'serialport', 'serialspeed', 'serialflow' -# ] -# ); + my $macent = $macents{$node}->[0]; my $instserver = $xcatmaster; if ($ent and $ent->{nfsserver}) { $instserver=$ent->{nfsserver}; @@ -1408,15 +1347,15 @@ sub mkinstall $instserver=$ip; } } - my $httpprefix=$pkgdir; - if ($installroot =~ /\/$/) { - $httpprefix =~ s/^$installroot/\/install\//; - } else { - $httpprefix =~ s/^$installroot/\/install/; - } + my $httpprefix=$pkgdir; + if ($installroot =~ /\/$/) { + $httpprefix =~ s/^$installroot/\/install\//; + } else { + $httpprefix =~ s/^$installroot/\/install/; + } my $kcmdline; - + my $kversion=$os; $kversion =~ s/^\D*([\.0-9]+)/$1/; $kversion =~ s/\.$//; @@ -1440,63 +1379,27 @@ sub mkinstall if ($maxmem) { $kcmdline.=" mem=$maxmem"; } - my $ksdev = ""; - if ($ent->{installnic}) - { - if ($ent->{installnic} eq "mac") - { - my $mactab = xCAT::Table->new("mac"); - my $macref = $mactab->getNodeAttribs($node, ['mac']); - $ksdev = xCAT::Utils->parseMacTabEntry($macref->{mac},$node); - } - else - { - $ksdev = $ent->{installnic}; - } - } - elsif ($ent->{primarynic}) - { - if ($ent->{primarynic} eq "mac") - { - my $mactab = xCAT::Table->new("mac"); - my $macref = $mactab->getNodeAttribs($node, ['mac']); - $ksdev = xCAT::Utils->parseMacTabEntry($macref->{mac},$node); - } - else - { - $ksdev = $ent->{primarynic}; - } - } - else - { - $ksdev = "bootif"; #if not specified, fall back to bootif - } - if ($ksdev eq "") - { - $callback->( - { - error => ["No MAC address defined for " . $node], - errorcode => [1] - } - ); - } - if($esxi){ - $ksdev =~ s/eth/vmnic/g; - } - - my $nicname; - if(xCAT::Utils->version_cmp($kversion,"7.0")<0){ - $kcmdline .= " ksdevice=" . $ksdev; - }else{ - if(xCAT::NetworkUtils->isValidMAC($ksdev)){ - $kcmdline .= " BOOTIF=" . $ksdev; - }elsif($ksdev ne "bootif"){ - $nicname=$ksdev; - } - } + # Add kernel parameters to specify the boot network interface + if($esxi){ + $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 $nicname = $net_params->{nicname}; + + if(xCAT::Utils->version_cmp($kversion,"7.0") < 0){ + $kcmdline .= " $net_params->{ksdevice} "; + }elsif ($arch =~ /ppc/) { + $kcmdline .= " $net_params->{BOOTIF} "; + } + #if site.managedaddressmode=static, specify the network configuration as kernel options #to avoid multicast dhcp if($::XCATSITEVALS{managedaddressmode} =~ /static/){ @@ -1527,7 +1430,6 @@ sub mkinstall $kcmdline .= " ifname=$nicname:$mac"; } - $kcmdline .=" ip=$ipaddr"."::"."$gateway".":"."$netmask".":"."$hostname".":"."$nicname".":"."none"; $kcmdline .=" bootdev=$nicname "; } @@ -1557,12 +1459,8 @@ sub mkinstall } } }else{ - unless(xCAT::Utils->version_cmp($kversion,"7.0")<0){ - if($nicname){ - $kcmdline .=" ip=$nicname:dhcp "; - }else{ - $kcmdline .=" ip=dhcp "; - } + if (xCAT::Utils->version_cmp($kversion,"7.0") >= 0){ + $kcmdline .= " $net_params->{ip} "; } } @@ -1684,13 +1582,15 @@ sub mksysclone my $restab = xCAT::Table->new('noderes'); my $bptab = xCAT::Table->new('bootparams',-create=>1); my $hmtab = xCAT::Table->new('nodehm'); + my $mactab = xCAT::Table->new('mac'); + my %osents = %{$ostab->getNodesAttribs(\@nodes, ['profile', 'os', 'arch', 'provmethod'])}; - my %rents = - %{$restab->getNodesAttribs(\@nodes, + my %rents = %{$restab->getNodesAttribs(\@nodes, ['xcatmaster', 'nfsserver', 'tftpdir', 'primarynic', 'installnic'])}; - my %hents = - %{$hmtab->getNodesAttribs(\@nodes, + my %hents = %{$hmtab->getNodesAttribs(\@nodes, ['serialport', 'serialspeed', 'serialflow'])}; + my %macents = %{$mactab->getNodesAttribs(\@nodes, ['mac'])}; + my @entries = xCAT::TableUtils->get_site_attribute("xcatdport"); my $port_entry = $entries[0]; my $xcatdport="3001"; @@ -1958,50 +1858,16 @@ sub mksysclone #We have a shot... my $ent = $rents{$node}->[0]; my $sent = $hents{$node}->[0]; + my $macent = $macents{$node}->[0]; - my $kcmdline = - "ramdisk_size=$ramdisk_size"; - my $ksdev = ""; - if ($ent->{installnic}) - { - if ($ent->{installnic} eq "mac") - { - my $mactab = xCAT::Table->new("mac"); - my $macref = $mactab->getNodeAttribs($node, ['mac']); - $ksdev = xCAT::Utils->parseMacTabEntry($macref->{mac},$node); - } - else - { - $ksdev = $ent->{installnic}; - } - } - elsif ($ent->{primarynic}) - { - if ($ent->{primarynic} eq "mac") - { - my $mactab = xCAT::Table->new("mac"); - my $macref = $mactab->getNodeAttribs($node, ['mac']); - $ksdev = xCAT::Utils->parseMacTabEntry($macref->{mac},$node); - } - else - { - $ksdev = $ent->{primarynic}; - } - } - else - { - $ksdev = "bootif"; #if not specified, fall back to bootif - } - if ($ksdev eq "") - { - $callback->( - { - error => ["No MAC address defined for " . $node], - errorcode => [1] - } - ); - } - $kcmdline .= " ksdevice=" . $ksdev; + 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}); + $kcmdline .= " $net_params->{ksdevice} "; + if ($arch =~ /ppc/) { + $kcmdline .= " $net_params->{BOOTIF} "; + } #TODO: dd= for driver disks if (defined($sent->{serialport})) @@ -2031,27 +1897,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 .= " noipv6"; - # add the addkcmdline attribute to the end - # of the command, if it exists - #my $addkcmd = $addkcmdhash->{$node}->[0]; - # add the extra addkcmd command info, if in the table - #if ($addkcmd->{'addkcmdline'}) { - # $kcmdline .= " "; - # $kcmdline .= $addkcmd->{'addkcmdline'}; - #} - my $k; my $i; #$k = "xcat/genesis.kernel.$arch"; From 3881d6fefe562b7e9c9e27b68ff56058091f3e8d Mon Sep 17 00:00:00 2001 From: GONG Jie Date: Tue, 10 Feb 2015 15:42:22 +0800 Subject: [PATCH 02/12] Add pkglist, exlist, postinstall files for RHEL 7.1 support on ppc64le --- .../install/rh/service.rhels7.ppc64le.pkglist | 36 +++++++++++++++++++ .../sysclone.rhels7.ppc64le.otherpkgs.pkglist | 1 + .../netboot/rh/compute.rhels7.ppc64le.exlist | 1 + .../netboot/rh/compute.rhels7.ppc64le.pkglist | 1 + .../rh/compute.rhels7.ppc64le.postinstall | 1 + 5 files changed, 40 insertions(+) create mode 100644 xCAT-server/share/xcat/install/rh/service.rhels7.ppc64le.pkglist create mode 100644 xCAT-server/share/xcat/install/rh/sysclone.rhels7.ppc64le.otherpkgs.pkglist create mode 120000 xCAT-server/share/xcat/netboot/rh/compute.rhels7.ppc64le.exlist create mode 120000 xCAT-server/share/xcat/netboot/rh/compute.rhels7.ppc64le.pkglist create mode 120000 xCAT-server/share/xcat/netboot/rh/compute.rhels7.ppc64le.postinstall diff --git a/xCAT-server/share/xcat/install/rh/service.rhels7.ppc64le.pkglist b/xCAT-server/share/xcat/install/rh/service.rhels7.ppc64le.pkglist new file mode 100644 index 000000000..681455dfb --- /dev/null +++ b/xCAT-server/share/xcat/install/rh/service.rhels7.ppc64le.pkglist @@ -0,0 +1,36 @@ +#Please make sure there is a space between @ and group name +@ Network Infrastructure Server +@ System administration tools +@ System Management +@ X Window System +@ Development Tools +autofs +ksh +tcsh +ntp +tftp +xinetd +rsh +rsh-server +psacct +nfs-utils +net-snmp +rsync +yp-tools +ypserv +ypbind +m4 +sendmail-cf +gdb +binutils +openssh-server +util-linux +perl-DBD-MySQL +perl-Socket6 +unixODBC +perl-DBD-MySQL +mysql-connector-odbc +perl-DBD-Pg +wget +util-linux-ng +net-tools diff --git a/xCAT-server/share/xcat/install/rh/sysclone.rhels7.ppc64le.otherpkgs.pkglist b/xCAT-server/share/xcat/install/rh/sysclone.rhels7.ppc64le.otherpkgs.pkglist new file mode 100644 index 000000000..1e612f91b --- /dev/null +++ b/xCAT-server/share/xcat/install/rh/sysclone.rhels7.ppc64le.otherpkgs.pkglist @@ -0,0 +1 @@ +xcat/xcat-dep/rh7/ppc64le/systemimager-client diff --git a/xCAT-server/share/xcat/netboot/rh/compute.rhels7.ppc64le.exlist b/xCAT-server/share/xcat/netboot/rh/compute.rhels7.ppc64le.exlist new file mode 120000 index 000000000..6375475eb --- /dev/null +++ b/xCAT-server/share/xcat/netboot/rh/compute.rhels7.ppc64le.exlist @@ -0,0 +1 @@ +compute.rhels7.ppc64.exlist \ No newline at end of file diff --git a/xCAT-server/share/xcat/netboot/rh/compute.rhels7.ppc64le.pkglist b/xCAT-server/share/xcat/netboot/rh/compute.rhels7.ppc64le.pkglist new file mode 120000 index 000000000..ed37ea3e9 --- /dev/null +++ b/xCAT-server/share/xcat/netboot/rh/compute.rhels7.ppc64le.pkglist @@ -0,0 +1 @@ +compute.rhels7.ppc64.pkglist \ No newline at end of file diff --git a/xCAT-server/share/xcat/netboot/rh/compute.rhels7.ppc64le.postinstall b/xCAT-server/share/xcat/netboot/rh/compute.rhels7.ppc64le.postinstall new file mode 120000 index 000000000..f1421f48d --- /dev/null +++ b/xCAT-server/share/xcat/netboot/rh/compute.rhels7.ppc64le.postinstall @@ -0,0 +1 @@ +compute.rhels7.ppc64.postinstall \ No newline at end of file From 60a94b982b85a2d5fb5f6347ad34ad4ddad5776e Mon Sep 17 00:00:00 2001 From: daniceexi Date: Tue, 10 Feb 2015 03:43:17 -0500 Subject: [PATCH 03/12] Ubuntu/genimage: support to use local mirror in pkgdir with http format --- .../share/xcat/netboot/ubuntu/genimage | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/xCAT-server/share/xcat/netboot/ubuntu/genimage b/xCAT-server/share/xcat/netboot/ubuntu/genimage index faefa5943..9c5533159 100755 --- a/xCAT-server/share/xcat/netboot/ubuntu/genimage +++ b/xCAT-server/share/xcat/netboot/ubuntu/genimage @@ -228,8 +228,14 @@ unless ($onlyinitrd) { # Get the ubuntu repo path from osimage.pkgdir my @srcdirs = split(',', $srcdir); + my $pkgdir_internet; #only support one http mirror which will be used to create bootstrap foreach my $dir (@srcdirs) { - find(\&isaptdir, <$dir/>); + if ($dir =~ /^http.*/){ + $pkgdir_internet = $dir; + } else { + $srcdir = $dir; #set $srcdir to be the one which is not http path + find(\&isaptdir, <$dir/>); + } } # Add the dir for kernel deb to be installed if ($kernelver) { @@ -251,6 +257,11 @@ unless ($onlyinitrd) { $repnum += 1; } $repnum-=1; + + # Add the internet mirror + if ($pkgdir_internet) { + print $aptconfig "deb $pkgdir_internet\n\n"; + } close($aptconfig); mkpath "$rootimg_dir/etc"; @@ -282,9 +293,10 @@ unless ($onlyinitrd) { # Check whether a local Ubuntu mirror is specified # if linuximage.pkgdir has second mirror is set, we consider the second mirror as a full Ubuntu mirror - if ($#srcdirs > 0) { - $aptcmd2 = "--verbose --arch $uarch $dist $rootimg_dir file://$srcdirs[1]"; - $srcdir = $srcdirs[0]; + if ($pkgdir_internet) { + my $mirrorurl = $pkgdir_internet; + $mirrorurl =~ s/ .*$//g; # get the url part of mirror path + $aptcmd2 = "--verbose --arch $uarch $dist $rootimg_dir $mirrorurl"; } else { if ($uarch eq 'ppc64el') { $aptcmd2 = "--verbose --arch $uarch $dist $rootimg_dir http://ports.ubuntu.com/ubuntu-ports/"; From 4bb15df15e709ce204bd0a0198c05d40d704a443 Mon Sep 17 00:00:00 2001 From: ertaozh Date: Tue, 10 Feb 2015 04:01:54 -0500 Subject: [PATCH 04/12] To use the refined code about installnic and primarynic for ubuntu --- xCAT-server/lib/xcat/plugins/debian.pm | 89 ++++++++------------------ 1 file changed, 28 insertions(+), 61 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/debian.pm b/xCAT-server/lib/xcat/plugins/debian.pm index 89023d3d3..3adf885d0 100755 --- a/xCAT-server/lib/xcat/plugins/debian.pm +++ b/xCAT-server/lib/xcat/plugins/debian.pm @@ -465,6 +465,7 @@ sub mkinstall my $restab = xCAT::Table->new('noderes'); my $bptab = xCAT::Table->new('bootparams',-create=>1); my $hmtab = xCAT::Table->new('nodehm'); + my $mactab = xCAT::Table->new('mac'); my %osents = %{$ostab->getNodesAttribs(\@nodes, ['profile', 'os', 'arch', 'provmethod'])}; my %rents = %{$restab->getNodesAttribs(\@nodes, @@ -472,6 +473,7 @@ sub mkinstall my %hents = %{$hmtab->getNodesAttribs(\@nodes, ['serialport', 'serialspeed', 'serialflow'])}; + my %macents = %{$mactab->getNodesAttribs(\@nodes, ['mac'])}; #my $addkcmdhash = # $bptab->getNodesAttribs(\@nodes, ['addkcmdline']); require xCAT::Template; @@ -796,6 +798,7 @@ sub mkinstall # 'serialport', 'serialspeed', 'serialflow' # ] # ); + my $macent = $macents{$node}->[0]; my $instserver; if ($ent and $ent->{xcatmaster}){ $instserver = $ent->{xcatmaster}; @@ -827,32 +830,13 @@ sub mkinstall if ($maxmem) { $kcmdline.=" mem=$maxmem"; } - my $ksdev = ""; - if ($ent->{installnic}){ - if ($ent->{installnic} eq "mac"){ - my $mactab = xCAT::Table->new("mac"); - my $macref = $mactab->getNodeAttribs($node, ['mac']); - $ksdev = xCAT::Utils->parseMacTabEntry($macref->{mac},$node); - } - else{ - $ksdev = $ent->{installnic}; - } - } - elsif ($ent->{primarynic}){ - if ($ent->{primarynic} eq "mac"){ - my $mactab = xCAT::Table->new("mac"); - my $macref = $mactab->getNodeAttribs($node, ['mac']); - $ksdev = xCAT::Utils->parseMacTabEntry($macref->{mac},$node); - } - else{ - $ksdev = $ent->{primarynic}; - } + my $net_params = xCAT::NetworkUtils->gen_net_boot_params($ent->{installnic},$ent->{primarynic},$macent->{mac}); + if (exists($net_params->{nicname})) { + $kcmdline .= " netcfg/choose_interface=". $net_params->{nicname}; + } elsif (exists($net_params->{mac})) { + $kcmdline .= " netcfg/choose_interface=". $net_params->{mac}; } - if ($ksdev){ - $kcmdline .= " netcfg/choose_interface=" . $ksdev; - } - #TODO: dd= for driver disks if (defined($sent->{serialport})){ unless ($sent->{serialspeed}){ @@ -1448,17 +1432,16 @@ sub mknetboot # add one parameter: ifname=: # which is used for dracut # the redhat5.x os will ignore it - my $useifname=0; - if ($reshash->{$node}->[0] and $reshash->{$node}->[0]->{installnic} and $reshash->{$node}->[0]->{installnic} ne "mac") { - $useifname=1; - $kcmdline .= "ifname=".$reshash->{$node}->[0]->{installnic} . ":"; - } elsif ($nodebootif) { - $useifname=1; - $kcmdline .= "ifname=$nodebootif:"; - } elsif ($reshash->{$node}->[0] and $reshash->{$node}->[0]->{primarynic} and $reshash->{$node}->[0]->{primarynic} ne "mac") { - $useifname=1; - $kcmdline .= "ifname=".$reshash->{$node}->[0]->{primarynic}.":"; + my $installnic = undef; + my $primarynic = undef; + my $mac = undef; + + if ($reshash->{$node}->[0] and $reshash->{$node}->[0]->{installnic}) { + $installnic = $reshash->{$node}->[0]->{installnic}; + } + if ($reshash->{$node}->[0] and $reshash->{$node}->[0]->{primarynic}) { + $primarynic= $reshash->{$node}->[0]->{primarynic}; } #else { #no, we autodetect and don't presume anything # $kcmdline .="eth0:"; @@ -1469,35 +1452,19 @@ 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 ( (index($mac, "|") eq -1) and (index($mac, "!") eq -1) ) { - #convert to linux format - if ($mac !~ /:/) { - $mac =~s/(..)(..)(..)(..)(..)(..)/$1:$2:$3:$4:$5:$6/; - } -# } else { -# $callback->({ error=>[ qq{In the "mac" table, the "|" delimited string of "macaddress!hostname" format is not supported by "nodeset netboot|statelite if installnic/primarynic is set".}], errorcode=>[1]}); -# return; -# } - } - - if ($useifname && $mac) { - $kcmdline .= "$mac "; - } - - # add "netdev=" or "BOOTIF=" - # which are used for other scenarios - my $netdev = ""; - 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 ( !$useifname && $mac) { - $kcmdline .= "BOOTIF=" . $mac . " "; + 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})) { + $kcmdline .= "$net_params->{ifname} "; + } + if (defined($net_params->{netdev})) { + $kcmdline .= "$net_params->{netdev} "; + } elsif (defined($net_params->{BOOTIF})) { + $kcmdline .= "$net_params->{BOOTIF} "; + } my %client_nethash = xCAT::DBobjUtils->getNetwkInfo( [$node] ); if ( $client_nethash{$node}{mgtifname} =~ /hf/ ) From d21467eb4731f5c09a609f0515bb664d3a07dce9 Mon Sep 17 00:00:00 2001 From: immarvin Date: Tue, 10 Feb 2015 02:40:59 -0800 Subject: [PATCH 05/12] refine the code to use installnic and primarynic to generate network boot kernel parameters. All the logic to use installnic/primarynic have been put in NetworkUtils->gen_net_boot_params --- xCAT-server/lib/xcat/plugins/sles.pm | 255 +++++++++++++++++---------- 1 file changed, 163 insertions(+), 92 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/sles.pm b/xCAT-server/lib/xcat/plugins/sles.pm index ea13dc732..bdadc2d48 100755 --- a/xCAT-server/lib/xcat/plugins/sles.pm +++ b/xCAT-server/lib/xcat/plugins/sles.pm @@ -584,27 +584,53 @@ sub mknetboot $kcmdline .= "ip=dhcp "; # add the kernel-booting parameter: netdev=, or BOOTIF= - my $netdev = ""; - my $mac = xCAT::Utils->parseMacTabEntry($machash->{$node}->[0]->{mac},$node); + #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] - }); - } - } + #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; + + if ($reshash->{$node}->[0] and $reshash->{$node}->[0]->{installnic}){ + $installnic=$reshash->{$node}->[0]->{installnic}; + } + + if ($reshash->{$node}->[0] and $reshash->{$node}->[0]->{primarynic}){ + $primarynic=$reshash->{$node}->[0]->{primarynic}; + } + + if (defined ($machash->{$node}->[0]) && $machash->{$node}->[0]->{'mac'}) { + $mac = xCAT::Utils->parseMacTabEntry($machash->{$node}->[0]->{mac},$node); + } + + 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/) { + $kcmdline .= " $net_params->{BOOTIF} "; + } + if (defined $sent->{serialport}) { @@ -1116,49 +1142,74 @@ 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}; - } + #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; + + if ($ent->{installnic}){ + $installnic=$ent->{installnic}; + } + + if($ent->{primarynic}){ + $primarynic=$ent->{primarynic}; } - 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}; - } + + + my $mactab = xCAT::Table->new("mac"); + my $macref = $mactab->getNodeAttribs($node, ['mac']); + if($macref->{mac}){ + $mac=xCAT::Utils->parseMacTabEntry($macref->{mac},$node); } - 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 $net_params=xCAT::NetworkUtils->gen_net_boot_params($installnic, $primarynic, $mac); + if (defined ($net_params->{netdevice})) { + $kcmdline .= " $net_params->{netdevice} "; } + # Add the kernel paramets for driver update disk loading foreach (@dd_drivers) { @@ -1467,30 +1518,50 @@ sub mksysclone my $sent = $hents{$node}->[0]; my $kcmdline = "ramdisk_size=$ramdisk_size"; - my $ksdev = ""; - if ($ent->{installnic}) - { - $ksdev = $ent->{installnic}; + #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; + my $mac; + if ($ent->{installnic}){ + $installnic= $ent->{installnic}; + } + + if ($ent->{primarynic}){ + $primarynic=$ent->{primarynic}; } - elsif ($ent->{primarynic}) - { - $ksdev = $ent->{primarynic}; - } - else - { - $ksdev = "bootif"; #if not specified, fall back to bootif + + my $mactab = xCAT::Table->new("mac"); + my $macref = $mactab->getNodeAttribs($node, ['mac']); + if($macref->{mac}){ + $mac=xCAT::Utils->parseMacTabEntry($macref->{mac},$node); } - 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 $net_params = xCAT::NetworkUtils->gen_net_boot_params($installnic,$primarynic,$mac); + $kcmdline .= " $net_params->{netdevice} "; if ($arch =~ /ppc/) { $kcmdline .= " dhcptimeout=150"; @@ -1515,17 +1586,17 @@ 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 "; - } - + #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" ){ From 5e7cb438286c7fc701bdf6b79338fe51723c56c5 Mon Sep 17 00:00:00 2001 From: jjohnson2 Date: Tue, 10 Feb 2015 14:42:32 -0500 Subject: [PATCH 06/12] Remove dead reference to a password The line in question is dead code, and therefore has no effect (it either dies or gets overwritten short time later). Removing it makes the code cleaner and counters the tendency for someone to think we might be using a hard coded password in this file. --- xCAT-server/lib/xcat/plugins/esx.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-server/lib/xcat/plugins/esx.pm b/xCAT-server/lib/xcat/plugins/esx.pm index 3029e7738..268467298 100644 --- a/xCAT-server/lib/xcat/plugins/esx.pm +++ b/xCAT-server/lib/xcat/plugins/esx.pm @@ -2476,7 +2476,7 @@ sub clone_vms_from_master { sub make_customization_spec { my $node = shift; my %args = @_; - my $password="Passw0rd"; + my $password; my $wintimezone; #map of number to strings can be found at #http://osman-shener-en.blogspot.com/2008/02/unattendedtxt-time-zone-index.html From a05d09e4dd7b61f62c0874ca032c6712b533c91f Mon Sep 17 00:00:00 2001 From: daniceexi Date: Wed, 11 Feb 2015 02:30:36 -0500 Subject: [PATCH 07/12] 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 5a73450599a9a7e1cc5685ae6e966688b3dd0432 Mon Sep 17 00:00:00 2001 From: ertaozh Date: Wed, 11 Feb 2015 02:36:36 -0500 Subject: [PATCH 08/12] 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 07f873858fa40ee8748bf6c9224a55c496071148 Mon Sep 17 00:00:00 2001 From: daniceexi Date: Wed, 11 Feb 2015 02:51:18 -0500 Subject: [PATCH 09/12] 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 4307c052fb2e57d383d5b560c53d1b1c792247e7 Mon Sep 17 00:00:00 2001 From: immarvin Date: Wed, 11 Feb 2015 01:19:56 -0800 Subject: [PATCH 10/12] 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 23fb6f39fe1b6252e465ce5dbc5ce28769813757 Mon Sep 17 00:00:00 2001 From: immarvin Date: Wed, 11 Feb 2015 03:12:38 -0800 Subject: [PATCH 11/12] 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}; From aedd887876da75a78c4b4e32f2e94d7d45620e3f Mon Sep 17 00:00:00 2001 From: Casandra Qiu Date: Wed, 11 Feb 2015 10:22:10 -0500 Subject: [PATCH 12/12] support confluent console for kvm --- .../confluent/lib/python/confluent/plugins/console/xcatkvm.sh | 2 ++ 1 file changed, 2 insertions(+) create mode 100755 xCAT-confluent/confluent/lib/python/confluent/plugins/console/xcatkvm.sh diff --git a/xCAT-confluent/confluent/lib/python/confluent/plugins/console/xcatkvm.sh b/xCAT-confluent/confluent/lib/python/confluent/plugins/console/xcatkvm.sh new file mode 100755 index 000000000..80545d242 --- /dev/null +++ b/xCAT-confluent/confluent/lib/python/confluent/plugins/console/xcatkvm.sh @@ -0,0 +1,2 @@ +#!/bin/bash +exec /opt/xcat/share/xcat/cons/kvm $CONFLUENT_NODE