mirror of
				https://github.com/xcat2/xcat-core.git
				synced 2025-11-04 05:12:30 +00:00 
			
		
		
		
	add get_DBName routine
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@4980 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
		@@ -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;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user