Remove get_remote_client & check_vm_connectivity methods
As tempest.scenario.manager was announced stable interface in Tempest 27.0.0[1] it can be now reused in plugins.
Replaced methods:
* get_remote_client
* check_vm_connectivity
Etherpad concerning this effort:
https://etherpad.opendev.org/p/tempest-scenario-manager-cleanup
[1] https://docs.openstack.org/releasenotes/tempest/v27.0.0.html#release-notes-27-0-0
Change-Id: I41f2a17f924e4f555f176564d365aa7119e1fd5b
diff --git a/ironic_tempest_plugin/manager.py b/ironic_tempest_plugin/manager.py
index 9f992be..ce472df 100644
--- a/ironic_tempest_plugin/manager.py
+++ b/ironic_tempest_plugin/manager.py
@@ -21,7 +21,6 @@
from oslo_log import log
from oslo_utils import netutils
-from tempest.common.utils.linux import remote_client
from tempest import config
from tempest import exceptions
from tempest.lib.common.utils import data_utils
@@ -84,75 +83,6 @@
# The create_[resource] functions only return body and discard the
# resp part which is not used in scenario tests
- def get_remote_client(self, ip_address, username=None, private_key=None):
- """Get a SSH client to a remote server
-
- @param ip_address the server floating or fixed IP address to use
- for ssh validation
- @param username name of the Linux account on the remote server
- @param private_key the SSH private key to use
- @return a RemoteClient object
- """
-
- if username is None:
- username = CONF.validation.image_ssh_user
- # Set this with 'keypair' or others to log in with keypair or
- # username/password.
- if CONF.validation.auth_method == 'keypair':
- password = None
- if private_key is None:
- private_key = self.keypair['private_key']
- else:
- password = CONF.validation.image_ssh_password
- private_key = None
- linux_client = remote_client.RemoteClient(ip_address, username,
- pkey=private_key,
- password=password)
- try:
- linux_client.validate_authentication()
- except Exception as e:
- message = ('Initializing SSH connection to %(ip)s failed. '
- 'Error: %(error)s' % {'ip': ip_address,
- 'error': e})
- caller = test_utils.find_test_caller()
- if caller:
- message = '(%s) %s' % (caller, message)
- LOG.exception(message)
- self.log_console_output()
- raise
-
- return linux_client
-
- def check_vm_connectivity(self, ip_address,
- username=None,
- private_key=None,
- should_connect=True,
- mtu=None):
- """Check server connectivity
-
- :param ip_address: server to test against
- :param username: server's ssh username
- :param private_key: server's ssh private key to be used
- :param should_connect: True/False indicates positive/negative test
- positive - attempt ping and ssh
- negative - attempt ping and fail if succeed
- :param mtu: network MTU to use for connectivity validation
-
- :raises: AssertError if the result of the connectivity check does
- not match the value of the should_connect param
- """
- if should_connect:
- msg = "Timed out waiting for %s to become reachable" % ip_address
- else:
- msg = "ip address %s is reachable" % ip_address
- self.assertTrue(self.ping_ip_address(ip_address,
- should_succeed=should_connect,
- mtu=mtu),
- msg=msg)
- if should_connect:
- # no need to check ssh for negative connectivity
- self.get_remote_client(ip_address, username, private_key)
-
def create_floating_ip(self, thing, pool_name=None):
"""Create a floating IP and associates to a server on Nova"""
diff --git a/ironic_tempest_plugin/tests/scenario/baremetal_manager.py b/ironic_tempest_plugin/tests/scenario/baremetal_manager.py
index 4820c64..b897e34 100644
--- a/ironic_tempest_plugin/tests/scenario/baremetal_manager.py
+++ b/ironic_tempest_plugin/tests/scenario/baremetal_manager.py
@@ -276,4 +276,4 @@
waiters.wait_for_server_status(servers_client,
instance['id'], 'ACTIVE')
# Verify server connection
- self.get_remote_client(server_ip)
+ self.get_remote_client(server_ip, server=instance)
diff --git a/ironic_tempest_plugin/tests/scenario/test_baremetal_basic_ops.py b/ironic_tempest_plugin/tests/scenario/test_baremetal_basic_ops.py
index 692edef..35dfed5 100644
--- a/ironic_tempest_plugin/tests/scenario/test_baremetal_basic_ops.py
+++ b/ironic_tempest_plugin/tests/scenario/test_baremetal_basic_ops.py
@@ -215,7 +215,7 @@
self.validate_ports()
self.validate_scheduling()
ip_address = self.get_server_ip(self.instance)
- vm_client = self.get_remote_client(ip_address)
+ vm_client = self.get_remote_client(ip_address, server=self.instance)
# We expect the ephemeral partition to be mounted on /mnt and to have
# the same size as our flavor definition.
diff --git a/ironic_tempest_plugin/tests/scenario/test_baremetal_boot_from_volume.py b/ironic_tempest_plugin/tests/scenario/test_baremetal_boot_from_volume.py
index 154fc96..b724683 100644
--- a/ironic_tempest_plugin/tests/scenario/test_baremetal_boot_from_volume.py
+++ b/ironic_tempest_plugin/tests/scenario/test_baremetal_boot_from_volume.py
@@ -147,6 +147,7 @@
# Get server ip and validate authentication
ip_address = self.get_server_ip(self.instance)
- self.get_remote_client(ip_address).validate_authentication()
+ self.get_remote_client(ip_address,
+ server=self.instance).validate_authentication()
self.terminate_instance(instance=self.instance)
diff --git a/ironic_tempest_plugin/tests/scenario/test_baremetal_multitenancy.py b/ironic_tempest_plugin/tests/scenario/test_baremetal_multitenancy.py
index fc4c513..cc3ca73 100644
--- a/ironic_tempest_plugin/tests/scenario/test_baremetal_multitenancy.py
+++ b/ironic_tempest_plugin/tests/scenario/test_baremetal_multitenancy.py
@@ -104,7 +104,8 @@
instance1,
)['floating_ip_address']
self.check_vm_connectivity(ip_address=floating_ip1,
- private_key=keypair['private_key'])
+ private_key=keypair['private_key'],
+ server=instance1)
if use_vm:
# Create VM on compute node
alt_instance = self.create_server(
@@ -127,7 +128,8 @@
)['floating_ip_address']
self.check_vm_connectivity(
ip_address=alt_floating_ip,
- private_key=alt_keypair['private_key'])
+ private_key=alt_keypair['private_key'],
+ server=alt_instance)
self.verify_l3_connectivity(
alt_floating_ip,
alt_keypair['private_key'],
diff --git a/ironic_tempest_plugin/tests/scenario/test_baremetal_single_tenant.py b/ironic_tempest_plugin/tests/scenario/test_baremetal_single_tenant.py
index e06d43a..60f986a 100644
--- a/ironic_tempest_plugin/tests/scenario/test_baremetal_single_tenant.py
+++ b/ironic_tempest_plugin/tests/scenario/test_baremetal_single_tenant.py
@@ -118,7 +118,8 @@
instance1,
)['floating_ip_address']
self.check_vm_connectivity(ip_address=floating_ip1,
- private_key=keypair['private_key'])
+ private_key=keypair['private_key'],
+ server=instance1)
if use_vm:
# Create VM on compute node
@@ -146,7 +147,8 @@
)['floating_ip_address']
self.check_vm_connectivity(
ip_address=floating_ip2,
- private_key=keypair['private_key'])
+ private_key=keypair['private_key'],
+ server=instance2)
self.verify_l3_connectivity(
floating_ip2,