Commit b54515a6 authored by Antoine Kaufmann's avatar Antoine Kaufmann
Browse files

experiments: support extra ssh args for hosts.json in distributed exps

parent 61ba39e8
...@@ -114,6 +114,10 @@ def load_executors(path): ...@@ -114,6 +114,10 @@ def load_executors(path):
ex = exectools.LocalExecutor() ex = exectools.LocalExecutor()
elif h['type'] == 'remote': elif h['type'] == 'remote':
ex = exectools.RemoteExecutor(h['host'], h['workdir']) ex = exectools.RemoteExecutor(h['host'], h['workdir'])
if 'ssh_args' in h:
ex.ssh_extra_args += h['ssh_args']
if 'scp_args' in h:
ex.scp_extra_args += h['scp_args']
else: else:
raise RuntimeError('invalid host type "' + h['type'] + '"') raise RuntimeError('invalid host type "' + h['type'] + '"')
ex.ip = h['ip'] ex.ip = h['ip']
......
...@@ -182,8 +182,9 @@ class SimpleComponent(Component): ...@@ -182,8 +182,9 @@ class SimpleComponent(Component):
raise Exception('Command Failed: ' + str(self.cmd_parts)) raise Exception('Command Failed: ' + str(self.cmd_parts))
class SimpleRemoteComponent(SimpleComponent): class SimpleRemoteComponent(SimpleComponent):
def __init__(self, host_name, label, cmd_parts, cwd=None, *args, **kwargs): def __init__(self, host_name, label, cmd_parts, cwd=None, ssh_extra_args=[], *args, **kwargs):
self.host_name = host_name self.host_name = host_name
self.extra_flags = ssh_extra_args
# add a wrapper to print the PID # add a wrapper to print the PID
remote_parts = ['echo', 'PID', '$$', '&&'] remote_parts = ['echo', 'PID', '$$', '&&']
...@@ -208,7 +209,8 @@ class SimpleRemoteComponent(SimpleComponent): ...@@ -208,7 +209,8 @@ class SimpleRemoteComponent(SimpleComponent):
'-o', '-o',
'UserKnownHostsFile=/dev/null', 'UserKnownHostsFile=/dev/null',
'-o', '-o',
'StrictHostKeyChecking=no', 'StrictHostKeyChecking=no'
] + self.extra_flags + [
self.host_name, self.host_name,
'--'] + parts '--'] + parts
...@@ -318,10 +320,12 @@ class RemoteExecutor(Executor): ...@@ -318,10 +320,12 @@ class RemoteExecutor(Executor):
def __init__(self, host_name, workdir): def __init__(self, host_name, workdir):
self.host_name = host_name self.host_name = host_name
self.cwd = workdir self.cwd = workdir
self.ssh_extra_args = []
self.scp_extra_args = []
def create_component(self, label, parts, **kwargs): def create_component(self, label, parts, **kwargs):
return SimpleRemoteComponent(self.host_name, label, parts, return SimpleRemoteComponent(self.host_name, label, parts,
cwd=self.cwd, **kwargs) cwd=self.cwd, ssh_extra_args=self.ssh_extra_args, **kwargs)
async def await_file(self, path, delay=0.05, verbose=False, timeout=30): async def await_file(self, path, delay=0.05, verbose=False, timeout=30):
if verbose: if verbose:
...@@ -346,7 +350,8 @@ class RemoteExecutor(Executor): ...@@ -346,7 +350,8 @@ class RemoteExecutor(Executor):
'-o', '-o',
'UserKnownHostsFile=/dev/null', 'UserKnownHostsFile=/dev/null',
'-o', '-o',
'StrictHostKeyChecking=no', 'StrictHostKeyChecking=no'
] + self.scp_extra_args + [
path, path,
'%s:%s' % (self.host_name, path)] '%s:%s' % (self.host_name, path)]
sc = SimpleComponent("%s.send_file('%s')" % ( sc = SimpleComponent("%s.send_file('%s')" % (
...@@ -364,4 +369,4 @@ class RemoteExecutor(Executor): ...@@ -364,4 +369,4 @@ class RemoteExecutor(Executor):
sc = self.create_component("%s.rmtree('%s')" % (self.host_name, path), sc = self.create_component("%s.rmtree('%s')" % (self.host_name, path),
['rm', '-rf', path], canfail=False, verbose=verbose) ['rm', '-rf', path], canfail=False, verbose=verbose)
await sc.start() await sc.start()
await sc.wait() await sc.wait()
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment