From d482c3c2acdb448da632b5a9fcd5ff8d26f8f898 Mon Sep 17 00:00:00 2001 From: lissav Date: Tue, 19 Jan 2010 18:48:23 +0000 Subject: [PATCH] add get_DBName routine git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@4980 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT/xCAT/Utils.pm | 44 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/perl-xCAT/xCAT/Utils.pm b/perl-xCAT/xCAT/Utils.pm index 5a05ddeca..48bc7f738 100644 --- a/perl-xCAT/xCAT/Utils.pm +++ b/perl-xCAT/xCAT/Utils.pm @@ -5459,5 +5459,49 @@ sub updateEtcHosts close( HOSTS ); return [$host,$ip]; } +#------------------------------------------------------------------------------- + +=head3 getDBName + Description: + Returns the current database (SQLITE,DB2,MYSQL,PG) + + Arguments: + None + Returns: + Return string. + Globals: + none + Error: + none + Example: + my $DBname = xCAT::Utils->getDBName; + Comments: + +=cut + +#------------------------------------------------------------------------------- +sub get_DBName +{ + my $name = "SQLITE"; # default + my $xcatcfg; + if (-r "/etc/xcat/cfgloc") { + my $cfgl; + open($cfgl,"<","/etc/xcat/cfgloc"); + $xcatcfg = <$cfgl>; + close($cfgl); + if ($xcatcfg =~ /^mysql:/) { + $name="MYSQL" + } else { + if ($xcatcfg =~ /^DB2:/) { + $name="DB2" + } else { + if ($xcatcfg =~ /^Pg:/) { + $name="PG" + } + } + } + } + return $name; +} 1;