From 3cdd3f9bb410b37f47cec2cb40fe729807142b82 Mon Sep 17 00:00:00 2001 From: lissav Date: Wed, 23 Apr 2008 18:14:57 +0000 Subject: [PATCH] Add isSN routine to determine if an input node name is a service node. git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@1169 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT-2.0/xCAT/Utils.pm | 55 +++++++++++++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 2 deletions(-) diff --git a/perl-xCAT-2.0/xCAT/Utils.pm b/perl-xCAT-2.0/xCAT/Utils.pm index 2db2e5049..9e80f2959 100644 --- a/perl-xCAT-2.0/xCAT/Utils.pm +++ b/perl-xCAT-2.0/xCAT/Utils.pm @@ -1865,7 +1865,7 @@ sub get_site_Master =head3 get_ServiceNode Will get the Service node ( name or ipaddress) as known by the Management - Server or NOde for the input nodename or ipadress of the node + Server or Node for the input nodename or ipadress of the node input: list of nodenames and/or node ipaddresses (array ref) service name @@ -2085,7 +2085,15 @@ sub get_ServiceNode } -# IPv4 function to convert hostname to IP address +#----------------------------------------------------------------------------- + +=head3 toIP + + IPv4 function to convert hostname to IP address + +=cut + +#----------------------------------------------------------------------------- sub toIP { @@ -2101,4 +2109,47 @@ sub toIP return ([0, inet_ntoa($packed_ip)]); } +#----------------------------------------------------------------------------- + +=head3 isSN + + Determines if the input node name is a service node + + returns 1 if input host is a service node + Arguments: + hostname + Returns: + 1 - is Service Node + 0 - is not a Service Node + Globals: + none + Error: + none + Example: + if (xCAT::Utils->isSN($nodename)) { blah; } + Comments: + none + +=cut + +#----------------------------------------------------------------------------- +sub isSN +{ + my ($class, $node) = @_; + + # read the node from the nodelist table and see if it + # is a member of the service group + my $attr = "groups"; + my $nodelisttab = xCAT::Table->new('nodelist'); + my $sn = $nodelisttab->getNodeAttribs($node, [$attr]); + if ($sn) + { + if (grep /service/, $sn->{$attr}) + { + return 1; + } + } + $nodelisttab->close; + return 0; +} 1;