本文整理汇总了Python中pulse2.consts.PULSE2_WRAPPER_ARG_SEPARATOR.join方法的典型用法代码示例。如果您正苦于以下问题:Python PULSE2_WRAPPER_ARG_SEPARATOR.join方法的具体用法?Python PULSE2_WRAPPER_ARG_SEPARATOR.join怎么用?Python PULSE2_WRAPPER_ARG_SEPARATOR.join使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pulse2.consts.PULSE2_WRAPPER_ARG_SEPARATOR
的用法示例。
在下文中一共展示了PULSE2_WRAPPER_ARG_SEPARATOR.join方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: remote_exec
# 需要导入模块: from pulse2.consts import PULSE2_WRAPPER_ARG_SEPARATOR [as 别名]
# 或者: from pulse2.consts.PULSE2_WRAPPER_ARG_SEPARATOR import join [as 别名]
def remote_exec(command_id, client, command, mode, wrapper_timeout):
""" Handle remote execution on target """
client = pulse2.launcher.utils.setDefaultClientOptions(client)
target_path = os.path.join(LauncherConfig().target_path, pulse2.launcher.utils.getTempFolderName(command_id, client['uuid']))
if client['protocol'] == "ssh":
# command is issued though our wrapper, time to build it
if not LauncherConfig().is_ssh_available:
return False
# Built "thru" command
thru_command_list = [LauncherConfig().ssh_path]
thru_command_list += client['transp_args']
thru_command_list += [client['host']]
# Build "exec" command
real_command = ['cd', target_path, ';', command]
# Build final command line
command_list = [
LauncherConfig().wrapper_path,
'--max-log-size',
str(LauncherConfig().wrapper_max_log_size),
'--max-exec-time',
str(wrapper_timeout),
'--thru',
PULSE2_WRAPPER_ARG_SEPARATOR.join(thru_command_list),
'--exec',
PULSE2_WRAPPER_ARG_SEPARATOR.join(real_command),
]
# from {'a': 'b', 'c: 'd'} to 'a=b,c=d'
if client['client_check']:
command_list += ['--check-client-side', ','.join(map((lambda x: '='.join(x)), client['client_check'].items()))]
if client['server_check']:
command_list += ['--check-server-side', ','.join(map((lambda x: '='.join(x)), client['server_check'].items()))]
if client['action']:
command_list += ['--action', client['action']]
if mode == 'async':
return pulse2.launcher.process_control.commandForker(
command_list,
__cb_async_process_end,
command_id,
LauncherConfig().defer_results,
'completed_execution',
LauncherConfig().max_command_age,
client['group'],
'exec'
)
elif mode == 'sync':
return pulse2.launcher.process_control.commandRunner(
command_list,
__cb_sync_process_end
)
return None
示例2: remote_push
# 需要导入模块: from pulse2.consts import PULSE2_WRAPPER_ARG_SEPARATOR [as 别名]
# 或者: from pulse2.consts.PULSE2_WRAPPER_ARG_SEPARATOR import join [as 别名]
def remote_push(command_id, client, files_list, mode, wrapper_timeout):
""" Handle remote copy (push) """
target_path = os.path.join(LauncherConfig().target_path, pulse2.launcher.utils.getTempFolderName(command_id, client['uuid']))
client = pulse2.launcher.utils.setDefaultClientOptions(client)
if client['protocol'] == "rsyncssh":
# command is issued though our wrapper, time to build it
real_files_list = files_list
if not LauncherConfig().is_rsync_available:
logging.getLogger().warn('Can\'t do remote push because rsync is not available')
return False
# Build "exec" command
real_command = [LauncherConfig().rsync_path]
real_command += client['proto_args']
real_command += real_files_list
real_command += [ '%[email protected]%s:%s/' % (client['user'], client['host'], target_path)]
# Build "thru" command
thru_command_list = [LauncherConfig().ssh_path]
thru_command_list += client['transp_args']
thru_command_list += [ "%[email protected]%s" % (client['user'], client['host'])]
# Define environnement
envir = {
'SSHPATH': LauncherConfig().ssh_path,
'SSHARGS': client['transp_args'],
'SSHTARGET' : "%[email protected]%s" % (client['user'], client['host']),
'STEP': 'PUSH'
}
# Build final command line
command_list = [
LauncherConfig().wrapper_path,
'--max-log-size',
str(LauncherConfig().wrapper_max_log_size),
'--max-exec-time',
str(wrapper_timeout),
'--exec',
PULSE2_WRAPPER_ARG_SEPARATOR.join(real_command),
'--thru',
PULSE2_WRAPPER_ARG_SEPARATOR.join(thru_command_list),
'--exec-server-side'
]
# from {'a': 'b', 'c: 'd'} to 'a=b,c=d'
if client['client_check']:
command_list += ['--check-client-side', ','.join(map((lambda x: '='.join(x)), client['client_check'].items()))]
if client['server_check']:
command_list += ['--check-server-side', ','.join(map((lambda x: '='.join(x)), client['server_check'].items()))]
if client['action']:
command_list += ['--action', client['action']]
return get_command_result(command_id, command_list, mode, client['group'], envir, 'push', 'Remote push (rsyncssh/async)')
logging.getLogger().warn("Remote push failed for CoH #%d" % command_id)
return None
示例3: from_remote_to_launcher
# 需要导入模块: from pulse2.consts import PULSE2_WRAPPER_ARG_SEPARATOR [as 别名]
# 或者: from pulse2.consts.PULSE2_WRAPPER_ARG_SEPARATOR import join [as 别名]
def from_remote_to_launcher(command_id, client, paths, targetpath, bwlimit, wrapper_timeout):
"""
Recursive copy of a directory from a client to the launcher using scp.
"""
client = pulse2.launcher.utils.setDefaultClientOptions(client)
if not LauncherConfig().is_scp_available:
logging.getLogger().warn("Can't do remote to launcher because scp is not available")
return False
real_command = [LauncherConfig().scp_path]
real_command += client['transp_args']
if bwlimit:
real_command += ['-l'] + [str(bwlimit)]
real_command += ['-r']
for path in paths:
real_command += [ "%[email protected]%s:%s" % (client['user'], client['host'], path)]
real_command += [targetpath]
# The following ssh options are not used by scp, so we remove them
real_command.remove('-T')
real_command.remove('-a')
# Built "thru" command
thru_command_list = [LauncherConfig().ssh_path]
thru_command_list += client['transp_args']
thru_command_list += [ "%[email protected]%s" % (client['user'], client['host'])]
# Build final command line
command_list = [
LauncherConfig().wrapper_path,
'--max-log-size',
str(LauncherConfig().wrapper_max_log_size),
'--max-exec-time',
str(wrapper_timeout),
'--exec',
PULSE2_WRAPPER_ARG_SEPARATOR.join(real_command),
'--thru',
PULSE2_WRAPPER_ARG_SEPARATOR.join(thru_command_list),
'--exec-server-side'
]
# from {'a': 'b', 'c: 'd'} to 'a=b,c=d'
if client['client_check']:
command_list += ['--check-client-side', ','.join(map((lambda x: '='.join(x)), client['client_check'].items()))]
if client['server_check']:
command_list += ['--check-server-side', ','.join(map((lambda x: '='.join(x)), client['server_check'].items()))]
if client['action']:
command_list += ['--action', client['action']]
result = pulse2.launcher.process_control.commandRunner(
command_list,
__cb_sync_process_end)
if not result:
logging.getLogger().warn("Remote to launcher failed for CoH #%d" % command_id)
return result
示例4: remote_exec
# 需要导入模块: from pulse2.consts import PULSE2_WRAPPER_ARG_SEPARATOR [as 别名]
# 或者: from pulse2.consts.PULSE2_WRAPPER_ARG_SEPARATOR import join [as 别名]
def remote_exec(command_id, client, command, mode, wrapper_timeout):
""" Handle remote execution on target """
client = pulse2.launcher.utils.setDefaultClientOptions(client)
target_path = os.path.join(LauncherConfig().target_path, pulse2.launcher.utils.getTempFolderName(command_id, client['uuid']))
if client['protocol'] == "ssh":
# command is issued though our wrapper, time to build it
if not LauncherConfig().is_ssh_available:
logging.getLogger().warn("Can't do remote exec because ssh is not available")
return False
# Built "thru" command
thru_command_list = [LauncherConfig().ssh_path]
thru_command_list += client['transp_args']
thru_command_list += [client['host']]
# Define environnement
envir = {
'SSHPATH': LauncherConfig().ssh_path,
'SSHARGS': client['transp_args'],
'SSHTARGET' : client['host'],
'STEP': 'EXEC'
}
# Build "exec" command
real_command = ['cd', target_path, ';', command]
# Build final command line
command_list = [
LauncherConfig().wrapper_path,
'--max-log-size',
str(LauncherConfig().wrapper_max_log_size),
'--max-exec-time',
str(wrapper_timeout),
'--thru',
PULSE2_WRAPPER_ARG_SEPARATOR.join(thru_command_list),
'--exec',
PULSE2_WRAPPER_ARG_SEPARATOR.join(real_command),
]
# from {'a': 'b', 'c: 'd'} to 'a=b,c=d'
if client['client_check']:
command_list += ['--check-client-side', ','.join(map((lambda x: '='.join(x)), client['client_check'].items()))]
if client['server_check']:
command_list += ['--check-server-side', ','.join(map((lambda x: '='.join(x)), client['server_check'].items()))]
if client['action']:
command_list += ['--action', client['action']]
return get_command_result(command_id, command_list, mode, client['group'], envir, 'exec', 'Remote exec (ssh/async)')
logging.getLogger().warn("Remote exec failed for CoH #%d" % command_id)
return None
示例5: remote_direct
# 需要导入模块: from pulse2.consts import PULSE2_WRAPPER_ARG_SEPARATOR [as 别名]
# 或者: from pulse2.consts.PULSE2_WRAPPER_ARG_SEPARATOR import join [as 别名]
def remote_direct(command_id, client, command, mode, max_log_size, wrapper_timeout):
""" Handle remote direct stuff on target """
client = pulse2.launcher.utils.setDefaultClientOptions(client)
if client['protocol'] == "ssh":
# command is issued though our wrapper, time to build it
if not LauncherConfig().is_ssh_available:
logging.getLogger().warn("Can't do remote direct because ssh is not available")
return False
# Built "thru" command
thru_command_list = [LauncherConfig().ssh_path]
thru_command_list += client['transp_args']
thru_command_list += [client['host']]
# Define environnement
envir = {
'SSHPATH': LauncherConfig().ssh_path,
'SSHARGS': client['transp_args'],
'SSHTARGET' : client['host'],
'STEP': 'REMOTEDIRECT'
}
# Build "exec" command
real_command = command
if max_log_size == None:
# If no max_log_size set, use the value from the configuration file
max_log_size = LauncherConfig().wrapper_max_log_size
# Build final command line
command_list = [
LauncherConfig().wrapper_path,
'--max-log-size',
str(max_log_size),
'--max-exec-time',
str(wrapper_timeout),
'--thru',
PULSE2_WRAPPER_ARG_SEPARATOR.join(thru_command_list),
'--exec',
real_command, # we do not use the PULSE2_WRAPPER_ARG_SEPARATOR here, as the command is send "as is"
'--no-wrap',
'--only-stdout',
'--remove-empty-lines'
]
# from {'a': 'b', 'c: 'd'} to 'a=b,c=d'
if client['client_check']:
command_list += ['--check-client-side', ','.join(map((lambda x: '='.join(x)), client['client_check'].items()))]
if client['server_check']:
command_list += ['--check-server-side', ','.join(map((lambda x: '='.join(x)), client['server_check'].items()))]
if client['action']:
command_list += ['--action', client['action']]
return get_command_result(command_id, command_list, mode, client['group'], envir, 'direct', 'Remote direct (ssh/async)')
logging.getLogger().warn("Remote direct failed for CoH #%d" % command_id)
return None
示例6: remote_halt
# 需要导入模块: from pulse2.consts import PULSE2_WRAPPER_ARG_SEPARATOR [as 别名]
# 或者: from pulse2.consts.PULSE2_WRAPPER_ARG_SEPARATOR import join [as 别名]
def remote_halt(command_id, client, mode, wrapper_timeout):
""" Handle remote halt on target
"""
client = pulse2.launcher.utils.setDefaultClientOptions(client)
halt_command = LauncherConfig().halt_command
if client['protocol'] == "ssh":
# command is issued though our wrapper, time to build it
if not LauncherConfig().is_ssh_available:
logging.getLogger().warn("Can't do remote halt because ssh is not available")
return False
# Built "thru" command
thru_command_list = [LauncherConfig().ssh_path]
thru_command_list += client['transp_args']
thru_command_list += [client['host']]
# Define environnement
envir = {
'SSHPATH': LauncherConfig().ssh_path,
'SSHARGS': client['transp_args'],
'SSHTARGET' : client['host'],
'STEP': 'HALT'
}
# Build "exec" command
real_command = halt_command
# Build final command line
command_list = [
LauncherConfig().wrapper_path,
'--max-log-size',
str(LauncherConfig().wrapper_max_log_size),
'--max-exec-time',
str(wrapper_timeout),
'--thru',
PULSE2_WRAPPER_ARG_SEPARATOR.join(thru_command_list),
'--exec',
real_command, # we do not use the PULSE2_WRAPPER_ARG_SEPARATOR here, as the command is send "as is"
]
# from {'a': 'b', 'c: 'd'} to 'a=b,c=d'
if client['client_check']:
command_list += ['--check-client-side', ','.join(map((lambda x: '='.join(x)), client['client_check'].items()))]
if client['server_check']:
command_list += ['--check-server-side', ','.join(map((lambda x: '='.join(x)), client['server_check'].items()))]
if client['action']:
command_list += ['--action', client['action']]
if mode == 'async':
result = pulse2.launcher.process_control.commandForker(
command_list,
__cb_async_process_end,
command_id,
LauncherConfig().defer_results,
'completed_halt',
LauncherConfig().max_command_age,
client['group'],
'halt',
env_=envir
)
if not result :
logging.getLogger().warn("Remote halt (ssh/async) failed for CoH #%d" % command_id)
return result
elif mode == 'sync':
result = pulse2.launcher.process_control.commandRunner(
command_list,
__cb_sync_process_end,
env_=envir
)
if not result :
logging.getLogger().warn("Remote halt (ssh/sync) failed for CoH #%d" % command_id)
return result
logging.getLogger().warn("Remote halt failed for CoH #%d" % command_id)
return None
示例7: remote_delete
# 需要导入模块: from pulse2.consts import PULSE2_WRAPPER_ARG_SEPARATOR [as 别名]
# 或者: from pulse2.consts.PULSE2_WRAPPER_ARG_SEPARATOR import join [as 别名]
def remote_delete(command_id, client, files_list, mode, wrapper_timeout):
""" Handle remote deletion on target """
client = pulse2.launcher.utils.setDefaultClientOptions(client)
target_path = os.path.join(LauncherConfig().target_path, pulse2.launcher.utils.getTempFolderName(command_id, client['uuid']))
if client['protocol'] == "ssh":
# command is issued through our wrapper, time to build it
if not LauncherConfig().is_ssh_available:
logging.getLogger().warn("Can't do remote delete because ssh is not available")
return False
# Built "thru" command
thru_command_list = [LauncherConfig().ssh_path]
thru_command_list += client['transp_args']
thru_command_list += [client['host']]
# Define environnement
envir = {
'SSHPATH': LauncherConfig().ssh_path,
'SSHARGS': client['transp_args'],
'SSHTARGET' : client['host'],
'STEP': 'DELETE'
}
# Build "exec" command
# The permissions need to be modified, else the directory can't be
# deleted.
real_command = ['if', 'id', 'SYSTEM', '>', '/dev/null', ';', 'then']
real_command += ['chown', 'SYSTEM.SYSTEM', '"%s"' % target_path, ';']
real_command += ['fi', ';']
if LauncherConfig().is_smart_cleaner_available:
real_command += ['if', '[', '-x', LauncherConfig().smart_cleaner_path, ']', ';']
real_command += ['then']
real_command += [ LauncherConfig().smart_cleaner_path ]
real_command += ['--directory', '"%s"' % target_path]
real_command += ['--files', '"%s"' % ','.join(files_list)]
real_command += LauncherConfig().smart_cleaner_options
real_command += [';']
real_command += ['else']
real_command += ['rm']
real_command += map(lambda(a): '"%s"' % os.path.join(target_path, a), files_list)
real_command += ['&&', 'if', '!', 'rmdir', target_path, ';']
real_command += ['then']
# Use the dellater command if available
real_command += ['if', '[', '-x', '/usr/bin/dellater.exe', ']', ';']
real_command += ['then']
# The mount/grep/sed stuff is needed to get the directory name for
# Windows.
real_command += ['dellater', '"$(mount | grep " on / type" | sed "s| on / type.*$||")"' + target_path, ';']
real_command += ['fi', ';']
real_command += ['fi', ';']
if LauncherConfig().is_smart_cleaner_available:
real_command += ['fi', ';']
# Build final command line
command_list = [
LauncherConfig().wrapper_path,
'--max-log-size',
str(LauncherConfig().wrapper_max_log_size),
'--max-exec-time',
str(wrapper_timeout),
'--thru',
PULSE2_WRAPPER_ARG_SEPARATOR.join(thru_command_list),
'--exec',
PULSE2_WRAPPER_ARG_SEPARATOR.join(real_command),
]
# from {'a': 'b', 'c: 'd'} to 'a=b,c=d'
if client['client_check']:
command_list += ['--check-client-side', ','.join(map((lambda x: '='.join(x)), client['client_check'].items()))]
if client['server_check']:
command_list += ['--check-server-side', ','.join(map((lambda x: '='.join(x)), client['server_check'].items()))]
if client['action']:
command_list += ['--action', client['action']]
if mode == 'async':
result = pulse2.launcher.process_control.commandForker(
command_list,
__cb_async_process_end,
command_id,
LauncherConfig().defer_results,
'completed_deletion',
LauncherConfig().max_command_age,
client['group'],
'delete',
env_=envir
)
if not result :
logging.getLogger().warn("Remote delete (ssh/async) failed for CoH #%d" % command_id)
return result
elif mode == 'sync':
result = pulse2.launcher.process_control.commandRunner(
command_list,
__cb_sync_process_end,
env_=envir
)
if not result :
logging.getLogger().warn("Remote delete (ssh/sync) failed for CoH #%d" % command_id)
#.........这里部分代码省略.........
示例8: remote_pull
# 需要导入模块: from pulse2.consts import PULSE2_WRAPPER_ARG_SEPARATOR [as 别名]
# 或者: from pulse2.consts.PULSE2_WRAPPER_ARG_SEPARATOR import join [as 别名]
def remote_pull(command_id, client, files_list, mode, wrapper_timeout):
""" Handle remote copy (pull) on target """
client = pulse2.launcher.utils.setDefaultClientOptions(client)
target_path = os.path.join(LauncherConfig().target_path, pulse2.launcher.utils.getTempFolderName(command_id, client['uuid']))
if client['protocol'] == "wget":
# command is issued though our wrapper, time to build it
if not LauncherConfig().is_ssh_available:
logging.getLogger().warn("Can't do remote pull because ssh is not available")
return False
# Built "thru" command
thru_command_list = [LauncherConfig().ssh_path]
thru_command_list += client['transp_args']
thru_command_list += [ "%[email protected]%s" % (client['user'], client['host'])]
# Define environnement
envir = {
'SSHPATH': LauncherConfig().ssh_path,
'SSHARGS': client['transp_args'],
'SSHTARGET' : "%[email protected]%s" % (client['user'], client['host']),
'STEP': 'PUSHPULL'
}
# Build "exec" command
real_command = [LauncherConfig().wget_path]
real_command += client['proto_args']
real_command += ['-N']
real_command += files_list
real_command += ['-P']
real_command += [target_path]
# Make downloaded files executable
real_command += ['&&']
real_command += ['chmod']
real_command += ['u+x']
real_command += ['-R']
real_command += [target_path]
# Check files integrity with MD5SUMS file if available AND size > 0
real_command += ['&&']
real_command += ['cd', target_path]
real_command += ['&&']
real_command += ['if', '[', '-s', 'MD5SUMS', ']', ';'] # '-s' : size > 0
real_command += ['then']
real_command += ['md5sum', '-c', 'MD5SUMS', ';']
real_command += ['fi']
# Build final command line
command_list = [
LauncherConfig().wrapper_path,
'--max-log-size',
str(LauncherConfig().wrapper_max_log_size),
'--max-exec-time',
str(wrapper_timeout),
'--thru',
PULSE2_WRAPPER_ARG_SEPARATOR.join(thru_command_list),
'--exec',
PULSE2_WRAPPER_ARG_SEPARATOR.join(real_command),
]
# from {'a': 'b', 'c: 'd'} to 'a=b,c=d'
if client['client_check']:
command_list += ['--check-client-side', ','.join(map((lambda x: '='.join(x)), client['client_check'].items()))]
if client['server_check']:
command_list += ['--check-server-side', ','.join(map((lambda x: '='.join(x)), client['server_check'].items()))]
if client['action']:
command_list += ['--action', client['action']]
if mode == 'async':
result = pulse2.launcher.process_control.commandForker(
command_list,
__cb_async_process_end,
command_id,
LauncherConfig().defer_results,
'completed_pull',
LauncherConfig().max_command_age,
client['group'],
'pull',
env_=envir
)
if not result :
logging.getLogger().warn("Remote pull (wget/async) failed for CoH #%d" % command_id)
return result
elif mode == 'sync':
result = pulse2.launcher.process_control.commandRunner(
command_list,
__cb_sync_process_end,
env_=envir
)
if not result :
logging.getLogger().warn("Remote pull (wget/sync) failed for CoH #%d" % command_id)
return result
elif client['protocol'] == "rsyncproxy":
# Built "thru" command
thru_command_list = [LauncherConfig().ssh_path]
thru_command_list += client['transp_args']
thru_command_list += [ "%[email protected]%s" % (client['user'], client['host'])]
# Define environnement
envir = {
'SSHPATH': LauncherConfig().ssh_path,
'SSHARGS': client['transp_args'],
#.........这里部分代码省略.........
示例9: remote_inventory
# 需要导入模块: from pulse2.consts import PULSE2_WRAPPER_ARG_SEPARATOR [as 别名]
# 或者: from pulse2.consts.PULSE2_WRAPPER_ARG_SEPARATOR import join [as 别名]
def remote_inventory(command_id, client, mode, wrapper_timeout):
""" Handle remote inventoring on target, sync mode
This function will simply run the inventory on the othe side
client is the method used to connect to the client
TODO: same as sync_remote_push
Return: same as sync_remote_push
"""
client = pulse2.launcher.utils.setDefaultClientOptions(client)
inventory_command = LauncherConfig().inventory_command
if client['protocol'] == "ssh":
# command is issued though our wrapper, time to build it
if not LauncherConfig().is_ssh_available:
logging.getLogger().warn("Can't do remote inventory because ssh is not available")
return False
# Built "thru" command
thru_command_list = [LauncherConfig().ssh_path]
thru_command_list += client['transp_args']
thru_command_list += [client['host']]
# Define environnement
envir = {
'SSHPATH': LauncherConfig().ssh_path,
'SSHARGS': client['transp_args'],
'SSHTARGET' : client['host'],
'STEP': 'INVENTORY'
}
# Build "exec" command
real_command = inventory_command
# Build final command line
command_list = [
LauncherConfig().wrapper_path,
'--max-log-size',
str(LauncherConfig().wrapper_max_log_size),
'--max-exec-time',
str(wrapper_timeout),
'--thru',
PULSE2_WRAPPER_ARG_SEPARATOR.join(thru_command_list),
'--exec',
real_command, # we do not use the PULSE2_WRAPPER_ARG_SEPARATOR here, as the command is send "as is"
]
# from {'a': 'b', 'c: 'd'} to 'a=b,c=d'
if client['client_check']:
command_list += ['--check-client-side', ','.join(map((lambda x: '='.join(x)), client['client_check'].items()))]
if client['server_check']:
command_list += ['--check-server-side', ','.join(map((lambda x: '='.join(x)), client['server_check'].items()))]
if client['action']:
command_list += ['--action', client['action']]
return get_command_result(command_id, command_list, mode, client['group'], envir, 'inventory', 'Remote inventory (ssh/async)')
logging.getLogger().warn("Remote inventory failed for CoH #%d" % command_id)
return None
示例10: remote_inventory
# 需要导入模块: from pulse2.consts import PULSE2_WRAPPER_ARG_SEPARATOR [as 别名]
# 或者: from pulse2.consts.PULSE2_WRAPPER_ARG_SEPARATOR import join [as 别名]
def remote_inventory(command_id, client, mode, wrapper_timeout):
""" Handle remote inventoring on target, sync mode
This function will simply run the inventory on the othe side
client is the method used to connect to the client
TODO: same as sync_remote_push
Return: same as sync_remote_push
"""
client = pulse2.launcher.utils.setDefaultClientOptions(client)
inventory_command = LauncherConfig().inventory_command
if client['protocol'] == "ssh":
# command is issued though our wrapper, time to build it
if not LauncherConfig().is_ssh_available:
return False
# Built "thru" command
thru_command_list = [LauncherConfig().ssh_path]
thru_command_list += client['transp_args']
thru_command_list += [client['host']]
# Build "exec" command
real_command = inventory_command
# Build final command line
command_list = [
LauncherConfig().wrapper_path,
'--max-log-size',
str(LauncherConfig().wrapper_max_log_size),
'--max-exec-time',
str(wrapper_timeout),
'--thru',
PULSE2_WRAPPER_ARG_SEPARATOR.join(thru_command_list),
'--exec',
real_command, # we do not use the PULSE2_WRAPPER_ARG_SEPARATOR here, as the command is send "as is"
]
# from {'a': 'b', 'c: 'd'} to 'a=b,c=d'
if client['client_check']:
command_list += ['--check-client-side', ','.join(map((lambda x: '='.join(x)), client['client_check'].items()))]
if client['server_check']:
command_list += ['--check-server-side', ','.join(map((lambda x: '='.join(x)), client['server_check'].items()))]
if client['action']:
command_list += ['--action', client['action']]
if mode == 'async':
return pulse2.launcher.process_control.commandForker(
command_list,
__cb_async_process_end,
command_id,
LauncherConfig().defer_results,
'completed_inventory',
LauncherConfig().max_command_age,
client['group'],
'inventory'
)
elif mode == 'sync':
return pulse2.launcher.process_control.commandRunner(
command_list,
__cb_sync_process_end
)
return None
示例11: remote_push
# 需要导入模块: from pulse2.consts import PULSE2_WRAPPER_ARG_SEPARATOR [as 别名]
# 或者: from pulse2.consts.PULSE2_WRAPPER_ARG_SEPARATOR import join [as 别名]
def remote_push(command_id, client, files_list, mode, wrapper_timeout):
""" Handle remote copy (push) """
target_path = os.path.join(LauncherConfig().target_path, pulse2.launcher.utils.getTempFolderName(command_id, client['uuid']))
client = pulse2.launcher.utils.setDefaultClientOptions(client)
if client['protocol'] == "rsyncssh":
# command is issued though our wrapper, time to build it
real_files_list = files_list
if not LauncherConfig().is_rsync_available:
logging.getLogger().warn('Can\'t do remote push because rsync is not available')
return False
# Build "exec" command
real_command = [LauncherConfig().rsync_path]
real_command += client['proto_args']
real_command += real_files_list
real_command += [ '%[email protected]%s:%s/' % (client['user'], client['host'], target_path)]
# Build "thru" command
thru_command_list = [LauncherConfig().ssh_path]
thru_command_list += client['transp_args']
thru_command_list += [ "%[email protected]%s" % (client['user'], client['host'])]
# Build final command line
command_list = [
LauncherConfig().wrapper_path,
'--max-log-size',
str(LauncherConfig().wrapper_max_log_size),
'--max-exec-time',
str(wrapper_timeout),
'--exec',
PULSE2_WRAPPER_ARG_SEPARATOR.join(real_command),
'--thru',
PULSE2_WRAPPER_ARG_SEPARATOR.join(thru_command_list),
'--exec-server-side'
]
# from {'a': 'b', 'c: 'd'} to 'a=b,c=d'
if client['client_check']:
command_list += ['--check-client-side', ','.join(map((lambda x: '='.join(x)), client['client_check'].items()))]
if client['server_check']:
command_list += ['--check-server-side', ','.join(map((lambda x: '='.join(x)), client['server_check'].items()))]
if client['action']:
command_list += ['--action', client['action']]
if mode == 'async':
return pulse2.launcher.process_control.commandForker(
command_list,
__cb_async_process_end,
command_id,
LauncherConfig().defer_results,
'completed_push',
LauncherConfig().max_command_age,
client['group'],
'push'
)
elif mode == 'sync':
return pulse2.launcher.process_control.commandRunner(
command_list,
__cb_sync_process_end
)
return None
示例12: remote_direct
# 需要导入模块: from pulse2.consts import PULSE2_WRAPPER_ARG_SEPARATOR [as 别名]
# 或者: from pulse2.consts.PULSE2_WRAPPER_ARG_SEPARATOR import join [as 别名]
def remote_direct(command_id, client, command, mode, max_log_size, wrapper_timeout):
""" Handle remote direct stuff on target """
client = pulse2.launcher.utils.setDefaultClientOptions(client)
if client['protocol'] == "ssh":
# command is issued though our wrapper, time to build it
if not LauncherConfig().is_ssh_available:
return False
# Built "thru" command
thru_command_list = [LauncherConfig().ssh_path]
thru_command_list += client['transp_args']
thru_command_list += [client['host']]
# Build "exec" command
real_command = command
if max_log_size == None:
# If no max_log_size set, use the value from the configuration file
max_log_size = LauncherConfig().wrapper_max_log_size
# Build final command line
command_list = [
LauncherConfig().wrapper_path,
'--max-log-size',
str(max_log_size),
'--max-exec-time',
str(wrapper_timeout),
'--thru',
PULSE2_WRAPPER_ARG_SEPARATOR.join(thru_command_list),
'--exec',
real_command, # we do not use the PULSE2_WRAPPER_ARG_SEPARATOR here, as the command is send "as is"
'--no-wrap',
'--only-stdout',
'--remove-empty-lines'
]
# from {'a': 'b', 'c: 'd'} to 'a=b,c=d'
if client['client_check']:
command_list += ['--check-client-side', ','.join(map((lambda x: '='.join(x)), client['client_check'].items()))]
if client['server_check']:
command_list += ['--check-server-side', ','.join(map((lambda x: '='.join(x)), client['server_check'].items()))]
if client['action']:
command_list += ['--action', client['action']]
if mode == 'async':
return pulse2.launcher.process_control.commandForker(
command_list,
__cb_async_process_end,
command_id,
LauncherConfig().defer_results,
'completed_direct',
LauncherConfig().max_command_age,
client['group'],
'direct'
)
elif mode == 'sync':
return pulse2.launcher.process_control.commandRunner(
command_list,
__cb_sync_process_end
)
return None