From a2d4429bba7054a3ee8aaf98f0f5fd382c742eb1 Mon Sep 17 00:00:00 2001 From: ligc Date: Tue, 8 Mar 2011 05:54:53 +0000 Subject: [PATCH] postscript to put AIX paging space on external NFS server git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@9005 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT/postscripts/redirectps | 66 +++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100755 xCAT/postscripts/redirectps diff --git a/xCAT/postscripts/redirectps b/xCAT/postscripts/redirectps new file mode 100755 index 000000000..fdd0ba096 --- /dev/null +++ b/xCAT/postscripts/redirectps @@ -0,0 +1,66 @@ +#!/usr/bin/env perl +# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html +##################################################### +# +# xCAT post script for diskless nodes +# to redirect paging space to external NFS server, +# which is specified through nfsserver attribute +# +##################################################### + +if (!$ENV{'NFSSERVER'}) +{ + `logger -t xcat "environment variable does not exist, exiting..."`; + exit; +} + +my $nfsserver = $ENV{'NFSSERVER'}; + +my $cmd = "lsps -t nfs -c"; +&runcmd($cmd); + +foreach my $line (@::outref) +{ + chomp($line); + if ($line =~ /^#/) + { + next; + } + my ($psname, $pshost, $psfile, $pssize, $psused, $psactive, $psauto, $pstype, $pschksum) = split(/:/, $line); + if ($pshost eq $nfsserver) + { + next; + } + my $cmd = "mkps -a -n -t nfs $nfsserver $psfile"; + &runcmd($cmd); + + $cmd = "swapoff /dev/$psname"; + &runcmd($cmd); + + $cmd = "rmps $psname"; + &runcmd($cmd); + +} +sub runcmd +{ + my ($cmd) = @_; + my $rc=0; + $cmd .= ' 2>&1' ; + @::outref = `$cmd`; + if ($?) + { + $rc = $? >> 8; + if ($rc > 0) + { + `logger -t xcat "runcmd $cmd failed, error message is:"`; + my $errmsg; + foreach my $err (@::outref) + { + $errmsg .= $err; + } + `logger -t xcat "$errmsg"`; + exit; + } + } + return $rc; +}