Merge "make the os clients dynamiclly imported"
This commit is contained in:
commit
6b9eb38bd0
@ -14,11 +14,11 @@
|
||||
|
||||
from oslo_log import log
|
||||
|
||||
from vitrage import clients
|
||||
from vitrage.datasources.alarm_driver_base import AlarmDriverBase
|
||||
from vitrage.datasources.aodh import AODH_DATASOURCE
|
||||
from vitrage.datasources.aodh.properties import AodhProperties as AodhProps
|
||||
from vitrage.datasources.aodh.properties import AodhState
|
||||
from vitrage import os_clients
|
||||
|
||||
LOG = log.getLogger(__name__)
|
||||
|
||||
@ -32,7 +32,7 @@ class AodhDriver(AlarmDriverBase):
|
||||
@property
|
||||
def client(self):
|
||||
if not self._client:
|
||||
self._client = clients.ceilometer_client(self.conf)
|
||||
self._client = os_clients.ceilometer_client(self.conf)
|
||||
return self._client
|
||||
|
||||
def _sync_type(self):
|
||||
|
@ -12,11 +12,11 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from vitrage import clients
|
||||
from vitrage.common.constants import DatasourceProperties as DSProps
|
||||
from vitrage.common.constants import SyncMode
|
||||
from vitrage.datasources.cinder.volume import CINDER_VOLUME_DATASOURCE
|
||||
from vitrage.datasources.driver_base import DriverBase
|
||||
from vitrage import os_clients
|
||||
|
||||
|
||||
class CinderVolumeDriver(DriverBase):
|
||||
@ -29,7 +29,7 @@ class CinderVolumeDriver(DriverBase):
|
||||
@property
|
||||
def client(self):
|
||||
if not self._client:
|
||||
self._client = clients.cinder_client(self.conf)
|
||||
self._client = os_clients.cinder_client(self.conf)
|
||||
return self._client
|
||||
|
||||
@staticmethod
|
||||
|
@ -12,7 +12,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from vitrage import clients
|
||||
from vitrage.common.constants import DatasourceProperties as DSProps
|
||||
from vitrage.common.constants import SyncMode
|
||||
from vitrage.datasources.cinder.volume import CINDER_VOLUME_DATASOURCE
|
||||
@ -21,6 +20,7 @@ from vitrage.datasources.heat.stack import HEAT_STACK_DATASOURCE
|
||||
from vitrage.datasources.neutron.network import NEUTRON_NETWORK_DATASOURCE
|
||||
from vitrage.datasources.neutron.port import NEUTRON_PORT_DATASOURCE
|
||||
from vitrage.datasources.nova.instance import NOVA_INSTANCE_DATASOURCE
|
||||
from vitrage import os_clients
|
||||
|
||||
|
||||
class HeatStackDriver(DriverBase):
|
||||
@ -46,7 +46,8 @@ class HeatStackDriver(DriverBase):
|
||||
@staticmethod
|
||||
def client():
|
||||
if not HeatStackDriver._client:
|
||||
HeatStackDriver._client = clients.heat_client(HeatStackDriver.conf)
|
||||
HeatStackDriver._client = os_clients.heat_client(
|
||||
HeatStackDriver.conf)
|
||||
return HeatStackDriver._client
|
||||
|
||||
@staticmethod
|
||||
|
@ -13,8 +13,8 @@
|
||||
# under the License.
|
||||
|
||||
|
||||
from vitrage import clients
|
||||
from vitrage.datasources.driver_base import DriverBase
|
||||
from vitrage import os_clients
|
||||
|
||||
|
||||
class NeutronBase(DriverBase):
|
||||
@ -26,5 +26,5 @@ class NeutronBase(DriverBase):
|
||||
@property
|
||||
def client(self):
|
||||
if not self._client:
|
||||
self._client = clients.neutron_client(self.conf)
|
||||
self._client = os_clients.neutron_client(self.conf)
|
||||
return self._client
|
||||
|
@ -13,8 +13,8 @@
|
||||
# under the License.
|
||||
|
||||
|
||||
from vitrage import clients
|
||||
from vitrage.datasources.driver_base import DriverBase
|
||||
from vitrage import os_clients
|
||||
|
||||
|
||||
class NovaDriverBase(DriverBase):
|
||||
@ -26,5 +26,5 @@ class NovaDriverBase(DriverBase):
|
||||
@property
|
||||
def client(self):
|
||||
if not self._client:
|
||||
self._client = clients.nova_client(self.conf)
|
||||
self._client = os_clients.nova_client(self.conf)
|
||||
return self._client
|
||||
|
@ -13,13 +13,13 @@
|
||||
# under the License.
|
||||
from oslo_log import log as logging
|
||||
|
||||
from vitrage import clients
|
||||
from vitrage.common.constants import NotifierEventTypes
|
||||
from vitrage.common.constants import VertexProperties as VProps
|
||||
from vitrage.datasources.aodh.properties import AodhState
|
||||
from vitrage.entity_graph.mappings.operational_alarm_severity import \
|
||||
OperationalAlarmSeverity
|
||||
from vitrage.notifier.plugins.base import NotifierBase
|
||||
from vitrage import os_clients
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
@ -40,7 +40,7 @@ class AodhNotifier(NotifierBase):
|
||||
|
||||
def __init__(self, conf):
|
||||
super(AodhNotifier, self).__init__(conf)
|
||||
self.client = clients.ceilometer_client(conf)
|
||||
self.client = os_clients.ceilometer_client(conf)
|
||||
|
||||
def process_event(self, data, event_type):
|
||||
response = None
|
||||
|
@ -13,11 +13,11 @@
|
||||
# under the License.
|
||||
from oslo_log import log as logging
|
||||
|
||||
from vitrage import clients
|
||||
from vitrage.common.constants import NotifierEventTypes
|
||||
from vitrage.common.constants import VertexProperties as VProps
|
||||
from vitrage.datasources import NOVA_HOST_DATASOURCE
|
||||
from vitrage.notifier.plugins.base import NotifierBase
|
||||
from vitrage import os_clients
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
@ -30,7 +30,7 @@ class NovaNotifier(NotifierBase):
|
||||
|
||||
def __init__(self, conf):
|
||||
super(NovaNotifier, self).__init__(conf)
|
||||
self.client = clients.nova_client(conf)
|
||||
self.client = os_clients.nova_client(conf)
|
||||
self.enable_evacuate = conf.nova.enable_host_evacuate
|
||||
self.on_shared_storage = conf.nova.on_shared_storage
|
||||
|
||||
|
@ -19,12 +19,12 @@ from oslo_log import log
|
||||
from oslo_utils import importutils
|
||||
|
||||
import vitrage.api
|
||||
import vitrage.clients
|
||||
import vitrage.datasources
|
||||
import vitrage.entity_graph.consistency
|
||||
import vitrage.evaluator
|
||||
import vitrage.keystone_client
|
||||
import vitrage.notifier
|
||||
import vitrage.os_clients
|
||||
import vitrage.rpc
|
||||
|
||||
LOG = log.getLogger(__name__)
|
||||
@ -44,7 +44,7 @@ def list_opts():
|
||||
('entity_graph', vitrage.entity_graph.OPTS),
|
||||
('service_credentials', vitrage.keystone_client.OPTS),
|
||||
('DEFAULT', itertools.chain(
|
||||
vitrage.clients.OPTS,
|
||||
vitrage.os_clients.OPTS,
|
||||
vitrage.rpc.OPTS,
|
||||
vitrage.notifier.OPTS))
|
||||
]
|
||||
|
@ -16,12 +16,8 @@ import keystoneauth1.identity.v2 as v2
|
||||
import keystoneauth1.session as kssession
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log
|
||||
from oslo_utils import importutils as utils
|
||||
|
||||
from ceilometerclient import client as cm_client
|
||||
from cinderclient import client as cin_client
|
||||
from heatclient.v1 import client as he_client
|
||||
from neutronclient.v2_0 import client as ne_client
|
||||
from novaclient import client as n_client
|
||||
from vitrage import keystone_client
|
||||
|
||||
LOG = log.getLogger(__name__)
|
||||
@ -33,11 +29,26 @@ OPTS = [
|
||||
cfg.StrOpt('heat_version', default='1', help='Heat version'),
|
||||
]
|
||||
|
||||
_client_modules = {
|
||||
'ceilometer': 'ceilometerclient.client',
|
||||
'nova': 'novaclient.client',
|
||||
'cinder': 'cinderclient.client',
|
||||
'neutron': 'neutronclient.v2_0.client',
|
||||
'heat': 'heatclient.v1.client',
|
||||
}
|
||||
|
||||
|
||||
def driver_module(driver):
|
||||
mod_name = _client_modules[driver]
|
||||
module = utils.import_module(mod_name)
|
||||
return module
|
||||
|
||||
|
||||
def ceilometer_client(conf):
|
||||
"""Get an instance of ceilometer client"""
|
||||
auth_config = conf.service_credentials
|
||||
try:
|
||||
cm_client = driver_module('ceilometer')
|
||||
client = cm_client.get_client(
|
||||
version=conf.aodh_version,
|
||||
session=keystone_client.get_session(conf),
|
||||
@ -54,6 +65,7 @@ def nova_client(conf):
|
||||
"""Get an instance of nova client"""
|
||||
auth_config = conf.service_credentials
|
||||
try:
|
||||
n_client = driver_module('nova')
|
||||
client = n_client.Client(
|
||||
version=conf.nova_version,
|
||||
session=keystone_client.get_session(conf),
|
||||
@ -70,6 +82,7 @@ def cinder_client(conf):
|
||||
"""Get an instance of cinder client"""
|
||||
auth_config = conf.service_credentials
|
||||
try:
|
||||
cin_client = driver_module('cinder')
|
||||
client = cin_client.Client(
|
||||
version=conf.cinder_version,
|
||||
session=keystone_client.get_session(conf),
|
||||
@ -86,6 +99,7 @@ def neutron_client(conf):
|
||||
"""Get an instance of neutron client"""
|
||||
auth_config = conf.service_credentials
|
||||
try:
|
||||
ne_client = driver_module('neutron')
|
||||
client = ne_client.Client(
|
||||
session=keystone_client.get_session(conf),
|
||||
region_name=auth_config.region_name,
|
||||
@ -109,6 +123,7 @@ def heat_client(conf):
|
||||
session = kssession.Session(auth=auth)
|
||||
endpoint = session.get_endpoint(service_type='orchestration',
|
||||
interface='publicURL')
|
||||
he_client = driver_module('heat')
|
||||
client = he_client.Client(session=session, endpoint=endpoint)
|
||||
LOG.info('Heat client created')
|
||||
return client
|
@ -17,7 +17,7 @@ import time
|
||||
|
||||
from oslo_log import log as logging
|
||||
|
||||
from vitrage import clients
|
||||
from vitrage import os_clients
|
||||
from vitrage_tempest_tests.tests.api.base import BaseApiTest
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
@ -32,7 +32,7 @@ class BaseAlarmsTest(BaseApiTest):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(BaseAlarmsTest, cls).setUpClass()
|
||||
cls.ceilometer_client = clients.ceilometer_client(cls.conf)
|
||||
cls.ceilometer_client = os_clients.ceilometer_client(cls.conf)
|
||||
|
||||
def _create_ceilometer_alarm(self, resource_id=None,
|
||||
name=None, unic=True):
|
||||
|
@ -17,7 +17,6 @@ import time
|
||||
from oslo_log import log as logging
|
||||
from oslotest import base
|
||||
|
||||
from vitrage import clients
|
||||
from vitrage.common.constants import EntityCategory
|
||||
from vitrage.common.constants import VertexProperties as VProps
|
||||
from vitrage.datasources.aodh import AODH_DATASOURCE
|
||||
@ -34,6 +33,7 @@ from vitrage.graph import Edge
|
||||
from vitrage.graph import NXGraph
|
||||
from vitrage.graph import Vertex
|
||||
from vitrage import keystone_client
|
||||
from vitrage import os_clients
|
||||
from vitrage import service
|
||||
import vitrage_tempest_tests.tests.utils as utils
|
||||
from vitrageclient import client as v_client
|
||||
@ -55,10 +55,10 @@ class BaseApiTest(base.BaseTestCase):
|
||||
|
||||
cls.vitrage_client = \
|
||||
v_client.Client('1', session=keystone_client.get_session(cls.conf))
|
||||
cls.nova_client = clients.nova_client(cls.conf)
|
||||
cls.cinder_client = clients.cinder_client(cls.conf)
|
||||
cls.neutron_client = clients.neutron_client(cls.conf)
|
||||
cls.heat_client = clients.heat_client(cls.conf)
|
||||
cls.nova_client = os_clients.nova_client(cls.conf)
|
||||
cls.cinder_client = os_clients.cinder_client(cls.conf)
|
||||
cls.neutron_client = os_clients.neutron_client(cls.conf)
|
||||
cls.heat_client = os_clients.heat_client(cls.conf)
|
||||
|
||||
cls.num_default_networks = \
|
||||
len(cls.neutron_client.list_networks()['networks'])
|
||||
|
@ -15,7 +15,7 @@ import json
|
||||
|
||||
from oslo_log import log as logging
|
||||
|
||||
from vitrage import clients
|
||||
from vitrage import os_clients
|
||||
from vitrage_tempest_tests.tests.api.base import BaseApiTest
|
||||
import vitrage_tempest_tests.tests.utils as utils
|
||||
|
||||
@ -40,7 +40,7 @@ class BaseTemplateTest(BaseApiTest):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(BaseTemplateTest, cls).setUpClass()
|
||||
cls.ceilometer_client = clients.ceilometer_client(cls.conf)
|
||||
cls.ceilometer_client = os_clients.ceilometer_client(cls.conf)
|
||||
|
||||
def _compare_template_lists(self, api_templates, cli_templates):
|
||||
self.assertNotEqual(len(api_templates), 0,
|
||||
|
Loading…
Reference in New Issue
Block a user