def listSlotsForQueue(queue): output = yield commands.getOutput(['qconf', '-sq', queue], log=True) conf = _parseSGEConf(output['stdout']) slots = conf['slots'].split(',') clusterWide = [s for s in slots if s[0] != '['] nodeSpecific = [s[1:-1].split('=') for s in slots if s[0] == '['] defer.returnValue({'cluster': int(clusterWide[0]), 'nodes': dict([(h, int(v)) for h, v in nodeSpecific])})
def listSlotsForQueue(queue): output = yield commands.getOutput(['qconf', '-sq', queue], log=True) conf = _parseSGEConf(output['stdout']) slots = conf['slots'].split(',') clusterWide = [s for s in slots if s[0] != '['] nodeSpecific = [s[1:-1].split('=') for s in slots if s[0] == '['] defer.returnValue({ 'cluster': int(clusterWide[0]), 'nodes': dict([(h, int(v)) for h, v in nodeSpecific]) })
def _createSupervisor(state): log.msg('LOAD: Starting') output = yield commands.getOutput(['hostname', '-f'], log=True) state.hostname = output['stdout'].strip() # Let's get our queue information execSlots = yield sge_queue.listSlotsForQueue(EXEC_QUEUE) stagingSlots = yield sge_queue.listSlotsForQueue(STAGING_QUEUE) state.master = MachineInformation() state.master.setExecSlots(execSlots['nodes'].get(state.hostname, execSlots['cluster'])) state.master.setStagingSlots(stagingSlots['nodes'].get(state.hostname, stagingSlots['cluster'])) reactor.callLater(0.0, _loopSupervisor, state)
def _createSupervisor(state): log.msg('LOAD: Starting') output = yield commands.getOutput(['hostname', '-f'], log=True) state.hostname = output['stdout'].strip() # Let's get our queue information execSlots = yield sge_queue.listSlotsForQueue(EXEC_QUEUE) stagingSlots = yield sge_queue.listSlotsForQueue(STAGING_QUEUE) state.master = MachineInformation() state.master.setExecSlots(execSlots['nodes'].get(state.hostname, execSlots['cluster'])) state.master.setStagingSlots(stagingSlots['nodes'].get( state.hostname, stagingSlots['cluster'])) reactor.callLater(0.0, _loopSupervisor, state)
def getOutput(host, cmd, sshUser=None, sshFlags=None, initialText=None, log=False, **kwargs): command = ['ssh'] if sshUser: host = sshUser + '@' + host if sshFlags: command.append(sshFlags) command.append(host) command.append(core.quoteEscape(cmd)) command = ' '.join(command) return commands.getOutput(commands.shell(str(command)), initialText=str(initialText), log=log, **kwargs)
def _getOutput(batchState, command, *args, **kwargs): _log(batchState, 'CMD: ' + ' '.join(command)) return commands.getOutput(command, *args, **kwargs)
clusters = yield clusters_www.listClusters('localhost', {'cluster_name': clusterName}, 'guest') cluster = clusters[0] yield pipeline_www.resumePipeline(cluster['master']['public_dns'], 'local', pipeline.userName, child) except Exception, err: log.err('Error trying to resume child') log.err(err) # Reset the pipeline task to IDLE yield tasks_tx.updateTask(pipeline.taskName, lambda t : t.setState(tasks_tx.task.TASK_IDLE)) if pipeline.pipelineId: cmd = ['resume_pipeline.pl', '--pipeline_id=' + pipeline.pipelineId, '--taskname=' + pipeline.taskName] if pipeline.queue: cmd.append('--queue=' + pipeline.queue) yield commands.getOutput(cmd, log=True) defer.returnValue(pipeline)
def _getOutput(batchState, command, *args, **kwargs): _log(batchState, 'CMD: ' + ' '.join(command)) return commands.getOutput(command, *args, **kwargs)