本文整理汇总了Python中ClusterShell.Worker.Worker.DistantWorker.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python DistantWorker.__init__方法的具体用法?Python DistantWorker.__init__怎么用?Python DistantWorker.__init__使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ClusterShell.Worker.Worker.DistantWorker
的用法示例。
在下文中一共展示了DistantWorker.__init__方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from ClusterShell.Worker.Worker import DistantWorker [as 别名]
# 或者: from ClusterShell.Worker.Worker.DistantWorker import __init__ [as 别名]
def __init__(self, nodes, handler, timeout, **kwargs):
"""
Initialize Ssh worker instance.
"""
DistantWorker.__init__(self, handler)
self.clients = []
self.nodes = NodeSet(nodes)
self.command = kwargs.get('command')
self.source = kwargs.get('source')
self.dest = kwargs.get('dest')
autoclose = kwargs.get('autoclose', False)
stderr = kwargs.get('stderr', False)
self._close_count = 0
self._has_timeout = False
# Prepare underlying engine clients (ssh/scp processes)
if self.command is not None:
# secure remote shell
for node in self.nodes:
self.clients.append(Ssh(node, self.command, self, stderr,
timeout, autoclose))
elif self.source:
# secure copy
for node in self.nodes:
self.clients.append(Scp(node, self.source, self.dest,
self, stderr, timeout, kwargs.get('preserve', False),
kwargs.get('reverse', False)))
else:
raise ValueError("missing command or source parameter in " \
"WorkerSsh constructor")
示例2: __init__
# 需要导入模块: from ClusterShell.Worker.Worker import DistantWorker [as 别名]
# 或者: from ClusterShell.Worker.Worker.DistantWorker import __init__ [as 别名]
def __init__(self, nodes, handler, timeout, **kwargs):
"""
Initialize Tree worker instance.
@param nodes: Targeted nodeset.
@param handler: Worker EventHandler.
@param timeout: Timeout value for worker.
@param command: Command to execute.
@param topology: Force specific TopologyTree.
@param newroot: Root node of TopologyTree.
"""
DistantWorker.__init__(self, handler)
self.workers = []
self.nodes = NodeSet(nodes)
self.timeout = timeout
self.command = kwargs.get('command')
self.source = kwargs.get('source')
self.dest = kwargs.get('dest')
autoclose = kwargs.get('autoclose', False)
self.stderr = kwargs.get('stderr', False)
self.remote = kwargs.get('remote', True)
self._close_count = 0
self._start_count = 0
self._child_count = 0
self._target_count = 0
self._has_timeout = False
self.logger = logging.getLogger(__name__)
if self.command is None and self.source is None:
raise ValueError("missing command or source parameter in "
"WorkerTree constructor")
# build gateway invocation command
invoke_gw_args = []
for envname in ('PYTHONPATH', \
'CLUSTERSHELL_GW_LOG_DIR', \
'CLUSTERSHELL_GW_LOG_LEVEL'):
envval = os.getenv(envname)
if envval:
invoke_gw_args.append("%s=%s" % (envname, envval))
invoke_gw_args.append("python -m ClusterShell/Gateway -Bu")
self.invoke_gateway = ' '.join(invoke_gw_args)
self.topology = kwargs.get('topology')
if self.topology is not None:
self.newroot = kwargs.get('newroot') or str(self.topology.root.nodeset)
self.router = PropagationTreeRouter(self.newroot, self.topology)
else:
self.router = None
self.upchannel = None
self.metahandler = MetaWorkerEventHandler(self)
# gateway -> active targets selection
self.gwtargets = {}
示例3: __init__
# 需要导入模块: from ClusterShell.Worker.Worker import DistantWorker [as 别名]
# 或者: from ClusterShell.Worker.Worker.DistantWorker import __init__ [as 别名]
def __init__(self, nodes, handler, timeout, **kwargs):
"""
Initialize Pdsh worker instance.
"""
DistantWorker.__init__(self, handler)
self.nodes = NodeSet(nodes)
self.closed_nodes = NodeSet()
self.command = kwargs.get('command')
self.source = kwargs.get('source')
self.dest = kwargs.get('dest')
autoclose = kwargs.get('autoclose', False)
stderr = kwargs.get('stderr', False)
EngineClient.__init__(self, self, stderr, timeout, autoclose)
if self.command is not None:
# PDSH
self.source = None
self.dest = None
self.mode = 'pdsh'
elif self.source:
# PDCP
self.command = None
self.mode = 'pdcp'
# Preserve modification times and modes?
self.preserve = kwargs.get('preserve', False)
# Reverse copy (rpdcp)?
self.reverse = kwargs.get('reverse', False)
if self.reverse:
self.isdir = os.path.isdir(self.dest)
if not self.isdir:
raise ValueError("reverse copy dest must be a directory")
else:
self.isdir = os.path.isdir(self.source)
else:
raise ValueError("missing command or source parameter in " \
"WorkerPdsh constructor")
self.popen = None
self._buf = ""
示例4: __init__
# 需要导入模块: from ClusterShell.Worker.Worker import DistantWorker [as 别名]
# 或者: from ClusterShell.Worker.Worker.DistantWorker import __init__ [as 别名]
def __init__(self, nodes, handler, timeout, **kwargs):
"""
Initialize Tree worker instance.
:param nodes: Targeted nodeset.
:param handler: Worker EventHandler.
:param timeout: Timeout value for worker.
:param command: Command to execute.
:param topology: Force specific TopologyTree.
:param newroot: Root node of TopologyTree.
"""
DistantWorker.__init__(self, handler)
self.logger = logging.getLogger(__name__)
self.workers = []
self.nodes = NodeSet(nodes)
self.timeout = timeout
self.command = kwargs.get('command')
self.source = kwargs.get('source')
self.dest = kwargs.get('dest')
autoclose = kwargs.get('autoclose', False)
self.stderr = kwargs.get('stderr', False)
self.logger.debug("stderr=%s", self.stderr)
self.remote = kwargs.get('remote', True)
self.preserve = kwargs.get('preserve', None)
self.reverse = kwargs.get('reverse', False)
self._rcopy_bufs = {}
self._rcopy_tars = {}
self._close_count = 0
self._start_count = 0
self._child_count = 0
self._target_count = 0
self._has_timeout = False
if self.command is None and self.source is None:
raise ValueError("missing command or source parameter in "
"TreeWorker constructor")
# rcopy is enforcing separated stderr to handle tar error messages
# because stdout is used for data transfer
if self.source and self.reverse:
self.stderr = True
# build gateway invocation command
invoke_gw_args = []
for envname in ('PYTHONPATH',
'CLUSTERSHELL_GW_LOG_DIR',
'CLUSTERSHELL_GW_LOG_LEVEL',
'CLUSTERSHELL_GW_B64_LINE_LENGTH'):
envval = os.getenv(envname)
if envval:
invoke_gw_args.append("%s=%s" % (envname, envval))
# It is critical to launch a remote Python executable with the same
# major version (ie. python or python3) as we use the (default) pickle
# protocol and for example, version 3+ (Python 3 with bytes
# support) cannot be unpickled by Python 2.
python_executable = os.getenv('CLUSTERSHELL_GW_PYTHON_EXECUTABLE',
basename(sys.executable or 'python'))
invoke_gw_args.append(python_executable)
invoke_gw_args.extend(['-m', 'ClusterShell.Gateway', '-Bu'])
self.invoke_gateway = ' '.join(invoke_gw_args)
self.topology = kwargs.get('topology')
if self.topology is not None:
self.newroot = kwargs.get('newroot') or \
str(self.topology.root.nodeset)
self.router = PropagationTreeRouter(self.newroot, self.topology)
else:
self.router = None
self.upchannel = None
self.metahandler = MetaWorkerEventHandler(self)
# gateway (string) -> active targets selection
self.gwtargets = {}