move check for ssh enablement to Utils.pm so Postage and xdsh can share it

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@8000 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
lissav 2010-11-02 11:58:45 +00:00
parent 034a2b75b9
commit fbeaa49a22

View File

@ -6047,6 +6047,91 @@ sub getAppStatus
return $ret_nodeappstat;
}
#-------------------------------------------------------------------------------
=head3 enableSSH
Description:
Reads the site.sshbetweennodes attribute and determines
if the input node should be enabled to ssh between nodes
Arguments:
$node
Returns:
1 = enable ssh
0 = do not enable ssh
Globals:
none
Error:
none
Example:
my $eable = $xCAT::Utils::enablessh($node);
Comments:
=cut
#-----------------------------------------------------------------------------
sub enablessh
{
my ($class, $node) = @_;
my $enablessh=1;
if (xCAT::Utils->isSN($node))
{
$enablessh=1; # service nodes always enabled
}
else
{
# if not a service node we need to check, before enabling
my $sitetab = xCAT::Table->new('site');
my $attr = "sshbetweennodes";
my $ref = $sitetab->getAttribs({key => $attr}, 'value');
if ($ref)
{
my $values = $ref->{value};
my @groups = split(/,/, $values);
if (grep(/^ALLGROUPS$/, @groups))
{
$enablessh=1;
}
else
{
if (grep(/^NOGROUPS$/, @groups))
{
$enablessh=0;
}
else
{ # check to see if the node is a member of a group
my $ismember = 0;
foreach my $group (@groups)
{
$ismember = xCAT::Utils->isMemberofGroup($node, $group);
if ($ismember == 1)
{
last;
}
}
if ($ismember == 1)
{
$enablessh=1;
}
else
{
$enablessh=0;
}
}
}
}
else
{ # does not exist, set default
$enablessh=1;
}
}
return $enablessh;
}
1;