Package nokia :: Module gscm
[hide private]
[frames] | no frames]

Source Code for Module nokia.gscm

 1  #============================================================================  
 2  #Name        : gscm.py  
 3  #Part of     : Helium  
 4   
 5  #Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
 6  #All rights reserved. 
 7  #This component and the accompanying materials are made available 
 8  #under the terms of the License "Eclipse Public License v1.0" 
 9  #which accompanies this distribution, and is available 
10  #at the URL "http://www.eclipse.org/legal/epl-v10.html". 
11  # 
12  #Initial Contributors: 
13  #Nokia Corporation - initial contribution. 
14  # 
15  #Contributors: 
16  # 
17  #Description: 
18  #=============================================================================== 
19   
20  """ Wrapper module that get CCM info using GSCM framework. """ 
21   
22   
23  import logging 
24  import os 
25  import subprocess 
26   
27   
28  # Uncomment this line to enable logging in this module, or configure logging elsewhere 
29  #logging.basicConfig(level=logging.DEBUG) 
30  _logger = logging.getLogger("gscm") 
31   
32   
33 -def _execute(command):
34 """ Runs a command and returns the result data. """ 35 process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) 36 output = process.stdout.read() 37 process.poll() 38 status = process.returncode 39 return (output, status)
40 41
42 -def __get_gscm_info(method, dbname):
43 """ Generic method that call function 'method' on GSCM wrapper script. """ 44 command = "perl " + os.path.join(os.environ['HELIUM_HOME'], "tools/common/bin/get_gscm_info.pl") 45 command += " %s %s" % (method, dbname) 46 _logger.debug("Running command: %s" % command) 47 (output, status) = _execute(command) 48 _logger.debug("Status: %s" % status) 49 _logger.debug("Output: %s" % output) 50 if status == 0 or status == None and not ("Can't locate" in output): 51 return output.strip() 52 if not 'HLM_SUBCON' in os.environ: 53 raise Exception("Error retrieving get_db_path info for '%s' database.\nOUTPUT:%s" % (dbname, output.strip())) 54 return None
55
56 -def get_db_path(dbname):
57 """ Returns the database path for dbname database. """ 58 _logger.debug("get_db_path: %s" % dbname) 59 return __get_gscm_info('get_db_path', dbname)
60 61
62 -def get_router_address(dbname):
63 """ Returns the database router address for dbname database. """ 64 _logger.debug("get_router_address: %s" % dbname) 65 return __get_gscm_info('get_router_address', dbname)
66 67
68 -def get_engine_host(dbname):
69 """ Returns the database engine host for dbname database. """ 70 _logger.debug("get_engine_host: %s" % dbname) 71 return __get_gscm_info('get_engine_host', dbname)
72