|
|
|
@ -27,38 +27,43 @@ import tobiko
|
|
|
|
|
LOG = log.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def ssh_config(config_files=None):
|
|
|
|
|
if config_files:
|
|
|
|
|
fixture = SSHConfigFixture(config_files=config_files)
|
|
|
|
|
def ssh_config(config_files=None, **defaults):
|
|
|
|
|
if config_files or defaults:
|
|
|
|
|
fixture = SSHConfigFixture(config_files=config_files, **defaults)
|
|
|
|
|
else:
|
|
|
|
|
fixture = SSHConfigFixture
|
|
|
|
|
return tobiko.setup_fixture(fixture)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def ssh_host_config(host=None, config_files=None):
|
|
|
|
|
return ssh_config(config_files=config_files).lookup(host)
|
|
|
|
|
def ssh_host_config(host=None, config_files=None, **defaults):
|
|
|
|
|
return ssh_config(config_files=config_files, **defaults).lookup(host)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SSHDefaultConfigFixture(tobiko.SharedFixture):
|
|
|
|
|
|
|
|
|
|
conf = None
|
|
|
|
|
|
|
|
|
|
def setup_fixture(self):
|
|
|
|
|
self.conf = tobiko.tobiko_config().ssh
|
|
|
|
|
def __init__(self, **defaults):
|
|
|
|
|
super(SSHDefaultConfigFixture, self).__init__()
|
|
|
|
|
self.__dict__.update((key, value)
|
|
|
|
|
for key, value in defaults.items()
|
|
|
|
|
if value is not None)
|
|
|
|
|
|
|
|
|
|
def __getattr__(self, name):
|
|
|
|
|
return getattr(self.conf, name)
|
|
|
|
|
config = tobiko.tobiko_config().ssh
|
|
|
|
|
value = getattr(config, name)
|
|
|
|
|
self.__dict__[name] = value
|
|
|
|
|
return value
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SSHConfigFixture(tobiko.SharedFixture):
|
|
|
|
|
|
|
|
|
|
default = tobiko.required_setup_fixture(SSHDefaultConfigFixture)
|
|
|
|
|
|
|
|
|
|
default = None
|
|
|
|
|
config_files = None
|
|
|
|
|
config = None
|
|
|
|
|
|
|
|
|
|
def __init__(self, config_files=None):
|
|
|
|
|
def __init__(self, config_files=None, **defaults):
|
|
|
|
|
super(SSHConfigFixture, self).__init__()
|
|
|
|
|
self.default = tobiko.setup_fixture(
|
|
|
|
|
SSHDefaultConfigFixture(**defaults))
|
|
|
|
|
if config_files:
|
|
|
|
|
self.config_files = tuple(config_files)
|
|
|
|
|
else:
|
|
|
|
@ -87,7 +92,8 @@ class SSHConfigFixture(tobiko.SharedFixture):
|
|
|
|
|
return SSHHostConfig(host=host,
|
|
|
|
|
ssh_config=self,
|
|
|
|
|
host_config=host_config,
|
|
|
|
|
config_files=self.config_files)
|
|
|
|
|
config_files=self.config_files,
|
|
|
|
|
default=self.default)
|
|
|
|
|
|
|
|
|
|
def __repr__(self):
|
|
|
|
|
return "{class_name!s}(config_files={config_files!r})".format(
|
|
|
|
@ -97,9 +103,8 @@ class SSHConfigFixture(tobiko.SharedFixture):
|
|
|
|
|
class SSHHostConfig(collections.namedtuple('SSHHostConfig', ['host',
|
|
|
|
|
'ssh_config',
|
|
|
|
|
'host_config',
|
|
|
|
|
'config_files'])):
|
|
|
|
|
|
|
|
|
|
default = tobiko.required_setup_fixture(SSHDefaultConfigFixture)
|
|
|
|
|
'config_files',
|
|
|
|
|
'default'])):
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def hostname(self):
|
|
|
|
|