From dd3e24ec7ba4a83440446b0ec725dd22070865a5 Mon Sep 17 00:00:00 2001 From: lissav Date: Mon, 12 May 2008 21:34:15 +0000 Subject: [PATCH] new plugin to mount install git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@1359 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server-2.0/lib/xcat/plugins/AAsn.pm | 167 +++++++++++++++++++++++ 1 file changed, 167 insertions(+) create mode 100644 xCAT-server-2.0/lib/xcat/plugins/AAsn.pm diff --git a/xCAT-server-2.0/lib/xcat/plugins/AAsn.pm b/xCAT-server-2.0/lib/xcat/plugins/AAsn.pm new file mode 100644 index 000000000..dc1b911ac --- /dev/null +++ b/xCAT-server-2.0/lib/xcat/plugins/AAsn.pm @@ -0,0 +1,167 @@ +#!/usr/bin/env perl +# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html +#------------------------------------------------------- +package xCAT_plugin::AAsn; +use xCAT::Table; + +use xCAT::Utils; + +use xCAT::MsgUtils; +use File::Path; +use Getopt::Long; + +#------------------------------------------------------- + +=head1 + + mounts /install if site->installoc set + + +#------------------------------------------------------- + +=head3 handled_commands + +Check to see if on a Service Node +Call mountInstall + +=cut + +#------------------------------------------------------- + +sub handled_commands + +{ + my $rc = 0; + + if (xCAT::Utils->isServiceNode()) + { + my @nodeinfo = xCAT::Utils->determinehostname; + my $nodename = pop @nodeinfo; # get hostname + my @nodeipaddr = @nodeinfo; # get ip addresses + my $service = "mountInstall"; + + # service needed on this Service Node + $rc = &mountInstall($nodename); # setup NFS + if ($rc == 0) + { + xCAT::Utils->update_xCATSN($service); + } + } + return $rc; +} + +#------------------------------------------------------- + +=head3 process_request + + Process the command + +=cut + +#------------------------------------------------------- +sub process_request +{ + return; +} + +#----------------------------------------------------------------------------- + +=head3 mountInstall + + if site->installoc attribute set + mount the install directory + +=cut + +#----------------------------------------------------------------------------- +sub mountInstall +{ + my ($nodename) = @_; + my $rc = 0; + my $installdir = "/install"; # default + my $installoc = "/install"; # default + + # read DB for nodeinfo + my $master; + my $os; + my $arch; + my $nomount = 0; + + my $retdata = xCAT::Utils->readSNInfo($nodename); + if ($retdata->{'arch'}) + { # no error + $master = $retdata->{'master'}; # management node + $os = $retdata->{'os'}; + $arch = $retdata->{'arch'}; + + # read install directory and install location from database, + # if they exists + my @installocation= xCAT::Utils->get_site_attribute("installoc"); + my $hostname; + my $path; + if ($installocation[0]) + { + if (grep /:/, $installocation[0]){ + my ($hostname, $installoc) = split ":",$installocation[0]; + if ($hostname) + { # hostname set in /installoc attribute + $master = $hostname; # set name for mount + } + } else { + $installoc=$installocation[0]; + } + } + else + { # if no install location then we do not mount + $nomount = 1; + } + + if ($nomount == 0) + { # mount the install directory + my @installdir1 = xCAT::Utils->get_site_attribute("installdir"); + if ($installdir1[0]) + { + $installdir = $installdir1[0]; # save directory to mount to + } + if (!(-e $installdir)) + { + mkpath($installdir); + } + + # check to see if install already mounted + + my $mounted = xCAT::Utils->isMounted($installdir); + if ($mounted == 0) + { # not mounted + + # need to mount the directory + my $cmd= "mount -o rw,nolock $master:$installoc $installdir"; + system $cmd; + if ($? > 0) + { # error + $rc = 1; + xCAT::MsgUtils->message("S", "Error $cmd"); + } + } + } + + } + else + { # error reading Db + $rc = 1; + } + if ($rc == 0 && $nomount == 0) + { + + # update fstab to mount on reboot + $cmd = "grep $master:$installoc $installdir /etc/fstab "; + xCAT::Utils->runcmd($cmd, -1); + if ($::RUNCMD_RC != 0) + { + `echo "$master:$installoc $installdir nfs timeo=14,intr 1 2" >>/etc/fstab`; + } + } + return $rc; +} + +1;