예제 #1
0
def start_proc(proc, body):
    """Start individual process as specified in startClusterReq command.
    proc - the process object in the message
    body - the whole message
    """
    f = proc['file']
    (user, pwd) = get_cred(body)
 
    with produce_ABClusterHost(f['hostName'], user, pwd) as ch:
        pc = proc['procCtrl']
        params = proc['params']
        if f.has_key('autoComplete'): 
            if isinstance(f['autoComplete'], list):
                executable = ch.auto_complete(f['path'], f['autoComplete'], f['name'])
            else:
                executable = ch.auto_complete(f['path'], ['bin', 'sbin', 'scripts', '', ch.path_module.join('..','scripts')], f['name'])
        else:
            executable = ch.path_module.join(f['path'], f['name'])
        
        stdinFile = None
        if f.has_key('stdinFile'):
            assert (ch.file_exists(f['stdinFile'])), 'File ' + f['stdinFile'] + " does not exist on host " + ch.host
            stdinFile = f['stdinFile']

        _logger.debug('Attempting to launch '+executable+' on '+ch.host+
                      ' with pc='+str(pc))

        cmdv = util.params_to_cmdv(executable, params)
	if proc.has_key('isCommand'):
            return ch.execute_command(cmdv, stdinFile)
		
        return ch.exec_cmdv(cmdv, pc, stdinFile)
def start_proc(proc, body):
    """Start individual process as specified in startClusterReq command.
    proc - the process object in the message
    body - the whole message
    """
    f = proc['file']
    (user, pwd) = get_cred(body)
 
    with produce_ABClusterHost(f['hostName'], user, pwd) as ch:
        pc = proc['procCtrl']
        params = proc['params']
        if f.has_key('autoComplete'): 
            if isinstance(f['autoComplete'], list):
                executable = ch.auto_complete(f['path'], f['autoComplete'], f['name'])
            else:
                executable = ch.auto_complete(f['path'], ['bin', 'sbin', 'scripts', '', ch.path_module.join('..','scripts')], f['name'])
        else:
            executable = ch.path_module.join(f['path'], f['name'])
        
        stdinFile = None
        if f.has_key('stdinFile'):
            assert (ch.file_exists(f['stdinFile'])), 'File ' + f['stdinFile'] + " does not exist on host " + ch.host
            stdinFile = f['stdinFile']

        _logger.debug('Attempting to launch '+executable+' on '+ch.host+
                      ' with pc='+str(pc))

        cmdv = util.params_to_cmdv(executable, params)
	if proc.has_key('isCommand'):
            return ch.execute_command(cmdv, stdinFile)
		
        return ch.exec_cmdv(cmdv, pc, stdinFile)