diff --git a/build-ubunturepo b/build-ubunturepo index d133d2af3..2829edeb2 100755 --- a/build-ubunturepo +++ b/build-ubunturepo @@ -43,6 +43,10 @@ printusage() # Process cmd line variable assignments, assigning each attr=val pair to a variable of same name for i in $*; do + echo $i | grep '=' + if [ $? != 0 ];then + continue + fi # upper case the variable name varstring=`echo "$i"|cut -d '=' -f 1|tr '[a-z]' '[A-Z]'`=`echo "$i"|cut -d '=' -f 2` export $varstring @@ -167,6 +171,7 @@ then short_ver=`cat Version|cut -d. -f 1,2` short_short_ver=`cat Version|cut -d. -f 1` + package_dir_name=debs$REL #TODO: define the core path and tarball name tarball_name="core-debs-snap.tar.bz2" @@ -186,8 +191,8 @@ then cur_date=`date +%Y%m%d` pkg_version="${short_ver}-${pkg_type}${cur_date}" - if [ ! -d ../../debs ];then - mkdir -p "../../debs" + if [ ! -d ../../$package_dir_name ];then + mkdir -p "../../$package_dir_name" fi packages="xCAT-client xCAT-genesis-scripts perl-xCAT xCAT-server xCAT-UI xCAT xCATsn xCAT-test xCAT-OpenStack" @@ -195,9 +200,9 @@ then do file_low=`echo $file | tr '[A-Z]' '[a-z]'` if grep -q $file $update_log || [ "$BUILDALL" == 1 -o "$file" = "perl-xCAT" ]; then - rm -f ../../debs/${file_low}_*.deb + rm -f ../../$package_dir_name/${file_low}_*.deb #only for genesis package - rm -f ../../debs/${file_low}-amd64_*.deb + rm -f ../../$package_dir_name/${file_low}-amd64_*.deb cd $file dch -v $pkg_version -b -c debian/changelog $build_string dpkg-buildpackage -uc -us @@ -208,11 +213,11 @@ then cd - find $file -maxdepth 3 -type d -name "${file_low}*" | grep debian | xargs rm -rf find $file -maxdepth 3 -type f -name "files" | grep debian | xargs rm -rf - mv ${file_low}* ../../debs/ + mv ${file_low}* ../../$package_dir_name/ fi done - find ../../debs/* ! -name *.deb | xargs rm -f + find ../../$package_dir_name/* ! -name *.deb | xargs rm -f fi if [ "$PROMOTE" = 1 ]; then @@ -256,7 +261,7 @@ __EOF__ #import the deb packages into the repo for dist in $dists; do - for file in `ls ../debs/*.deb`; do + for file in `ls ../$package_dir_name/*.deb`; do reprepro -b ./ includedeb $dist $file; done done diff --git a/perl-xCAT/xCAT/FSPscan.pm b/perl-xCAT/xCAT/FSPscan.pm index 90a985caf..6ed064c17 100644 --- a/perl-xCAT/xCAT/FSPscan.pm +++ b/perl-xCAT/xCAT/FSPscan.pm @@ -13,6 +13,7 @@ use xCAT::GlobalDef; use xCAT::Usage; use xCAT::NetworkUtils; use xCAT::FSPUtils; +require xCAT::data::ibmhwtypes; #use Data::Dumper; ############################################## @@ -391,6 +392,7 @@ sub format_stanza { ################################# # Add each attribute ################################# + my $mtm = undef; foreach ( @attribs ) { my $d = $data[$i++]; @@ -401,7 +403,8 @@ sub format_stanza { } elsif ( /^hwtype$/ ) { $d = $globalhwtype{$type}; } elsif ( /^groups$/ ) { - $d = "$type,all"; + next; + #$d = "$type,all"; } elsif ( /^mgt$/ ) { $d = $hwtype; } elsif ( /^cons$/ ) { @@ -414,7 +417,9 @@ sub format_stanza { } elsif ( /^(mtm|serial)$/ ) { if ( $type eq "lpar" ) { $d = undef; - } + } elsif (/^mtm$/) { + $mtm = $d; + } } elsif (/^side$/) { unless ( $type =~ /^fsp|bpa$/ ) { next; @@ -422,6 +427,15 @@ sub format_stanza { } $result .= "\t$_=$d\n"; } + my $tmp_groups = "$type,all"; + if (defined($mtm)) { + my $tmp_pre = xCAT::data::ibmhwtypes::parse_group($mtm); + if (defined($tmp_pre)) { + $tmp_groups .= ",$tmp_pre"; + } + } + $result .= "\tgroups=$tmp_groups\n"; + } return( $result ); } @@ -464,6 +478,7 @@ sub format_xml { ################################# # Add each attribute ################################# + my $mtm = undef; foreach ( @attribs ) { my $d = $data[$i++]; @@ -472,7 +487,8 @@ sub format_xml { } elsif ( /^hwtype$/ ) { $d = $globalhwtype{$type}; } elsif ( /^groups$/ ) { - $d = "$type,all"; + next; + #$d = "$type,all"; } elsif ( /^mgt$/ ) { $d = $hwtype; } elsif ( /^cons$/ ) { @@ -484,6 +500,8 @@ sub format_xml { } elsif ( /^(mtm|serial)$/ ) { if ( $type eq "lpar" ) { $d = undef; + } elsif (/^mtm$/) { + $mtm = $d; } } elsif (/^side$/) { unless ( $type =~ /^fsp|bpa$/ ) { @@ -492,6 +510,15 @@ sub format_xml { } $href->{Node}->{$_} = $d; } + my $tmp_groups = "$type,all"; + if (defined($mtm)) { + my $tmp_pre = xCAT::data::ibmhwtypes::parse_group($mtm); + if (defined($tmp_pre)) { + $tmp_groups .= ",$tmp_pre"; + } + } + $href->{Node}->{groups}=$tmp_groups; + #print Dumper($href); ################################# # XML encoding diff --git a/perl-xCAT/xCAT/NodeRange.pm b/perl-xCAT/xCAT/NodeRange.pm index 66df2c45c..1a34b912b 100644 --- a/perl-xCAT/xCAT/NodeRange.pm +++ b/perl-xCAT/xCAT/NodeRange.pm @@ -602,28 +602,16 @@ sub noderange { my $op = ","; if ($start =~ m/-$/) { #subtract the parenthetical $op .= "-" - } elsif ($start =~ m/@$/) { + } elsif ($start =~ m/\@$/) { $op = "@" } $start =~ s/,-$//; $start =~ s/,$//; - $start =~ s/@$//; + $start =~ s/\@$//; %nodes = map { $_ => 1 } noderange($start,$verify,$exsitenode,%options); my %innernodes = map { $_ => 1 } noderange($middle,$verify,$exsitenode,%options); set_arith(\%nodes,$op,\%innernodes); - $op=","; - if ($end =~ m/^,-/) { - $op = ",-"; - $end =~ s/^,-//; - } elsif ($end =~ m/^@/) { - $op = "@"; - $end =~ s/^@//; - } else { - $end =~ s/^,//; - } - my %endnodes = map { $_ => 1 } noderange($end,$verify,$exsitenode,%options); - set_arith(\%nodes,$op,\%endnodes); - return sort(keys %nodes) + $range = $end; } my $op = ","; @@ -632,14 +620,19 @@ sub noderange { @elems = split(/(@(?![^\(]*?\)))/,$range); # only split on @ when no , are present (inner recursion) } - while (my $atom = shift @elems) { + while (defined(my $atom = shift @elems)) { + if ($atom eq '') { next; } if ($atom eq ',') { next; } if ($atom =~ /^-/) { # if this is an exclusion, strip off the minus, but remember it $atom = substr($atom,1); $op = $op."-"; + } elsif ($atom =~ /^\@/) { # if this is an exclusion, strip off the minus, but remember it + $atom = substr($atom,1); + $op = "@"; } + if ($atom eq '') { next; } if ($atom =~ /^\^(.*)$/) { # get a list of nodes from a file open(NRF,$1); diff --git a/perl-xCAT/xCAT/PPCdb.pm b/perl-xCAT/xCAT/PPCdb.pm index 52bc3a804..145652510 100644 --- a/perl-xCAT/xCAT/PPCdb.pm +++ b/perl-xCAT/xCAT/PPCdb.pm @@ -7,6 +7,7 @@ use xCAT::GlobalDef; use xCAT::Utils; use xCAT::TableUtils; use xCAT::NetworkUtils; +require xCAT::data::ibmhwtypes; ########################################### # Factory defaults @@ -168,6 +169,10 @@ sub add_ppc { # Update nodelist table ########################### updategroups( $name, $db{nodelist}, $type ); + my $tmp_group = xCAT::data::ibmhwtypes::parse_group($model); + if (defined($tmp_group)) { + updategroups($name, $db{nodelist}, $tmp_group); + } if ( $type =~ /^(fsp|bpa)$/ ) { $db{nodelist}->setNodeAttribs( $name, {hidden => '1'}); } else { @@ -525,6 +530,10 @@ sub update_node_attribs if ( $namediff) { updategroups( $name, $db->{nodelist}, $type ); + my $tmp_group = xCAT::data::ibmhwtypes::parse_group($model); + if (defined($tmp_group)) { + updategroups($name, $db->{nodelist}, $tmp_group); + } $db->{nodelist}->setNodeAttribs( $name, {status=>$nodelisthash->{status}, appstatus=>$nodelisthash->{appstatus}, primarysn=>$nodelisthash->{primarysn}, diff --git a/perl-xCAT/xCAT/PPCinv.pm b/perl-xCAT/xCAT/PPCinv.pm index 640cc1dd9..ea7f0d0c0 100644 --- a/perl-xCAT/xCAT/PPCinv.pm +++ b/perl-xCAT/xCAT/PPCinv.pm @@ -5,6 +5,8 @@ use strict; use Getopt::Long; use xCAT::PPCcli qw(SUCCESS EXPECT_ERROR RC_ERROR NR_ERROR); use xCAT::Usage; +use xCAT::TableUtils; +require xCAT::data::ibmhwtypes; ########################################## @@ -59,7 +61,7 @@ sub parse_args { $Getopt::Long::ignorecase = 0; Getopt::Long::Configure( "bundling" ); - if ( !GetOptions( \%opt, qw(V|verbose) )) { + if ( !GetOptions( \%opt, qw(V|verbose t) )) { return( usage() ); } #################################### @@ -75,6 +77,9 @@ sub parse_args { if ( !defined( $cmd )) { return(usage( "Invalid command: $ARGV[0]" )); } + if (exists($opt{t}) and $cmd ne "model") { + return(["Option 't' can only work with 'model'."]); + } #################################### # Check for an extra argument #################################### @@ -411,6 +416,12 @@ sub vpd { ############################# # Output value ############################# + if ($_ eq 'model' and exists($request->{opt}->{t})) { + my $tmp_pre = xCAT::data::ibmhwtypes::parse_args($data->{$_}); + if (defined($tmp_pre)) { + xCAT::TableUtils->updatenodegroups($name, $tmp_pre); + } + } my $value = "@{$prefix{$_}}[0]: $data->{$_}"; push @result, [$name,$value,$Rc]; } diff --git a/perl-xCAT/xCAT/PPCscan.pm b/perl-xCAT/xCAT/PPCscan.pm index 513d52c88..413e93f05 100644 --- a/perl-xCAT/xCAT/PPCscan.pm +++ b/perl-xCAT/xCAT/PPCscan.pm @@ -11,7 +11,7 @@ use xCAT::PPCdb; use xCAT::GlobalDef; use xCAT::Usage; use xCAT::NetworkUtils; - +require xCAT::data::ibmhwtypes; ############################################## # Globals @@ -545,6 +545,7 @@ sub format_stanza { ################################# # Add each attribute ################################# + my $mtm = undef; foreach ( @attribs ) { my $d = $data[$i++]; @@ -555,7 +556,8 @@ sub format_stanza { } elsif ( /^hwtype$/ ) { $d = $globalhwtype{$type}; } elsif ( /^groups$/ ) { - $d = "$type,all"; + next; + #$d = "$type,all"; } elsif ( /^mgt$/ ) { $d = $hwtype; } elsif ( /^cons$/ ) { @@ -568,7 +570,9 @@ sub format_stanza { } elsif ( /^(mtm|serial)$/ ) { if ( $type eq "lpar" ) { $d = undef; - } + } elsif (/^mtm$/) { + $mtm = $d; + } } elsif (/^side$/) { unless ( $type =~ /^fsp|bpa$/ ) { next; @@ -576,6 +580,14 @@ sub format_stanza { } $result .= "\t$_=$d\n"; } + my $tmp_groups = "$type,all"; + if (defined($mtm)) { + my $tmp_pre = xCAT::data::ibmhwtypes::parse_group($mtm); + if (defined($tmp_pre)) { + $tmp_groups .= ",$tmp_pre"; + } + } + $result .= "\tgroups=$tmp_groups\n"; } return( $result ); } @@ -623,6 +635,7 @@ sub format_xml { ################################# # Add each attribute ################################# + my $mtm = undef; foreach ( @attribs ) { my $d = $data[$i++]; @@ -631,7 +644,8 @@ sub format_xml { } elsif ( /^hwtype$/ ) { $d = $globalhwtype{$type}; } elsif ( /^groups$/ ) { - $d = "$type,all"; + next; + #$d = "$type,all"; } elsif ( /^mgt$/ ) { $d = $hwtype; } elsif ( /^cons$/ ) { @@ -643,6 +657,8 @@ sub format_xml { } elsif ( /^(mtm|serial)$/ ) { if ( $type eq "lpar" ) { $d = undef; + } elsif (/^mtm$/){ + $mtm = $d; } } elsif (/^side$/) { unless ( $type =~ /^fsp|bpa$/ ) { @@ -651,6 +667,14 @@ sub format_xml { } $href->{Node}->{$_} = $d; } + my $tmp_groups = "$type,all"; + if (defined($mtm)) { + my $tmp_pre = xCAT::data::ibmhwtypes::parse_group($mtm); + if (defined($tmp_pre)) { + $tmp_groups .= ",$tmp_pre"; + } + } + $href->{Node}->{groups}=$tmp_groups; ################################# # XML encoding ################################# diff --git a/perl-xCAT/xCAT/SINV.pm b/perl-xCAT/xCAT/SINV.pm index 2b01f5cb3..2df6d6420 100644 --- a/perl-xCAT/xCAT/SINV.pm +++ b/perl-xCAT/xCAT/SINV.pm @@ -202,9 +202,11 @@ sub parse_and_run_sinv # my @nodelist = (); my @cmdparts = (); + my $devicecommand =0; if ($options{'devicetype'}) { # must split different because devices have commands with spaces @cmdparts = split(' ', $cmd,3); + $devicecommand =1; } else { @cmdparts = split(' ', $cmd); } @@ -503,7 +505,7 @@ sub parse_and_run_sinv ); # write the results to the tempfile after running through xdshcoll - $rc = &storeresults($callback); + $rc = &storeresults($callback,$devicecommand); } $processflg = "node"; @@ -534,7 +536,7 @@ sub parse_and_run_sinv # write the results to the tempfile after running through xdshcoll - $rc = &storeresults($callback); + $rc = &storeresults($callback,$devicecommand); # Build report and write to output file # if file exist and has something in it @@ -1451,12 +1453,11 @@ sub rinvoutput sub storeresults { my $callback = shift; - + my $devicecommand= shift; # open file to write results of xdsh or rinv command my $newtempfile = $tempfile; $newtempfile .= "temp"; - open(FILE, ">$newtempfile"); - if ($? > 0) + unless (open(NEWTMPFILE, ">$newtempfile")) { my $rsp = {}; $rsp->{data}->[0] = "Could not open $newtempfile\n"; @@ -1465,9 +1466,9 @@ sub storeresults } foreach my $line (@cmdresult) { - print FILE $line; + print NEWTMPFILE $line; } - close FILE; + close NEWTMPFILE; my $outputfile; if ($processflg eq "seednode") { # cmd to seednode @@ -1479,8 +1480,7 @@ sub storeresults } # open file to put results of xdshcoll - open(FILE, ">$outputfile"); - if ($? > 0) + unless (open(NEWOUTFILE, ">$outputfile")) { my $rsp = {}; $rsp->{data}->[0] = "Could not open $outputfile\n"; @@ -1489,8 +1489,7 @@ sub storeresults } my $cmd = " $::XCATROOT/sbin/xdshcoll <$newtempfile |"; - open(XCOLL, "$cmd"); - if ($? > 0) + unless (open(XCOLL, "$cmd")) { my $rsp = {}; $rsp->{data}->[0] = "Could not call xdshcoll \n"; @@ -1503,18 +1502,37 @@ sub storeresults while () { $line = $_; - print FILE $line + print NEWOUTFILE $line } close(XCOLL); - close FILE; + close NEWOUTFILE; system("/bin/rm $newtempfile"); + # is device command, we get false errors from the Switch, check for + # blank error output lines and remove them. If there is nothing left + # then there really were no errors + my @newerrresult=(); + my $processerrors =1; + if ($devicecommand==1) { + foreach my $line (@errresult) + { + my @newline = (split(/:/, $line)); + if ($newline[1] !~ /^\s*$/) { # Not blank, then save it + push @newerrresult,$line; + } + + } + my $arraysize=@newerrresult; + if ($arraysize < 1) { + $processerrors =0; + } + } # capture errors # - if (@errresult) + if ((@errresult) && ($processerrors ==1)) { # if errors my $rsp = {}; my $i = 0; diff --git a/perl-xCAT/xCAT/Schema.pm b/perl-xCAT/xCAT/Schema.pm index 8a2ac5965..2434bbd55 100644 --- a/perl-xCAT/xCAT/Schema.pm +++ b/perl-xCAT/xCAT/Schema.pm @@ -3231,7 +3231,7 @@ push(@{$defspec{group}->{'attrs'}}, @nodeattrs); access_tabentry => 'firmware.file=attr:cfgfile', }, {attr_name => 'disable', - tabentry => 'auditlog.disable', + tabentry => 'firmware.disable', access_tabentry => 'firmware.file=attr:cfgfile', }, ); diff --git a/perl-xCAT/xCAT/ServiceNodeUtils.pm b/perl-xCAT/xCAT/ServiceNodeUtils.pm index 242ccbf08..5bcf6508b 100644 --- a/perl-xCAT/xCAT/ServiceNodeUtils.pm +++ b/perl-xCAT/xCAT/ServiceNodeUtils.pm @@ -355,7 +355,7 @@ sub getSNList $servicenodetab->close; foreach my $node (@nodes) { - if ($service eq "") # want all the service nodes + if (! defined ($service) || ($service eq "")) # want all the service nodes { push @servicenodes, $node->{node}; } diff --git a/perl-xCAT/xCAT/TableUtils.pm b/perl-xCAT/xCAT/TableUtils.pm index a6b2128ff..da113712a 100644 --- a/perl-xCAT/xCAT/TableUtils.pm +++ b/perl-xCAT/xCAT/TableUtils.pm @@ -1735,4 +1735,51 @@ sub getimagenames() $nodetab->close; return @imagenames; } +#----------------------------------------------------------------------------- + + +=head3 updatenodegroups + Update groups attribute for the specified node + + Arguments: + node + tabhd: the handler of 'nodelist' table, + groups: the groups attribute need to be merged. + Can be an array or string. + Globals: + none + Error: + Example: + xCAT::TableUtils->updatenodegroups($node, $tab, $groups); + +=cut + +#----------------------------------------------------------------------------- + +sub updatenodegroups { + my ($class, $node, $tabhd, $groups) = @_; + if (!$groups) { + $groups = $tabhd; + $tabhd = xCAT::Table->new('nodelist'); + unless ($tabhd) { + xCAT::MsgUtils->message("E", " Could not read the nodelist table\n"); + return; + } + } + my ($ent) = $tabhd->getNodeAttribs($node, ['groups']); + my @list = qw(all); + if (defined($ent) and $ent->{groups}) { + push @list, split(/,/,$ent->{groups}); + } + if (ref($groups) eq 'ARRAY') { + push @list, @$groups; + } else { + push @list, split(/,/,$groups); + } + my %saw; + @saw{@list} = (); + @list = keys %saw; + $tabhd->setNodeAttribs($node, {groups=>join(",",@list)}); +} + 1; diff --git a/perl-xCAT/xCAT/Usage.pm b/perl-xCAT/xCAT/Usage.pm index 52e362627..242104d2e 100644 --- a/perl-xCAT/xCAT/Usage.pm +++ b/perl-xCAT/xCAT/Usage.pm @@ -72,16 +72,16 @@ my %usage = ( rinv [all|model|serial] [-V|--verbose] rinv [-h|--help|-v|--version] BMC specific: - rinv [vpd|mprom|deviceid|uuid|guid] + rinv [mprom|deviceid|uuid|guid|vpd [-t]|all [-t]] MPA specific: - rinv [firm|bios|diag|mprom|sprom|mparom|mac|mtm] + rinv [firm|bios|diag|mprom|sprom|mparom|mac|mtm [-t]] PPC specific(with HMC): - rinv [bus|config|serial|model|firm|all] + rinv [all|bus|config|serial|model|firm [-t]] PPC specific(using Direct FSP Management): rinv [firm] rinv [deconfig [-x]] Blade specific: - rinv [mtm|serial|mac|bios|diag|mprom|mparom|firm|all] + rinv [all|serial|mac|bios|diag|mprom|mparom|firm|mtm [-t]] IBM Flex System Compute Node specific: rinv [firm] VMware specific: diff --git a/perl-xCAT/xCAT/Utils.pm b/perl-xCAT/xCAT/Utils.pm index d37ebdb19..c3e90a275 100644 --- a/perl-xCAT/xCAT/Utils.pm +++ b/perl-xCAT/xCAT/Utils.pm @@ -3330,4 +3330,61 @@ sub filter_nodes{ return 0; } +#------------------------------------------------------------------------------- +=head3 filter_nostatusupdate() + + filter out the nodes which support provision status feedback from the status-nodes hash + Returns: + returns the filtered status-nodes hash + Globals: + none + Error: + none + Input: + the ref of status-nodes hash to filter + Example: + my $mn=xCAT::Utils->filter_nostatusupdate(\%statusnodehash); + Comments: +=cut +#------------------------------------------------------------------------------- +sub filter_nostatusupdate{ + + my ($class,$inref)=@_; + my $nttabdata; + my @allnodes=(); + #read "nodetype" table to get the "os" attribs for all the nodes with status "installing" or "netbooting" + if(exists $inref->{$::STATUS_INSTALLING}){ + push @allnodes, @{$inref->{$::STATUS_INSTALLING}}; + } + if(exists $inref->{$::STATUS_NETBOOTING}){ + push @allnodes, @{$inref->{$::STATUS_NETBOOTING}}; + } + + my $nodetypetab = xCAT::Table->new('nodetype'); + if ($nodetypetab) { + $nttabdata = $nodetypetab->getNodesAttribs(\@allnodes, ['node', 'os']); + $nodetypetab->close(); + } + + #filter out the nodes which support the node provision status feedback + my @nodesfiltered=(); + if(exists $inref->{$::STATUS_INSTALLING}){ + map{ if($nttabdata->{$_}->[0]->{os} !~ /(fedora|rh|centos|sles|ubuntu)/) {push @nodesfiltered,$_;} } @{$inref->{$::STATUS_INSTALLING}}; + delete $inref->{$::STATUS_INSTALLING}; + if(@nodesfiltered){ + @{$inref->{$::STATUS_INSTALLING}}=@nodesfiltered; + } + } + + @nodesfiltered=(); + if(exists $inref->{$::STATUS_NETBOOTING}){ + map{ if($nttabdata->{$_}->[0]->{os} !~ /(fedora|rh|centos|sles|ubuntu)/) {push @nodesfiltered,$_;} } @{$inref->{$::STATUS_NETBOOTING}}; + delete $inref->{$::STATUS_NETBOOTING}; + if(@nodesfiltered){ + @{$inref->{$::STATUS_NETBOOTING}}=@nodesfiltered; + } + } + +} + 1; diff --git a/perl-xCAT/xCAT/data/ibmhwtypes.pm b/perl-xCAT/xCAT/data/ibmhwtypes.pm new file mode 100755 index 000000000..efe78c025 --- /dev/null +++ b/perl-xCAT/xCAT/data/ibmhwtypes.pm @@ -0,0 +1,43 @@ +#!/usr/bin/env perl +# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html + +package xCAT::data::ibmhwtypes; +require Exporter; +@EXPORT_OK=qw(parse_group mt2group); +use Data::Dumper; +my %groups2mtm = ( + "x3250" => ["2583","4251","4252"], + "x3550" => ["7914","7944","7946"], + "x3650" => ["7915","7945"], + "dx360" => [], + "x220" => ["7906"], + "x240" => ["8737","7863"], + "x440" => ["7917"], + "p260" => ["7895"], #789522X, 789523X + "p460" => [], #789542X + "p470" => ["7954"], +); + +%mt2group = (); +foreach my $group (keys %groups2mtm) { + foreach my $mtm (@{$groups2mtm{$group}}) { + $mt2group{$mtm} = $group; + } +} + +sub parse_group { + my $mtm = shift; + if ($mtm =~ /xCAT::data/) { + $mtm = shift; + } + if ($mtm =~ /^(\w{4})/) { + $mt = $1; + if ($mt eq "7895" and $mtm =~ /789542X/i) { + return "p460"; + } + return $mt2group{$mt}; + } + return undef; +} + +1; diff --git a/xCAT-client/bin/pasu b/xCAT-client/bin/pasu index d8c380c7a..3ebdb6038 100755 --- a/xCAT-client/bin/pasu +++ b/xCAT-client/bin/pasu @@ -386,7 +386,7 @@ sub getdefaultcredentials { last; } } - if (!defined($user) || !defined($pw)) { die "Did not find the ipmi username and password in the xCAT passwd table.\n"; } + if (!defined($user) || !defined($pw)) { $user = "USERID"; $pw = "PASSW0RD"; } return ($user, $pw); } diff --git a/xCAT-client/bin/psh b/xCAT-client/bin/psh index 057ca7929..c25951266 100755 --- a/xCAT-client/bin/psh +++ b/xCAT-client/bin/psh @@ -32,7 +32,7 @@ if (!GetOptions( "nonodecheck" => \$::NONODECHECK, #does not check the noderange, in this case, noderange need to be a list of nodes. 'h|help' => \$help, ) || $help || scalar(@ARGV)<2 ) { - print "Usage: psh [-i ] [-l ] [-f ] \n"; + print "Usage: psh [-i ] [-l ] [-f ] [--nonodecheck] \n"; exit; } my %nodehdl; diff --git a/xCAT-client/pods/man1/psh.1.pod b/xCAT-client/pods/man1/psh.1.pod index 100f34e7c..a2a48c313 100644 --- a/xCAT-client/pods/man1/psh.1.pod +++ b/xCAT-client/pods/man1/psh.1.pod @@ -43,6 +43,12 @@ rently executing remote shell processes. Log into the nodes as the specified username. The default is to use the same username as you are running the psh command as. +=item B<-n|--nonodecheck> + +Do not send the noderange to xcatd to expand it into a list of nodes. Instead, use the noderange exactly as it is specified. +In this case, the noderange must be a simple list of comma-separated hostnames of the nodes. +This allows you to run B even when xcatd is not running. + =item B See L. diff --git a/xCAT-client/pods/man1/renergy.1.pod b/xCAT-client/pods/man1/renergy.1.pod index 36019e0bc..f12187487 100644 --- a/xCAT-client/pods/man1/renergy.1.pod +++ b/xCAT-client/pods/man1/renergy.1.pod @@ -192,7 +192,7 @@ cappingperc =back -B<9125-F2C> +B<9125-F2C>, B<9119-FHB> =over 4 @@ -208,6 +208,22 @@ cappingperc,fsavingstatus,ffovalue =back +B + +=over 4 + +For the machine type which is not in the above list, the following +attributes can be tried but not guaranteed: + +B: savingstatus,dsavingstatus,cappingstatus,cappingmin, +cappingmax,,cappingvalue,cappingsoftmin,averageAC,averageDC, +ambienttemp,exhausttemp,CPUspeed,syssbpower,sysIPLtime + +B: savingstatus,dsavingstatus,cappingstatus,cappingwatt, +cappingperc + +=back + =back Note: diff --git a/xCAT-client/pods/man1/xdsh.1.pod b/xCAT-client/pods/man1/xdsh.1.pod index a98eb07ab..e5ba3c110 100644 --- a/xCAT-client/pods/man1/xdsh.1.pod +++ b/xCAT-client/pods/man1/xdsh.1.pod @@ -565,7 +565,7 @@ To define a BNT Ethernet switch as a node and run a command to create a new vlan B I -B I +B I where I and I are the SSH user name and password for the switch. If it is for Telnet, add I in front of the user name: I. I diff --git a/xCAT-client/pods/man8/xcatconfig.8.pod b/xCAT-client/pods/man8/xcatconfig.8.pod index e65e90a54..fe8b07110 100644 --- a/xCAT-client/pods/man8/xcatconfig.8.pod +++ b/xCAT-client/pods/man8/xcatconfig.8.pod @@ -74,7 +74,6 @@ Redistribute credentials and ssh keys to the service nodes and ssh keys to the n This option will add the Management Node to the database with the correct attributes set to be recognized by xCAT. This should be run after the hostname of the Management Node is set to the name that will resolve to the cluster-facing NIC. - =item B<-t|--tunables> This option will set tunable parameters on the Management and Service nodes recommended for your Linux cluster. It will only set them during initial install, if you run xcatconfig -f or xcatconfig -t. diff --git a/xCAT-genesis-builder/install b/xCAT-genesis-builder/install index a756ae655..1ee268a35 100755 --- a/xCAT-genesis-builder/install +++ b/xCAT-genesis-builder/install @@ -623,4 +623,4 @@ dracut_install /lib64/rsyslog/lmnet.so dracut_install /lib64/rsyslog/lmstrmsrv.so dracut_install /lib64/rsyslog/imuxsock.so dracut_install /usr/lib64/libnfsidmap/nsswitch.so -dracut_install killall logger nc nslookup bc chown chroot dd expr kill mkdosfs parted rsync shutdown sort ssh-keygen tr blockdev findfs insmod kexec lvm mdadm mke2fs pivot_root sshd swapon tune2fs # for sysclone +dracut_install killall logger nc nslookup bc chown chroot dd expr kill mkdosfs parted rsync shutdown sort ssh-keygen tr blockdev findfs insmod kexec lvm mdadm mke2fs pivot_root sshd swapon tune2fs mkreiserfs reiserfstune # for sysclone diff --git a/xCAT-genesis-builder/installkernel b/xCAT-genesis-builder/installkernel index 9e52ac794..4217d9988 100755 --- a/xCAT-genesis-builder/installkernel +++ b/xCAT-genesis-builder/installkernel @@ -4,3 +4,4 @@ instmods e1000 e1000e virtio_net igb ines sfc mlx4_en cxgb3 cxgb4 tg3 bnx2 bnx2x instmods macvlan macvtap 8021q bridge bonding vmxnet3 cpufreq_ondemand acpi-cpufreq powernow-k8 cdc_ether instmods mptctl #LSI firmware management requires this instmods mlx4_ib ib_umad #make the mellanox ib available enough to examine /sys +instmods reiserfs #reiserfs on sysclone diff --git a/xCAT-genesis-scripts/bin/bmcsetup b/xCAT-genesis-scripts/bin/bmcsetup index 2cca4e2e9..a3336706a 100755 --- a/xCAT-genesis-scripts/bin/bmcsetup +++ b/xCAT-genesis-scripts/bin/bmcsetup @@ -54,6 +54,11 @@ if [ "$IPMIMFG" == 2 ]; then #IBM for p in $BMCPORT; do ipmitool -d $idev raw 0xc 1 1 0xc0 $p > /dev/null ipmitool -d $idev raw 0x04 0x12 0x09 0x01 0x18 0x${p}1 0x00 > /dev/null + CURBMCPORT=`ipmitool -d $idev raw 0xc 2 1 0xc0 0 0 | awk '{print $2}'` + while [ "$CURBMCPORT" -ne "$BMCPORT" ]; do + sleep 1 + CURBMCPORT=`ipmitool -d $idev raw 0xc 2 1 0xc0 0 0 | awk '{print $2}'` + done let idev=idev+1 done fi @@ -67,7 +72,12 @@ if [ "$IPMIMFG" == 2 ]; then #IBM let idev=0 for p in $BMCPORT; do ipmitool -d $idev raw 0xc 1 1 0xc0 $p > /dev/null - let idev=idev+1 + CURBMCPORT=`ipmitool -d $idev raw 0xc 2 1 0xc0 0 0 | awk '{print $2}'` + while [ "$CURBMCPORT" -ne "$BMCPORT" ]; do + sleep 1 + CURBMCPORT=`ipmitool -d $idev raw 0xc 2 1 0xc0 0 0 | awk '{print $2}'` + done + let idev=idev+1 done fi fi @@ -84,8 +94,17 @@ elif [ "$IPMIMFG" == 20301 ] ; then let idev=0 for p in $BMCPORT; do ipmitool -d $idev raw 0xc 1 1 0xc0 $p > /dev/null - NEWPORT=`ipmitool -d $idev raw 0xc 2 1 0xc0 0 0|awk '{print $2}'` - sleep 10 + # after this change, we need to watch and wait to see that it + # actually takes effect. On port change, the service processor + # does not migrate the network configuration over + # so we might be halfway through setting up when the net config + # reverts to dhcp then static, which setting a static ip for is + # considered invalid + CURBMCPORT=`ipmitool -d $idev raw 0xc 2 1 0xc0 0 0 | awk '{print $2}'` + while [ -z "$CURBMCPORT" -o 0"$CURBMCPORT" -ne "$BMCPORT" ]; do + sleep 1 + CURBMCPORT=`ipmitool -d $idev raw 0xc 2 1 0xc0 0 0 | awk '{print $2}'` + done let idev=idev+1 done diff --git a/xCAT-server/lib/perl/xCAT/PPC.pm b/xCAT-server/lib/perl/xCAT/PPC.pm index 7921ffeb0..2285601e7 100644 --- a/xCAT-server/lib/perl/xCAT/PPC.pm +++ b/xCAT-server/lib/perl/xCAT/PPC.pm @@ -269,6 +269,8 @@ sub process_command { } } } + #donot update node provision status (installing or netbooting) here + xCAT::Utils->filter_nostatusupdate(\%newnodestatus); #print "newstatus" . Dumper(\%newnodestatus); xCAT_monitoring::monitorctrl::setNodeStatusAttributes(\%newnodestatus, 1); } diff --git a/xCAT-server/lib/xcat/plugins/anaconda.pm b/xCAT-server/lib/xcat/plugins/anaconda.pm index ac4493666..77da2276a 100644 --- a/xCAT-server/lib/xcat/plugins/anaconda.pm +++ b/xCAT-server/lib/xcat/plugins/anaconda.pm @@ -180,6 +180,8 @@ sub mknetboot my $installroot; $installroot = "/install"; my $xcatdport = "3001"; + my $xcatiport = "3002"; + my $nodestatus = "y"; #if ($sitetab) #{ @@ -190,6 +192,12 @@ sub mknetboot { $installroot = $site_ent; } + @ents = xCAT::TableUtils->get_site_attribute("nodestatus"); + $site_ent = $ents[0]; + if ( defined($site_ent) ) + { + $nodestatus = $site_ent; + } # ($ref) = $sitetab->getAttribs({key => 'xcatdport'}, 'value'); @ents = xCAT::TableUtils->get_site_attribute("xcatdport"); $site_ent = $ents[0]; @@ -197,6 +205,12 @@ sub mknetboot { $xcatdport = $site_ent; } + @ents = xCAT::TableUtils->get_site_attribute("xcatiport"); + $site_ent = $ents[0]; + if ( defined($site_ent) ) + { + $xcatiport = $site_ent; + } # ($ref) = $sitetab->getAttribs({key => 'tftpdir'}, 'value'); @ents = xCAT::TableUtils->get_site_attribute("tftpdir"); $site_ent = $ents[0]; @@ -679,8 +693,10 @@ sub mknetboot } else { $xcatmasterip = $xcatmaster; } - $kcmdline .= - "XCAT=$xcatmasterip:$xcatdport "; + + $kcmdline .= "XCAT=$xcatmaster:$xcatdport "; + + if ($rootfstype ne "ramdisk") { # BEGIN service node my $isSV = xCAT::Utils->isServiceNode(); @@ -701,9 +717,14 @@ sub mknetboot else { $kcmdline = "imgurl=$httpmethod://$imgsrv:$httpport/$rootimgdir/rootimg.$suffix "; - $kcmdline .= "XCAT=$xcatmaster:$xcatdport "; + $kcmdline .= "XCAT=$xcatmaster:$xcatdport "; $kcmdline .= "NODE=$node "; } + #inform statelite/stateless node not to update the nodestatus during provision + if(($nodestatus eq "n") or ($nodestatus eq "N") or ($nodestatus eq "0")){ + $kcmdline .= " nonodestatus "; + } + # add one parameter: ifname=: # which is used for dracut @@ -913,7 +934,6 @@ sub mkinstall my $doreq = shift; my @nodes = @{$request->{node}}; my $noupdateinitrd = $request->{'noupdateinitrd'}; - #my $sitetab = xCAT::Table->new('site'); my $linuximagetab; my $osimagetab; @@ -2409,6 +2429,7 @@ sub insert_dd { my @rpm_list; my @driver_list; my $Injectalldriver; + my $updatealldriver; my @rpm_drivers; @@ -2453,6 +2474,9 @@ sub insert_dd { if (/^allupdate$/) { $Injectalldriver = 1; next; + } elsif (/^updateonly$/) { + $updatealldriver = 1; + next; } unless (/\.ko$/) { s/$/.ko/; @@ -2463,7 +2487,7 @@ sub insert_dd { chomp(@dd_list); chomp(@rpm_list); - unless (@dd_list || (@rpm_list && ($Injectalldriver || @driver_list))) { + unless (@dd_list || (@rpm_list && ($Injectalldriver || $updatealldriver || @driver_list))) { return (); } @@ -2474,7 +2498,7 @@ sub insert_dd { # dracut + drvier rpm # !dracut + driver rpm # !dracut + driver disk - if (!<$install_dir/$os/$arch/Packages/dracut*> || (@rpm_list && ($Injectalldriver || @driver_list))) { + if (!<$install_dir/$os/$arch/Packages/dracut*> || (@rpm_list && ($Injectalldriver || $updatealldriver || @driver_list))) { mkpath "$dd_dir/initrd_img"; # The dir for the new initrd # unzip the initrd image @@ -2537,13 +2561,12 @@ sub insert_dd { } my $new_kernel_ver; - if (@rpm_list && ($Injectalldriver || @driver_list)) { + if (@rpm_list && ($Injectalldriver || $updatealldriver || @driver_list)) { # Extract the files from rpm to the tmp dir mkpath "$dd_dir/rpm"; foreach my $rpm (@rpm_list) { if (-r $rpm) { $cmd = "cd $dd_dir/rpm; rpm2cpio $rpm | cpio -idum"; - #$cmd = "rpm -i --quiet --nodeps --force --ignorearch --ignoreos --nosignature --root $dd_dir/rpm $rpm"; xCAT::Utils->runcmd($cmd, -1); if ($::RUNCMD_RC != 0) { my $rsp; @@ -2560,17 +2583,17 @@ sub insert_dd { # and copy it to the /tftpboot my @new_kernels = <$dd_dir/rpm/boot/vmlinuz*>; foreach my $new_kernel (@new_kernels) { - if (-r $new_kernel && $new_kernel =~ /\/vmlinuz-(.*(x86_64|ppc64))$/) { - $new_kernel_ver = $1; - $cmd = "/bin/mv -f $new_kernel $kernelpath"; - xCAT::Utils->runcmd($cmd, -1); - if ($::RUNCMD_RC != 0) { - my $rsp; - push @{$rsp->{data}}, "Handle the driver update failed. Could not move $new_kernel to $kernelpath."; - xCAT::MsgUtils->message("I", $rsp, $callback); + if (-r $new_kernel && $new_kernel =~ /\/vmlinuz-(.*(x86_64|ppc64|el\d+))$/) { + $new_kernel_ver = $1; + $cmd = "/bin/mv -f $new_kernel $kernelpath"; + xCAT::Utils->runcmd($cmd, -1); + if ($::RUNCMD_RC != 0) { + my $rsp; + push @{$rsp->{data}}, "Handle the driver update failed. Could not move $new_kernel to $kernelpath."; + xCAT::MsgUtils->message("I", $rsp, $callback); + } } } - } # To skip the conflict of files that some rpm uses the xxx.ko.new as the name of the driver # Change it back to xxx.ko here @@ -2601,7 +2624,7 @@ sub insert_dd { # For dracut mode, only copy the drivers from rpm packages to the /lib/modules/ # The driver disk will be handled that append the whole disk to the orignial initrd - if (@rpm_list && ($Injectalldriver || @driver_list)) { + if (@rpm_list && ($Injectalldriver || $updatealldriver || @driver_list)) { # Copy the firmware to the rootimage if (-d "$dd_dir/rpm/lib/firmware") { if (! -d "$dd_dir/initrd_img/lib/firmware") { @@ -2616,14 +2639,15 @@ sub insert_dd { } } - # if the new kernel from update distro is not existed in initrd, copy all the modules for the new kernel to initrd - if ((! -r "$dd_dir/initrd_img/lib/modules/$new_kernel_ver") && (-r "$dd_dir/rpm/lib/modules/$new_kernel_ver")) { - $cmd = "/bin/cp -rf $dd_dir/rpm/lib/modules/$new_kernel_ver $dd_dir/initrd_img/lib/modules/"; - xCAT::Utils->runcmd($cmd, -1); - if ($::RUNCMD_RC != 0) { - my $rsp; - push @{$rsp->{data}}, "Handle the driver update failed. Could not copy $dd_dir/rpm/lib/modules/$new_kernel_ver to $dd_dir/initrd_img/lib/modules."; - xCAT::MsgUtils->message("E", $rsp, $callback); + # get the name list for all drivers in the original initrd if 'netdrivers=updateonly' + # then only the drivers in this list will be updated from the drvier rpms + if ($updatealldriver) { + $driver_name = "\*\.ko"; + @all_real_path = (); + find(\&get_all_path, <$dd_dir/initrd_img/lib/modules/*>); + foreach my $real_path (@all_real_path) { + my $driver = basename($real_path); + push @driver_list, $driver; } } @@ -2631,9 +2655,19 @@ sub insert_dd { # Figure out the kernel version my @kernelpaths = <$dd_dir/initrd_img/lib/modules/*>; my @kernelvers; + if ($new_kernel_ver) { + push @kernelvers, $new_kernel_ver; + } + + # if new kernel is used, remove all the original kernel directories foreach (@kernelpaths) { - if (basename($_) =~ /^[\d\.]+/) { - push @kernelvers, basename($_); + my $kernelv = basename($_); + if ($kernelv =~ /^[\d\.]+/) { + if ($new_kernel_ver) { + rmtree ("$dd_dir/initrd_img/lib/modules/$kernelv"); + } else { + push @kernelvers, $kernelv; + } } } @@ -2643,6 +2677,7 @@ sub insert_dd { } if (@driver_list) { foreach my $driver (@driver_list) { + $driver =~ s/\.gz$//; $driver_name = $driver; @all_real_path = (); find(\&get_all_path, <$dd_dir/rpm/lib/modules/$kernelver/*>); @@ -2805,7 +2840,7 @@ sub insert_dd { } # Merge the drviers from rpm packages to the initrd - if (@rpm_list && ($Injectalldriver || @driver_list)) { + if (@rpm_list && ($Injectalldriver || $updatealldriver || @driver_list)) { # Copy the firmware to the rootimage if (-d "$dd_dir/rpm/lib/firmware") { if (! -d "$dd_dir/initrd_img/lib") { @@ -2825,18 +2860,44 @@ sub insert_dd { mkpath ("$dd_dir/modules/$new_kernel_ver/$arch/"); } + # get the name list for all drivers in the original initrd if 'netdrivers=updateonly' + # then only the drivers in this list will be updated from the drvier rpms + if ($updatealldriver) { + $driver_name = "\*\.ko"; + @all_real_path = (); + find(\&get_all_path, <$dd_dir/modules/*>); + foreach my $real_path (@all_real_path) { + my $driver = basename($real_path); + push @driver_list, $driver; + } + } + # Copy the drivers to the initrd # Figure out the kernel version my @kernelpaths = <$dd_dir/modules/*>; my @kernelvers; + if ($new_kernel_ver) { + push @kernelvers, $new_kernel_ver; + } foreach (@kernelpaths) { - push @kernelvers, basename($_); + my $kernelv = basename($_); + if ($kernelv =~ /^[\d\.]+/) { + if ($new_kernel_ver) { + rmtree ("$dd_dir/modules/$kernelv"); + } else { + push @kernelvers, $kernelv; + } + } } foreach my $kernelver (@kernelvers) { unless (-d "$dd_dir/rpm/lib/modules/$kernelver") { next; } + # create path for the new kernel in the modules package + unless (-d "$dd_dir/modules/$kernelver") { + mkpath ("$dd_dir/modules/$kernelver/$arch/"); + } # find the $kernelver/$arch dir in the $dd_dir/modules my $arch4modules; foreach (<$dd_dir/modules/$kernelver/*>) { @@ -2912,13 +2973,23 @@ sub insert_dd { if (-d $ma) { mkpath "$dd_dir/depmod/lib/modules/$mk"; xCAT::Utils->runcmd("/bin/cp -rf $ma/* $dd_dir/depmod/lib/modules/$mk", -1); - $cmd = "depmod -b $dd_dir/depmod/"; + $cmd = "depmod -b $dd_dir/depmod/ $mk"; + #$cmd = "depmod -b $dd_dir/depmod/"; xCAT::Utils->runcmd($cmd, -1); if ($::RUNCMD_RC != 0) { my $rsp; push @{$rsp->{data}}, "Handle the driver update failed. Could not generate the depdency for the drivers in the initrd."; xCAT::MsgUtils->message("I", $rsp, $callback); } + # remove the .ko postfix from the driver name for rh5 + $cmd = "/bin/sed ".'s/\.ko//g'." $dd_dir/depmod/lib/modules/$mk/modules.dep > $dd_dir/depmod/lib/modules/$mk/modules.dep1; mv -f $dd_dir/depmod/lib/modules/$mk/modules.dep1 $dd_dir/depmod/lib/modules/$mk/modules.dep"; + xCAT::Utils->runcmd($cmd, -1); + if ($::RUNCMD_RC != 0) { + my $rsp; + push @{$rsp->{data}}, "Handle the driver update failed. Could not generate the depdency for the drivers in the initrd."; + xCAT::MsgUtils->message("I", $rsp, $callback); + } + if (-f "$dd_dir/depmod/lib/modules/$mk/modules.dep") { copy ("$dd_dir/depmod/lib/modules/$mk/modules.dep", "$dd_dir/initrd_img/modules/modules.dep"); } diff --git a/xCAT-server/lib/xcat/plugins/blade.pm b/xCAT-server/lib/xcat/plugins/blade.pm index 5fda1e917..88e7f2fc0 100644 --- a/xCAT-server/lib/xcat/plugins/blade.pm +++ b/xCAT-server/lib/xcat/plugins/blade.pm @@ -28,6 +28,7 @@ use xCAT::GlobalDef; use xCAT_monitoring::monitorctrl; use strict; use LWP; +require xCAT::data::ibmhwtypes; #use warnings; my %mm_comm_pids; @@ -1773,6 +1774,7 @@ sub rscan_xml { my $href = { Node => { } }; + my $mtm = undef; foreach ( @rscan_attribs ) { my $d = $data[$i++]; @@ -1789,6 +1791,7 @@ sub rscan_xml { } } elsif ( /^groups$/ ) { $d = "$type,all"; + $ignore = 1; } elsif ( /^mgt$/ ) { if ($origtype eq "ppcblade") { $d = "fsp"; @@ -1831,13 +1834,23 @@ sub rscan_xml { } else { $ignore = 1; } + } elsif (/^mtm$/) { + $d =~ /^(\w{4})/; + $mtm = $1; } if (!$ignore) { $href->{Node}->{$_} = $d; } } - + my $tmp_groups = "$type,all"; + if (defined($mtm)) { + my $tmp_pre = xCAT::data::ibmhwtypes::parse_group($mtm); + if (defined($tmp_pre)) { + $tmp_groups .= ",$tmp_pre"; + } + } + $href->{Node}->{groups} = $tmp_groups; $xml.= XMLout($href,NoAttr=>1,KeyAttr=>[],RootName=>undef); } return( $xml ); @@ -1872,7 +1885,7 @@ sub rscan_stanza { $objname = $data[1]; } $result .= "$objname:\n\tobjtype=node\n"; - + my $mtm = undef; foreach ( @rscan_attribs ) { my $d = $data[$i++]; @@ -1889,6 +1902,7 @@ sub rscan_stanza { } } elsif ( /^groups$/ ) { $d = "$type,all"; + $ignore = 1; } elsif ( /^mgt$/ ) { if ($origtype eq "ppcblade") { $d = "fsp"; @@ -1931,12 +1945,23 @@ sub rscan_stanza { } else { $ignore = 1; } + } elsif (/^mtm$/) { + $d =~ /^(\w{4})/; + $mtm = $1; } if (!$ignore) { $result .= "\t$_=$d\n"; } } + my $tmp_groups = "$type,all"; + if (defined ($mtm)) { + my $tmp_pre = xCAT::data::ibmhwtypes::parse_group($mtm); + if (defined ($tmp_pre)) { + $tmp_groups .= ",$tmp_pre"; + } + } + $result .= "\tgroups=$tmp_groups\n"; } return( $result ); } @@ -2246,6 +2271,13 @@ sub inv { } } } + if ($updatetable and $updatehash{mtm}) { + #updatenodegroups + my $tmp_pre = xCAT::data::ibmhwtypes::parse_group($updatehash{mtm}) ; + if (defined($tmp_pre)) { + xCAT::TableUtils->updatenodegroups($currnode, $tmp_pre); + } + } if ($updatetable and keys %updatehash) { my $vpdtab = xCAT::Table->new('vpd'); $vpdtab->setNodeAttribs($currnode,\%updatehash); @@ -4388,6 +4420,12 @@ sub process_request { unless ($node) { return 1; #failure } + if ($request->{mtm} and $request->{mtm} =~ /^(\w{4})/) { + my $group = xCAT::data::ibmhwtypes::parse_group($request->{mtm}); + if (defined($group)) { + xCAT::TableUtils->updatenodegroups($node, $group); + } + } if ($mac) { my $mactab = xCAT::Table->new('mac',-create=>1); $mactab->setNodeAttribs($macmap{$mac},{mac=>$mac}); @@ -5901,6 +5939,10 @@ sub dompa { } } } + + + #donot update node provision status (installing or netbooting) here + xCAT::Utils->filter_nostatusupdate(\%newnodestatus); #print "newstatus" . Dumper(\%newnodestatus); xCAT_monitoring::monitorctrl::setNodeStatusAttributes(\%newnodestatus, 1); } diff --git a/xCAT-server/lib/xcat/plugins/debian.pm b/xCAT-server/lib/xcat/plugins/debian.pm index 8a3e81c82..76ef5e2fa 100644 --- a/xCAT-server/lib/xcat/plugins/debian.pm +++ b/xCAT-server/lib/xcat/plugins/debian.pm @@ -897,6 +897,8 @@ sub mknetboot my $installroot; $installroot = "/install"; my $xcatdport = "3001"; + my $xcatiport = "3002"; + my $nodestatus = "y"; if ($sitetab) { @@ -910,11 +912,21 @@ sub mknetboot { $xcatdport = $ref->{value}; } + ($ref) = $sitetab->getAttribs({key => 'xcatiport'}, 'value'); + if ($ref and $ref->{value}) + { + $xcatiport = $ref->{value}; + } ($ref) = $sitetab->getAttribs({key => 'tftpdir'}, 'value'); if ($ref and $ref->{value}) { $globaltftpdir = $ref->{value}; } + ($ref) = $sitetab->getAttribs({key => 'nodestatus'}, 'value'); + if ($ref and $ref->{value}) + { + $nodestatus = $ref->{value}; + } } my %donetftp=(); my %oents = %{$ostab->getNodesAttribs(\@nodes,[qw(os arch profile provmethod)])}; @@ -1317,6 +1329,7 @@ sub mknetboot + # add support for subVars in the value of "statemnt" my $statemnt = ""; if (exists($stateHash->{$node})) { @@ -1366,6 +1379,10 @@ sub mknetboot $kcmdline .= "XCAT=$xcatmaster:$xcatdport "; } + # if site.nodestatus='n', add "nonodestatus" to kcmdline to inform the node not to update nodestatus during provision + if(($nodestatus eq "n") or ($nodestatus eq "N") or ($nodestatus eq "0")){ + $kcmdline .= " nonodestatus "; + } # add one parameter: ifname=: # which is used for dracut # the redhat5.x os will ignore it diff --git a/xCAT-server/lib/xcat/plugins/geninitrd.pm b/xCAT-server/lib/xcat/plugins/geninitrd.pm index 9a9fe45f1..18782cb99 100644 --- a/xCAT-server/lib/xcat/plugins/geninitrd.pm +++ b/xCAT-server/lib/xcat/plugins/geninitrd.pm @@ -116,7 +116,7 @@ sub geninitrd { $netdrivers = $lient->{'netdrivers'}; # if the provmethod equals 'netboot', call the genimage --onlyinitrd directly - if ($oient->{'provmethod'} && $oient->{'provmethod'} eq "netboot") { + if ($oient->{'provmethod'} && ($oient->{'provmethod'} eq "netboot" || $oient->{'provmethod'} eq "statelite")) { 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); @@ -132,7 +132,7 @@ sub geninitrd { # 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); + xCAT::MsgUtils->message("E", {error=>["The attribute [provmethod] for osimage [$osimage] must be set to install, netboot or statelite."], errorcode=>["1"]}, $callback); return; } diff --git a/xCAT-server/lib/xcat/plugins/ipmi.pm b/xCAT-server/lib/xcat/plugins/ipmi.pm index ae7104d07..62e2c741f 100644 --- a/xCAT-server/lib/xcat/plugins/ipmi.pm +++ b/xCAT-server/lib/xcat/plugins/ipmi.pm @@ -34,6 +34,7 @@ my $iem_support; my $vpdhash; my %allerrornodes=(); my $global_sessdata; +require xCAT::data::ibmhwtypes; eval { require IBM::EnergyManager; @@ -1591,6 +1592,11 @@ sub inv { sub fru_initted { my $sessdata = shift; my $key; + my @args = @{$sessdata->{extraargs}}; + my $up_group = undef; + if (grep /-t/, @args) { + $up_group = '1'; + } my @types = @{$sessdata->{invtypes}}; my $format = "%-20s %s"; @@ -1599,11 +1605,17 @@ sub fru_initted { my $type; foreach $type (split /,/,$fru->rec_type) { if(grep {$_ eq $type} @types) { - my $bmcifo=""; - if ($sessdata->{bmcnum} != 1) { - $bmcifo=" on BMC ".$sessdata->{bmcnum}; - } - xCAT::SvrUtils::sendmsg(sprintf($format.$bmcifo,$sessdata->{fru_hash}->{$key}->desc . ":",$sessdata->{fru_hash}->{$key}->value),$callback,$sessdata->{node},%allerrornodes); + my $bmcifo=""; + if ($sessdata->{bmcnum} != 1) { + $bmcifo=" on BMC ".$sessdata->{bmcnum}; + } + xCAT::SvrUtils::sendmsg(sprintf($format.$bmcifo,$sessdata->{fru_hash}->{$key}->desc . ":",$sessdata->{fru_hash}->{$key}->value),$callback,$sessdata->{node},%allerrornodes); + if ($up_group and $type eq "model" and $fru->desc =~ /MTM/) { + my $tmp_pre = xCAT::data::ibmhwtypes::parse_group($fru->value); + if (defined($tmp_pre)) { + xCAT::TableUtils->updatenodegroups($sessdata->{node}, $tmp_pre); + } + } last; } } @@ -6124,6 +6136,14 @@ sub preprocess_request { my (@bmcnodes, @nohandle); xCAT::Utils->filter_nodes($request, undef, undef, \@bmcnodes, \@nohandle); $realnoderange = \@bmcnodes; + } elsif ($command eq "rinv") { + if ($exargs[0] eq "-t" and $#exargs == 0) { + unshift @{$request->{arg}}, 'all'; + } elsif ((grep /-t/, @exargs) and !(grep /(all|vpd)/, @exargs) ) { + $callback->({errorcode=>[1],error=>["option '-t' can only work with 'all' or 'vpd'"]}); + $request = {}; + return 0; + } } if (!$realnoderange) { @@ -6497,6 +6517,9 @@ sub process_request { } } } + + #donot update node provision status (installing or netbooting) here + xCAT::Utils->filter_nostatusupdate(\%newnodestatus); #print "newstatus" . Dumper(\%newnodestatus); xCAT_monitoring::monitorctrl::setNodeStatusAttributes(\%newnodestatus, 1); } diff --git a/xCAT-server/lib/xcat/plugins/ipmi.pm.legacy b/xCAT-server/lib/xcat/plugins/ipmi.pm.legacy index 1313d8ee0..82b307fe5 100644 --- a/xCAT-server/lib/xcat/plugins/ipmi.pm.legacy +++ b/xCAT-server/lib/xcat/plugins/ipmi.pm.legacy @@ -6203,6 +6203,8 @@ sub process_request { } } } + #donot update node provision status (installing or netbooting) here + xCAT::Utils->filter_nostatusupdate(\%newnodestatus); #print "newstatus" . Dumper(\%newnodestatus); xCAT_monitoring::monitorctrl::setNodeStatusAttributes(\%newnodestatus, 1); } diff --git a/xCAT-server/lib/xcat/plugins/kit.pm b/xCAT-server/lib/xcat/plugins/kit.pm index f16b15676..8bacb467e 100644 --- a/xCAT-server/lib/xcat/plugins/kit.pm +++ b/xCAT-server/lib/xcat/plugins/kit.pm @@ -2427,7 +2427,6 @@ sub rmkitcomp my %rsp; push@{ $rsp{data} }, "kitcomponent $kitcompdep basename does not exist"; xCAT::MsgUtils->message( "E", \%rsp, $callback ); - return 1; } my $kitcompdepname = get_highest_version('kitcompname', 'version', 'release', @entries); @@ -2486,7 +2485,7 @@ sub rmkitcomp foreach my $kitcomponent (keys %kitcomps) { my @kitcompscripts = split( ',', $kitcomps{$kitcomponent}{postbootscripts} ); foreach my $kitcompscript ( @kitcompscripts ) { - if ( $osimagescript =~ /^$kitcompscript$/ ) { + if ( $osimagescript =~ /^$kitcompscript/ ) { $match = 1; last; } diff --git a/xCAT-server/lib/xcat/plugins/kvm.pm b/xCAT-server/lib/xcat/plugins/kvm.pm index 53d7568ef..5679815d6 100644 --- a/xCAT-server/lib/xcat/plugins/kvm.pm +++ b/xCAT-server/lib/xcat/plugins/kvm.pm @@ -2813,6 +2813,8 @@ sub process_request { } } } + #donot update node provision status (installing or netbooting) here + xCAT::Utils->filter_nostatusupdate(\%newnodestatus); #print "newstatus" . Dumper(\%newnodestatus); xCAT_monitoring::monitorctrl::setNodeStatusAttributes(\%newnodestatus, 1); } diff --git a/xCAT-server/lib/xcat/plugins/lsslp.pm b/xCAT-server/lib/xcat/plugins/lsslp.pm index f5d4eac94..f2b4a6dd2 100644 --- a/xCAT-server/lib/xcat/plugins/lsslp.pm +++ b/xCAT-server/lib/xcat/plugins/lsslp.pm @@ -20,6 +20,7 @@ use xCAT::MacMap; use xCAT::IMMUtils; use xCAT_plugin::blade; use xCAT::SLP; +require xCAT::data::ibmhwtypes; my $mpahash; @@ -1418,11 +1419,18 @@ sub xCATdB { my $id = ($type =~ /bpa|frame/) ? $frameid:$cageid; my $hidden = ($type =~ /bpa|fsp/)? 1:0; + my $groups = lc($type).",all"; + my $tmp_pre = xCAT::data::ibmhwtypes::parse_group($model); + + if (defined($tmp_pre)) { + $groups .= ",$tmp_pre"; + } ######################################## # Write result to every tables, ######################################## if ( $type =~ /^bpa|fsp|cec|frame$/ ) { - $nodelisthash{$hostname} = {groups=>"$type,all", hidden=>$hidden}; + #$nodelisthash{$hostname} = {groups=>"$type,all", hidden=>$hidden}; + $nodelisthash{$hostname} = {groups=>$groups, hidden=>$hidden}; $ppchash{$hostname} = {id=>$id, parent=>$parent, hcp=>$hostname, nodetype=>$globalhwtype{$type}}; $vpdhash{$hostname} = {mtm=>$model, serial=>$serial, side=>$side}; $nodehmhash{$hostname} = {mgt=>$globalmgt{$type}}; @@ -1433,7 +1441,7 @@ sub xCATdB { my @data = ($type, $model, $serial, $side, $ip, $frameid, $cageid, $parent, $mac); xCAT::PPCdb::add_systemX( $type, $hostname, \@data ); } elsif ( $type =~ /^(hmc|ivm)$/ ) { - $nodelisthash{$hostname} = {groups=>"$type,all", hidden=>$hidden}; + $nodelisthash{$hostname} = {groups=>$groups, hidden=>$hidden}; $ppchash{$hostname} = {nodetype=>$globalhwtype{$type}}; $vpdhash{$hostname} = {mtm=>$model, serial=>$serial}; $nodetypehash{$hostname} = {nodetype=>$globalnodetype{$type}}; @@ -1441,7 +1449,7 @@ sub xCATdB { $hostshash{$hostname} = {ip=>$ip}; $machash{$hostname} = {mac=>$mac}; }elsif ($type =~ /^cmm$/){ - $nodelisthash{$hostname} = {groups=>"cmm,all", hidden=>$hidden}; + $nodelisthash{$hostname} = {groups=>$groups, hidden=>$hidden}; $vpdhash{$hostname} = {mtm=>$model, serial=>$serial}; $nodetypehash{$hostname} = {nodetype=>$globalnodetype{$type}}; $nodehmhash{$hostname} = {mgt=>"blade"}; @@ -1491,6 +1499,12 @@ sub format_stanza { $ip = $2; } my $type = ${$outhash->{$name}}{type}; + my $groups = "$type,all"; + my $tmp_pre = xCAT::data::ibmhwtypes::parse_group(${$outhash->{$name}}{mtm}); + if (defined($tmp_pre)) { + $groups .= ",$tmp_pre"; + } + ################################# # Node attributes @@ -1507,7 +1521,8 @@ sub format_stanza { if ($type =~ /^fsp|bpa|cmm$/) { $result .= "\tside=${$outhash->{$name}}{side}\n"; } - $result .= "\tgroups=$type,all\n"; + #$result .= "\tgroups=$type,all\n"; + $result .= "\tgroups=$groups\n"; $result .= "\tmgt=$globalmgt{$type}\n"; if ($type =~ /^fsp|bpa|frame|cec$/) { $result .= "\tid=${$outhash->{$name}}{$globalid{$type}}\n"; diff --git a/xCAT-server/lib/xcat/plugins/seqdiscovery.pm b/xCAT-server/lib/xcat/plugins/seqdiscovery.pm index 10afe143d..e3d2d3116 100644 --- a/xCAT-server/lib/xcat/plugins/seqdiscovery.pm +++ b/xCAT-server/lib/xcat/plugins/seqdiscovery.pm @@ -27,6 +27,7 @@ use xCAT::NetworkUtils; use xCAT::MsgUtils; use xCAT::DiscoveryUtils; use xCAT::NodeRange qw/noderange/; +require xCAT::data::ibmhwtypes; use Time::HiRes qw(gettimeofday sleep); @@ -272,7 +273,14 @@ sub findme { $nltab->setNodeAttribs($node, {groups=>"all"}); } } - + # update node groups with pre-defined groups + if (defined($param{'mtm'})){ + my @list = (); + my $tmp_group = xCAT::data::ibmhwtypes::parse_group($param{'mtm'}); + if (defined($tmp_group)) { + xCAT::TableUtils->updatenodegroups($node, $nltab, $tmp_group); + } + } # set the mgt for the node my $hmtab = xCAT::Table->new('nodehm'); unless ($hmtab) { diff --git a/xCAT-server/lib/xcat/plugins/sles.pm b/xCAT-server/lib/xcat/plugins/sles.pm index 3404b7566..7c76da347 100644 --- a/xCAT-server/lib/xcat/plugins/sles.pm +++ b/xCAT-server/lib/xcat/plugins/sles.pm @@ -37,7 +37,8 @@ sub handled_commands copycd => "sles", mknetboot => "nodetype:os=(sles.*)|(suse.*)", mkinstall => "nodetype:os=(sles.*)|(suse.*)", - mkstatelite => "nodetype:os=(sles.*)" + mkstatelite => "nodetype:os=(sles.*)", + mksysclone => "nodetype:os=(sles.*)|(suse.*)" }; } @@ -64,7 +65,8 @@ sub mknetboot $installroot = "/install"; my $xcatdport = "3001"; - + my $xcatiport = "3002"; + my $nodestatus = "y"; #if ($sitetab) #{ #(my $ref) = $sitetab->getAttribs({key => 'installdir'}, 'value'); @@ -79,6 +81,17 @@ sub mknetboot if ( defined($t_entry) ) { $xcatdport = $t_entry; } + @entries = xCAT::TableUtils->get_site_attribute("xcatiport"); + $t_entry = $entries[0]; + if ( defined($t_entry) ) { + $xcatiport = $t_entry; + } + @entries = xCAT::TableUtils->get_site_attribute("nodestatus"); + $t_entry = $entries[0]; + if ( defined($t_entry) ) { + $nodestatus = $t_entry; + } + #} my $ntents = $ostab->getNodesAttribs($req->{node}, ['os', 'arch', 'profile', 'provmethod']); @@ -553,6 +566,13 @@ sub mknetboot "imgurl=$httpmethod://$imgsrv/$rootimgdir/rootimg.$suffix "; } $kcmdline .= "XCAT=$xcatmaster:$xcatdport quiet "; + + #if site.nodestatus="n", append "nonodestatus" to kcmdline + #to inform the statelite/stateless node not to update the nodestatus during provision + if(($nodestatus eq "n") or ($nodestatus eq "N") or ($nodestatus eq "0")){ + $kcmdline .= " nonodestatus "; + } + $kcmdline .= "NODE=$node "; # add the kernel-booting parameter: netdev=, or BOOTIF= @@ -671,6 +691,10 @@ sub process_request { return mknetboot($request, $callback, $doreq); } + elsif ($request->{command}->[0] eq 'mksysclone') + { + return mksysclone($request, $callback, $doreq); + } } sub mkinstall @@ -1185,6 +1209,250 @@ sub mkinstall #} } +sub mksysclone +{ + my $request = shift; + my $callback = shift; + my $doreq = shift; + my @nodes = @{$request->{node}}; + my $osimagetab; + my %img_hash=(); + + my $installroot; + my $globaltftpdir; + $installroot = "/install"; + $globaltftpdir = "/tftpboot"; + + my @ents = xCAT::TableUtils->get_site_attribute("installdir"); + my $site_ent = $ents[0]; + if( defined($site_ent) ) + { + $installroot = $site_ent; + } + @ents = xCAT::TableUtils->get_site_attribute("tftpdir"); + $site_ent = $ents[0]; + if( defined($site_ent) ) + { + $globaltftpdir = $site_ent; + } + + my $node; + my $ostab = xCAT::Table->new('nodetype'); + my $restab = xCAT::Table->new('noderes'); + my $bptab = xCAT::Table->new('bootparams',-create=>1); + my $hmtab = xCAT::Table->new('nodehm'); + my %osents = %{$ostab->getNodesAttribs(\@nodes, ['os', 'arch', 'provmethod'])}; + my %rents = + %{$restab->getNodesAttribs(\@nodes, + ['xcatmaster', 'nfsserver', 'tftpdir', 'primarynic', 'installnic'])}; + my %hents = + %{$hmtab->getNodesAttribs(\@nodes, + ['serialport', 'serialspeed', 'serialflow'])}; + my $xcatdport="3001"; + my @entries = xCAT::TableUtils->get_site_attribute("xcatdport"); + if ( defined($entries[0])) { + $xcatdport = $entries[0]; + } + + my @entries = xCAT::TableUtils->get_site_attribute("master"); + my $master_entry = $entries[0]; + + require xCAT::Template; + + my $flag_return = 0; + # Warning message for nodeset install/netboot/statelite + foreach my $knode (keys %osents) + { + my $ent = $osents{$knode}->[0]; + if ($ent && $ent->{provmethod} && ($ent->{provmethod} eq 'sysclone')){ + $callback->( { error => ["$knode: The provmethod \"sysclone\" have been deprecated. use \"nodeset osimage=\" instead."], + errorcode => [1]}); + # Do not print this warning message multiple times + $flag_return = 1; + } + } + + if ( $flag_return == 1 ){ + return; + } + + # copy postscripts + my $pspath = "$installroot/sysclone/scripts/post-install/"; + my $clusterfile = "$installroot/sysclone/scripts/cluster.txt"; + + mkpath("$pspath"); + copy("$installroot/postscripts/configefi","$pspath/15all.configefi"); + copy("$installroot/postscripts/updatenetwork","$pspath/16all.updatenetwork"); + copy("$installroot/postscripts/runxcatpost","$pspath/17all.runxcatpost"); + copy("$installroot/postscripts/killsyslog","$pspath/17all.killsyslog"); + + unless (-r "$pspath/10all.fix_swap_uuids") + { + mkpath("$pspath"); + copy("/var/lib/systemimager/scripts/post-install/10all.fix_swap_uuids","$pspath"); + } + + unless (-r "$pspath/95all.monitord_rebooted") + { + mkpath("$pspath"); + copy("/var/lib/systemimager/scripts/post-install/95all.monitord_rebooted","$pspath"); + } + + # copy hosts + copy("/etc/hosts","$installroot/sysclone/scripts/"); + + foreach $node (@nodes) + { + my $os; + my $tftpdir; + my $arch; + my $imagename; # set it if running of 'nodeset osimage=xxx' + my $xcatmaster; + my $instserver; + + my $ient = $rents{$node}->[0]; + if ($ient and $ient->{xcatmaster}) + { + $xcatmaster = $ient->{xcatmaster}; + } else { + $xcatmaster = $master_entry; + } + + my $osinst; + if ($rents{$node}->[0] and $rents{$node}->[0]->{tftpdir}) { + $tftpdir = $rents{$node}->[0]->{tftpdir}; + } else { + $tftpdir = $globaltftpdir; + } + my $ent = $osents{$node}->[0]; + if ($ent and $ent->{provmethod} and ($ent->{provmethod} ne 'install') and ($ent->{provmethod} ne 'netboot') and ($ent->{provmethod} ne 'statelite') and ($ent->{provmethod} ne 'sysclone')) { + $imagename=$ent->{provmethod}; + #print "imagename=$imagename\n"; + if (!exists($img_hash{$imagename})) { + if (!$osimagetab) { + $osimagetab=xCAT::Table->new('osimage', -create=>1); + } + (my $ref) = $osimagetab->getAttribs({imagename => $imagename}, 'osvers', 'osarch', 'profile', 'provmethod'); + if ($ref) { + $img_hash{$imagename}->{osarch}=$ref->{'osarch'}; + } else { + $callback->( + {error => ["The os image $imagename does not exists on the osimage table for $node"], + errorcode => [1]}); + next; + } + } + my $ph=$img_hash{$imagename}; + $arch = $ph->{osarch}; + } + + # copy kernel and initrd from image dir to /tftpboot + my $ramdisk_size = 200000; + + if ( + -r "$tftpdir/xcat/genesis.kernel.$arch" + and -r "$tftpdir/xcat/genesis.fs.$arch.gz" + ) + { + #We have a shot... + my $ent = $rents{$node}->[0]; + 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 = $macref->{mac}; + } + + unless ( $ksdev eq "bootif" ) { + $kcmdline .= " netdevice=" . $ksdev; + } + + if ($arch =~ /ppc/) { + $kcmdline .= " dhcptimeout=150"; + } + + if (defined($sent->{serialport})) + { + unless ($sent->{serialspeed}) + { + $callback->( { error => [ "serialport defined, but no serialspeed for $node in nodehm table" ], + errorcode => [1] } ); + } + else { + #go cmdline if serial console is requested, the shiny ansi is just impractical + $kcmdline .= " cmdline console=tty0 console=ttyS" + . $sent->{serialport} . "," + . $sent->{serialspeed}; + if ($sent->{serialflow} =~ /(hard|cts|ctsrts)/) { + $kcmdline .= "n8r"; + } + } + } + $kcmdline .= " xcatd=$xcatmaster:$xcatdport SCRIPTNAME=$imagename"; + + $bptab->setNodeAttribs( + $node, + { + kernel => "xcat/genesis.kernel.$arch", + initrd => "xcat/genesis.fs.$arch.gz", + kcmdline => $kcmdline + } + ); + } + else + { + $callback->( { error => ["Kernel and initrd not found in $tftpdir/xcat"], + errorcode => [1] } ); + } + + # assign nodes to an image + if (-r "$clusterfile") + { + my $cmd = qq{cat $clusterfile | grep "$node"}; + my $out = xCAT::Utils->runcmd($cmd, -1); + if ($::RUNCMD_RC == 0) + { + my $out = `sed -i /$node./d $clusterfile`; + } + } + + my $cmd =qq{echo "$node:compute:$imagename:" >> $clusterfile}; + my $out = xCAT::Utils->runcmd($cmd, -1); + + unless (-r "$installroot/sysclone/images/$imagename/opt/xcat/xcatdsklspost") + { + mkpath("$installroot/sysclone/images/$imagename/opt/xcat/"); + copy("$installroot/postscripts/xcatdsklspost","$installroot/sysclone/images/$imagename/opt/xcat/"); + } + } + + # check systemimager-server-rsyncd to make sure it's running. + my $out = xCAT::Utils->runcmd("service systemimager-server-rsyncd status", -1); + if ($::RUNCMD_RC != 0) { # not running + my $rc = xCAT::Utils->startService("systemimager-server-rsyncd"); + if ($rc != 0) { + return 1; + } + } +} + sub copycd { my $request = shift; @@ -1670,6 +1938,7 @@ sub insert_dd () { my @rpm_list; my @driver_list; my $Injectalldriver; + my $updatealldriver; my @rpm_drivers; @@ -1715,6 +1984,9 @@ sub insert_dd () { if (/^allupdate$/) { $Injectalldriver = 1; next; + } elsif (/^updateonly$/) { + $updatealldriver = 1; + next; } unless (/\.ko$/) { s/$/.ko/; @@ -1725,7 +1997,7 @@ sub insert_dd () { chomp(@dd_list); chomp(@rpm_list); - unless (@dd_list || (@rpm_list && ($Injectalldriver || @driver_list))) { + unless (@dd_list || (@rpm_list && ($Injectalldriver || $updatealldriver || @driver_list))) { return (); } @@ -1738,7 +2010,7 @@ sub insert_dd () { # Unzip the original initrd # This only needs to be done for ppc or handling the driver rpm # For the driver disk against x86, append the driver disk to initrd directly - if ($arch =~/ppc/ || (@rpm_list && ($Injectalldriver || @driver_list))) { + if ($arch =~/ppc/ || (@rpm_list && ($Injectalldriver || $updatealldriver || @driver_list))) { if ($arch =~ /ppc/) { $cmd = "gunzip --quiet -c $pkgdir/1/suseboot/initrd64 > $dd_dir/initrd"; } elsif ($arch =~ /x86/) { @@ -1763,7 +2035,7 @@ sub insert_dd () { } # Start to load the drivers from rpm packages - if (@rpm_list && ($Injectalldriver || @driver_list)) { + if (@rpm_list && ($Injectalldriver || $updatealldriver || @driver_list)) { # Extract the files from rpm to the tmp dir mkpath "$dd_dir/rpm"; my $new_kernel_ver; @@ -1785,17 +2057,17 @@ sub insert_dd () { # get the new kernel if it exists in the update distro my @new_kernels = <$dd_dir/rpm/boot/vmlinu*>; foreach my $new_kernel (@new_kernels) { - if (-r $new_kernel && $new_kernel =~ /\/vmlinu[zx]-(.*(x86_64|ppc64|default))$/) { - $new_kernel_ver = $1; - $cmd = "/bin/mv -f $new_kernel $dd_dir/rpm/newkernel"; - xCAT::Utils->runcmd($cmd, -1); - if ($::RUNCMD_RC != 0) { - my $rsp; - push @{$rsp->{data}}, "Handle the driver update failed. Could not move $new_kernel to $dd_dir/rpm/newkernel."; - xCAT::MsgUtils->message("I", $rsp, $callback); + if (-r $new_kernel && $new_kernel =~ /\/vmlinu[zx]-(.*(x86_64|ppc64|default))$/) { + $new_kernel_ver = $1; + $cmd = "/bin/mv -f $new_kernel $dd_dir/rpm/newkernel"; + xCAT::Utils->runcmd($cmd, -1); + if ($::RUNCMD_RC != 0) { + my $rsp; + push @{$rsp->{data}}, "Handle the driver update failed. Could not move $new_kernel to $dd_dir/rpm/newkernel."; + xCAT::MsgUtils->message("I", $rsp, $callback); + } } } - } # To skip the conflict of files that some rpm uses the xxx.ko.new as the name of the driver # Change it back to xxx.ko here @@ -1842,13 +2114,35 @@ sub insert_dd () { xCAT::MsgUtils->message("I", $rsp, $callback); } } + + # get the name list for all drivers in the original initrd if 'netdrivers=updateonly' + # then only the drivers in this list will be updated from the drvier rpms + if ($updatealldriver) { + $driver_name = "\*\.ko"; + @all_real_path = (); + find(\&get_all_path, <$dd_dir/initrd_img/lib/modules/*>); + foreach my $real_path (@all_real_path) { + my $driver = basename($real_path); + push @driver_list, $driver; + } + } # Copy the drivers to the rootimage # Figure out the kernel version my @kernelpaths = <$dd_dir/initrd_img/lib/modules/*>; my @kernelvers; + if ($new_kernel_ver) { + push @kernelvers, $new_kernel_ver; + } foreach (@kernelpaths) { - push @kernelvers, basename($_); + my $kernelv = basename($_); + if ($kernelv =~ /^[\d\.]+/) { + if ($new_kernel_ver) { + rmtree ("$dd_dir/initrd_img/lib/modules/$kernelv"); + } else { + push @kernelvers, $kernelv; + } + } } foreach my $kernelver (@kernelvers) { @@ -1861,7 +2155,6 @@ sub insert_dd () { $driver_name = $driver; @all_real_path = (); find(\&get_all_path, <$dd_dir/rpm/lib/modules/$kernelver/*>); - #if ($real_path && $real_path =~ m!$dd_dir/rpm(/lib/modules/$kernelver/.*?)[^\/]*$!) { # NOTE: for the initrd of sles that the drivers are put in the /lib/modules/$kernelver/initrd/ foreach my $real_path (@all_real_path) { if ($real_path && $real_path =~ m!$dd_dir/rpm/lib/modules/$kernelver/!) { @@ -1885,8 +2178,7 @@ sub insert_dd () { $driver_name = "\*\.ko"; @all_real_path = (); find(\&get_all_path, <$dd_dir/rpm/lib/modules/$kernelver/*>); - foreach $real_path (@all_real_path) { - #if ($real_path && $real_path =~ m!$dd_dir/rpm(/lib/modules/$kernelver/.*?)[^\/]*$!) { + foreach my $real_path (@all_real_path) { # NOTE: for the initrd of sles that the drivers are put in the /lib/modules/$kernelver/initrd/ if ($real_path && $real_path =~ m!$dd_dir/rpm/lib/modules/$kernelver/!) { if (! -d "$dd_dir/initrd_img/lib/modules/$kernelver/initrd") { diff --git a/xCAT-server/lib/xcat/plugins/xen.pm b/xCAT-server/lib/xcat/plugins/xen.pm index c8468d656..daf520a3a 100644 --- a/xCAT-server/lib/xcat/plugins/xen.pm +++ b/xCAT-server/lib/xcat/plugins/xen.pm @@ -871,6 +871,8 @@ sub process_request { } } } + #donot update node provision status (installing or netbooting) here + xCAT::Utils->filter_nostatusupdate(\%newnodestatus); #print "newstatus" . Dumper(\%newnodestatus); xCAT_monitoring::monitorctrl::setNodeStatusAttributes(\%newnodestatus, 1); } diff --git a/xCAT-server/share/xcat/install/scripts/pre.rh b/xCAT-server/share/xcat/install/scripts/pre.rh index a0d8675c6..8fc78775f 100644 --- a/xCAT-server/share/xcat/install/scripts/pre.rh +++ b/xCAT-server/share/xcat/install/scripts/pre.rh @@ -13,6 +13,24 @@ if [ -r /tmp/updates/etc/pki/tls/certs/ca-bundle.crt ]; then cp -f /tmp/updates/etc/pki/tls/certs/ca-bundle.crt /etc/pki/tls/certs/ fi +cat >/tmp/baz.py </tmp/foo.py </foo.log 2>&1 & #time to ascertain fstype and PReP/UEFI/legacy diff --git a/xCAT-server/share/xcat/install/scripts/pre.sles b/xCAT-server/share/xcat/install/scripts/pre.sles index 8951c234d..6c616c9e8 100644 --- a/xCAT-server/share/xcat/install/scripts/pre.sles +++ b/xCAT-server/share/xcat/install/scripts/pre.sles @@ -14,28 +14,30 @@ cat >/tmp/bar.awk </tmp/foo.log 2>&1 & + shopt -s nullglob for disk in /dev/vd*[^0-9];do if [ -z "$firstdirectdisk" ]; then firstdirectdisk=$disk; fi #remember first disk as a guess of medium resort diff --git a/xCAT-server/share/xcat/install/scripts/pre.ubuntu b/xCAT-server/share/xcat/install/scripts/pre.ubuntu index 95c95ece9..b6a86c2d1 100644 --- a/xCAT-server/share/xcat/install/scripts/pre.ubuntu +++ b/xCAT-server/share/xcat/install/scripts/pre.ubuntu @@ -63,9 +63,18 @@ cat >/tmp/foo.sh <', "$rootimg_dir/etc/dracut.conf"); if (-d glob("$rootimg_dir/usr/share/dracut/modules.d/[0-9]*fadump")){ print $DRACUTCONF qq{dracutmodules+="xcat nfs base network kernel-modules fadump"\n}; @@ -802,6 +811,10 @@ sub mkinitrd_dracut { $perm = (stat("$fullpath/$dracutdir/xcat-cmdline.sh"))[2]; chmod($perm&07777, "$dracutmpath/xcat-cmdline.sh"); + cp("$fullpath/$dracutdir/xcat-updateflag",$dracutmpath); + $perm = (stat("$fullpath/$dracutdir/xcat-updateflag"))[2]; + chmod($perm&07777, "$dracutmpath/xcat-updateflag"); + if ($prinic) { my $optspec; open($optspec,'>>',"$dracutmpath/xcat-cmdline.sh"); @@ -1058,6 +1071,7 @@ grep '\(debug\)' /proc/cmdline > /dev/null && export DEBUG=1 # TODO: does "anaconda.busybox sh" support "set " ? PRINIC=$prinic +NODESTATUS='y' for i in `cat /proc/cmdline`; do KEY=`echo \$i |awk -F= '{print \$1}'` @@ -1070,6 +1084,14 @@ for i in `cat /proc/cmdline`; do VALUE=`echo \$i |awk -F= '{print \$2}'` # format: XCAT=xcatmaster:3001 XCATSERVER=\$VALUE + elif [ "\$KEY" == 'XCATIPORT' ]; then + VALUE=`echo \$i |awk -F= '{print \$2}'` + # format: XCAT=xcatmaster:3001 + XCATIPORT=\$VALUE + fi + #if "nonodestatus" specified,do not update the nodestatus + if [ \$i == 'nonodestatus' ]; then + NODESTATUS='n' fi done @@ -1098,6 +1120,18 @@ while ! ifconfig | grep inet; do done ifconfig lo 127.0.0.1 ifconfig lo up + +XCATMASTER=`echo \$XCATSERVER|awk -F: '{print \$1}'` + +if [ -z \$XCATIPORT ]; then + XCATIPORT="3002" +fi + +#update nodelist.nodestatus to "netbooting" +if [ \$NODESTATUS != 'n' ]; then + /tmp/updateflag \$XCATMASTER \$XCATIPORT "installstatus netbooting" +fi + cd / for i in `cat /proc/cmdline`; do KEY=`echo \$i |awk -F= '{print \$1}'` @@ -1144,6 +1178,10 @@ for i in `cat /proc/cmdline`; do fi done + + + + # show xCAT logo fancydisplay @@ -1353,8 +1391,38 @@ EOMS open($inifile,">"."/tmp/xcatinitrd.$$/bin/netstart"); print $inifile "#!/sbin/nash\n"; close($inifile); + + #/tmp/updateflag: a script to feedback node provision status to xcatd + system("mkdir -p /tmp/xcatinitrd.$$/tmp/"); + open($inifile, ">","/tmp/xcatinitrd.$$/tmp/updateflag"); + + print $inifile < /tmp/ncarg + nc \$1 \$2 -w 60 -e /tmp/updateflag +else + retrytimes=0 + cmd="" + while [ "\$cmd" != "done" ]; do + retrytimes=`expr \$retrytimes + 1` + if [ \$retrytimes -eq 60 ]; then + break; + fi + read -t 60 cmd + if [ "\$cmd" == "ready" ]; then + head -n 1 /tmp/ncarg + rm -rf /tmp/ncarg + fi + done + +fi +EOMS + close($inifile); + chmod(0755,"/tmp/xcatinitrd.$$/init"); chmod(0755,"/tmp/xcatinitrd.$$/bin/netstart"); + chmod(0755,"/tmp/xcatinitrd.$$/tmp/updateflag"); @filestoadd=(); foreach (@ndrivers) { if (-f "$customdir/$_") { diff --git a/xCAT-server/share/xcat/netboot/sles/genimage b/xCAT-server/share/xcat/netboot/sles/genimage index b4a018698..a619a80e0 100755 --- a/xCAT-server/share/xcat/netboot/sles/genimage +++ b/xCAT-server/share/xcat/netboot/sles/genimage @@ -472,7 +472,7 @@ unless ($onlyinitrd) { } } - foreach $pass (sort {$a <=> $b} (keys(%extra_hash))) { + foreach $pass (sort {$a <=> $b} (keys(%extra_hash))) { my $index=1; #remove the old repository for extra packages @@ -1032,6 +1032,7 @@ EOMS # check the kernel parameters firstly # if one parameter for the booting device is here, it will be used PRINIC=$prinic +NODESTATUS='y' XCATMNTOPTS='nolock,tcp' for i in `cat /proc/cmdline`; do KEY=`echo \$i |awk -F= '{print \$1}'` @@ -1050,6 +1051,11 @@ for i in `cat /proc/cmdline`; do XCATMNTOPTS=\$VALUE fi + + + if [ \$i == 'nonodestatus' ]; then + NODESTATUS='n' + fi done if [ -z "\$IFACE" ]; then @@ -1083,6 +1089,18 @@ echo "STARTMODE=nfsroot" > /tmp/ifcfg-\$IFACE ip addr add dev lo 127.0.0.1/8 ip link set lo up + + +XCATMASTER=`echo \$XCATSERVER|awk -F: '{print \$1}'` + +if [ -z \$XCATIPORT ]; then + XCATIPORT="3002" +fi + +if [ \$NODESTATUS != 'n' ]; then + /tmp/updateflag \$XCATMASTER \$XCATIPORT "installstatus netbooting" +fi + cd / for i in `cat /proc/cmdline`; do KEY=`echo \$i |awk -F= '{print \$1}'` @@ -1373,8 +1391,43 @@ cat /var/lib/dhcpcd/*info | grep HOSTNAME | uniq | awk -F= '{print \$2}'| sed \" END close($inifile); - chmod(0755,"/tmp/xcatinitrd.$$/init"); - chmod(0755,"/tmp/xcatinitrd.$$/bin/netstart"); + + #if "nonodestatus" specified,do not update the nodestatus + system("mkdir -p /tmp/xcatinitrd.$$/tmp/"); + open($inifile, ">","/tmp/xcatinitrd.$$/tmp/updateflag"); + + print $inifile < $b} (keys(%pkg_hash))) { + foreach $pass (sort {$a <=> $b} (keys(%pkg_hash))) { my $pkgnames = ""; foreach (keys(%{$pkg_hash{$pass}})) { if (($_ eq "PRE_REMOVE") || ($_ eq "POST_REMOVE") || ($_ eq "ENVLIST")) { next;} @@ -959,6 +959,8 @@ grep '\(debug\)' /proc/cmdline > /dev/null && export DEBUG=1 # TODO: does "anaconda.busybox sh" support "set " ? PRINIC=$prinic +NODESTATUS='y' +XCATIPORT="3002" for i in `cat /proc/cmdline`; do KEY=`echo \$i |awk -F= '{print \$1}'` @@ -971,7 +973,17 @@ for i in `cat /proc/cmdline`; do VALUE=`echo \$i |awk -F= '{print \$2}'` # format: XCAT=xcatmaster:3001 XCATSERVER=\$VALUE + elif [ "\$KEY" == 'XCATIPORT' ]; then + VALUE=`echo \$i |awk -F= '{print \$2}'` + # format: XCAT=xcatmaster:3001 + XCATIPORT=\$VALUE fi + + #if "nonodestatus" specified,do not update the nodestatus + if [ \$i == 'nonodestatus' ]; then + NODESTATUS='n' + fi + done if [ -z "\$IFACE" ]; then @@ -998,6 +1010,16 @@ while ! ifconfig | grep 'inet addr'; do done ifconfig lo 127.0.0.1 ifconfig lo up + + +XCATMASTER=`echo \$XCATSERVER|awk -F: '{print \$1}'` + + +#update nodelist.nodestatus to "netbooting" +if [ \$NODESTATUS != 'n' ]; then + /tmp/updateflag \$XCATMASTER \$XCATIPORT "installstatus netbooting" +fi + cd / for i in `cat /proc/cmdline`; do KEY=`echo \$i |awk -F= '{print \$1}'` @@ -1309,10 +1331,40 @@ exit 0 EOF close($inifile); + + #if "nonodestatus" specified,do not update the nodestatus + system("mkdir -p /tmp/xcatinitrd.$$/tmp/"); + open($inifile, ">","/tmp/xcatinitrd.$$/tmp/updateflag"); + + print $inifile < /tmp/ncarg + nc \$1 \$2 -w 60 -e /tmp/updateflag +else + retrytimes=0 + cmd="" + while [ "\$cmd" != "done" ]; do + retrytimes=`expr \$retrytimes + 1` + if [ \$retrytimes -eq 60 ]; then + break; + fi + read -t 60 cmd + if [ "\$cmd" == "ready" ]; then + head -n 1 /tmp/ncarg + rm -rf /tmp/ncarg + fi + done + +fi +EOMS + close($inifile); + chmod(0755,"/tmp/xcatinitrd.$$/usr/share/udhcpc/default.script"); chmod(0755,"/tmp/xcatinitrd.$$/init"); chmod(0755,"/tmp/xcatinitrd.$$/bin/netstart"); + chmod(0755,"/tmp/xcatinitrd.$$/tmp/updateflag"); @filestoadd=(); foreach (@ndrivers) { if (-f "$customdir/$_") { diff --git a/xCAT-server/share/xcat/tools/detect_dhcpd b/xCAT-server/share/xcat/tools/detect_dhcpd index 10956e144..d696a66eb 100755 --- a/xCAT-server/share/xcat/tools/detect_dhcpd +++ b/xCAT-server/share/xcat/tools/detect_dhcpd @@ -88,7 +88,13 @@ my $sock = IO::Socket::INET->new(Proto => 'udp', #LocalAddr => 0, LocalAddr => $IP, LocalPort => '68', - PeerAddr => inet_ntoa(INADDR_BROADCAST)) or die "Create socket error: $@\n"; + PeerAddr => inet_ntoa(INADDR_BROADCAST)); + +unless ($sock) { + print "Create socket error: $@\n"; + kill_child(); + exit 1; +} my $timeout = 10; if ($::TIMEOUT) { @@ -104,6 +110,8 @@ while ($end - $start <= $timeout) { $end =~ s/(\d.*)\.(\d.*)/$1/; } + +kill_child(); #kill the child process kill 15, $pid; my @pidoftcpdump = `ps -ef | grep -E "[0-9]+:[0-9]+:[0-9]+ tcpdump -i $IF" | awk -F' ' '{print \$2}'`; @@ -297,4 +305,11 @@ sub packdhcppkg{ return $package; } - +sub kill_child { + kill 15, $pid; + my @pidoftcpdump = `ps -ef | grep -E "[0-9]+:[0-9]+:[0-9]+ tcpdump -i $IF" | awk -F' ' '{print \$2}'`; + foreach my $cpid (@pidoftcpdump) { + kill 15, $cpid; + #print "try to kill $cpid\n"; + } +} diff --git a/xCAT/postscripts/configefi b/xCAT/postscripts/configefi index 6067248ce..4db78507c 100644 --- a/xCAT/postscripts/configefi +++ b/xCAT/postscripts/configefi @@ -1,2 +1,45 @@ -echo "Setting Boot Manager for the next boot." -efibootmgr -c -l \\EFI\\redhat\\grub.efi -L Linux +if [ -d /sys/firmware/efi ]; then + echo "Setting Boot Manager for the next boot." + efibootmgr -c -l \\EFI\\redhat\\grub.efi -L Linux +else + echo "run grub-install to configure the MBR." + if [ -e /etc/mtab ];then + mv /etc/mtab /etc/mtab.bak + fi + grep -v rootfs /proc/mounts > /etc/mtab + boot_device='' + if [ -f "/etc/systemconfig/systemconfig.conf" ];then + boot_device=`cat /etc/systemconfig/systemconfig.conf | grep BOOTDEV | awk '{print $3}'` + else + str_temp=`mount | awk '{print $1","$3}'` + for line in $str_temp + do + mp=`echo $line | awk -F, '{print $2}'` + if [ "$mp" = "/" ];then + boot_device=`echo $line | awk -F, '{print $1}' | sed -e 's/[0-9]*$//'` + break + fi + done + fi + + if [ -n "$boot_device" ];then + echo "the boot device is $boot_device" + else + echo "Can not find the boot device, return error" + exit 1 + fi + + #for sles10, should run grub-install with parameters + echo "grub-install --no-floppy --recheck $boot_device" + grub-install --no-floppy --recheck $boot_device + if [ $? -ne 0 ];then + #sles11, run grub install directly + grub-install + fi + + if [ -e /etc/mtab.bak ];then + mv -f /etc/mtab.bak /etc/mtab + else + rm -f /etc/mtab + fi +fi diff --git a/xCAT/postscripts/killsyslog b/xCAT/postscripts/killsyslog new file mode 100755 index 000000000..ba2395caa --- /dev/null +++ b/xCAT/postscripts/killsyslog @@ -0,0 +1,7 @@ +if [ -f "/etc/SuSE-release" ];then + str_out=`ps -ef | grep -v grep | grep syslog-ng` + if [ $? -eq 0 ];then + str_id=`echo $str_out | awk '{print $2}'` + kill -9 $str_id + fi +fi diff --git a/xCAT/postscripts/runxcatpost b/xCAT/postscripts/runxcatpost index 0dbf33f5e..9d4647342 100644 --- a/xCAT/postscripts/runxcatpost +++ b/xCAT/postscripts/runxcatpost @@ -1 +1,9 @@ -/opt/xcat/xcatdsklspost \ No newline at end of file +#!/bin/bash +/opt/xcat/xcatdsklspost + +. /tmp/post-install/variables.txt + +if [ -x "/xcatpost/updateflag.awk" ];then + /xcatpost/updateflag.awk $IMAGESERVER 3002 +fi + diff --git a/xCAT/postscripts/updatenetwork b/xCAT/postscripts/updatenetwork index d40cfdbd2..fc82ab64d 100644 --- a/xCAT/postscripts/updatenetwork +++ b/xCAT/postscripts/updatenetwork @@ -1,17 +1,35 @@ #!/bin/bash . /tmp/post-install/variables.txt -echo "Updating hostname to $HOSTNAME" -sed -i "s/HOSTNAME=.*/HOSTNAME=$HOSTNAME/g" /etc/sysconfig/network +#delete the udev rule in the image +rule_file=`ls /etc/udev/rules.d/*net_persistent_names.rules` +if [ -n "$rule_file" ];then + rm -f $rule_file +fi hostname $HOSTNAME +str_cfg_file='' +if [ -d "/etc/sysconfig/network-scripts/" ];then + #redhat + str_cfg_file="/etc/sysconfig/network-scripts/ifcfg-$DEVICE" + sed -i "s/HOSTNAME=.*/HOSTNAME=$HOSTNAME/g" /etc/sysconfig/network +elif [ -d "/etc/sysconfig/network/" ];then + #suse + str_cfg_file="/etc/sysconfig/network/ifcfg-$DEVICE" + echo "$HOSTNAME" > /etc/HOSTNAME +else + #ubuntu + str_cfg_file="/etc/network/interfaces.d/$DEVICE" + echo "$HOSTNAME" > /etc/hostname +fi + echo "Old ifcfg-$DEVICE is:" -cat /etc/sysconfig/network-scripts/ifcfg-$DEVICE +cat $str_cfg_file HWADDR=`ifconfig $DEVICE|grep HWaddr|awk '{print $5}'` -sed -i "s/HWADDR=.*/HWADDR="$HWADDR"/g" /etc/sysconfig/network-scripts/ifcfg-$DEVICE -sed -i "s/UUID=.*//g" /etc/sysconfig/network-scripts/ifcfg-$DEVICE +sed -i "s/HWADDR=.*/HWADDR="$HWADDR"/g" $str_cfg_file +sed -i "s/UUID=.*//g" $str_cfg_file echo "New ifcfg-$DEVICE is:" -cat /etc/sysconfig/network-scripts/ifcfg-$DEVICE +cat $str_cfg_file diff --git a/xCAT/postscripts/xcatflowrequest b/xCAT/postscripts/xcatflowrequest index 79112ca68..ab1253ead 100644 --- a/xCAT/postscripts/xcatflowrequest +++ b/xCAT/postscripts/xcatflowrequest @@ -24,8 +24,7 @@ while ! grep 'resourcerequest: ok' /tmp/goahead.$parpid > /dev/null; do done sleeper=$(cat /tmp/sleeperpid.$parpid) sleeper=$(ps -ef|awk "\$3==$sleeper"|awk '{print $2}') -kill -TERM $sleeper rm /tmp/goahead.$parpid rm /tmp/sleeperpid.$parpid rm /tmp/killme.$parpid - +kill -TERM $sleeper diff --git a/xCAT/postscripts/xcatlib.sh b/xCAT/postscripts/xcatlib.sh index e5b5da8fd..17a5adf6f 100644 --- a/xCAT/postscripts/xcatlib.sh +++ b/xCAT/postscripts/xcatlib.sh @@ -1,17 +1,73 @@ function hashencode(){ - local map="$1" - echo `echo $map | sed 's/\./xDOTx/g' | sed 's/:/xCOLONx/g' | sed 's/,/:xCOMMAx/g'` + local str_map="$1" + echo `echo $str_map | sed 's/\./xDOTx/g' | sed 's/:/xCOLONx/g' | sed 's/,/:xCOMMAx/g'` } function hashset(){ - local hashname="hash${1}${2}" - local value=$3 - hashname=$(hashencode $hashname) - eval "${hashname}='${value}'" + local str_hashname="hash${1}${2}" + local str_value=$3 + str_hashname=$(hashencode $str_hashname) + eval "${str_hashname}='${str_value}'" } function hashget(){ - local hashname="hash${1}${2}" - hashname=$(hashencode $hashname) - eval echo "\$${hashname}" + local str_hashname="hash${1}${2}" + str_hashname=$(hashencode $str_hashname) + eval echo "\$${str_hashname}" } + +function debianpreconf(){ + #create the config sub dir + if [ ! -d "/etc/network/interfaces.d" ];then + mkdir -p "/etc/network/interfaces.d" + fi + #search xcat flag + `grep "#XCAT_CONFIG" /etc/network/interfaces` + if [ $? -eq 0 ];then + return + fi + + #back up the old interface configure + if [ ! -e "/etc/network/interfaces.bak" ];then + mv /etc/network/interfaces /etc/network/interfaces.bak + fi + + #create the new config file + echo "#XCAT_CONFIG" > /etc/network/interfaces + echo "source /etc/network/interfaces.d/*" >> /etc/network/interfaces + + local str_conf_file='' + + #read the backfile + cat /etc/network/interfaces.bak | while read str_line + do + if [ ! "$str_line" ];then + continue + fi + local str_first_char=${str_line:0:1} + if [ $str_first_char = '#' ];then + continue + fi + + local str_conf_type=`echo $str_line | cut -d" " -f1` + if [ $str_conf_type = 'auto' -o $str_conf_type = 'allow-hotplug' ];then + str_line=${str_line#$str_conf_type} + for str_nic_name in $str_line; do + echo "$str_conf_type $str_nic_name" > "/etc/network/interfaces.d/$str_nic_name" + done + elif [ $str_conf_type = 'iface' -o $str_conf_type = 'mapping' ];then + #find out the nic name, should think about the eth0:1 + str_nic_name=`echo $str_line | cut -d" " -f 2 | cut -d":" -f 1` + str_conf_file="/etc/network/interfaces.d/$str_nic_name" + if [ ! -e $str_conf_file ];then + echo "auto $str_nic_name" > $str_conf_file + fi + + #write lines into the conffile + echo $str_line >> $str_conf_file + else + echo $str_line >> $str_conf_file + fi + done +} +