2008-05-12 21:34:15 +00:00
|
|
|
#!/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;
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
2008-05-22 13:01:40 +00:00
|
|
|
=head1
|
|
|
|
|
|
|
|
mounts /install if site.installloc set
|
2008-09-09 12:31:27 +00:00
|
|
|
on a Linux Service Node
|
2008-05-12 21:34:15 +00:00
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
2008-05-22 13:01:40 +00:00
|
|
|
=head3 handled_commands
|
2008-05-12 21:34:15 +00:00
|
|
|
|
|
|
|
Check to see if on a Service Node
|
2008-05-22 13:01:40 +00:00
|
|
|
Call mountInstall
|
2008-05-12 21:34:15 +00:00
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
sub handled_commands
|
|
|
|
|
|
|
|
{
|
2008-05-19 18:15:48 +00:00
|
|
|
# If called in XCATBYPASS mode, don't do any setup
|
|
|
|
if ($ENV{'XCATBYPASS'}) {
|
|
|
|
return 0;
|
|
|
|
}
|
2008-09-09 12:31:27 +00:00
|
|
|
if (xCAT::Utils->isAIX()) { # do not run on AIX
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-05-19 18:15:48 +00:00
|
|
|
|
2008-05-12 21:34:15 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
2008-05-22 13:01:40 +00:00
|
|
|
=head3 process_request
|
2008-05-12 21:34:15 +00:00
|
|
|
|
|
|
|
Process the command
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
sub process_request
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
|
2008-05-22 13:01:40 +00:00
|
|
|
=head3 mountInstall
|
2008-05-12 21:34:15 +00:00
|
|
|
|
2008-05-22 13:01:40 +00:00
|
|
|
if site.installloc attribute set
|
|
|
|
mount the install directory
|
2008-05-12 21:34:15 +00:00
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
sub mountInstall
|
|
|
|
{
|
|
|
|
my ($nodename) = @_;
|
|
|
|
my $rc = 0;
|
|
|
|
my $installdir = "/install"; # default
|
2008-05-22 13:01:40 +00:00
|
|
|
my $installloc = "/install"; # default
|
2008-05-12 21:34:15 +00:00
|
|
|
|
|
|
|
# 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
|
2008-05-22 13:01:40 +00:00
|
|
|
my @installlocation= xCAT::Utils->get_site_attribute("installloc");
|
2008-05-12 21:34:15 +00:00
|
|
|
my $hostname;
|
|
|
|
my $path;
|
2008-05-22 13:01:40 +00:00
|
|
|
if ($installlocation[0])
|
2008-05-12 21:34:15 +00:00
|
|
|
{
|
2008-05-22 13:01:40 +00:00
|
|
|
if (grep /:/, $installlocation[0]){
|
|
|
|
my ($hostname, $installloc) = split ":",$installlocation[0];
|
2008-05-12 21:34:15 +00:00
|
|
|
if ($hostname)
|
2008-05-22 13:01:40 +00:00
|
|
|
{ # hostname set in /installloc attribute
|
2008-05-12 21:34:15 +00:00
|
|
|
$master = $hostname; # set name for mount
|
|
|
|
}
|
|
|
|
} else {
|
2008-05-22 13:01:40 +00:00
|
|
|
$installloc=$installlocation[0];
|
2008-05-12 21:34:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
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
|
2008-05-22 13:01:40 +00:00
|
|
|
my $cmd= "mount -o rw,nolock $master:$installloc $installdir";
|
2008-05-12 21:34:15 +00:00
|
|
|
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
|
2008-05-22 13:01:40 +00:00
|
|
|
$cmd = "grep $master:$installloc $installdir /etc/fstab ";
|
2008-05-12 21:34:15 +00:00
|
|
|
xCAT::Utils->runcmd($cmd, -1);
|
|
|
|
if ($::RUNCMD_RC != 0)
|
|
|
|
{
|
2008-05-22 13:01:40 +00:00
|
|
|
`echo "$master:$installloc $installdir nfs timeo=14,intr 1 2" >>/etc/fstab`;
|
2008-05-12 21:34:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return $rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
1;
|