From 3c27aa56cd71e3f4f328047cbc6fff08041cf173 Mon Sep 17 00:00:00 2001 From: lissav Date: Thu, 24 Apr 2008 17:28:35 +0000 Subject: [PATCH] Add routine to get hash of service nodes and the nodes they service. git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@1187 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT-2.0/xCAT/Utils.pm | 47 ++++++++++++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 3 deletions(-) diff --git a/perl-xCAT-2.0/xCAT/Utils.pm b/perl-xCAT-2.0/xCAT/Utils.pm index fa4a4fe18..4f0deea27 100644 --- a/perl-xCAT-2.0/xCAT/Utils.pm +++ b/perl-xCAT-2.0/xCAT/Utils.pm @@ -1881,7 +1881,7 @@ sub get_site_Master Todo: Handle dhcpserver and nameserver from the networks table - output: A hash ref of of arrays, the key is the service node pointing to + output: A hash ref of arrays, the key is the service node pointing to an array of nodes that are serviced by that service node Globals: @@ -2155,7 +2155,7 @@ sub isSN #----------------------------------------------------------------------------- -=head3 get_AllSN +=head3 getAllSN Returns an array of all service nodes @@ -2175,7 +2175,7 @@ sub isSN =cut #----------------------------------------------------------------------------- -sub get_AllSN +sub getAllSN { # read the node from the nodelist table and see if it @@ -2193,4 +2193,45 @@ sub get_AllSN $nodelisttab->close; return @servicenodes; } + +#----------------------------------------------------------------------------- + +=head3 getSNandNodes + + Returns an hash-array of all service nodes and the nodes they service + + Arguments: + none + Returns: + Service Nodes and the nodes they service or empty , if none + Globals: + none + Error: + 1 - error + Example: + $sn=xCAT::Utils->getSNandNodes() + Comments: + none + +=cut + +#----------------------------------------------------------------------------- +sub getSNandNodes +{ + + # read all the nodes from the nodelist table + # call get_ServiceNode to find which Service Node + # the node belongs to. + my %sn; + my @nodes; + my $nodelisttab = xCAT::Table->new('nodelist'); + my $recs = $nodelisttab->getAllEntries(); + foreach (@$recs) + { + push @nodes, $_->{node}; + } + $nodelisttab->close; + $sn = xCAT::Utils->get_ServiceNode(\@nodes, "xcat", "MN"); + return $sn; +} 1;