Merge "Remove get_remote_client & create_keypair"

This commit is contained in:
Zuul 2023-07-13 16:31:29 +00:00 committed by Gerrit Code Review
commit a934903e96

View File

@ -18,11 +18,9 @@ import os
from oslo_log import log
from tempest.common import image as common_image
from tempest.common.utils.linux import remote_client
from tempest.common import waiters
from tempest import config
from tempest.lib.common.utils import data_utils
from tempest.lib.common.utils import test_utils
from tempest.lib import exceptions as lib_exc
import tempest.scenario.manager
@ -80,14 +78,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 create_keypair(self, client=None):
if not client:
client = self.keypairs_client
name = data_utils.rand_name(self.__class__.__name__)
# We don't need to create a keypair by pubkey in scenario
body = client.create_keypair(name=name)
return body['keypair']
def create_server(self, name=None, image_id=None, flavor=None,
net_id=None, key=None, wait_until='ACTIVE',
sec_grps=[], metadata={}, **kwargs):
@ -149,42 +139,3 @@ class ScenarioTest(tempest.scenario.manager.ScenarioTest):
else:
self.image_client.store_image_file(image['id'], image_file)
return image['id']
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