From 75781a06633e93a504ba49400c57d306ef1b91c8 Mon Sep 17 00:00:00 2001 From: Federico Ressi Date: Fri, 24 May 2019 06:10:49 +0200 Subject: [PATCH] Rename package: tobiko.shell.paramiko -> tobiko.shell.ssh This should avoid confusion when it is required to import paramiko and tobiko.shell.paramiko packages on the same module a the same time. Example: import paramiko from tobiko.shell import ssh Change-Id: I191c4ea69331b923e383b0f3d25ab979efa15273 --- tobiko/config.py | 2 +- tobiko/shell/sh/_execute.py | 6 +++--- tobiko/shell/{paramiko => ssh}/__init__.py | 8 ++------ tobiko/shell/{paramiko => ssh}/_client.py | 2 +- tobiko/shell/{paramiko => ssh}/_config.py | 2 +- tobiko/shell/{paramiko => ssh}/config.py | 4 ++-- tobiko/tests/unit/shell/{test_paramiko.py => test_ssh.py} | 4 ++-- 7 files changed, 12 insertions(+), 16 deletions(-) rename tobiko/shell/{paramiko => ssh}/__init__.py (86%) rename tobiko/shell/{paramiko => ssh}/_client.py (99%) rename tobiko/shell/{paramiko => ssh}/_config.py (99%) rename tobiko/shell/{paramiko => ssh}/config.py (97%) rename tobiko/tests/unit/shell/{test_paramiko.py => test_ssh.py} (95%) diff --git a/tobiko/config.py b/tobiko/config.py index 9c2523be9..e4d81c807 100644 --- a/tobiko/config.py +++ b/tobiko/config.py @@ -27,7 +27,7 @@ LOG = log.getLogger(__name__) CONFIG_MODULES = ['tobiko.openstack.keystone.config', 'tobiko.openstack.neutron.config', 'tobiko.openstack.nova.config', - 'tobiko.shell.paramiko.config', + 'tobiko.shell.ssh.config', 'tobiko.shell.ping.config', 'tobiko.shell.sh.config'] diff --git a/tobiko/shell/sh/_execute.py b/tobiko/shell/sh/_execute.py index 03f7fd83e..3178ac6f1 100644 --- a/tobiko/shell/sh/_execute.py +++ b/tobiko/shell/sh/_execute.py @@ -25,7 +25,7 @@ from oslo_log import log import six import tobiko -from tobiko.shell import paramiko +from tobiko.shell import ssh from tobiko.shell.sh import _exception @@ -65,7 +65,7 @@ def execute(command, stdin=None, environment=None, timeout=None, shell=None, else: command = [str(a) for a in command] - ssh_client = ssh_client or paramiko.ssh_proxy_client() + ssh_client = ssh_client or ssh.ssh_proxy_client() if ssh_client: result = execute_remote_command(command=command, stdin=stdin, environment=environment, @@ -104,7 +104,7 @@ def execute_remote_command(command, ssh_client, stdin=None, timeout=None, if shell: command = shell.split() + [str(subprocess.list2cmdline(command))] - if isinstance(ssh_client, paramiko.SSHClientFixture): + if isinstance(ssh_client, ssh.SSHClientFixture): # Connect to fixture ssh_client = tobiko.setup_fixture(ssh_client).client diff --git a/tobiko/shell/paramiko/__init__.py b/tobiko/shell/ssh/__init__.py similarity index 86% rename from tobiko/shell/paramiko/__init__.py rename to tobiko/shell/ssh/__init__.py index cc05c2cae..e35670720 100644 --- a/tobiko/shell/paramiko/__init__.py +++ b/tobiko/shell/ssh/__init__.py @@ -15,12 +15,8 @@ # under the License. from __future__ import absolute_import -import paramiko - -from tobiko.shell.paramiko import _config -from tobiko.shell.paramiko import _client - -SSHException = paramiko.SSHException +from tobiko.shell.ssh import _config +from tobiko.shell.ssh import _client SSHHostConfig = _config.SSHHostConfig diff --git a/tobiko/shell/paramiko/_client.py b/tobiko/shell/ssh/_client.py similarity index 99% rename from tobiko/shell/paramiko/_client.py rename to tobiko/shell/ssh/_client.py index e61b1e40d..0cead8b22 100644 --- a/tobiko/shell/paramiko/_client.py +++ b/tobiko/shell/ssh/_client.py @@ -23,7 +23,7 @@ import paramiko from oslo_log import log import tobiko -from tobiko.shell.paramiko import _config +from tobiko.shell.ssh import _config LOG = log.getLogger(__name__) diff --git a/tobiko/shell/paramiko/_config.py b/tobiko/shell/ssh/_config.py similarity index 99% rename from tobiko/shell/paramiko/_config.py rename to tobiko/shell/ssh/_config.py index b01ae9540..c8592f57b 100644 --- a/tobiko/shell/paramiko/_config.py +++ b/tobiko/shell/ssh/_config.py @@ -34,7 +34,7 @@ class SSHParamikoConfFixture(tobiko.SharedFixture): def setup_fixture(self): from tobiko import config CONF = config.CONF - self.conf = CONF.tobiko.paramiko + self.conf = CONF.tobiko.ssh def __getattr__(self, name): return getattr(self.conf, name) diff --git a/tobiko/shell/paramiko/config.py b/tobiko/shell/ssh/config.py similarity index 97% rename from tobiko/shell/paramiko/config.py rename to tobiko/shell/ssh/config.py index 8afe96ddc..5dbd4c62a 100644 --- a/tobiko/shell/paramiko/config.py +++ b/tobiko/shell/ssh/config.py @@ -19,7 +19,7 @@ from oslo_log import log def register_tobiko_options(conf): conf.register_opts( - group=cfg.OptGroup('paramiko'), + group=cfg.OptGroup('ssh'), opts=[cfg.BoolOpt('debug', default=False, help=('Logout debugging messages of paramiko ' @@ -59,7 +59,7 @@ def register_tobiko_options(conf): def setup_tobiko_config(conf): paramiko_logger = log.getLogger('paramiko') - if conf.paramiko.debug: + if conf.ssh.debug: if not paramiko_logger.isEnabledFor(log.DEBUG): # Print paramiko debugging messages paramiko_logger.logger.setLevel(log.DEBUG) diff --git a/tobiko/tests/unit/shell/test_paramiko.py b/tobiko/tests/unit/shell/test_ssh.py similarity index 95% rename from tobiko/tests/unit/shell/test_paramiko.py rename to tobiko/tests/unit/shell/test_ssh.py index dac2d7d9d..2ec6b60ad 100644 --- a/tobiko/tests/unit/shell/test_paramiko.py +++ b/tobiko/tests/unit/shell/test_ssh.py @@ -22,7 +22,7 @@ import paramiko import tobiko from tobiko import config -from tobiko.shell import paramiko as ssh +from tobiko.shell import ssh from tobiko.tests import unit @@ -57,7 +57,7 @@ class SSHClientFixtureTest(unit.TobikoUnitTest): fixture.setUp() ssh_config = paramiko.SSHConfig() - for ssh_config_file in CONF.tobiko.paramiko.config_files: + for ssh_config_file in CONF.tobiko.ssh.config_files: if os.path.exists(ssh_config_file): with open(ssh_config_file) as f: ssh_config.parse(f)