def __init__(self): # Collect host / user / installation specific config files def resolve_hostname(): import socket host = socket.gethostname() try: return socket.gethostbyaddr(host)[0] except Exception: return host try: host = hang_protection(resolve_hostname, timeout=5) hostCfg = lmap( lambda c: utils.pathPKG('../config/%s.conf' % host.split( '.', c)[-1]), irange(host.count('.') + 1, -1, -1)) except TimeoutException: sys.stderr.write('System call to resolve hostname is hanging!\n') sys.stderr.flush() hostCfg = [] defaultCfg = [ '/etc/grid-control.conf', '~/.grid-control.conf', utils.pathPKG('../config/default.conf') ] if os.environ.get('GC_CONFIG'): defaultCfg.append('$GC_CONFIG') log = logging.getLogger('config.default') log.log(logging.DEBUG1, 'Possible default config files: %s', str.join(', ', defaultCfg)) fqConfigFiles = lmap(lambda p: utils.resolvePath(p, mustExist=False), hostCfg + defaultCfg) FileConfigFiller.__init__(self, lfilter(os.path.exists, fqConfigFiles), addSearchPath=False)
def __init__(self): # Collect host / user / installation specific config files def resolve_hostname(): import socket host = socket.gethostname() try: return socket.gethostbyaddr(host)[0] except Exception: return host try: host = hang_protection(resolve_hostname, timeout = 5) hostCfg = lmap(lambda c: utils.pathPKG('../config/%s.conf' % host.split('.', c)[-1]), irange(host.count('.') + 1, -1, -1)) except TimeoutException: sys.stderr.write('System call to resolve hostname is hanging!\n') sys.stderr.flush() hostCfg = [] defaultCfg = ['/etc/grid-control.conf', '~/.grid-control.conf', utils.pathPKG('../config/default.conf')] if os.environ.get('GC_CONFIG'): defaultCfg.append('$GC_CONFIG') log = logging.getLogger('config.default') log.log(logging.DEBUG1, 'Possible default config files: %s', str.join(', ', defaultCfg)) fqConfigFiles = lmap(lambda p: utils.resolvePath(p, mustExist = False), hostCfg + defaultCfg) FileConfigFiller.__init__(self, lfilter(os.path.exists, fqConfigFiles), addSearchPath = False)
def _getSandboxFiles(self, task, monitor, smList): # Prepare all input files depList = set( ichain(imap(lambda x: x.getDependencies(), [task] + smList))) depPaths = lmap(lambda pkg: utils.pathShare('', pkg=pkg), os.listdir(utils.pathPKG())) depFiles = lmap( lambda dep: utils.resolvePath('env.%s.sh' % dep, depPaths), depList) taskEnv = utils.mergeDicts( imap(lambda x: x.getTaskConfig(), [monitor, task] + smList)) taskEnv.update({ 'GC_DEPFILES': str.join(' ', depList), 'GC_USERNAME': self._token.getUsername(), 'GC_WMS_NAME': self.wmsName }) taskConfig = sorted( utils.DictFormat(escapeString=True).format( taskEnv, format='export %s%s%s\n')) varMappingDict = dict( izip(monitor.getTaskConfig().keys(), monitor.getTaskConfig().keys())) varMappingDict.update(task.getVarMapping()) varMapping = sorted( utils.DictFormat(delimeter=' ').format(varMappingDict, format='%s%s%s\n')) # Resolve wildcards in task input files def getTaskFiles(): for f in task.getSBInFiles(): matched = glob.glob(f.pathAbs) if matched != []: for match in matched: yield match else: yield f.pathAbs return lchain([ monitor.getFiles(), depFiles, getTaskFiles(), [ VirtualFile('_config.sh', taskConfig), VirtualFile('_varmap.dat', varMapping) ] ])
def _getSandboxFiles(self, task, monitor, smList): # Prepare all input files depList = set(ichain(imap(lambda x: x.getDependencies(), [task] + smList))) depPaths = lmap(lambda pkg: utils.pathShare('', pkg = pkg), os.listdir(utils.pathPKG())) depFiles = lmap(lambda dep: utils.resolvePath('env.%s.sh' % dep, depPaths), depList) taskEnv = utils.mergeDicts(imap(lambda x: x.getTaskConfig(), [monitor, task] + smList)) taskEnv.update({'GC_DEPFILES': str.join(' ', depList), 'GC_USERNAME': self._token.getUsername(), 'GC_WMS_NAME': self._name}) taskConfig = sorted(utils.DictFormat(escapeString = True).format(taskEnv, format = 'export %s%s%s\n')) varMappingDict = dict(izip(monitor.getTaskConfig().keys(), monitor.getTaskConfig().keys())) varMappingDict.update(task.getVarMapping()) varMapping = sorted(utils.DictFormat(delimeter = ' ').format(varMappingDict, format = '%s%s%s\n')) # Resolve wildcards in task input files def getTaskFiles(): for f in task.getSBInFiles(): matched = glob.glob(f.pathAbs) if matched != []: for match in matched: yield match else: yield f.pathAbs return lchain([monitor.getFiles(), depFiles, getTaskFiles(), [VirtualFile('_config.sh', taskConfig), VirtualFile('_varmap.dat', varMapping)]])