Do not use OpenStack services clients from Vitrage

This patch adds python-*client initialization inside
vitrage-tempest-plugin.

Also for CLI calls all auth params are taken from config now.
Configuration via environment variables is not supported.

Story: 2004053
Task: 27631
Task: 28634
Change-Id: If873d36b4785369127cd3b4f8ce8ab64f09dc2b6
This commit is contained in:
Ivan Kolodyazhny 2019-02-18 16:21:19 +02:00
parent a0f3db18e4
commit be69eba436
9 changed files with 112 additions and 60 deletions

View File

@ -0,0 +1,9 @@
---
features:
- |
vitrage-tempest-plugin uses tempest.conf for any kind of configuration.
upgrade:
- |
Configuration via environment variables is not supported. If you need
configuration via environment variables, please use previous release of
vitrage-tempest-plugin.

View File

@ -4,22 +4,24 @@
# The order of packages isrequirementst, because pip processes them in the order
pbr!=2.1.0,>=2.0.0 # Apache-2.0
aodhclient>=0.9.0 # Apache-2.0
aodhclient>=1.0.0 # Apache-2.0
gnocchiclient>=3.3.1 # Apache-2.0
PyYAML>=3.12 # MIT
python-heatclient>=1.10.0 # Apache-2.0
python-ceilometerclient>=2.5.0 # Apache-2.0
python-heatclient>=1.14.0 # Apache-2.0
python-ceilometerclient>=2.9.0 # Apache-2.0
python-cinderclient>=3.3.0 # Apache-2.0
python-dateutil>=2.5.3 # BSD
python-keystoneclient>=3.15.0 # Apache-2.0
python-neutronclient>=6.7.0 # Apache-2.0
python-novaclient>=9.1.0 # Apache-2.0
python-mistralclient!=3.2.0,>=3.1.0 # Apache-2.0
python-novaclient>=10.1.0 # Apache-2.0
python-mistralclient>=3.3.0 # Apache-2.0
python-glanceclient>=2.8.0 # Apache-2.0
python-vitrageclient>=2.0.0 # Apache-2.0
six>=1.10.0 # MIT
oslo.config>=5.2.0 # Apache-2.0
oslo.serialization!=2.19.1,>=2.18.0 # Apache-2.0
oslo.log>=3.36.0 # Apache-2.0
oslo.utils>=3.36.0 # Apache-2.0
testtools>=2.2.0 # MIT
oslotest>=3.2.0 # Apache-2.0
tempest>=17.1.0 # Apache-2.0

View File

@ -35,4 +35,13 @@ RcaServiceGroup = [
default=120,
min=10,
help='Time to wait between subsequent datasource snapshots'),
cfg.StrOpt('aodh_version', default='2', help='Aodh version'),
cfg.StrOpt('ceilometer_version', default='2', help='Ceilometer version'),
cfg.StrOpt('nova_version', default='2.11', help='Nova version'),
cfg.StrOpt('cinder_version', default='3', help='Cinder version'),
cfg.StrOpt('glance_version', default='2', help='Glance version'),
cfg.StrOpt('heat_version', default='1', help='Heat version'),
cfg.StrOpt('mistral_version', default='2', help='Mistral version'),
cfg.StrOpt('gnocchi_version', default='1', help='Gnocchi version'),
cfg.StrOpt('trove_version', default='1', help='Trove version'),
]

View File

@ -64,7 +64,7 @@ class TestResource(BaseVitrageTempest):
LOG.info("api_resources = %s", api_resources)
cli_resources = utils.run_vitrage_command(
'vitrage resource list --all -f json', self.conf)
'vitrage resource list --all -f json')
self._compare_resources(api_resources, cli_resources)
except Exception as e:

View File

@ -60,7 +60,7 @@ class TestValidate(BaseTemplateTest):
"""
api_template_list = self.vitrage_client.template.list()
cli_template_list = utils.run_vitrage_command(
'vitrage template list', self.conf)
'vitrage template list')
self._compare_template_lists(api_template_list, cli_template_list)
@ -200,7 +200,7 @@ class TemplatesDBTest(BaseTemplateTest):
# Add standard ,equivalence and definition templates
templates_names = self._add_templates()
cli_templates_list = utils.run_vitrage_command(
"vitrage template list", self.conf)
"vitrage template list")
api_templates_list = self.client.template.list()
self.assertThat(api_templates_list, IsNotEmpty(),

View File

@ -53,8 +53,7 @@ class TestTopology(BaseTopologyTest):
"""
api_graph = self.vitrage_client.topology.get(all_tenants=True)
cli_graph = utils.run_vitrage_command(
'vitrage topology show --all-tenants',
self.conf)
'vitrage topology show --all-tenants')
LOG.info('api-graph=%(api)s cli-graph=%(cli)s', {'api': api_graph,
'cli': cli_graph})

View File

@ -16,13 +16,32 @@ from keystoneauth1 import loading as ka_loading
from keystoneauth1 import session as ka_session
from keystoneclient.v3 import client as ks_client_v3
from neutronclient.v2_0 import client as neutron_client
from oslo_utils import importutils as utils
from tempest.common import credentials_factory as common_creds
from tempest import config
from vitrage import os_clients
from vitrageclient import client as vc
CONF = config.CONF
_client_modules = {
'aodh': 'aodhclient.client',
'ceilometer': 'ceilometerclient.client',
'nova': 'novaclient.client',
'cinder': 'cinderclient.client',
'glance': 'glanceclient.client',
'neutron': 'neutronclient.v2_0.client',
'heat': 'heatclient.client',
'mistral': 'mistralclient.api.v2.client',
'gnocchi': 'gnocchiclient.v1.client',
'trove': 'troveclient.v1.client'
}
def driver_module(driver):
mod_name = _client_modules[driver]
module = utils.import_module(mod_name)
return module
class TempestClients(object):
@classmethod
@ -73,7 +92,12 @@ class TempestClients(object):
:rtype: ceilometerclient.v2.client.Client
"""
if not cls._ceilometer:
cls._ceilometer = os_clients.ceilometer_client(cls._conf)
cm_client = driver_module('ceilometer')
client = cm_client.get_client(
version=CONF.root_cause_analysis_service.ceilometer_version,
session=cls._get_session_for_admin(),
)
cls._ceilometer = client
return cls._ceilometer
@classmethod
@ -83,7 +107,12 @@ class TempestClients(object):
:rtype: novaclient.v2.client.Client
"""
if not cls._nova:
cls._nova = os_clients.nova_client(cls._conf)
n_client = driver_module('nova')
client = n_client.Client(
version=CONF.root_cause_analysis_service.nova_version,
session=cls._get_session_for_admin(),
)
cls._nova = client
return cls._nova
@classmethod
@ -93,7 +122,12 @@ class TempestClients(object):
:rtype: cinderclient.v2.client.Client
"""
if not cls._cinder:
cls._cinder = os_clients.cinder_client(cls._conf)
cin_client = driver_module('cinder')
client = cin_client.Client(
version=CONF.root_cause_analysis_service.cinder_version,
session=cls._get_session_for_admin(),
)
cls._cinder = client
return cls._cinder
@classmethod
@ -103,7 +137,13 @@ class TempestClients(object):
:rtype: glanceclient.v2.client.Client
"""
if not cls._glance:
cls._glance = os_clients.glance_client(cls._conf)
glan_client = driver_module('glance')
client = glan_client.Client(
version=CONF.root_cause_analysis_service.glance_version,
session=cls._get_session_for_admin(),
)
cls._glance = client
return cls._glance
@classmethod
@ -113,7 +153,11 @@ class TempestClients(object):
:rtype: neutronclient.v2_0.client.Client
"""
if not cls._neutron:
cls._neutron = os_clients.neutron_client(cls._conf)
ne_client = driver_module('neutron')
client = ne_client.Client(
session=cls._get_session_for_admin()
)
cls._neutron = client
return cls._neutron
@classmethod
@ -123,7 +167,12 @@ class TempestClients(object):
:rtype: heatclient.v1.client.Client
"""
if not cls._heat:
cls._heat = os_clients.heat_client(cls._conf)
he_client = driver_module('heat')
client = he_client.Client(
version=CONF.root_cause_analysis_service.heat_version,
session=cls._get_session_for_admin()
)
cls._heat = client
return cls._heat
@classmethod
@ -133,7 +182,11 @@ class TempestClients(object):
:rtype: mistralclient.v2.client.Client
"""
if not cls._mistral:
cls._mistral = os_clients.mistral_client(cls._conf)
mi_client = driver_module('mistral')
client = mi_client.Client(
session=cls._get_session_for_admin(),
)
cls._mistral = client
return cls._mistral
@classmethod
@ -143,7 +196,11 @@ class TempestClients(object):
:rtype: aodhclient.v2.client.Client
"""
if not cls._aodh:
cls._aodh = os_clients.aodh_client(cls._conf)
ao_client = driver_module('aodh')
client = ao_client.Client(
CONF.root_cause_analysis_service.aodh_version,
session=cls._get_session_for_admin())
cls._aodh = client
return cls._aodh
@classmethod
@ -164,7 +221,10 @@ class TempestClients(object):
:rtype: gnocchiclient.v1.client.Client
"""
if not cls._gnocchi:
cls._gnocchi = os_clients.gnocchi_client(cls._conf)
gn_client = driver_module('gnocchi')
client = gn_client.Client(
session=cls._get_session_for_admin())
cls._gnocchi = client
return cls._gnocchi
@classmethod

View File

@ -16,7 +16,6 @@ import json
from oslo_log import log as logging
from testtools.matchers import HasLength
from vitrage import os_clients
from vitrage_tempest_plugin.tests.api.event.base import BaseTestEvents
from vitrage_tempest_plugin.tests.common.tempest_clients import TempestClients
from vitrage_tempest_plugin.tests.common import vitrage_utils as v_utils
@ -55,7 +54,7 @@ class TestMistralNotifier(BaseTestEvents):
@classmethod
def setUpClass(cls):
super(TestMistralNotifier, cls).setUpClass()
cls.mistral_client = os_clients.mistral_client(cls.conf)
cls.mistral_client = TempestClients.mistral()
cls._templates = []
cls._templates.append(v_utils.add_template('v1_execute_mistral.yaml'))
cls._templates.append(v_utils.add_template('v2_execute_mistral.yaml'))

View File

@ -14,57 +14,44 @@
from functools import wraps
import socket
import time
from oslo_config.cfg import NoSuchOptError
from oslo_log import log as logging
from tempest.common import credentials_factory as common_creds
from tempest import config
import os
import subprocess
CONF = config.CONF
LOG = logging.getLogger(__name__)
TIMESTAMP_FORMAT = '%Y-%m-%dT%H:%M:%SZ'
def run_vitrage_command(command, conf):
# AUTH_URL
local_ip = '127.0.0.1'
try:
local_ip = socket.gethostbyname(socket.gethostname())
except socket.error:
LOG.info("didn't get local ip using default hostname=%s",
socket.gethostname())
auth_url = get_property_value('OS_AUTH_URL', 'auth_url',
'http://%s:5000/v2.0' % local_ip, conf)
def run_vitrage_command(command):
admin_creds = common_creds.get_configured_admin_credentials()
auth_url = CONF.identity.uri_v3
auth_url_param = '--os-auth-url ' + auth_url
# USERNAME
user = get_property_value('OS_USERNAME', 'username',
'admin', conf)
user = admin_creds.username
user_param = '--os-user-name ' + user
# PASSWORD
password = get_property_value('OS_PASSWORD', 'password',
'secretadmin', conf)
password = admin_creds.password
password_param = '--os-password ' + password
# PROJECT_NAME
project_name = get_property_value('OS_TENANT_NAME', 'project_name',
'admin', conf)
project_name = admin_creds.project_name
project_name_param = '--os-project-name ' + project_name
# USER_DOMAIN_ID
user_domain_id = get_property_value('OS_USER_DOMAIN_ID',
'user_domain_id',
'default', conf)
user_domain_id = admin_creds.user_domain_id
user_domain_id_param = '--os-user-domain-id ' + user_domain_id
# PROJECT_DOMAIN_ID
project_domain_id = get_property_value('OS_PROJECT_DOMAIN_ID',
'project_domain_id',
'default', conf)
project_domain_id = admin_creds.project_domain_id
project_domain_id_par = '--os-project-domain-id ' + project_domain_id
full_command = '%s %s %s %s %s %s %s' % (command, user_param,
@ -97,19 +84,6 @@ def run_vitrage_command(command, conf):
return output
def get_property_value(environment_name, conf_name, default_value, conf):
if os.environ.get(environment_name):
return os.environ[environment_name]
try:
return conf.service_credentials[conf_name]
except NoSuchOptError:
LOG.debug("Configuration doesn't exist: service_credentials.%s",
conf_name)
return default_value
def uni2str(text):
return text.encode('ascii', 'ignore')