From 00861c34553506bb09559139bc161072b8541b0e Mon Sep 17 00:00:00 2001 From: ligc Date: Thu, 8 Aug 2013 16:00:49 +0800 Subject: [PATCH 01/14] add test case lsdef_t_h_i --- xCAT-test/autotest/testcase/lsdef/cases0 | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/xCAT-test/autotest/testcase/lsdef/cases0 b/xCAT-test/autotest/testcase/lsdef/cases0 index 6f1e3780b..2c8f50bbe 100644 --- a/xCAT-test/autotest/testcase/lsdef/cases0 +++ b/xCAT-test/autotest/testcase/lsdef/cases0 @@ -189,3 +189,10 @@ cmd:lsdef -t wrongtype -o test check:rc!=0 check:output=~Error end + +start:lsdef_t_h_i +description:lsdef -t node -h -i status +cmd:lsdef -t node -h -i status +check:rc==0 +check:output=~status +end From a092441f67f52350dea0b3616cd6e4decf736129 Mon Sep 17 00:00:00 2001 From: ligc Date: Thu, 8 Aug 2013 16:21:03 +0800 Subject: [PATCH 02/14] add testcase lsdef --nics --- xCAT-test/autotest/testcase/lsdef/cases0 | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/xCAT-test/autotest/testcase/lsdef/cases0 b/xCAT-test/autotest/testcase/lsdef/cases0 index 2c8f50bbe..0a4af8608 100644 --- a/xCAT-test/autotest/testcase/lsdef/cases0 +++ b/xCAT-test/autotest/testcase/lsdef/cases0 @@ -196,3 +196,14 @@ cmd:lsdef -t node -h -i status check:rc==0 check:output=~status end + +start:lsdef_nics +description:lsdef --nics +cmd:mkdef -t node -o testnode1 groups=all mgt=ipmi nicips.eth0=1.1.1.1 +check:rc==0 +cmd:lsdef testnode1 --nics +check:rc==0 +check:output=~1.1.1.1 +cmd:rmdef testnode1 +check:rc==0 +end From c3ebc4ec3b3916521b43ebbc79a17b88bb47bdf6 Mon Sep 17 00:00:00 2001 From: ligc Date: Thu, 8 Aug 2013 16:41:06 +0800 Subject: [PATCH 03/14] update testcase lsdef_nics --- xCAT-test/autotest/testcase/lsdef/cases0 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xCAT-test/autotest/testcase/lsdef/cases0 b/xCAT-test/autotest/testcase/lsdef/cases0 index 0a4af8608..9850384fc 100644 --- a/xCAT-test/autotest/testcase/lsdef/cases0 +++ b/xCAT-test/autotest/testcase/lsdef/cases0 @@ -206,4 +206,6 @@ check:rc==0 check:output=~1.1.1.1 cmd:rmdef testnode1 check:rc==0 +cmd:lsdef testnode1 +check:output=~Could not find end From 96509197387146a98248e5337f7d26d5fb52982a Mon Sep 17 00:00:00 2001 From: daniceexi Date: Thu, 8 Aug 2013 12:52:35 -0400 Subject: [PATCH 04/14] defect 3703: make the configmic and flashmic could get the correct hostname on the host node --- xCAT-server/sbin/configmic | 49 +++++++++++++++++++++++++------------- xCAT-server/sbin/flashmic | 49 +++++++++++++++++++++++++------------- 2 files changed, 64 insertions(+), 34 deletions(-) diff --git a/xCAT-server/sbin/configmic b/xCAT-server/sbin/configmic index fdcba748c..7eb4d10f3 100755 --- a/xCAT-server/sbin/configmic +++ b/xCAT-server/sbin/configmic @@ -35,28 +35,43 @@ unless ($master && $cfgpath) { } # get the correct host name for the host -my $nodename; +my ($nodename, $nodename_short); my $masterip = `getent hosts $master | awk {'print \$1'}`; -chomp($masterip); -my $myip = `ip route get $masterip| head -n 1 | sed 's/^.*src//g' | awk {'print \$1'}`; -my $myipinfo =`getent hosts $myip`; -if ($myipinfo =~ /([^\s]+)\s+([^\s]+)\s+([^\s]+)/) { - my $n1 = $2; - my $n2 = $3; - if (length($n1) > length($n2)) { - $nodename = $n2; - } else { - $nodename = $n1; +if ($masterip) { + chomp($masterip); + my $myip = `ip route get $masterip| head -n 1 | sed 's/^.*src//g' | awk {'print \$1'}`; + if ($myip) { + my $myipinfo =`getent hosts $myip`; + + if ($myipinfo && $myipinfo =~ /([^\s]+)\s+([^\s]+)\s+([^\s]+)/) { + my $n1 = $2; + my $n2 = $3; + if (length($n1) > length($n2)) { + $nodename_short = $n2; + } else { + $nodename = $n1; + } + } elsif ($myipinfo && $myipinfo =~ /([^\s]+)\s+([^\s]+)/) { + $nodename_short = $2; + } } -} elsif ($myipinfo =~ /([^\s]+)\s+([^\s]+)/) { - $nodename = $2; -} else { - outputmsg("Error: cannot get the hostname of the host node\n", 2); +} +unless ($nodename) { + $nodename = `hostname`; + chomp($nodename); +} +unless ($nodename_short) { + $nodename_short = `hostname -s`; + chomp($nodename_short); } # download the mic configuration file from master -my $cmd = "wget -N --waitretry=10 --random-wait -T 60 http://$master/$cfgpath/miccfg.$nodename -P $tmppath"; -my ($rc, $output) = runsyscmd ($cmd, "Error: failed to download mic configuration file from $master\n", 3); +my $cmd = "wget -N --waitretry=10 --random-wait -T 60 http://$master/$cfgpath/miccfg.$nodename_short -P $tmppath"; +my ($rc, $output) = runsyscmd ($cmd); +if ($rc) { + $cmd = "wget -N --waitretry=10 --random-wait -T 60 http://$master/$cfgpath/miccfg.$nodename -P $tmppath"; + runsyscmd ($cmd, "Error: failed to download mic configuration file from $master\n", 3); +} unless (-r "$tmppath/miccfg.$nodename") { runsyscmd ("Error: cannot get the mic configuration file from http://$master/$cfgpath/miccfg.$nodename\n", 4); diff --git a/xCAT-server/sbin/flashmic b/xCAT-server/sbin/flashmic index 0b0271595..daee9256b 100755 --- a/xCAT-server/sbin/flashmic +++ b/xCAT-server/sbin/flashmic @@ -36,28 +36,43 @@ unless ($master && $cfgpath) { } # get the correct host name for the host -my $nodename; +my ($nodename, $nodename_short); my $masterip = `getent hosts $master | awk {'print \$1'}`; -chomp($masterip); -my $myip = `ip route get $masterip| head -n 1 | sed 's/^.*src//g' | awk {'print \$1'}`; -my $myipinfo =`getent hosts $myip`; -if ($myipinfo =~ /([^\s]+)\s+([^\s]+)\s+([^\s]+)/) { - my $n1 = $2; - my $n2 = $3; - if (length($n1) > length($n2)) { - $nodename = $n2; - } else { - $nodename = $n1; +if ($masterip) { + chomp($masterip); + my $myip = `ip route get $masterip| head -n 1 | sed 's/^.*src//g' | awk {'print \$1'}`; + if ($myip) { + my $myipinfo =`getent hosts $myip`; + + if ($myipinfo && $myipinfo =~ /([^\s]+)\s+([^\s]+)\s+([^\s]+)/) { + my $n1 = $2; + my $n2 = $3; + if (length($n1) > length($n2)) { + $nodename_short = $n2; + } else { + $nodename = $n1; + } + } elsif ($myipinfo && $myipinfo =~ /([^\s]+)\s+([^\s]+)/) { + $nodename_short = $2; + } } -} elsif ($myipinfo =~ /([^\s]+)\s+([^\s]+)/) { - $nodename = $2; -} else { - outputmsg("Error: cannot get the hostname of the host node\n", 2); +} +unless ($nodename) { + $nodename = `hostname`; + chomp($nodename); +} +unless ($nodename_short) { + $nodename_short = `hostname -s`; + chomp($nodename_short); } # download the mic configuration file from master -my $cmd = "wget -N --waitretry=10 --random-wait -T 60 http://$master/$cfgpath/micflash.$nodename -P $tmppath"; -my ($rc, $output) = runsyscmd ($cmd, "Error: failed to download mic configuration file from $master\n", 3); +my $cmd = "wget -N --waitretry=10 --random-wait -T 60 http://$master/$cfgpath/micflash.$nodename_short -P $tmppath"; +my ($rc, $output) = runsyscmd ($cmd); +if ($rc) { + $cmd = "wget -N --waitretry=10 --random-wait -T 60 http://$master/$cfgpath/micflash.$nodename -P $tmppath"; + runsyscmd ($cmd, "Error: failed to download mic configuration file from $master\n", 3); +} unless (-r "$tmppath/micflash.$nodename") { runsyscmd ("Error: cannot get the mic configuration file from http://$master/$cfgpath/micflash.$nodename\n", 4); From 4139e20fb33a6e91599bf0f23c1c5a4ca07d8bc0 Mon Sep 17 00:00:00 2001 From: daniceexi Date: Thu, 8 Aug 2013 12:54:07 -0400 Subject: [PATCH 05/14] defect 3703: to support command [nodeset osimage] when the provmethod has been set --- xCAT-server/lib/xcat/plugins/mic.pm | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/mic.pm b/xCAT-server/lib/xcat/plugins/mic.pm index ebc4421e5..3c64260db 100644 --- a/xCAT-server/lib/xcat/plugins/mic.pm +++ b/xCAT-server/lib/xcat/plugins/mic.pm @@ -596,7 +596,7 @@ sub nodeset { my $subreq = shift; my $host2mic = shift; - my $usage_string = "nodeset noderange [osimage=imagename]"; + my $usage_string = "nodeset noderange osimage[=imagename]"; my $nodes = $request->{'node'}; my $args = $request->{arg}; @@ -604,9 +604,6 @@ sub nodeset { foreach (@$args) { if (/osimage=(.*)/) { $setosimg = $1; - } else { - xCAT::MsgUtils->message("E", {error=>[$usage_string], errorcode=>["1"]}, $callback); - return; } } @@ -625,11 +622,12 @@ sub nodeset { } $nttab->setNodesAttribs(\%setpmethod); } - + + # get the provision method from nodetype table my $nthash = $nttab->getNodesAttribs($nodes,['provmethod']); foreach my $node (@$nodes) { unless (defined ($nthash->{$node}->[0]->{'provmethod'})) { - xCAT::MsgUtils->message("E", {error=>["The provmethod for the node $node must be set before the nodeset."], errorcode=>["1"]}, $callback); + xCAT::MsgUtils->message("E", {error=>["The provmethod for the node $node must be set by [nodeset osimage=] or set in the provmethod attribute of the node."], errorcode=>["1"]}, $callback); return; } } From 65e1f6f484ab716ec858911c25330f131419ecb9 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Thu, 8 Aug 2013 16:26:00 -0400 Subject: [PATCH 06/14] Implement vm.storagecache and vm.storageformat It has been requested to make these tunables available since different storage schemes can benefit greatly from them --- perl-xCAT/xCAT/Schema.pm | 12 +++++++++++- perl-xCAT/xCAT/VMCommon.pm | 2 +- xCAT-server/lib/xcat/plugins/kvm.pm | 27 +++++++++++++++++++++------ 3 files changed, 33 insertions(+), 8 deletions(-) diff --git a/perl-xCAT/xCAT/Schema.pm b/perl-xCAT/xCAT/Schema.pm index 574941075..8a2ac5965 100644 --- a/perl-xCAT/xCAT/Schema.pm +++ b/perl-xCAT/xCAT/Schema.pm @@ -191,7 +191,7 @@ vmmaster => { } }, vm => { - cols => [qw(node mgr host migrationdest storage storagemodel cfgstore memory cpus nics nicmodel bootorder clockoffset virtflags master vncport textconsole powerstate beacon datacenter cluster guestostype othersettings vidmodel vidproto vidpassword comments disable)], + cols => [qw(node mgr host migrationdest storage storagemodel storagecache storageformat cfgstore memory cpus nics nicmodel bootorder clockoffset virtflags master vncport textconsole powerstate beacon datacenter cluster guestostype othersettings vidmodel vidproto vidpassword comments disable)], keys => [qw(node)], tablespace =>'XCATTBS32K', table_desc => 'Virtualization parameters', @@ -230,6 +230,8 @@ vm => { 'vidproto' => "Request a specific protocol for remote video access be set up. For example, spice in KVM.", 'vidmodel' => "Model of video adapter to provide to guest. For example, qxl in KVM", 'vidpassword' => "Password to use instead of temporary random tokens for VNC and SPICE access", + 'storagecache' => "Select caching scheme to employ. E.g. KVM understands 'none', 'writethrough' and 'writeback'", + 'storageformat' => "Select disk format to use by default (e.g. raw versus qcow2)", } }, hypervisor => { @@ -2236,6 +2238,14 @@ my @nodeattrs = ( tabentry => 'vm.storagemodel', access_tabentry => 'vm.node=attr:node', }, + {attr_name => 'vmstoragecache', + tabentry => 'vm.storagecache', + access_tabentry => 'vm.node=attr:node', + }, + {attr_name => 'vmstorageformat', + tabentry => 'vm.storageformat', + access_tabentry => 'vm.node=attr:node', + }, {attr_name => 'vmcfgstore', tabentry => 'vm.cfgstore', access_tabentry => 'vm.node=attr:node', diff --git a/perl-xCAT/xCAT/VMCommon.pm b/perl-xCAT/xCAT/VMCommon.pm index 96dc6367f..ab657b47d 100644 --- a/perl-xCAT/xCAT/VMCommon.pm +++ b/perl-xCAT/xCAT/VMCommon.pm @@ -26,7 +26,7 @@ sub grab_table_data{ #grab table data relevent to VM guest nodes if ($vpdtab) { $cfghash->{vpd} = $vpdtab->getNodesAttribs($noderange,['uuid']); } - $cfghash->{vm} = $vmtab->getNodesAttribs($noderange,['node','host','migrationdest','cfgstore','storage','vidmodel','vidproto','vidpassword','storagemodel','memory','cpus','nics','nicmodel','bootorder','virtflags','datacenter','guestostype','othersettings','master']); + $cfghash->{vm} = $vmtab->getNodesAttribs($noderange,['node','host','migrationdest','cfgstore','storage','storagecache','storageformat','vidmodel','vidproto','vidpassword','storagemodel','memory','cpus','nics','nicmodel','bootorder','virtflags','datacenter','guestostype','othersettings','master']); my $mactab = xCAT::Table->new("mac",-create=>1); my $nrtab= xCAT::Table->new("noderes",-create=>1); $cfghash->{mac} = $mactab->getAllNodeAttribs(['mac'],1); diff --git a/xCAT-server/lib/xcat/plugins/kvm.pm b/xCAT-server/lib/xcat/plugins/kvm.pm index fc3880957..2c52ffb1e 100644 --- a/xCAT-server/lib/xcat/plugins/kvm.pm +++ b/xCAT-server/lib/xcat/plugins/kvm.pm @@ -488,6 +488,10 @@ sub build_diskstruct { $cdhash->{target}->{dev}='hdc'; push @returns,$cdhash; } + my $cachemethod = "none"; + if ( $confdata->{vm}->{$node}->[0]->{storagecache}) { + $cachemethod = $confdata->{vm}->{$node}->[0]->{storagecache}; + } if (defined $confdata->{vm}->{$node}->[0]->{storage}) { @@ -530,8 +534,7 @@ sub build_diskstruct { $tdiskhash->{device}='disk'; $tdiskhash->{driver}->{name}='qemu'; $tdiskhash->{driver}->{type}=$disks{$_}->{format}; - $tdiskhash->{driver}->{cache}="none"; #in this scenario, making a brand new vm, there is not much the hypervisor cache can do for us that the - #guest cannot do for itself + $tdiskhash->{driver}->{cache}=$cachemethod; $tdiskhash->{source}->{file}=$_; $tdiskhash->{target}->{dev} = $disks{$_}->{device}; if ($disks{$_} =~ /^vd/) { @@ -1209,13 +1212,17 @@ sub createstorage { #my $diskstruct = shift; my $node = $cfginfo->{node}; my @flags = split /,/,$cfginfo->{virtflags}; + my $format; foreach (@flags) { if (/^imageformat=(.*)\z/) { - $imgfmt=$1; + $format=$1; } elsif (/^clonemethod=(.*)\z/) { $clonemethod=$1; } } + if ($cfginfo->{storageformat}) { + $format = $cfginfo->{storageformat}; + } my $mountpath; my $pathappend; @@ -1242,7 +1249,7 @@ sub createstorage { if ($filename =~ /^nfs:/ or $filename =~ /^dir:/ or $filename =~ /^lvm:/) { #libvirt storage pool to be used for this my @sizes = split /,/,$size; foreach (@sizes) { - get_filepath_by_url(url=>$filename,dev=>$prefix.shift(@suffixes),create=>$_, force=>$force); + get_filepath_by_url(url=>$filename,dev=>$prefix.shift(@suffixes),create=>$_, force=>$force, format=>$format); } }else{ oldCreateStorage($filename, $mastername, $size, $cfginfo, $force); @@ -1653,6 +1660,15 @@ sub chvm { $suffix=$1; $format='raw'; } + if ($confdata->{vm}->{$node}->[0]->{storageformat}) { + $format = $confdata->{vm}->{$node}->[0]->{storageformat}; + } + #when creating a new disk not cloned from anything, disable cache as copy on write content similarity is a lost cause... + my $cachemode = 'none'; + #unless user knows better + if ($confdata->{vm}->{$node}->[0]->{storagecache}) { + $cachemode = $confdata->{vm}->{$node}->[0]->{storagecache}; + } my $bus; if ($suffix =~ /^sd/) { $bus='scsi'; @@ -1661,8 +1677,7 @@ sub chvm { } elsif ($suffix =~ /vd/) { $bus='virtio'; } - #when creating a new disk not cloned from anything, disable cache as copy on write content similarity is a lost cause... - my $xml = ""; + my $xml = ""; if ($currstate eq 'on') { #attempt live attach eval { $dom->attach_device($xml); From d5609b9ca85ef4f67015ea6aee2682e77e4ce3ce Mon Sep 17 00:00:00 2001 From: immarvin Date: Thu, 8 Aug 2013 21:32:03 -0700 Subject: [PATCH 07/14] fix defect 3734 makehosts throw exceptions when node ip is not illegal --- xCAT-server/lib/xcat/plugins/hosts.pm | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/xCAT-server/lib/xcat/plugins/hosts.pm b/xCAT-server/lib/xcat/plugins/hosts.pm index 1c46e4ed3..c17b48584 100644 --- a/xCAT-server/lib/xcat/plugins/hosts.pm +++ b/xCAT-server/lib/xcat/plugins/hosts.pm @@ -252,6 +252,13 @@ sub add_hosts_content { { addnode $callback, $nodename, $ip, $ref->{hostnames}, $domain; } + else + { + my $rsp; + push @{$rsp->{data}}, "Invalid IP Addr \'$ref->{ip}\' for node \'$ref->{node}\'."; + xCAT::MsgUtils->message("E", $rsp, $callback); + } + if (defined($ref->{otherinterfaces})) { addotherinterfaces $callback, $nodename, $ref->{otherinterfaces}, $domain; From ab02c12352356768a1fcad0fbc673aa5d407fec8 Mon Sep 17 00:00:00 2001 From: wanghuaz Date: Fri, 9 Aug 2013 17:10:36 +0800 Subject: [PATCH 08/14] fixing bug 3721, don't remove the repo from otherpkgdir if the repo is used by other osimage --- xCAT-server/lib/xcat/plugins/kit.pm | 73 +++++++++++++++++++++++++++-- 1 file changed, 69 insertions(+), 4 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/kit.pm b/xCAT-server/lib/xcat/plugins/kit.pm index b472dfc7e..f16b15676 100644 --- a/xCAT-server/lib/xcat/plugins/kit.pm +++ b/xCAT-server/lib/xcat/plugins/kit.pm @@ -303,6 +303,47 @@ sub comp_word } + +#------------------------------------------------------- + +=head3 check_newinstall + + Check if the given kitcomp list are in NEW_INSTALL_LIST + or not. If so, set $::noupgrade all other kitcomp + depending on this list will be put into NEW_INSTALL_LIST + also + +=cut + +#------------------------------------------------------- +sub check_newinstall +{ + my $kitcomponents = shift; + my @lines = @_; + + my @kitcomps = split /,/, $kitcomponents; + + foreach my $kitcomp ( @kitcomps ) { + last if ( $::noupgrade ); + + my $match_newinstall = 0; + foreach my $line ( @lines ) { + chomp($line); + if ( $line =~ /^#NEW_INSTALL_LIST#$/ ) { + $match_newinstall = 1; + } + if ( $line =~ /\/$kitcomp$/ ) { + if ( $match_newinstall ) { + $::noupgrade = 1; + } + last; + } + } + } + +} + + #------------------------------------------------------- =head3 assign_to_osimage @@ -319,7 +360,7 @@ sub assign_to_osimage my $callback = shift; my $tabs = shift; - (my $kitcomptable) = $tabs->{kitcomponent}->getAttribs({kitcompname=> $kitcomp}, 'kitname', 'kitreponame', 'basename', 'kitpkgdeps', 'prerequisite', 'exlist', 'genimage_postinstall','postbootscripts', 'driverpacks'); + (my $kitcomptable) = $tabs->{kitcomponent}->getAttribs({kitcompname=> $kitcomp}, 'kitname', 'kitreponame', 'basename', 'kitcompdeps', 'kitpkgdeps', 'prerequisite', 'exlist', 'genimage_postinstall','postbootscripts', 'driverpacks'); (my $osimagetable) = $tabs->{osimage}->getAttribs({imagename=> $osimage}, 'provmethod', 'osarch', 'postbootscripts', 'kitcomponents'); (my $linuximagetable) = $tabs->{linuximage}->getAttribs({imagename=> $osimage}, 'rootimgdir', 'exlist', 'postinstall', 'otherpkglist', 'otherpkgdir', 'driverupdatesrc'); @@ -688,6 +729,13 @@ sub assign_to_osimage push @lines, "$kitreponame/$kitcomptable->{prerequisite}\n"; $::noupgrade = 1; } + + # Check if this kitcomponent's kitcompdeps are in NEW_INSTALL_LIST or not. + # If so, set $::noupgrade to put this kitcomp in a new NEW_INSTALL_LIST + if ( $kitcomptable and $kitcomptable->{kitcompdeps} ) { + check_newinstall($kitcomptable->{kitcompdeps}, @lines); + } + if ( $::noupgrade ) { push @lines, "#NEW_INSTALL_LIST#\n"; foreach my $kitdeployparam ( @kitdeployparams ) { @@ -2141,7 +2189,7 @@ sub addkitcomp if ( $kitcomp eq $oskitcomp ) { my %rsp; push@{ $rsp{data} }, "$kitcomp kit component is already in osimage $osimage"; - xCAT::MsgUtils->message( "E", \%rsp, $callback ); + xCAT::MsgUtils->message( "I", \%rsp, $callback ); $catched = 1; } } @@ -2491,19 +2539,36 @@ sub rmkitcomp # Remove symlink from osimage.otherpkgdir. + # Read all the kitcomponents assigned to all the osimage to make sure the repo used by other osimage + # will not be deleted. + + my @allosikitcomps = $tabs{osimage}->getAllAttribs( 'imagename', 'kitcomponents' ); + (my $linuximagetable) = $tabs{linuximage}->getAttribs({imagename=> $osimage}, 'postinstall', 'exlist', 'otherpkglist', 'otherpkgdir', 'driverupdatesrc'); if ( $linuximagetable and $linuximagetable->{otherpkgdir} ) { my $otherpkgdir = $linuximagetable->{otherpkgdir}; foreach my $kitcomponent (keys %kitcomps) { + my %newosikitcomponents; + foreach my $allosikitcomp (@allosikitcomps) { + if ( $allosikitcomp->{kitcomponents} and $allosikitcomp->{imagename} ) { + my @allkitcomps = split /,/, $allosikitcomp->{kitcomponents}; + foreach my $allkitcomp ( @allkitcomps ) { + if ( $allosikitcomp->{imagename} ne $osimage or $allkitcomp ne $kitcomponent ) { + $newosikitcomponents{$allkitcomp} = 1; + } + } + } + } + if ( $kitcomps{$kitcomponent}{kitreponame} ) { if ( -d "$otherpkgdir/$kitcomps{$kitcomponent}{kitreponame}" ) { # Check if this repo is used by other kitcomponent before removing the link my $match = 0; - foreach my $osikitcomp ( @osikitcomps ) { - next if ( $osikitcomp =~ /$kitcomponent/ ); + foreach my $osikitcomp ( keys %newosikitcomponents ) { + my $depkitrepodir; (my $kitcomptable) = $tabs{kitcomponent}->getAttribs({kitcompname => $osikitcomp}, 'kitreponame'); if ( $kitcomptable and $kitcomptable->{kitreponame} ) { From 2952f0e90728c15707b03f9769ac5e0b8790d76e Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Fri, 9 Aug 2013 10:30:58 -0400 Subject: [PATCH 09/14] Do sparse allocation for non-lvm raw format images --- xCAT-server/lib/xcat/plugins/kvm.pm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/xCAT-server/lib/xcat/plugins/kvm.pm b/xCAT-server/lib/xcat/plugins/kvm.pm index 2c52ffb1e..53d7568ef 100644 --- a/xCAT-server/lib/xcat/plugins/kvm.pm +++ b/xCAT-server/lib/xcat/plugins/kvm.pm @@ -278,7 +278,9 @@ sub get_filepath_by_url { #at the end of the day, the libvirt storage api gives my $create = $args{create}; my $force = $args{force}; my $format = $args{format}; + my $sparse = 1; if ($url =~ /^lvm:/) { + $sparse = 0; $format = 'raw'; } unless ($format) { @@ -327,7 +329,7 @@ sub get_filepath_by_url { #at the end of the day, the libvirt storage api gives # additionally, when mastering a powered down node, we should rebase the node to be a cow clone of the master it just spawned } else { my $vol; - if ($format eq 'raw') { #skip allocation specification for now + unless ($sparse) { #skip allocation specification for now #currently, LV can have reduced allocation, but *cannot* grow..... $vol = $poolobj->create_volume("".$desiredname."".getUnits($create,"G",1).""); } else { From 221caa74ab133d4f0d9f189b1507dc0f231c2276 Mon Sep 17 00:00:00 2001 From: xq2005 Date: Mon, 12 Aug 2013 02:48:54 -0700 Subject: [PATCH 10/14] add comments in anaconda.pm --- xCAT-server/lib/xcat/plugins/anaconda.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/xCAT-server/lib/xcat/plugins/anaconda.pm b/xCAT-server/lib/xcat/plugins/anaconda.pm index fdb1d6c82..ac4493666 100644 --- a/xCAT-server/lib/xcat/plugins/anaconda.pm +++ b/xCAT-server/lib/xcat/plugins/anaconda.pm @@ -1556,7 +1556,8 @@ sub mksysclone } } - # copy postscripts + # copy postscripts, the xCAT scripts may update, but the image is captured long time ago + # should update the scripts at each nodeset my $script1 = "configefi"; my $script2 = "updatenetwork"; my $pspath = "$installroot/sysclone/scripts/post-install/"; From ddc5274f50b633cf9059ad51ab2fbb488fd2c55e Mon Sep 17 00:00:00 2001 From: daniceexi Date: Mon, 12 Aug 2013 11:18:49 -0400 Subject: [PATCH 11/14] Add usage message and manpage for geninitrd command; Add --noupdateinitrd flag for nodeset manpage; Make geninitrd to check the provmethod if no image name is specified --- xCAT-client/pods/man1/geninitrd.1.pod | 100 ++++++++++++++++++++++ xCAT-client/pods/man8/nodeset.8.pod | 7 ++ xCAT-server/lib/xcat/plugins/geninitrd.pm | 53 ++++++++++-- 3 files changed, 155 insertions(+), 5 deletions(-) create mode 100644 xCAT-client/pods/man1/geninitrd.1.pod diff --git a/xCAT-client/pods/man1/geninitrd.1.pod b/xCAT-client/pods/man1/geninitrd.1.pod new file mode 100644 index 000000000..65de247df --- /dev/null +++ b/xCAT-client/pods/man1/geninitrd.1.pod @@ -0,0 +1,100 @@ +=head1 NAME + +B - Generate an initrd (initial ramfs) which to be used for statefull install or stateless netboot. + +=head1 SYNOPSIS + +B + +B [B<-h> | B<--help>] + + +=head1 DESCRIPTION + +Generate the initrd for the osimage: B which is an xCAT object of I type. + +B + +=over 2 + +If the B is a statefull one (The provmethod attribute for the osimage is 'install'), +this command is used to rebuild the initrd to inject the new drivers from driver rpms or +'update distro' and copy the rebuilt initrd and new kernel (If there's new kernel in 'update +distro') to the directory I>. + +If the initrd has been rebuilt by geninitrd, when run nodeset, the I<--noupdateinitrd> option +should be used to skip the rebuilding of initrd to improve the performance. + +Three attributes of osimage object can be used to specify the Driver RPM location and Driver names +for injecting new drviers to initrd. + +B - comma separated driver names that need to be injected to the initrd. +The postfix '.ko' can be ignored. The netdrivers attribute must be set to specify the new driver list. +If you want to load all the drivers from the driver rpms, using the keyword allupdate. + +B - comma separated driver rpm packages (full path should be specified) + +B - comma separated 'osdistroupdate' object. Each 'osdistroupdate' object specifies a +Linux distro update. When run geninitrd, 'kernel-*.rpm' will be searched from osdistroupdate.dirpath +to get all the rpm packages and then search the drivers from the rpm packages. + +Refer to the doc: https://sourceforge.net/apps/mediawiki/xcat/index.php?title=Using_Linux_Driver_Update_Disk + +=back + +B + +=over 2 + +If the B is a stateless one (The provmethod attribute for the osimage is 'netboot'), +this command is used to generate the initrd from the rootimg which generated by 'genimage' command. +So the 'genimage' must be run once before running the geninitrd command. + +Two attributes of osimage object can be used to specify the Driver RPM location and Driver names +for injecting new drviers to initrd. + +B - comma separated driver names that need to be injected to the initrd. +The postfix '.ko' can be ignored. The netdrivers attribute must be set to specify the new driver list. +If you want to load all the drivers from the driver rpms, using the keyword allupdate. + +B - comma separated driver rpm packages (full path should be specified) + +=back + + +=head1 Parameters + +I specifies the name of an os image definition to be used. The specification for the image is storted in the I table and I table. + + +=head1 RETURN VALUE + +0 The command completed successfully. + +1 An error has occurred. + + +=head1 EXAMPLES + +=over 3 + +=item 1 +To generate initrd for the osimage B: + + geninitrd myimagename + +=back + + +=head1 FILES + +/opt/xcat/bin/geninitrd + +/opt/xcat/bin/genimage + +/opt/xcat/share/xcat/netboot//genimage + + +=head1 SEE ALSO + +L, L diff --git a/xCAT-client/pods/man8/nodeset.8.pod b/xCAT-client/pods/man8/nodeset.8.pod index 75e49d312..b29373a9b 100644 --- a/xCAT-client/pods/man8/nodeset.8.pod +++ b/xCAT-client/pods/man8/nodeset.8.pod @@ -6,6 +6,8 @@ B - set the boot state for a noderange B [I] [I|I|I|I|I|I|I|I|I>]] +B I [I> I<--noupdateinitrd>] + B [I<-h>|I<--help>|I<-v>|I<--version>] =head1 B @@ -67,6 +69,11 @@ Cleanup the current pxe/tftp boot configuration files for the nodes requested Prepare server for installing a node using the specified os image. The os image is defined in the I table and I table. If the is omitted, the os image name will be obtained from I for the node. +=item B<--noupdateinitrd> + +Skip the rebuilding of initrd when the 'netdrivers', 'drvierupdatesrc' or 'osupdatename' were set for injecting new drviers to initrd. But, the geninitrd command +should be run to rebuild the initrd for new drivers injecting. This is used to improve the performance of nodeset command. + =item B=> If you would like to run a task after deployment, you can define that task with this attribute. diff --git a/xCAT-server/lib/xcat/plugins/geninitrd.pm b/xCAT-server/lib/xcat/plugins/geninitrd.pm index a364a6210..9a9fe45f1 100644 --- a/xCAT-server/lib/xcat/plugins/geninitrd.pm +++ b/xCAT-server/lib/xcat/plugins/geninitrd.pm @@ -26,8 +26,28 @@ sub preprocess_request my $req = shift; my $callback = shift; - unless (defined ($req->{arg}) && $req->{arg}->[0]) { - xCAT::MsgUtils->message("E", {error=>["An osimage name needs to be specified."], errorcode=>["1"]}, $callback); + my $usage = sub { + my $callback = shift; + xCAT::MsgUtils->message("I", {data=>["Usage: geninitrd [-h | --help]"]}, $callback); + }; + + my $osimage; + if (defined ($req->{arg})) { + foreach (@{$req->{arg}}) { + if (/^-/) { + $usage->($callback); + return; + }else { + $osimage = $_; + } + } + } else { + $usage->($callback); + return; + } + + unless ($osimage) { + $usage->($callback); return; } @@ -46,10 +66,11 @@ sub process_request { my $req = shift; my $callback = shift; + my $doreq = shift; if ($req->{command}->[0] eq 'geninitrd') { - return geninitrd($req, $callback); + return geninitrd($req, $callback, $doreq); } } @@ -57,6 +78,7 @@ sub process_request sub geninitrd { my $req = shift; my $callback = shift; + my $doreq = shift; my $osimage = $req->{arg}->[0]; @@ -69,7 +91,7 @@ sub geninitrd { return; } - my $oient = $osimagetab->getAttribs({imagename => $osimage}, 'osvers', 'osarch', 'osupdatename'); + my $oient = $osimagetab->getAttribs({imagename => $osimage}, 'provmethod', 'osvers', 'osarch', 'osupdatename'); unless ($oient && $oient->{'osvers'} && $oient->{'osarch'} ) { xCAT::MsgUtils->message("E", {error=>["The osimage [$osimage] was not defined or [osvers, osarch] attributes were not set."], errorcode=>["1"]}, $callback); return; @@ -84,7 +106,7 @@ sub geninitrd { return; } - my $lient = $linuximagetab->getAttribs({imagename => $osimage}, 'pkgdir', 'driverupdatesrc', 'netdrivers'); + my $lient = $linuximagetab->getAttribs({imagename => $osimage}, 'rootimgdir', 'pkgdir', 'driverupdatesrc', 'netdrivers'); unless ($lient && $lient->{'pkgdir'}) { xCAT::MsgUtils->message("E", {error=>["The osimage [$osimage] was not defined or [pkgdir] attribute was not set."], errorcode=>["1"]}, $callback); return; @@ -93,6 +115,27 @@ sub geninitrd { $driverupdatesrc = $lient->{'driverupdatesrc'}; $netdrivers = $lient->{'netdrivers'}; + # if the provmethod equals 'netboot', call the genimage --onlyinitrd directly + if ($oient->{'provmethod'} && $oient->{'provmethod'} eq "netboot") { + if ($lient->{'rootimgdir'}) { + unless (-d $lient->{'rootimgdir'}."/rootimg/lib/modules") { + xCAT::MsgUtils->message("E", {error=>["The genimage should be run before running geninitrd."], errorcode=>["1"]}, $callback); + return; + } + } else { + xCAT::MsgUtils->message("E", {error=>["The rootimgdir attribute for the osimage should be set."], errorcode=>["1"]}, $callback); + return; + } + my @output = `genimage $osimage --onlyinitrd`; + xCAT::MsgUtils->message("I", {data=>\@output}, $callback); + #$doreq->({ command => ['genimage'], + # arg => [$osimage, '--onlyinitrd'] }, $callback); + return; + } elsif (!$oient->{'provmethod'} || $oient->{'provmethod'} ne "install") { + xCAT::MsgUtils->message("E", {error=>["The attribute [provmethod] for osimage [$osimage] must be set to install or netboot."], errorcode=>["1"]}, $callback); + return; + } + # get the path list of the osdistroupdate if ($oient->{'osupdatename'}) { my @osupdatenames = split (/,/, $oient->{'osupdatename'}); From 9209ba674bb0a5fa15ecf58b64a5154065bb62bb Mon Sep 17 00:00:00 2001 From: lissav Date: Mon, 12 Aug 2013 12:52:25 -0400 Subject: [PATCH 12/14] Defect 3731 --- perl-xCAT/xCAT/MsgUtils.pm | 3 --- 1 file changed, 3 deletions(-) diff --git a/perl-xCAT/xCAT/MsgUtils.pm b/perl-xCAT/xCAT/MsgUtils.pm index 4f7462669..a26cbe75e 100644 --- a/perl-xCAT/xCAT/MsgUtils.pm +++ b/perl-xCAT/xCAT/MsgUtils.pm @@ -457,7 +457,6 @@ sub message # If they want this msg to also go to syslog, do that now eval { openlog("xCAT", '', 'local4'); - setlogsock(["tcp", "unix", "stream"]); if ($sev eq 'SE') { syslog("err", $rsp); } else { @@ -504,7 +503,6 @@ sub message print $stdouterrf "Unable to open auditlog\n"; eval { openlog("xCAT", '', 'local4'); - setlogsock(["tcp", "unix", "stream"]); syslog("err", "Unable to write to auditlog"); closelog(); }; @@ -522,7 +520,6 @@ sub message print $stdouterrf "Unable to open auditlog\n"; eval { openlog("xCAT", '', 'local4'); - setlogsock(["tcp", "unix", "stream"]); syslog("err", "Unable to open auditlog"); closelog(); }; From a02372c5cb2d28e5ba731c6b45a03268a5de76a6 Mon Sep 17 00:00:00 2001 From: lissav Date: Mon, 12 Aug 2013 13:49:31 -0400 Subject: [PATCH 13/14] defect 3731 --- perl-xCAT/xCAT/MsgUtils.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/perl-xCAT/xCAT/MsgUtils.pm b/perl-xCAT/xCAT/MsgUtils.pm index a26cbe75e..6a554d8ae 100644 --- a/perl-xCAT/xCAT/MsgUtils.pm +++ b/perl-xCAT/xCAT/MsgUtils.pm @@ -10,7 +10,7 @@ if ($^O =~ /^aix/i) { } use strict; -use Sys::Syslog qw (:DEFAULT setlogsock); +use Sys::Syslog; use xCAT::Utils; #use locale; use Socket; @@ -456,7 +456,7 @@ sub message # If they want this msg to also go to syslog, do that now eval { - openlog("xCAT", '', 'local4'); + openlog("xCAT", "nofatal,pid", "local4"); if ($sev eq 'SE') { syslog("err", $rsp); } else { @@ -502,7 +502,7 @@ sub message { print $stdouterrf "Unable to open auditlog\n"; eval { - openlog("xCAT", '', 'local4'); + openlog("xCAT", "nofatal,pid", "local4"); syslog("err", "Unable to write to auditlog"); closelog(); }; @@ -519,7 +519,7 @@ sub message { # error print $stdouterrf "Unable to open auditlog\n"; eval { - openlog("xCAT", '', 'local4'); + openlog("xCAT", "nofatal,pid", "local4"); syslog("err", "Unable to open auditlog"); closelog(); }; From 275a19151bf749d73373f227afe43ecb6116a163 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Mon, 12 Aug 2013 16:04:08 -0400 Subject: [PATCH 14/14] Fix ipmi FRU parser to give up once malformed data is encountered --- xCAT-server/lib/xcat/plugins/ipmi.pm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/xCAT-server/lib/xcat/plugins/ipmi.pm b/xCAT-server/lib/xcat/plugins/ipmi.pm index 2f19bdfea..ae7104d07 100644 --- a/xCAT-server/lib/xcat/plugins/ipmi.pm +++ b/xCAT-server/lib/xcat/plugins/ipmi.pm @@ -2895,6 +2895,7 @@ sub parseprod { } $idx+=$currsize; ($currsize,$currdata,$encode)=extractfield(\@area,$idx); + if ($currsize < 0) { last } } return \%info; @@ -2967,6 +2968,7 @@ sub parseboard { } $idx+=$currsize; ($currsize,$currdata,$encode)=extractfield(\@area,$idx); + if ($currsize < 0) { last } } if ($global_sessdata->{isanimm}) { #we can understand more specifically some of the extra fields... $boardinf{frunum}=$boardinf{extra}->[0]->{value}; @@ -3031,6 +3033,7 @@ sub parsechassis { } $idx+=$currsize; ($currsize,$currdata,$encode)=extractfield(\@chassarea,$idx); + if ($currsize < 0) { last } } return \%chassisinf; } @@ -3042,7 +3045,7 @@ sub extractfield { #idx is location of the type/length byte, returns something a my $data; if ($idx >= scalar @$area) { xCAT::SvrUtils::sendmsg([1,"Error parsing FRU data from BMC"],$callback); - return 1,undef,undef; + return -1,undef,undef; } my $size = $area->[$idx] & 0b00111111; my $encoding = ($area->[$idx] & 0b11000000)>>6;