mirror of
https://github.com/ceph/ceph
synced 2024-12-22 19:34:30 +00:00
dc9aaacfb2
Most importantly right now, it knows its name, and can prettyprint it.
35 lines
773 B
Python
35 lines
773 B
Python
from orchestra import run
|
|
|
|
class Remote(object):
|
|
"""
|
|
A connection to a remote host.
|
|
|
|
This is a higher-level wrapper around Paramiko's `SSHClient`.
|
|
"""
|
|
|
|
# for unit tests to hook into
|
|
_runner = run.run
|
|
|
|
def __init__(self, name, ssh, shortname=None):
|
|
self.name = name
|
|
self._shortname = shortname
|
|
self.ssh = ssh
|
|
|
|
@property
|
|
def shortname(self):
|
|
name = self._shortname
|
|
if name is None:
|
|
name = self.name
|
|
return name
|
|
|
|
def __str__(self):
|
|
return self.shortname
|
|
|
|
def run(self, **kwargs):
|
|
"""
|
|
This calls `orchestra.run.run` with our SSH client.
|
|
|
|
TODO refactor to move run.run here?
|
|
"""
|
|
return self._runner(client=self.ssh, **kwargs)
|