From e8306256259e12e72c4e944b6ac425dcee858470 Mon Sep 17 00:00:00 2001 From: nott Date: Wed, 13 Apr 2011 19:19:31 +0000 Subject: [PATCH] AIX statelite cleanup plus soft mount support git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@9304 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT/xCAT/InstUtils.pm | 91 ++++++++++++++++------ perl-xCAT/xCAT/Schema.pm | 3 +- xCAT-server/lib/xcat/plugins/aixinstall.pm | 13 +++- xCAT/postscripts/aixlitesetup | 12 ++- 4 files changed, 90 insertions(+), 29 deletions(-) diff --git a/perl-xCAT/xCAT/InstUtils.pm b/perl-xCAT/xCAT/InstUtils.pm index 5f7a86ba6..9ef705352 100644 --- a/perl-xCAT/xCAT/InstUtils.pm +++ b/perl-xCAT/xCAT/InstUtils.pm @@ -33,7 +33,6 @@ use xCAT::NetworkUtils; require xCAT::NodeRange; require DBI; - #------------------------------------------------------------------------------- =head1 xCAT::InstUtils @@ -925,7 +924,8 @@ sub dolitesetup } # create the statelite table file - my $stateHash = $statelitetab->getNodesAttribs(\@nodelist, ['statemnt']); + my $foundentry=0; + my $stateHash = $statelitetab->getNodesAttribs(\@nodelist, ['statemnt', 'mntopts']); foreach my $node (@nodelist) { # process statelite entry @@ -935,7 +935,10 @@ sub dolitesetup # then - on node - a nodename subdir is created my $statemnt=""; + my $mntopts; if (exists($stateHash->{$node})) { + + $mntopts = $stateHash->{$node}->[0]->{mntopts}; $statemnt = $stateHash->{$node}->[0]->{statemnt}; my ($server, $dir) = split(/:/, $statemnt); @@ -959,14 +962,31 @@ sub dolitesetup } my $entry = qq~$node|$statemnt~; + if ($mntopts) { + $entry = qq~$node|$statemnt|$mntopts~; + } $entry =~ s/\s*//g; #remove blanks if ($statemnt) { print STATELITE $entry . "\n"; + $foundentry++; } } close(STATELITE); + if (!$foundentry) { + # don't leave empty file + my $rc = xCAT::Utils->runcmd("rm $statelitetable", -1); + if ($::RUNCMD_RC != 0) + { + my $rsp; + push @{$rsp->{data}}, "Could not remove $statelitetable file."; + xCAT::MsgUtils->message("E", $rsp, $callback); + return 1; + } + + } + unless (open(LITEFILE, ">$litefiletable")) { my $rsp; @@ -976,15 +996,29 @@ sub dolitesetup } my @filelist = xCAT::Utils->runcmd("/opt/xcat/bin/litefile $noderange", -1); - - foreach my $l (@filelist) { - $l =~ s/://g; # remove ":"'s - $l =~ s/\s+/|/g; # change separator to "|" - print LITEFILE $l . "\n"; - push (@litefiles, $l); - $foundstatelite++; + if (scalar(@filelist) > 0) { + foreach my $l (@filelist) { + $l =~ s/://g; # remove ":"'s + $l =~ s/\s+/|/g; # change separator to "|" + print LITEFILE $l . "\n"; + push (@litefiles, $l); + $foundstatelite++; + } + close(LITEFILE); + } else { + close(LITEFILE); + # remove empty files + my $rc = xCAT::Utils->runcmd("rm $litefiletable", -1); + if ($::RUNCMD_RC != 0) + { + my $rsp; + push @{$rsp->{data}}, "Could not remove $litefiletable file."; + xCAT::MsgUtils->message("E", $rsp, $callback); + return 1; + } } - close(LITEFILE); + + unless (open(LITETREE, ">$litetreetable")) { @@ -994,18 +1028,30 @@ sub dolitesetup return 1; } my @treelist = xCAT::Utils->runcmd("/opt/xcat/bin/litetree $noderange", -1); - foreach my $l (@treelist) { - - my ($p, $serv, $dir) = split (/:/, $l); - $p =~ s/\s*//g; - $serv =~ s/\s*//g; - $dir =~ s/\s*//g; - my $serverIP = xCAT::NetworkUtils->getipaddr($serv); - my $entry = "$p|$serverIP|$dir"; - print LITETREE $entry . "\n"; - $foundstatelite++; - } - close(LITETREE); + if (scalar(@treelist) > 0) { + foreach my $l (@treelist) { + my ($p, $serv, $dir) = split (/:/, $l); + $p =~ s/\s*//g; + $serv =~ s/\s*//g; + $dir =~ s/\s*//g; + my $serverIP = xCAT::NetworkUtils->getipaddr($serv); + my $entry = "$p|$serverIP|$dir"; + print LITETREE $entry . "\n"; + $foundstatelite++; + } + close(LITETREE); + } else { + close(LITETREE); + # don't leave empty file + my $rc = xCAT::Utils->runcmd("rm $litetreetable", -1); + if ($::RUNCMD_RC != 0) + { + my $rsp; + push @{$rsp->{data}}, "Could not remove $litetreetable file."; + xCAT::MsgUtils->message("E", $rsp, $callback); + return 1; + } + } # if there is no statelite info then just return if (!$foundstatelite) { @@ -1050,7 +1096,6 @@ sub dolitesetup } } - # populate the .defaults dir with files and dirs from the image - if any my $default="$instrootloc/.default"; diff --git a/perl-xCAT/xCAT/Schema.pm b/perl-xCAT/xCAT/Schema.pm index 348d13831..389415b3d 100644 --- a/perl-xCAT/xCAT/Schema.pm +++ b/perl-xCAT/xCAT/Schema.pm @@ -42,7 +42,7 @@ use xCAT::ExtTab; #New format, not sql statements, but info enough to describe xcat tables %tabspec = ( statelite => { - cols => [qw(node image statemnt comments disable)], + cols => [qw(node image statemnt mntopts comments disable)], keys => [qw(node)], required => [qw(node statemnt)], table_desc => 'The location on an NFS server where a nodes persistent files are stored. Any file marked persistent in the litefile table will be stored in the location specified in this table for that node.', @@ -50,6 +50,7 @@ statelite => { node => 'The name of the node or group that will use this location.', image => "Reserved for future development, not used. ", statemnt => "The persistant read/write area where a node's persistent files will be written to, e.g: 10.0.0.1/state/. The node name will be automatically added to the pathname, so 10.0.0.1:/state, will become 10.0.0.1:/state/.", + mntopts => "A comma-separated list of options to use when mounting the persistent directory. (Ex. 'soft') The default is to do a 'hard' mount. ", comments => 'Any user-written notes.', disable => "Set to 'yes' or '1' to comment out this row.", }, diff --git a/xCAT-server/lib/xcat/plugins/aixinstall.pm b/xCAT-server/lib/xcat/plugins/aixinstall.pm index 23f180e26..9c22b1b09 100644 --- a/xCAT-server/lib/xcat/plugins/aixinstall.pm +++ b/xCAT-server/lib/xcat/plugins/aixinstall.pm @@ -1264,7 +1264,7 @@ sub spot_updates my $rsp; push @{$rsp->{data}}, "Could not get NIM spot definitions from $srvnode."; xCAT::MsgUtils->message("E", $rsp, $callback); - return 1; + # return 1; } my @SNspots; @@ -3067,6 +3067,7 @@ sub mknimimage $newres{spot} = $spot_name; if (!defined($spot_name)) { + my $rsp; push @{$rsp->{data}}, "Could not create spot definition.\n"; xCAT::MsgUtils->message("E", $rsp, $callback); @@ -5781,6 +5782,7 @@ if (0) { { my $rsp; push @{$rsp->{data}}, "Could not copy the odmscript back"; + xCAT::MsgUtils->message("E", $rsp, $callback); return 1; } @@ -5994,13 +5996,16 @@ sub update_dd_boot fi \n\n~; my $patch = - qq~\n\t# xCAT support #3\n\tif [ -z "\$(odmget -qattribute=syscons CuAt)" ] \n\tthen\n\t \${SHOWLED} 0x911\n\t cp /usr/ODMscript /tmp/ODMscript\n\t [ \$? -eq 0 ] && odmadd /tmp/ODMscript\n\tfi \n\n~; + qq~\n\t# xCAT support #3\n\tif [ -z "\$(odmget -qattribute=syscons CuAt)" ] \n\tthen\n\t \${SHOWLED} 0x911\n\t cp /usr/ODMscript /tmp/ODMscript\n\tchmod 600 /tmp/ODMscript\n\t [ \$? -eq 0 ] && odmadd /tmp/ODMscript\n\tfi \n\n~; my $scripthook = qq~ # xCAT support #4 # do statelite setup if needed cp /../SPOT/niminfo /etc/niminfo - /aixlitesetup + if [ -f "/aixlitesetup" ] + then + /aixlitesetup + fi \n\n~; if (open(DDBOOT, "<$dd_boot_file_mn")) @@ -9611,7 +9616,7 @@ sub prermdsklsnode ) { &rmdsklsnode_usage($callback); - return 2; + return; } if ($::HELP) diff --git a/xCAT/postscripts/aixlitesetup b/xCAT/postscripts/aixlitesetup index feca2e20a..2f23d9319 100644 --- a/xCAT/postscripts/aixlitesetup +++ b/xCAT/postscripts/aixlitesetup @@ -49,6 +49,16 @@ ProcessStatelite () { SERVER=`echo $i | /usr/bin/awk -F'|' '{print $2}'` TOMNT=`echo $i | /usr/bin/awk -F'|' '{print $3}'` + OPTS=`echo $i | /usr/bin/awk -F'|' '{print $4}'` + +# ndebug + + if [ "$OPTS" = "" ]; then + MNTOPTS=" " + else + MNTOPTS=" -o $OPTS " + fi + # /.statelite/tmpdir if [ ! -d ${TMPDIR} ]; then @@ -61,7 +71,7 @@ ProcessStatelite () { fi # mount 10.2.0.200:/nodedata /.statelite/persistent - /usr/sbin/mount $SERVER:$TOMNT ${PERSISTENT} + /usr/sbin/mount ${MNTOPTS} $SERVER:$TOMNT ${PERSISTENT} # make a node subdir # /.statelite/persistent/