Commit 559b88ff authored by David Wilson's avatar David Wilson

ssh: Support specifying the port too.

parent bdf4fcfb
...@@ -13,10 +13,14 @@ class Stream(mitogen.master.Stream): ...@@ -13,10 +13,14 @@ class Stream(mitogen.master.Stream):
#: The path to the SSH binary. #: The path to the SSH binary.
ssh_path = 'ssh' ssh_path = 'ssh'
def construct(self, hostname, username=None, ssh_path=None, **kwargs): port = None
def construct(self, hostname, username=None, ssh_path=None, port=None,
**kwargs):
super(Stream, self).construct(**kwargs) super(Stream, self).construct(**kwargs)
self.hostname = hostname self.hostname = hostname
self.username = username self.username = username
self.port = port
if ssh_path: if ssh_path:
self.ssh_path = ssh_path self.ssh_path = ssh_path
...@@ -24,6 +28,8 @@ class Stream(mitogen.master.Stream): ...@@ -24,6 +28,8 @@ class Stream(mitogen.master.Stream):
bits = [self.ssh_path] bits = [self.ssh_path]
if self.username: if self.username:
bits += ['-l', self.username] bits += ['-l', self.username]
if self.port is not None:
bits += ['-p', str(self.port)]
bits.append(self.hostname) bits.append(self.hostname)
base = super(Stream, self).get_boot_command() base = super(Stream, self).get_boot_command()
return bits + map(commands.mkarg, base) return bits + map(commands.mkarg, base)
...@@ -31,3 +37,5 @@ class Stream(mitogen.master.Stream): ...@@ -31,3 +37,5 @@ class Stream(mitogen.master.Stream):
def connect(self): def connect(self):
super(Stream, self).connect() super(Stream, self).connect()
self.name = 'ssh.' + self.hostname self.name = 'ssh.' + self.hostname
if self.port:
self.name += ':%s' % (self.port,)
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