2008-02-21 18:23:01 +00:00
|
|
|
#!/usr/bin/env perl
|
|
|
|
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
|
|
|
|
#-------------------------------------------------------
|
|
|
|
package xCAT_plugin::NFSsn;
|
|
|
|
use xCAT::Table;
|
|
|
|
|
|
|
|
use xCAT::Utils;
|
|
|
|
|
|
|
|
use xCAT::MsgUtils;
|
2008-05-07 21:15:13 +00:00
|
|
|
use File::Path;
|
2008-02-21 18:23:01 +00:00
|
|
|
use Getopt::Long;
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
=head1
|
2008-05-12 21:26:54 +00:00
|
|
|
xCAT plugin package to start nfs
|
2008-02-21 18:23:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 handled_commands
|
|
|
|
|
|
|
|
Check to see if on a Service Node
|
2008-02-26 13:50:39 +00:00
|
|
|
Check database to see if this node is a NFS server
|
2008-02-21 18:23:01 +00:00
|
|
|
Call setup_NFS
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
sub handled_commands
|
|
|
|
|
|
|
|
{
|
2008-02-25 13:05:21 +00:00
|
|
|
my $rc = 0;
|
2008-05-12 21:26:54 +00:00
|
|
|
|
2008-02-21 18:23:01 +00:00
|
|
|
if (xCAT::Utils->isServiceNode())
|
|
|
|
{
|
2008-02-25 13:05:21 +00:00
|
|
|
my @nodeinfo = xCAT::Utils->determinehostname;
|
2008-03-16 13:40:12 +00:00
|
|
|
my $nodename = pop @nodeinfo; # get hostname
|
|
|
|
my @nodeipaddr = @nodeinfo; # get ip addresses
|
2008-02-26 13:50:39 +00:00
|
|
|
my $service = "nfsserver";
|
2008-03-06 18:42:32 +00:00
|
|
|
$rc = xCAT::Utils->isServiceReq($nodename, $service, \@nodeipaddr);
|
2008-05-12 21:26:54 +00:00
|
|
|
if ($rc == 1)
|
2008-02-26 13:50:39 +00:00
|
|
|
{
|
2008-02-21 18:23:01 +00:00
|
|
|
|
2008-02-26 13:50:39 +00:00
|
|
|
# service needed on this Service Node
|
2008-03-16 13:40:12 +00:00
|
|
|
$rc = &setup_NFS($nodename); # setup NFS
|
2008-02-26 13:50:39 +00:00
|
|
|
if ($rc == 0)
|
|
|
|
{
|
|
|
|
xCAT::Utils->update_xCATSN($service);
|
|
|
|
}
|
|
|
|
}
|
2008-03-16 13:40:12 +00:00
|
|
|
else
|
|
|
|
{
|
2008-05-12 21:26:54 +00:00
|
|
|
if ($rc == 2)
|
2008-03-16 13:40:12 +00:00
|
|
|
{ # just start the daemon
|
2008-05-12 21:26:54 +00:00
|
|
|
system "service nfs restart";
|
|
|
|
if ($? > 0)
|
2008-03-16 13:40:12 +00:00
|
|
|
{ # error
|
|
|
|
xCAT::MsgUtils->message("S", "Error on command: $cmd");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-02-21 18:23:01 +00:00
|
|
|
}
|
|
|
|
return $rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 process_request
|
|
|
|
|
|
|
|
Process the command
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
sub process_request
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 setup_NFS
|
|
|
|
|
2008-05-12 21:26:54 +00:00
|
|
|
Sets up NFS services
|
2008-02-21 18:23:01 +00:00
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
sub setup_NFS
|
|
|
|
{
|
|
|
|
my ($nodename) = @_;
|
2008-05-12 21:26:54 +00:00
|
|
|
my $rc = 0;
|
2008-05-07 16:21:06 +00:00
|
|
|
|
2008-05-12 21:26:54 +00:00
|
|
|
system "chkconfig nfs on";
|
|
|
|
if ($? > 0)
|
2008-05-07 16:21:06 +00:00
|
|
|
{ # error
|
2008-05-12 21:26:54 +00:00
|
|
|
xCAT::MsgUtils->message("S", "Error on command:$cmd");
|
2008-05-07 16:21:06 +00:00
|
|
|
}
|
2008-04-22 13:24:38 +00:00
|
|
|
|
2008-05-12 21:26:54 +00:00
|
|
|
# make sure nfs is restarted
|
|
|
|
system "service nfs restart";
|
|
|
|
if ($? > 0)
|
2008-02-25 13:05:21 +00:00
|
|
|
{
|
2008-05-12 21:26:54 +00:00
|
|
|
xCAT::MsgUtils->message("S", "Error on command: $cmd");
|
|
|
|
return 1;
|
2008-02-25 13:05:21 +00:00
|
|
|
}
|
2008-05-12 21:26:54 +00:00
|
|
|
|
2008-02-21 18:23:01 +00:00
|
|
|
return $rc;
|
|
|
|
}
|
2008-05-12 21:26:54 +00:00
|
|
|
|
2008-02-21 18:23:01 +00:00
|
|
|
1;
|