示例#1
0
def _enqueue(nodes, work_dir, job_hook=JOB_HOOK, hostname=HOSTNAME):
    """
    Submit the given nodes to the active spread installation.
    """
    running = []
    for node in nodes:
        instances = []
        t = int(time.time())

        for _id in range(node.job.Instances):
            node = _expand_vars(node, _id)
            _copy_input_files(node, work_dir)
            job = node.job
            job.ClusterId = get_clusterid()
            job.ProcId = _id
            job.GlobalJobId = '%s#%d.%d#%d' % (hostname, job.ClusterId, _id, t)
            if(not job._raw_classad.endswith('\n')):
                job._raw_classad += '\n'
            job._raw_classad += 'GlobalJobId = "%s"\n' % (job.ClusterId)


            # Job hooks.
            if(not hasattr(job, 'HookKeyword')):
                job_hook = None
            if(not hasattr(job, 'Input')):
                job.Input = None
            if(not hasattr(job, 'Output')):
                job.Output = None
            if(not hasattr(job, 'Error')):
                job.Error = None

            promise = client.async_call('system',
                                        _mkargv(node),
                                        {'cwd': work_dir,
                                         'getenv': job.GetEnv,
                                         'environment': job.EnvironmentDict,
                                         'output': job.Output,
                                         'error': job.Error,
                                         'input': job.Input,
                                         'timeout': None,
                                         'root_dir': None,
                                         'pre_proc': job_hook,
                                         'post_proc': job_hook,
                                         'classad': job._raw_classad})
            instances.append((promise, node))
        running.append(instances)
    return(running)
示例#2
0
def system(argv, **kwds):
    return(async_call('system', argv, kwds, fast=True, host=BROKER_HOST))