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
This commit is contained in:
Roman Popelka 2022-03-17 11:08:34 +01:00
parent 7334c06230
commit 6512049526
6 changed files with 12 additions and 77 deletions

View File

@ -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 @@ class ScenarioTest(tempest.scenario.manager.ScenarioTest):
# 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"""

View File

@ -276,4 +276,4 @@ class BaremetalScenarioTest(manager.ScenarioTest):
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)

View File

@ -215,7 +215,7 @@ class BaremetalBasicOps(baremetal_manager.BaremetalScenarioTest):
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.

View File

@ -147,6 +147,7 @@ class BaremetalBFV(baremetal_manager.BaremetalScenarioTest):
# 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)

View File

@ -104,7 +104,8 @@ class BaremetalMultitenancy(baremetal_manager.BaremetalScenarioTest,
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 @@ class BaremetalMultitenancy(baremetal_manager.BaremetalScenarioTest,
)['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'],

View File

@ -118,7 +118,8 @@ class BaremetalSingleTenant(baremetal_manager.BaremetalScenarioTest,
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 @@ class BaremetalSingleTenant(baremetal_manager.BaremetalScenarioTest,
)['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,