def __init__(self): # Collect host / user / installation specific config files host = socket.gethostbyaddr(socket.gethostname())[0] hostCfg = map(lambda c: utils.pathGC('config/%s.conf' % host.split('.', c)[-1]), range(host.count('.') + 1, 0, -1)) defaultCfg = ['/etc/grid-control.conf', '~/.grid-control.conf', utils.pathGC('config/default.conf')] if os.environ.get('GC_CONFIG'): defaultCfg.append('$GC_CONFIG') fqConfigFiles = map(lambda p: utils.resolvePath(p, mustExist = False), hostCfg + defaultCfg) FileConfigFiller.__init__(self, filter(os.path.exists, fqConfigFiles))
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) except TimeoutException: sys.stderr.write('System call to resolve hostname is hanging!\n') sys.stderr.flush() os._exit(os.EX_OSERR) hostCfg = map(lambda c: utils.pathGC('config/%s.conf' % host.split('.', c)[-1]), range(host.count('.') + 1, -1, -1)) defaultCfg = ['/etc/grid-control.conf', '~/.grid-control.conf', utils.pathGC('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 = map(lambda p: utils.resolvePath(p, mustExist = False), hostCfg + defaultCfg) FileConfigFiller.__init__(self, filter(os.path.exists, fqConfigFiles), addSearchPath = False)
def _getSandboxFiles(self, module, monitor, smList): # Prepare all input files depList = set(itertools.chain(*map(lambda x: x.getDependencies(), [module] + smList))) depPaths = map(lambda pkg: utils.pathShare('', pkg = pkg), os.listdir(utils.pathGC('packages'))) depFiles = map(lambda dep: utils.resolvePath('env.%s.sh' % dep, depPaths), depList) taskEnv = list(itertools.chain(map(lambda x: x.getTaskConfig(), [monitor, module] + smList))) taskEnv.append({'GC_DEPFILES': str.join(' ', depList), 'GC_USERNAME': self.proxy.getUsername(), 'GC_WMS_NAME': self.wmsName}) taskConfig = sorted(utils.DictFormat(escapeString = True).format(utils.mergeDicts(taskEnv), format = 'export %s%s%s\n')) varMappingDict = dict(zip(monitor.getTaskConfig().keys(), monitor.getTaskConfig().keys())) varMappingDict.update(module.getVarMapping()) varMapping = sorted(utils.DictFormat(delimeter = ' ').format(varMappingDict, format = '%s%s%s\n')) # Resolve wildcards in module input files def getModuleFiles(): for f in module.getSBInFiles(): matched = glob.glob(f) if matched != []: for match in matched: yield match else: yield f return list(itertools.chain(monitor.getFiles(), depFiles, getModuleFiles(), [utils.VirtualFile('_config.sh', taskConfig), utils.VirtualFile('_varmap.dat', varMapping)]))