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