aboutsummaryrefslogtreecommitdiffstats
path: root/src/osmo_gsm_tester
diff options
context:
space:
mode:
authorNils F├╝rste <nils.fuerste@rub.de>2020-11-23 11:57:41 +0100
committerpespin <pespin@sysmocom.de>2020-11-30 16:32:51 +0000
commit2af2b15e2e7105581d21734d351653f70c6863d1 (patch)
tree4657930aeb8df280535b0065c89426cbaf7a46cd /src/osmo_gsm_tester
parentb33f36b9fb68c93135ed063e7b389203548e5764 (diff)
Process: Add remote_port as new parameterHEADmaster
remote_port defines a custom/additional port for connections over ssh. It may be used in case several ssh instances share one IP address. Change-Id: I2c93fd2ea1c10c333d00eafd3c1066c35796e398
Diffstat (limited to 'src/osmo_gsm_tester')
-rw-r--r--src/osmo_gsm_tester/core/process.py8
-rw-r--r--src/osmo_gsm_tester/core/remote.py9
-rw-r--r--src/osmo_gsm_tester/obj/run_node.py9
3 files changed, 21 insertions, 5 deletions
diff --git a/src/osmo_gsm_tester/core/process.py b/src/osmo_gsm_tester/core/process.py
index eaf8de7..0b96f2e 100644
--- a/src/osmo_gsm_tester/core/process.py
+++ b/src/osmo_gsm_tester/core/process.py
@@ -381,12 +381,14 @@ class Process(log.Origin):
class RemoteProcess(Process):
- def __init__(self, name, run_dir, remote_user, remote_host, remote_cwd, popen_args, remote_env={}, **popen_kwargs):
+ def __init__(self, name, run_dir, remote_user, remote_host, remote_cwd, popen_args,
+ remote_env={}, remote_port=None, **popen_kwargs):
super().__init__(name, run_dir, popen_args, **popen_kwargs)
self.remote_user = remote_user
self.remote_host = remote_host
self.remote_cwd = remote_cwd
self.remote_env = remote_env
+ self.remote_port = remote_port
# hacky: instead of just prepending ssh, i.e. piping stdout and stderr
# over the ssh link, we should probably run on the remote side,
@@ -402,6 +404,10 @@ class RemoteProcess(Process):
'%s %s %s' % (cd,
' '.join(['%s=%r'%(k,v) for k,v in self.remote_env.items()]),
' '.join(self.popen_args))]
+ if self.remote_port:
+ self.popen_args.insert(1, '-p')
+ self.popen_args.insert(2, self.remote_port)
+
self.dbg(self.popen_args, dir=self.run_dir, conf=self.popen_kwargs, remote_env=self.remote_env)
def RunError(self, msg_prefix):
diff --git a/src/osmo_gsm_tester/core/remote.py b/src/osmo_gsm_tester/core/remote.py
index 8deb25d..0ea873d 100644
--- a/src/osmo_gsm_tester/core/remote.py
+++ b/src/osmo_gsm_tester/core/remote.py
@@ -28,13 +28,14 @@ class RemoteHost(log.Origin):
WRAPPER_SCRIPT = 'ssh_sigkiller.sh'
- def __init__(self, run_dir, remote_user = 'root', remote_host = 'localhost', remote_cwd=None):
+ def __init__(self, run_dir, remote_user = 'root', remote_host = 'localhost', remote_cwd=None, remote_port=None):
super().__init__(log.C_RUN, 'host-' + remote_user + '@' + remote_host)
self.run_dir = util.Dir(run_dir.new_dir(self.name()))
self.remote_user = remote_user
self.remote_host = remote_host
self.remote_cwd = remote_cwd
self.remote_env = {}
+ self.remote_port = remote_port
def user(self):
return self.remote_user
@@ -51,9 +52,13 @@ class RemoteHost(log.Origin):
def get_remote_env(self):
return self.remote_env
+ def get_remote_port(self):
+ return self.remote_port
+
def RemoteProcess(self, name, popen_args, remote_env={}, **popen_kwargs):
run_dir = self.run_dir.new_dir(name)
- return process.RemoteProcess(name, run_dir, self.user(), self.host(), self.cwd(), popen_args, remote_env=remote_env, **popen_kwargs)
+ return process.RemoteProcess(name, run_dir, self.user(), self.host(), self.cwd(), popen_args,
+ remote_env=remote_env, remote_port=self.get_remote_port(), **popen_kwargs)
def generate_wrapper_script(self, wait_time_sec):
wrapper_script = self.run_dir.new_file(RemoteHost.WRAPPER_SCRIPT)
diff --git a/src/osmo_gsm_tester/obj/run_node.py b/src/osmo_gsm_tester/obj/run_node.py
index 6a030ac..7c41705 100644
--- a/src/osmo_gsm_tester/obj/run_node.py
+++ b/src/osmo_gsm_tester/obj/run_node.py
@@ -30,13 +30,14 @@ class RunNode(log.Origin):
T_LOCAL = 'local'
T_REM_SSH = 'ssh'
- def __init__(self, type=None, run_addr=None, ssh_user=None, ssh_addr=None, run_label=None):
+ def __init__(self, type=None, run_addr=None, ssh_user=None, ssh_addr=None, run_label=None, ssh_port=None):
super().__init__(log.C_RUN, 'runnode')
self._type = type
self._run_addr = run_addr
self._ssh_user = ssh_user
self._ssh_addr = ssh_addr
self._run_label = run_label
+ self._ssh_port = ssh_port
if not self._type:
raise log.Error('run_type not set')
if not self._run_addr:
@@ -55,7 +56,7 @@ class RunNode(log.Origin):
def from_conf(cls, conf):
return cls(conf.get('run_type', None), conf.get('run_addr', None),
conf.get('ssh_user', None), conf.get('ssh_addr', None),
- conf.get('run_label', None))
+ conf.get('run_label', None), conf.get('ssh_port', None))
@classmethod
def schema(cls):
@@ -65,6 +66,7 @@ class RunNode(log.Origin):
'ssh_user': schema.STR,
'ssh_addr': schema.IPV4,
'run_label': schema.STR,
+ 'ssh_port': schema.STR,
}
return resource_schema
@@ -89,4 +91,7 @@ class RunNode(log.Origin):
def run_label(self):
return self._run_label
+ def ssh_port(self):
+ return self._ssh_port
+
# vim: expandtab tabstop=4 shiftwidth=4