From 1ede5d28ecdc789e6d5e5b985002e7765b5e6dc0 Mon Sep 17 00:00:00 2001 From: lissav Date: Tue, 22 Jan 2008 14:59:14 +0000 Subject: [PATCH] Add isServiceNode routine git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@312 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT-2.0/xCAT/Utils.pm | 43 +++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/perl-xCAT-2.0/xCAT/Utils.pm b/perl-xCAT-2.0/xCAT/Utils.pm index 597d66a92..3676f8cd9 100644 --- a/perl-xCAT-2.0/xCAT/Utils.pm +++ b/perl-xCAT-2.0/xCAT/Utils.pm @@ -956,4 +956,47 @@ sub cpSSHFiles } return (0); } +#------------------------------------------------------------------------------- + +=head3 isServiceNode + checks for the /etc/xCATSN.cfg file and if it exists + reads the MasterNodename:port. Caches the MasterNodename:port. + in the %::XCATMasterPort defined in the caller. + + Arguments: + none + Returns: + MasterHostName:port, if it is a service node + return -1 - if not a service node + Globals: + none + Error: + none + Example: + %::XCATMasterPort defined in the caller. + $return=(xCAT::Utils->isServiceNode()) + Comments: + none +=cut + +#------------------------------------------------------------------------------- +sub isServiceNode +{ + my $value; + if (!(-e "/etc/xCATSN.cfg")) + { + return -1; + } + if (exists($::XCATMasterPort{$value})) + { # already hash'd it + return $::XCATMasterPort{$value}; + } + + else + { # read the file + $::XCATMasterPort{$value} = `cat /etc/xCATSN.cfg`; + chomp $::XCATMasterPort{$value}; + return $::XCATMasterPort{$value}; + } +} 1;