Home | Trees | Indices | Help |
---|
|
1 ################################################################################ 2 # Ganga - a computational task management tool for easy access to Grid resources 3 # http://cern.ch/ganga 4 # 5 # $Id: GridShell.py,v 1.1 2008-07-17 16:41:00 moscicki Exp $ 6 # 7 # Copyright (C) 2003 The Ganga Project 8 # 9 # This program is free software; you can redistribute it and/or modify 10 # it under the terms of the GNU General Public License as published by 11 # the Free Software Foundation; either version 2 of the License, or 12 # (at your option) any later version. 13 # 14 # This program is distributed in the hope that it will be useful, 15 # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 # GNU General Public License for more details. 18 # 19 # You should have received a copy of the GNU General Public License 20 # along with this program; if not, write to the Free Software 21 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 # 23 # LCG backend 24 # 25 # ATLAS/ARDA 26 # 27 # Date: August 2006 28 ################################################################################ 29 30 import os, sys, re, tempfile 31 from types import * 32 33 from Ganga.GPIDev.Base import GangaObject 34 from Ganga.GPIDev.Schema import * 35 from Ganga.GPIDev.Lib.File import * 36 37 from Ganga.Utility.Shell import Shell 38 from Ganga.Utility.Config import getConfig, ConfigError 39 from Ganga.Utility.logging import getLogger 40 from Ganga.Utility.util import isStringLike 41 42 _allShells = {} 4345 """ 46 Utility function for getting Grid Shell. 47 Caller should take responsiblity of credential checking if proxy is needed. 48 49 Argumennts: 50 51 middleware - grid m/w used 52 force - False : if the shell already exists in local cache return the previous created instance 53 True : recreate the shell and if not None update the cache 54 """ 55 56 logger = getLogger() 57 58 if not middleware: 59 logger.debug('No middleware specified, assuming default EDG') 60 middleware = 'EDG' 61 62 if middleware in _allShells.keys() and not force: 63 return _allShells[middleware] 64 65 values = {} 66 for key in [ 'X509_USER_PROXY', 'X509_CERT_DIR', 'X509_VOMS_DIR' ]: 67 try: 68 values[key] = os.environ[key] 69 except KeyError: 70 pass 71 72 configname = "" 73 if middleware=='EDG' or middleware=='GLITE': 74 configname = 'LCG' 75 else: 76 configname = middleware 77 78 config = None 79 try: 80 config = getConfig(configname) 81 except: 82 logger.warning('[%s] configuration section not found. Cannot set up a proper grid shell.' % configname) 83 return None 84 85 s = None 86 87 key = '%s_SETUP' % middleware 88 89 # 1. check if the *_SETUP is changed by user -> take the user's value as session value 90 # 2. else check if *_LOCATION is defined as env. variable -> do nothing (ie. create shell without any lcg setup) 91 # 3. else take the default *_SETUP as session value 92 93 MIDDLEWARE_LOCATION = '%s_LOCATION' % middleware 94 95 if config.getEffectiveLevel(key)==2 and os.environ.has_key(MIDDLEWARE_LOCATION): 96 s = Shell() 97 else: 98 if os.path.exists(config[key]): 99 # FIXME: Hardcoded rule for ARC middleware setup (pass explicitly 100 # the $ARC_LOCATION as argument), this is hardcoded to maintain 101 # backwards compatibility (and avoid any side effects) for EDG and 102 # GLITE setup scripts which did not take any arguments 103 if key.startswith('ARC') and os.environ.has_key(MIDDLEWARE_LOCATION): 104 s = Shell(config[key],setup_args=[os.environ[MIDDLEWARE_LOCATION]]) 105 else: 106 s = Shell(config[key]) 107 else: 108 logger.warning("Configuration of %s for %s: "%(middleware,configname)) 109 logger.warning("File not found: %s" %config[key]) 110 111 if s: 112 for key, val in values.items(): 113 s.env[key] = val 114 115 # check and set env. variables for default LFC setup 116 if not s.env.has_key('LFC_HOST'): 117 try: 118 s.env['LFC_HOST'] = config['DefaultLFC'] 119 except Ganga.Utility.Config.ConfigError: 120 pass 121 122 if not s.env.has_key('LFC_CONNTIMEOUT'): 123 s.env['LFC_CONNTIMEOUT'] = '20' 124 125 if not s.env.has_key('LFC_CONRETRY'): 126 s.env['LFC_CONRETRY'] = '0' 127 128 if not s.env.has_key('LFC_CONRETRYINT'): 129 s.env['LFC_CONRETRYINT'] = '1' 130 131 _allShells[middleware] = s 132 133 return s134
Home | Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Mon Jun 25 10:35:33 2012 | http://epydoc.sourceforge.net |