From 68df2bb9dc311f0492906f2502d963ecebd3d339 Mon Sep 17 00:00:00 2001 From: Dina Belova Date: Wed, 8 Oct 2014 16:47:33 +0400 Subject: [PATCH] Move central agent code to the polling agent module That's the preparation for further compute and central agents merge Partially-Implements-Blueprint: merge-compute-central-agents Change-Id: If5f151ab7d30c9711929f6dcade553fdca09ab67 --- ceilometer/{central => agent}/__init__.py | 0 ceilometer/{agent.py => agent/base.py} | 0 .../central => agent/discovery}/__init__.py | 0 .../discovery/endpoint.py} | 16 +--- ceilometer/agent/discovery/tenant.py | 37 +++++++++ ceilometer/{central => agent}/manager.py | 18 +++-- .../{plugin.py => agent/plugin_base.py} | 50 ++++++++++++ ceilometer/central/plugin.py | 80 ------------------- ceilometer/cmd/agent_central.py | 2 +- ceilometer/compute/discovery.py | 4 +- ceilometer/compute/manager.py | 4 +- ceilometer/compute/notifications/__init__.py | 4 +- ceilometer/compute/plugin.py | 2 +- ceilometer/data_processing/notifications.py | 4 +- ceilometer/energy/kwapi.py | 6 +- ceilometer/hardware/discovery.py | 4 +- ceilometer/hardware/plugin.py | 4 +- ceilometer/identity/notifications.py | 4 +- ceilometer/image/glance.py | 4 +- ceilometer/image/notifications.py | 4 +- ceilometer/ipmi/manager.py | 4 +- ceilometer/ipmi/notifications/ironic.py | 4 +- ceilometer/ipmi/pollsters/node.py | 4 +- ceilometer/ipmi/pollsters/sensor.py | 4 +- ceilometer/middleware.py | 4 +- ceilometer/network/floatingip.py | 4 +- ceilometer/network/notifications.py | 4 +- ceilometer/network/services/base.py | 4 +- ceilometer/network/services/discovery.py | 21 +++-- ceilometer/network/statistics/__init__.py | 4 +- ceilometer/objectstore/swift.py | 4 +- ceilometer/opts.py | 4 +- ceilometer/orchestration/notifications.py | 4 +- ceilometer/profiler/notifications.py | 4 +- ceilometer/tests/agent/__init__.py | 0 ceilometer/tests/{ => agent}/agentbase.py | 28 +++---- .../{central => agent}/test_discovery.py | 4 +- .../tests/{central => agent}/test_manager.py | 13 ++- ceilometer/tests/{ => agent}/test_plugin.py | 28 +++---- ceilometer/tests/energy/test_kwapi.py | 2 +- ceilometer/tests/hardware/pollsters/base.py | 2 +- ceilometer/tests/image/test_glance.py | 2 +- ceilometer/tests/ipmi/test_manager.py | 3 +- .../tests/network/services/test_fwaas.py | 10 +-- .../tests/network/services/test_lbaas.py | 10 +-- .../tests/network/services/test_vpnaas.py | 10 +-- ceilometer/tests/network/test_floatingip.py | 2 +- ceilometer/tests/objectstore/test_swift.py | 2 +- ceilometer/volume/notifications.py | 6 +- setup.cfg | 4 +- 50 files changed, 223 insertions(+), 223 deletions(-) rename ceilometer/{central => agent}/__init__.py (100%) rename ceilometer/{agent.py => agent/base.py} (100%) rename ceilometer/{tests/central => agent/discovery}/__init__.py (100%) rename ceilometer/{central/discovery.py => agent/discovery/endpoint.py} (78%) create mode 100644 ceilometer/agent/discovery/tenant.py rename ceilometer/{central => agent}/manager.py (83%) rename ceilometer/{plugin.py => agent/plugin_base.py} (78%) delete mode 100644 ceilometer/central/plugin.py create mode 100644 ceilometer/tests/agent/__init__.py rename ceilometer/tests/{ => agent}/agentbase.py (97%) rename ceilometer/tests/{central => agent}/test_discovery.py (92%) rename ceilometer/tests/{central => agent}/test_manager.py (90%) rename ceilometer/tests/{ => agent}/test_plugin.py (84%) diff --git a/ceilometer/central/__init__.py b/ceilometer/agent/__init__.py similarity index 100% rename from ceilometer/central/__init__.py rename to ceilometer/agent/__init__.py diff --git a/ceilometer/agent.py b/ceilometer/agent/base.py similarity index 100% rename from ceilometer/agent.py rename to ceilometer/agent/base.py diff --git a/ceilometer/tests/central/__init__.py b/ceilometer/agent/discovery/__init__.py similarity index 100% rename from ceilometer/tests/central/__init__.py rename to ceilometer/agent/discovery/__init__.py diff --git a/ceilometer/central/discovery.py b/ceilometer/agent/discovery/endpoint.py similarity index 78% rename from ceilometer/central/discovery.py rename to ceilometer/agent/discovery/endpoint.py index eee1595bf..4d628e191 100644 --- a/ceilometer/central/discovery.py +++ b/ceilometer/agent/discovery/endpoint.py @@ -1,4 +1,3 @@ -# # Copyright 2014 Red Hat, Inc # # Author: Nejc Saje @@ -17,9 +16,9 @@ from oslo.config import cfg +from ceilometer.agent import plugin_base as plugin from ceilometer.i18n import _LW from ceilometer.openstack.common import log -from ceilometer import plugin LOG = log.getLogger(__name__) @@ -47,16 +46,3 @@ class EndpointDiscovery(plugin.DiscoveryBase): return [] else: return endpoints - - -class TenantDiscovery(plugin.DiscoveryBase): - """Discovery that supplies keystone tenants. - - This discovery should be used when the pollster's work can't be divided - into smaller pieces than per-tenant. Example of this is the Swift - pollster, which polls account details and does so per-tenant. - """ - - def discover(self, manager, param=None): - tenants = manager.keystone.tenants.list() - return tenants or [] diff --git a/ceilometer/agent/discovery/tenant.py b/ceilometer/agent/discovery/tenant.py new file mode 100644 index 000000000..8e2c7debe --- /dev/null +++ b/ceilometer/agent/discovery/tenant.py @@ -0,0 +1,37 @@ +# Copyright 2014 Red Hat, Inc +# +# Author: Nejc Saje +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from oslo.config import cfg + +from ceilometer.agent import plugin_base as plugin +from ceilometer.openstack.common import log + +LOG = log.getLogger(__name__) + +cfg.CONF.import_group('service_credentials', 'ceilometer.service') + + +class TenantDiscovery(plugin.DiscoveryBase): + """Discovery that supplies keystone tenants. + + This discovery should be used when the pollster's work can't be divided + into smaller pieces than per-tenant. Example of this is the Swift + pollster, which polls account details and does so per-tenant. + """ + + def discover(self, manager, param=None): + tenants = manager.keystone.tenants.list() + return tenants or [] \ No newline at end of file diff --git a/ceilometer/central/manager.py b/ceilometer/agent/manager.py similarity index 83% rename from ceilometer/central/manager.py rename to ceilometer/agent/manager.py index e5ebd9fa7..e607f2e46 100644 --- a/ceilometer/central/manager.py +++ b/ceilometer/agent/manager.py @@ -18,30 +18,32 @@ from keystoneclient.v2_0 import client as ksclient from oslo.config import cfg -from ceilometer import agent +from ceilometer.agent import base from ceilometer.openstack.common import log OPTS = [ cfg.StrOpt('partitioning_group_prefix', default=None, + deprecated_group='central', help='Work-load partitioning group prefix. Use only if you ' - 'want to run multiple central agents with different ' - 'config files. For each sub-group of the central agent ' + 'want to run multiple polling agents with different ' + 'config files. For each sub-group of the agent ' 'pool with the same partitioning_group_prefix a disjoint ' 'subset of pollsters should be loaded.'), ] -cfg.CONF.register_opts(OPTS, group='central') -cfg.CONF.import_opt('http_timeout', 'ceilometer.service') + +cfg.CONF.register_opts(OPTS, group='polling') cfg.CONF.import_group('service_credentials', 'ceilometer.service') +cfg.CONF.import_opt('http_timeout', 'ceilometer.service') LOG = log.getLogger(__name__) -class AgentManager(agent.AgentManager): +class AgentManager(base.AgentManager): - def __init__(self): + def __init__(self, namespace='agent'): super(AgentManager, self).__init__( - 'central', group_prefix=cfg.CONF.central.partitioning_group_prefix) + namespace, group_prefix=cfg.CONF.polling.partitioning_group_prefix) def interval_task(self, task): try: diff --git a/ceilometer/plugin.py b/ceilometer/agent/plugin_base.py similarity index 78% rename from ceilometer/plugin.py rename to ceilometer/agent/plugin_base.py index 9c391d066..8e418c27b 100644 --- a/ceilometer/plugin.py +++ b/ceilometer/agent/plugin_base.py @@ -21,6 +21,8 @@ import abc import collections import fnmatch +from keystoneclient.v2_0 import client as ksclient +from oslo.config import cfg import oslo.messaging import six @@ -29,12 +31,60 @@ from ceilometer import messaging from ceilometer.openstack.common import context from ceilometer.openstack.common import log +cfg.CONF.import_group('service_credentials', 'ceilometer.service') + LOG = log.getLogger(__name__) ExchangeTopics = collections.namedtuple('ExchangeTopics', ['exchange', 'topics']) +def _get_keystone(): + try: + return ksclient.Client( + username=cfg.CONF.service_credentials.os_username, + password=cfg.CONF.service_credentials.os_password, + tenant_id=cfg.CONF.service_credentials.os_tenant_id, + tenant_name=cfg.CONF.service_credentials.os_tenant_name, + cacert=cfg.CONF.service_credentials.os_cacert, + auth_url=cfg.CONF.service_credentials.os_auth_url, + region_name=cfg.CONF.service_credentials.os_region_name, + insecure=cfg.CONF.service_credentials.insecure) + except Exception as e: + return e + + +def check_keystone(service_type=None): + """Decorator function to check if manager has valid keystone client. + + Also checks if the service is registered/enabled in Keystone. + + :param service_type: name of service in Keystone + """ + def wrapped(f): + def func(self, *args, **kwargs): + manager = kwargs.get('manager') + if not manager and len(args) > 0: + manager = args[0] + keystone = getattr(manager, 'keystone', None) + if not keystone: + keystone = _get_keystone() + if isinstance(keystone, Exception): + LOG.error(_('Skip due to keystone error %s'), + str(keystone) if keystone else '') + return iter([]) + elif service_type: + endpoints = keystone.service_catalog.get_endpoints( + service_type=service_type) + if not endpoints: + LOG.warning(_('Skipping because %s service is not ' + 'registered in keystone') % service_type) + return iter([]) + return f(self, *args, **kwargs) + return func + return wrapped + + class PluginBase(object): """Base class for all plugins.""" diff --git a/ceilometer/central/plugin.py b/ceilometer/central/plugin.py deleted file mode 100644 index 17a38a1c8..000000000 --- a/ceilometer/central/plugin.py +++ /dev/null @@ -1,80 +0,0 @@ -# -# Copyright 2012 New Dream Network, LLC (DreamHost) -# -# Author: Doug Hellmann -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -"""Base class for plugins used by the central agent. -""" -from keystoneclient.v2_0 import client as ksclient -from oslo.config import cfg - -from ceilometer.i18n import _ -from ceilometer.openstack.common import log -from ceilometer import plugin - -cfg.CONF.import_opt('http_timeout', 'ceilometer.service') -cfg.CONF.import_group('service_credentials', 'ceilometer.service') - -LOG = log.getLogger(__name__) - - -class CentralPollster(plugin.PollsterBase): - """Base class for plugins that support the polling API.""" - - -def _get_keystone(): - try: - return ksclient.Client( - username=cfg.CONF.service_credentials.os_username, - password=cfg.CONF.service_credentials.os_password, - tenant_id=cfg.CONF.service_credentials.os_tenant_id, - tenant_name=cfg.CONF.service_credentials.os_tenant_name, - cacert=cfg.CONF.service_credentials.os_cacert, - auth_url=cfg.CONF.service_credentials.os_auth_url, - region_name=cfg.CONF.service_credentials.os_region_name, - insecure=cfg.CONF.service_credentials.insecure, - timeout=cfg.CONF.http_timeout) - except Exception as e: - return e - - -def check_keystone(service_type=None): - """Decorator function to check if manager has valid keystone client. - - Also checks if the service is registered/enabled in Keystone. - - :param service_type: name of service in Keystone - """ - def wrapped(f): - def func(self, *args, **kwargs): - manager = kwargs.get('manager') - if not manager and len(args) > 0: - manager = args[0] - keystone = getattr(manager, 'keystone', None) - if not keystone: - keystone = _get_keystone() - if isinstance(keystone, Exception): - LOG.error(_('Skip due to keystone error %s'), - str(keystone) if keystone else '') - return iter([]) - elif service_type: - endpoints = keystone.service_catalog.get_endpoints( - service_type=service_type) - if not endpoints: - LOG.warning(_('Skipping because %s service is not ' - 'registered in keystone') % service_type) - return iter([]) - return f(self, *args, **kwargs) - return func - return wrapped diff --git a/ceilometer/cmd/agent_central.py b/ceilometer/cmd/agent_central.py index d0317cfed..45bb79ffa 100644 --- a/ceilometer/cmd/agent_central.py +++ b/ceilometer/cmd/agent_central.py @@ -14,7 +14,7 @@ # License for the specific language governing permissions and limitations # under the License. -from ceilometer.central import manager +from ceilometer.agent import manager from ceilometer.openstack.common import service as os_service from ceilometer import service diff --git a/ceilometer/compute/discovery.py b/ceilometer/compute/discovery.py index 01f8f083e..05175f210 100644 --- a/ceilometer/compute/discovery.py +++ b/ceilometer/compute/discovery.py @@ -17,8 +17,8 @@ from oslo.config import cfg +from ceilometer.agent import plugin_base from ceilometer import nova_client -from ceilometer import plugin OPTS = [ cfg.BoolOpt('workload_partitioning', @@ -29,7 +29,7 @@ OPTS = [ cfg.CONF.register_opts(OPTS, group='compute') -class InstanceDiscovery(plugin.DiscoveryBase): +class InstanceDiscovery(plugin_base.DiscoveryBase): def __init__(self): super(InstanceDiscovery, self).__init__() self.nova_cli = nova_client.Client() diff --git a/ceilometer/compute/manager.py b/ceilometer/compute/manager.py index 4259ae012..cb0e73668 100644 --- a/ceilometer/compute/manager.py +++ b/ceilometer/compute/manager.py @@ -15,14 +15,14 @@ # License for the specific language governing permissions and limitations # under the License. -from ceilometer import agent +from ceilometer.agent import manager from ceilometer.compute.virt import inspector as virt_inspector from ceilometer.openstack.common import log LOG = log.getLogger(__name__) -class AgentManager(agent.AgentManager): +class AgentManager(manager.AgentManager): def __init__(self): super(AgentManager, self).__init__('compute') diff --git a/ceilometer/compute/notifications/__init__.py b/ceilometer/compute/notifications/__init__.py index ed70c7f1c..a5213043e 100644 --- a/ceilometer/compute/notifications/__init__.py +++ b/ceilometer/compute/notifications/__init__.py @@ -18,7 +18,7 @@ from oslo.config import cfg import oslo.messaging -from ceilometer import plugin +from ceilometer.agent import plugin_base OPTS = [ @@ -31,7 +31,7 @@ OPTS = [ cfg.CONF.register_opts(OPTS) -class ComputeNotificationBase(plugin.NotificationBase): +class ComputeNotificationBase(plugin_base.NotificationBase): @staticmethod def get_targets(conf): """Return a sequence of oslo.messaging.Target diff --git a/ceilometer/compute/plugin.py b/ceilometer/compute/plugin.py index c22e56103..53596e8ef 100644 --- a/ceilometer/compute/plugin.py +++ b/ceilometer/compute/plugin.py @@ -22,7 +22,7 @@ import abc from oslo.utils import timeutils import six -from ceilometer import plugin +from ceilometer.agent import plugin_base as plugin @six.add_metaclass(abc.ABCMeta) diff --git a/ceilometer/data_processing/notifications.py b/ceilometer/data_processing/notifications.py index 8a4aca269..8ec61097c 100644 --- a/ceilometer/data_processing/notifications.py +++ b/ceilometer/data_processing/notifications.py @@ -17,7 +17,7 @@ from oslo.config import cfg import oslo.messaging -from ceilometer import plugin +from ceilometer.agent import plugin_base from ceilometer import sample @@ -31,7 +31,7 @@ cfg.CONF.register_opts(OPTS) SERVICE = 'sahara' -class DataProcessing(plugin.NotificationBase): +class DataProcessing(plugin_base.NotificationBase): resource_name = '%s.cluster' % SERVICE diff --git a/ceilometer/energy/kwapi.py b/ceilometer/energy/kwapi.py index e6439c1b2..93e490e01 100644 --- a/ceilometer/energy/kwapi.py +++ b/ceilometer/energy/kwapi.py @@ -21,7 +21,7 @@ from oslo.config import cfg import requests import six -from ceilometer.central import plugin +from ceilometer.agent import plugin_base from ceilometer.i18n import _ from ceilometer.openstack.common import log from ceilometer import sample @@ -62,8 +62,8 @@ class KwapiClient(object): yield probe_dict -class _Base(plugin.CentralPollster): - """Base class for the Kwapi pollster, derived from CentralPollster.""" +class _Base(plugin_base.PollsterBase): + """Base class for the Kwapi pollster, derived from PollsterBase.""" @property def default_discovery(self): diff --git a/ceilometer/hardware/discovery.py b/ceilometer/hardware/discovery.py index 15bb17401..fa2544729 100644 --- a/ceilometer/hardware/discovery.py +++ b/ceilometer/hardware/discovery.py @@ -14,10 +14,10 @@ from oslo.config import cfg +from ceilometer.agent import plugin_base from ceilometer.i18n import _ from ceilometer import nova_client from ceilometer.openstack.common import log -from ceilometer import plugin LOG = log.getLogger(__name__) @@ -37,7 +37,7 @@ OPTS = [ cfg.CONF.register_opts(OPTS, group='hardware') -class NodesDiscoveryTripleO(plugin.DiscoveryBase): +class NodesDiscoveryTripleO(plugin_base.DiscoveryBase): def __init__(self): super(NodesDiscoveryTripleO, self).__init__() self.nova_cli = nova_client.Client() diff --git a/ceilometer/hardware/plugin.py b/ceilometer/hardware/plugin.py index 5b42ba2bc..302fbe7ac 100644 --- a/ceilometer/hardware/plugin.py +++ b/ceilometer/hardware/plugin.py @@ -25,7 +25,7 @@ import itertools from oslo.utils import netutils import six -from ceilometer.central import plugin +from ceilometer.agent import plugin_base from ceilometer.hardware import inspector as insloader from ceilometer.i18n import _ from ceilometer.openstack.common import log @@ -34,7 +34,7 @@ LOG = log.getLogger(__name__) @six.add_metaclass(abc.ABCMeta) -class HardwarePollster(plugin.CentralPollster): +class HardwarePollster(plugin_base.PollsterBase): """Base class for plugins that support the polling API.""" CACHE_KEY = None diff --git a/ceilometer/identity/notifications.py b/ceilometer/identity/notifications.py index e7159f948..1c6dad684 100644 --- a/ceilometer/identity/notifications.py +++ b/ceilometer/identity/notifications.py @@ -14,7 +14,7 @@ from oslo.config import cfg import oslo.messaging -from ceilometer import plugin +from ceilometer.agent import plugin_base from ceilometer import sample OPTS = [ @@ -29,7 +29,7 @@ cfg.CONF.register_opts(OPTS) SERVICE = 'identity' -class _Base(plugin.NotificationBase): +class _Base(plugin_base.NotificationBase): """Convert identity notification into Samples.""" resource_type = None diff --git a/ceilometer/image/glance.py b/ceilometer/image/glance.py index 6225d216d..34d2d28bb 100644 --- a/ceilometer/image/glance.py +++ b/ceilometer/image/glance.py @@ -24,7 +24,7 @@ import glanceclient from oslo.config import cfg from oslo.utils import timeutils -from ceilometer.central import plugin +from ceilometer.agent import plugin_base from ceilometer import sample @@ -49,7 +49,7 @@ cfg.CONF.register_opts(OPTS) cfg.CONF.register_opts(SERVICE_OPTS, group='service_types') -class _Base(plugin.CentralPollster): +class _Base(plugin_base.PollsterBase): @property def default_discovery(self): diff --git a/ceilometer/image/notifications.py b/ceilometer/image/notifications.py index 08efc1b7b..dce3ed208 100644 --- a/ceilometer/image/notifications.py +++ b/ceilometer/image/notifications.py @@ -21,7 +21,7 @@ from oslo.config import cfg import oslo.messaging -from ceilometer import plugin +from ceilometer.agent import plugin_base from ceilometer import sample OPTS = [ @@ -34,7 +34,7 @@ OPTS = [ cfg.CONF.register_opts(OPTS) -class ImageBase(plugin.NotificationBase): +class ImageBase(plugin_base.NotificationBase): """Base class for image counting.""" @staticmethod diff --git a/ceilometer/ipmi/manager.py b/ceilometer/ipmi/manager.py index 6fbb1ec64..8a386f797 100644 --- a/ceilometer/ipmi/manager.py +++ b/ceilometer/ipmi/manager.py @@ -14,10 +14,10 @@ # License for the specific language governing permissions and limitations # under the License. -from ceilometer import agent +from ceilometer.agent import manager -class AgentManager(agent.AgentManager): +class AgentManager(manager.AgentManager): def __init__(self): super(AgentManager, self).__init__('ipmi') diff --git a/ceilometer/ipmi/notifications/ironic.py b/ceilometer/ipmi/notifications/ironic.py index f33571469..9172c4998 100644 --- a/ceilometer/ipmi/notifications/ironic.py +++ b/ceilometer/ipmi/notifications/ironic.py @@ -21,8 +21,8 @@ notification events. from oslo.config import cfg from oslo import messaging +from ceilometer.agent import plugin_base from ceilometer.openstack.common import log -from ceilometer import plugin from ceilometer import sample LOG = log.getLogger(__name__) @@ -67,7 +67,7 @@ class InvalidSensorData(ValueError): pass -class SensorNotification(plugin.NotificationBase): +class SensorNotification(plugin_base.NotificationBase): """A generic class for extracting samples from sensor data notifications. A notification message can contain multiple samples from multiple diff --git a/ceilometer/ipmi/pollsters/node.py b/ceilometer/ipmi/pollsters/node.py index 9a2cd238e..a765d9089 100644 --- a/ceilometer/ipmi/pollsters/node.py +++ b/ceilometer/ipmi/pollsters/node.py @@ -20,8 +20,8 @@ from oslo.config import cfg from oslo.utils import timeutils import six +from ceilometer.agent import plugin_base from ceilometer.ipmi.platform import intel_node_manager as node_manager -from ceilometer import plugin from ceilometer import sample CONF = cfg.CONF @@ -29,7 +29,7 @@ CONF.import_opt('host', 'ceilometer.service') @six.add_metaclass(abc.ABCMeta) -class _Base(plugin.PollsterBase): +class _Base(plugin_base.PollsterBase): def __init__(self): self.nodemanager = node_manager.NodeManager() diff --git a/ceilometer/ipmi/pollsters/sensor.py b/ceilometer/ipmi/pollsters/sensor.py index a1a4e542d..0230a3a28 100644 --- a/ceilometer/ipmi/pollsters/sensor.py +++ b/ceilometer/ipmi/pollsters/sensor.py @@ -17,9 +17,9 @@ from oslo.config import cfg from oslo.utils import timeutils +from ceilometer.agent import plugin_base from ceilometer.ipmi.notifications import ironic as parser from ceilometer.ipmi.platform import ipmi_sensor -from ceilometer import plugin from ceilometer import sample CONF = cfg.CONF @@ -30,7 +30,7 @@ class InvalidSensorData(ValueError): pass -class SensorPollster(plugin.PollsterBase): +class SensorPollster(plugin_base.PollsterBase): METRIC = None diff --git a/ceilometer/middleware.py b/ceilometer/middleware.py index c9c369f05..21e2edaa4 100644 --- a/ceilometer/middleware.py +++ b/ceilometer/middleware.py @@ -18,7 +18,7 @@ from oslo.config import cfg import oslo.messaging -from ceilometer import plugin +from ceilometer.agent import plugin_base from ceilometer import sample cfg.CONF.import_opt('nova_control_exchange', @@ -42,7 +42,7 @@ OPTS = [ cfg.CONF.register_opts(OPTS) -class HTTPRequest(plugin.NotificationBase): +class HTTPRequest(plugin_base.NotificationBase): event_types = ['http.request'] @staticmethod diff --git a/ceilometer/network/floatingip.py b/ceilometer/network/floatingip.py index 6bfebc1f8..f16defa39 100644 --- a/ceilometer/network/floatingip.py +++ b/ceilometer/network/floatingip.py @@ -21,7 +21,7 @@ from oslo.config import cfg from oslo.utils import timeutils -from ceilometer.central import plugin +from ceilometer.agent import plugin_base from ceilometer.i18n import _ from ceilometer import nova_client from ceilometer.openstack.common import log @@ -33,7 +33,7 @@ LOG = log.getLogger(__name__) cfg.CONF.import_group('service_types', 'ceilometer.nova_client') -class FloatingIPPollster(plugin.CentralPollster): +class FloatingIPPollster(plugin_base.PollsterBase): def _get_floating_ips(self, ksclient, endpoint): nv = nova_client.Client( diff --git a/ceilometer/network/notifications.py b/ceilometer/network/notifications.py index dd8c6b900..485700b7f 100644 --- a/ceilometer/network/notifications.py +++ b/ceilometer/network/notifications.py @@ -22,9 +22,9 @@ from oslo.config import cfg import oslo.messaging +from ceilometer.agent import plugin_base from ceilometer.i18n import _ from ceilometer.openstack.common import log -from ceilometer import plugin from ceilometer import sample OPTS = [ @@ -39,7 +39,7 @@ cfg.CONF.register_opts(OPTS) LOG = log.getLogger(__name__) -class NetworkNotificationBase(plugin.NotificationBase): +class NetworkNotificationBase(plugin_base.NotificationBase): resource_name = None diff --git a/ceilometer/network/services/base.py b/ceilometer/network/services/base.py index 61ae542c8..a80f641f3 100644 --- a/ceilometer/network/services/base.py +++ b/ceilometer/network/services/base.py @@ -15,9 +15,9 @@ # License for the specific language governing permissions and limitations # under the License. +from ceilometer.agent import plugin_base from ceilometer import neutron_client from ceilometer.openstack.common import log -from ceilometer import plugin LOG = log.getLogger(__name__) @@ -30,7 +30,7 @@ STATUS = { } -class BaseServicesPollster(plugin.PollsterBase): +class BaseServicesPollster(plugin_base.PollsterBase): FIELDS = [] nc = neutron_client.Client() diff --git a/ceilometer/network/services/discovery.py b/ceilometer/network/services/discovery.py index 55df01f59..6a67c794b 100644 --- a/ceilometer/network/services/discovery.py +++ b/ceilometer/network/services/discovery.py @@ -17,15 +17,14 @@ from oslo.config import cfg -from ceilometer.central import plugin +from ceilometer.agent import plugin_base from ceilometer import neutron_client -from ceilometer import plugin as base_plugin cfg.CONF.import_group('service_types', 'ceilometer.neutron_client') -class _BaseServicesDiscovery(base_plugin.DiscoveryBase): +class _BaseServicesDiscovery(plugin_base.DiscoveryBase): def __init__(self): super(_BaseServicesDiscovery, self).__init__() @@ -33,7 +32,7 @@ class _BaseServicesDiscovery(base_plugin.DiscoveryBase): class LBPoolsDiscovery(_BaseServicesDiscovery): - @plugin.check_keystone(cfg.CONF.service_types.neutron) + @plugin_base.check_keystone(cfg.CONF.service_types.neutron) def discover(self, manager, param=None): """Discover resources to monitor.""" @@ -43,7 +42,7 @@ class LBPoolsDiscovery(_BaseServicesDiscovery): class LBVipsDiscovery(_BaseServicesDiscovery): - @plugin.check_keystone(cfg.CONF.service_types.neutron) + @plugin_base.check_keystone(cfg.CONF.service_types.neutron) def discover(self, manager, param=None): """Discover resources to monitor.""" @@ -53,7 +52,7 @@ class LBVipsDiscovery(_BaseServicesDiscovery): class LBMembersDiscovery(_BaseServicesDiscovery): - @plugin.check_keystone(cfg.CONF.service_types.neutron) + @plugin_base.check_keystone(cfg.CONF.service_types.neutron) def discover(self, manager, param=None): """Discover resources to monitor.""" @@ -63,7 +62,7 @@ class LBMembersDiscovery(_BaseServicesDiscovery): class LBHealthMonitorsDiscovery(_BaseServicesDiscovery): - @plugin.check_keystone(cfg.CONF.service_types.neutron) + @plugin_base.check_keystone(cfg.CONF.service_types.neutron) def discover(self, manager, param=None): """Discover resources to monitor.""" @@ -72,7 +71,7 @@ class LBHealthMonitorsDiscovery(_BaseServicesDiscovery): class VPNServicesDiscovery(_BaseServicesDiscovery): - @plugin.check_keystone(cfg.CONF.service_types.neutron) + @plugin_base.check_keystone(cfg.CONF.service_types.neutron) def discover(self, manager, param=None): """Discover resources to monitor.""" @@ -82,7 +81,7 @@ class VPNServicesDiscovery(_BaseServicesDiscovery): class IPSecConnectionsDiscovery(_BaseServicesDiscovery): - @plugin.check_keystone(cfg.CONF.service_types.neutron) + @plugin_base.check_keystone(cfg.CONF.service_types.neutron) def discover(self, manager, param=None): """Discover resources to monitor.""" @@ -91,7 +90,7 @@ class IPSecConnectionsDiscovery(_BaseServicesDiscovery): class FirewallDiscovery(_BaseServicesDiscovery): - @plugin.check_keystone(cfg.CONF.service_types.neutron) + @plugin_base.check_keystone(cfg.CONF.service_types.neutron) def discover(self, manager, param=None): """Discover resources to monitor.""" @@ -101,7 +100,7 @@ class FirewallDiscovery(_BaseServicesDiscovery): class FirewallPolicyDiscovery(_BaseServicesDiscovery): - @plugin.check_keystone(cfg.CONF.service_types.neutron) + @plugin_base.check_keystone(cfg.CONF.service_types.neutron) def discover(self, manager, param=None): """Discover resources to monitor.""" diff --git a/ceilometer/network/statistics/__init__.py b/ceilometer/network/statistics/__init__.py index f890a785b..86a45c52f 100644 --- a/ceilometer/network/statistics/__init__.py +++ b/ceilometer/network/statistics/__init__.py @@ -20,12 +20,12 @@ import six from six.moves.urllib import parse as urlparse from stevedore import driver as _driver -from ceilometer.central import plugin +from ceilometer.agent import plugin_base from ceilometer import sample @six.add_metaclass(abc.ABCMeta) -class _Base(plugin.CentralPollster): +class _Base(plugin_base.PollsterBase): NAMESPACE = 'network.statistics.drivers' drivers = {} diff --git a/ceilometer/objectstore/swift.py b/ceilometer/objectstore/swift.py index c16f65e8a..ee084f2b6 100644 --- a/ceilometer/objectstore/swift.py +++ b/ceilometer/objectstore/swift.py @@ -25,7 +25,7 @@ from oslo.utils import timeutils import six.moves.urllib.parse as urlparse from swiftclient import client as swift -from ceilometer.central import plugin +from ceilometer.agent import plugin_base from ceilometer.i18n import _ from ceilometer.openstack.common import log from ceilometer import sample @@ -51,7 +51,7 @@ cfg.CONF.register_opts(SERVICE_OPTS, group='service_types') cfg.CONF.import_group('service_credentials', 'ceilometer.service') -class _Base(plugin.CentralPollster): +class _Base(plugin_base.PollsterBase): METHOD = 'head' _ENDPOINT = None diff --git a/ceilometer/opts.py b/ceilometer/opts.py index ea9aa5800..fcb89ccba 100644 --- a/ceilometer/opts.py +++ b/ceilometer/opts.py @@ -13,13 +13,13 @@ # under the License. import itertools +import ceilometer.agent.manager import ceilometer.alarm.notifier.rest import ceilometer.alarm.rpc import ceilometer.alarm.service import ceilometer.api import ceilometer.api.app import ceilometer.api.controllers.v2 -import ceilometer.central.manager import ceilometer.cmd.alarm import ceilometer.collector import ceilometer.compute.discovery @@ -104,7 +104,7 @@ def list_opts(): ('api', itertools.chain(ceilometer.api.OPTS, ceilometer.api.app.API_OPTS,)), - ('central', ceilometer.central.manager.OPTS), + ('central', ceilometer.agent.manager.OPTS), ('collector', ceilometer.collector.OPTS), ('compute', ceilometer.compute.discovery.OPTS), ('coordination', ceilometer.coordination.OPTS), diff --git a/ceilometer/orchestration/notifications.py b/ceilometer/orchestration/notifications.py index 77603400d..4bd780524 100644 --- a/ceilometer/orchestration/notifications.py +++ b/ceilometer/orchestration/notifications.py @@ -18,7 +18,7 @@ from oslo.config import cfg import oslo.messaging -from ceilometer import plugin +from ceilometer.agent import plugin_base from ceilometer import sample @@ -32,7 +32,7 @@ cfg.CONF.register_opts(OPTS) SERVICE = 'orchestration' -class StackCRUD(plugin.NotificationBase): +class StackCRUD(plugin_base.NotificationBase): resource_name = '%s.stack' % SERVICE diff --git a/ceilometer/profiler/notifications.py b/ceilometer/profiler/notifications.py index ee4363a1b..b3696208a 100644 --- a/ceilometer/profiler/notifications.py +++ b/ceilometer/profiler/notifications.py @@ -16,7 +16,7 @@ from oslo.config import cfg import oslo.messaging -from ceilometer import plugin +from ceilometer.agent import plugin_base from ceilometer import sample @@ -32,7 +32,7 @@ cfg.CONF.import_opt('keystone_control_exchange', 'ceilometer.identity.notifications') -class ProfilerNotifications(plugin.NotificationBase): +class ProfilerNotifications(plugin_base.NotificationBase): event_types = ["profiler.*"] diff --git a/ceilometer/tests/agent/__init__.py b/ceilometer/tests/agent/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/ceilometer/tests/agentbase.py b/ceilometer/tests/agent/agentbase.py similarity index 97% rename from ceilometer/tests/agentbase.py rename to ceilometer/tests/agent/agentbase.py index a95954503..0fc491df5 100644 --- a/ceilometer/tests/agentbase.py +++ b/ceilometer/tests/agent/agentbase.py @@ -31,8 +31,8 @@ from oslotest import mockpatch import six from stevedore import extension +from ceilometer.agent import plugin_base from ceilometer import pipeline -from ceilometer import plugin from ceilometer import publisher from ceilometer.publisher import test as test_publisher from ceilometer import sample @@ -70,7 +70,7 @@ default_test_data = TestSample( ) -class TestPollster(plugin.PollsterBase): +class TestPollster(plugin_base.PollsterBase): test_data = default_test_data discovery = None @@ -95,13 +95,13 @@ class TestPollsterException(TestPollster): raise Exception() -class TestDiscovery(plugin.DiscoveryBase): +class TestDiscovery(plugin_base.DiscoveryBase): def discover(self, manager, param=None): self.params.append(param) return self.resources -class TestDiscoveryException(plugin.DiscoveryBase): +class TestDiscoveryException(plugin_base.DiscoveryBase): def discover(self, manager, param=None): self.params.append(param) raise Exception() @@ -310,7 +310,7 @@ class BaseAgentManagerTestCase(base.BaseTestCase): def test_setup_polling_tasks(self): polling_tasks = self.mgr.setup_polling_tasks() self.assertEqual(1, len(polling_tasks)) - self.assertIn(60, polling_tasks.keys()) + self.assertTrue(60 in polling_tasks.keys()) per_task_resources = polling_tasks[60].resources self.assertEqual(1, len(per_task_resources)) self.assertEqual(set(self.pipeline_cfg[0]['resources']), @@ -332,8 +332,8 @@ class BaseAgentManagerTestCase(base.BaseTestCase): self.setup_pipeline() polling_tasks = self.mgr.setup_polling_tasks() self.assertEqual(2, len(polling_tasks)) - self.assertIn(60, polling_tasks.keys()) - self.assertIn(10, polling_tasks.keys()) + self.assertTrue(60 in polling_tasks.keys()) + self.assertTrue(10 in polling_tasks.keys()) def test_setup_polling_tasks_mismatch_counter(self): self.pipeline_cfg.append( @@ -347,7 +347,7 @@ class BaseAgentManagerTestCase(base.BaseTestCase): }) polling_tasks = self.mgr.setup_polling_tasks() self.assertEqual(1, len(polling_tasks)) - self.assertIn(60, polling_tasks.keys()) + self.assertTrue(60 in polling_tasks.keys()) def test_setup_polling_task_same_interval(self): self.pipeline_cfg.append({ @@ -529,7 +529,7 @@ class BaseAgentManagerTestCase(base.BaseTestCase): self.setup_pipeline() polling_tasks = self.mgr.setup_polling_tasks() self.assertEqual(1, len(polling_tasks)) - self.assertIn(60, polling_tasks.keys()) + self.assertTrue(60 in polling_tasks.keys()) self.mgr.interval_task(polling_tasks.get(60)) self.assertEqual([None], self.Discovery.params) self.assertEqual([None], self.DiscoveryAnother.params) @@ -553,11 +553,11 @@ class BaseAgentManagerTestCase(base.BaseTestCase): published = pipe_line.publishers[0].samples[0] published_resources = published.resource_metadata['resources'] self.assertEqual(3, len(published_resources)) - self.assertIn(published_resources[0], expected_pipelines) + self.assertTrue(published_resources[0] in expected_pipelines) self.assertEqual(expected_pipelines[published_resources[0]], pipe_line.name) for published_resource in published_resources: - self.assertIn(published_resource, all_resources) + self.assertTrue(published_resource in all_resources) sunk_resources.extend(published_resources) self.assertEqual(all_resources, set(sunk_resources)) @@ -585,7 +585,7 @@ class BaseAgentManagerTestCase(base.BaseTestCase): self.setup_pipeline() polling_tasks = self.mgr.setup_polling_tasks() self.assertEqual(1, len(polling_tasks)) - self.assertIn(60, polling_tasks.keys()) + self.assertTrue(60 in polling_tasks.keys()) self.mgr.interval_task(polling_tasks.get(60)) self.assertEqual(1, len(self.Pollster.samples)) self.assertEqual(['discovered_1', 'discovered_2'], @@ -612,7 +612,7 @@ class BaseAgentManagerTestCase(base.BaseTestCase): self.setup_pipeline() polling_tasks = self.mgr.setup_polling_tasks() self.assertEqual(1, len(polling_tasks)) - self.assertIn(60, polling_tasks.keys()) + self.assertTrue(60 in polling_tasks.keys()) self.mgr.interval_task(polling_tasks.get(60)) self.assertEqual(1, len(self.Pollster.samples)) self.assertEqual(['discovered_1', 'discovered_2'], @@ -681,7 +681,7 @@ class BaseAgentManagerTestCase(base.BaseTestCase): polling_task = self.mgr.setup_polling_tasks().values()[0] pollster = list(polling_task.pollster_matches['test_pipeline'])[0] LOG = mock.MagicMock() - with mock.patch('ceilometer.agent.LOG', LOG): + with mock.patch('ceilometer.agent.base.LOG', LOG): polling_task.poll_and_publish() if not self.mgr.discover(): LOG.info.assert_called_with('Skip polling pollster %s, no ' diff --git a/ceilometer/tests/central/test_discovery.py b/ceilometer/tests/agent/test_discovery.py similarity index 92% rename from ceilometer/tests/central/test_discovery.py rename to ceilometer/tests/agent/test_discovery.py index eac489b5a..e28caadda 100644 --- a/ceilometer/tests/central/test_discovery.py +++ b/ceilometer/tests/agent/test_discovery.py @@ -21,14 +21,14 @@ import mock from oslo.config import fixture as fixture_config from oslotest import base -from ceilometer.central import discovery +from ceilometer.agent.discovery import endpoint class TestEndpointDiscovery(base.BaseTestCase): def setUp(self): super(TestEndpointDiscovery, self).setUp() - self.discovery = discovery.EndpointDiscovery() + self.discovery = endpoint.EndpointDiscovery() self.manager = mock.MagicMock() self.CONF = self.useFixture(fixture_config.Config()).conf diff --git a/ceilometer/tests/central/test_manager.py b/ceilometer/tests/agent/test_manager.py similarity index 90% rename from ceilometer/tests/central/test_manager.py rename to ceilometer/tests/agent/test_manager.py index 10cf72778..212818bbf 100644 --- a/ceilometer/tests/central/test_manager.py +++ b/ceilometer/tests/agent/test_manager.py @@ -22,10 +22,10 @@ from oslotest import base from oslotest import mockpatch from stevedore import extension -from ceilometer.central import manager -from ceilometer.central import plugin +from ceilometer.agent import manager +from ceilometer.agent import plugin_base from ceilometer import pipeline -from ceilometer.tests import agentbase +from ceilometer.tests.agent import agentbase class TestManager(base.BaseTestCase): @@ -37,7 +37,7 @@ class TestManager(base.BaseTestCase): class TestPollsterKeystone(agentbase.TestPollster): - @plugin.check_keystone + @plugin_base.check_keystone def get_samples(self, manager, cache, resources): func = super(TestPollsterKeystone, self).get_samples return func(manager=manager, @@ -111,3 +111,8 @@ class TestRunTasks(agentbase.BaseAgentManagerTestCase): polling_tasks = self.mgr.setup_polling_tasks() self.mgr.interval_task(polling_tasks.values()[0]) self.assertFalse(self.PollsterKeystone.samples) + + def test_interval_exception_isolation(self): + super(TestRunTasks, self).test_interval_exception_isolation() + self.assertEqual(1, len(self.PollsterException.samples)) + self.assertEqual(1, len(self.PollsterExceptionAnother.samples)) diff --git a/ceilometer/tests/test_plugin.py b/ceilometer/tests/agent/test_plugin.py similarity index 84% rename from ceilometer/tests/test_plugin.py rename to ceilometer/tests/agent/test_plugin.py index 4ff16234f..90a135f46 100644 --- a/ceilometer/tests/test_plugin.py +++ b/ceilometer/tests/agent/test_plugin.py @@ -19,7 +19,7 @@ import mock from oslo.config import fixture as fixture_config from oslotest import base -from ceilometer import plugin +from ceilometer.agent import plugin_base TEST_NOTIFICATION = { @@ -78,29 +78,29 @@ class NotificationBaseTestCase(base.BaseTestCase): self.CONF = self.useFixture(fixture_config.Config()).conf def test_handle_event_type(self): - self.assertFalse(plugin.NotificationBase._handle_event_type( + self.assertFalse(plugin_base.NotificationBase._handle_event_type( 'compute.instance.start', ['compute'])) - self.assertFalse(plugin.NotificationBase._handle_event_type( + self.assertFalse(plugin_base.NotificationBase._handle_event_type( 'compute.instance.start', ['compute.*.foobar'])) - self.assertFalse(plugin.NotificationBase._handle_event_type( + self.assertFalse(plugin_base.NotificationBase._handle_event_type( 'compute.instance.start', ['compute.*.*.foobar'])) - self.assertTrue(plugin.NotificationBase._handle_event_type( + self.assertTrue(plugin_base.NotificationBase._handle_event_type( 'compute.instance.start', ['compute.*'])) - self.assertTrue(plugin.NotificationBase._handle_event_type( + self.assertTrue(plugin_base.NotificationBase._handle_event_type( 'compute.instance.start', ['*'])) - self.assertTrue(plugin.NotificationBase._handle_event_type( + self.assertTrue(plugin_base.NotificationBase._handle_event_type( 'compute.instance.start', ['compute.*.start'])) - self.assertTrue(plugin.NotificationBase._handle_event_type( + self.assertTrue(plugin_base.NotificationBase._handle_event_type( 'compute.instance.start', ['*.start'])) - self.assertTrue(plugin.NotificationBase._handle_event_type( + self.assertTrue(plugin_base.NotificationBase._handle_event_type( 'compute.instance.start', ['compute.*.*.foobar', 'compute.*'])) - class FakePlugin(plugin.NotificationBase): + class FakePlugin(plugin_base.NotificationBase): def get_exchange_topics(self, conf): - return [plugin.ExchangeTopics(exchange="exchange1", - topics=["t1", "t2"]), - plugin.ExchangeTopics(exchange="exchange2", - topics=['t3'])] + return [plugin_base.ExchangeTopics(exchange="exchange1", + topics=["t1", "t2"]), + plugin_base.ExchangeTopics(exchange="exchange2", + topics=['t3'])] def process_notification(self, message): return message diff --git a/ceilometer/tests/energy/test_kwapi.py b/ceilometer/tests/energy/test_kwapi.py index 4e5dd4705..d20e0d879 100644 --- a/ceilometer/tests/energy/test_kwapi.py +++ b/ceilometer/tests/energy/test_kwapi.py @@ -22,7 +22,7 @@ from oslotest import base from oslotest import mockpatch import six -from ceilometer.central import manager +from ceilometer.agent import manager from ceilometer.energy import kwapi from ceilometer.openstack.common import context diff --git a/ceilometer/tests/hardware/pollsters/base.py b/ceilometer/tests/hardware/pollsters/base.py index 2fa646356..2baa0946e 100644 --- a/ceilometer/tests/hardware/pollsters/base.py +++ b/ceilometer/tests/hardware/pollsters/base.py @@ -18,7 +18,7 @@ import fixtures import mock -from ceilometer.central import manager +from ceilometer.agent import manager from ceilometer.hardware.inspector import base as inspector_base from ceilometer.tests import base as test_base diff --git a/ceilometer/tests/image/test_glance.py b/ceilometer/tests/image/test_glance.py index f5bd398fa..5ae5f4821 100644 --- a/ceilometer/tests/image/test_glance.py +++ b/ceilometer/tests/image/test_glance.py @@ -20,7 +20,7 @@ from oslo.config import fixture as fixture_config from oslotest import base from oslotest import mockpatch -from ceilometer.central import manager +from ceilometer.agent import manager from ceilometer.image import glance from ceilometer.openstack.common import context diff --git a/ceilometer/tests/ipmi/test_manager.py b/ceilometer/tests/ipmi/test_manager.py index 795fb0eb4..5da784e80 100644 --- a/ceilometer/tests/ipmi/test_manager.py +++ b/ceilometer/tests/ipmi/test_manager.py @@ -17,11 +17,12 @@ """ from ceilometer.ipmi import manager -from ceilometer.tests import agentbase import mock from oslotest import base +from ceilometer.tests.agent import agentbase + class TestManager(base.BaseTestCase): diff --git a/ceilometer/tests/network/services/test_fwaas.py b/ceilometer/tests/network/services/test_fwaas.py index 91e56cf53..fd2b59b85 100644 --- a/ceilometer/tests/network/services/test_fwaas.py +++ b/ceilometer/tests/network/services/test_fwaas.py @@ -19,8 +19,8 @@ import mock from oslotest import base from oslotest import mockpatch -from ceilometer.central import manager -from ceilometer.central import plugin +from ceilometer.agent import manager +from ceilometer.agent import plugin_base from ceilometer.network.services import discovery from ceilometer.network.services import fwaas from ceilometer.openstack.common import context @@ -34,9 +34,9 @@ class _BaseTestFWPollster(base.BaseTestCase): self.addCleanup(mock.patch.stopall) self.context = context.get_admin_context() self.manager = manager.AgentManager() - plugin._get_keystone = mock.Mock() - plugin._get_keystone.service_catalog.get_endpoints = mock.MagicMock( - return_value={'network': mock.ANY}) + plugin_base._get_keystone = mock.Mock() + plugin_base._get_keystone.service_catalog.get_endpoints = ( + mock.MagicMock(return_value={'network': mock.ANY})) class TestFirewallPollster(_BaseTestFWPollster): diff --git a/ceilometer/tests/network/services/test_lbaas.py b/ceilometer/tests/network/services/test_lbaas.py index a76dc0fa9..e190e27c5 100644 --- a/ceilometer/tests/network/services/test_lbaas.py +++ b/ceilometer/tests/network/services/test_lbaas.py @@ -19,8 +19,8 @@ import mock from oslotest import base from oslotest import mockpatch -from ceilometer.central import manager -from ceilometer.central import plugin +from ceilometer.agent import manager +from ceilometer.agent import plugin_base from ceilometer.network.services import discovery from ceilometer.network.services import lbaas from ceilometer.openstack.common import context @@ -34,9 +34,9 @@ class _BaseTestLBPollster(base.BaseTestCase): self.addCleanup(mock.patch.stopall) self.context = context.get_admin_context() self.manager = manager.AgentManager() - plugin._get_keystone = mock.Mock() - plugin._get_keystone.service_catalog.get_endpoints = mock.MagicMock( - return_value={'network': mock.ANY}) + plugin_base._get_keystone = mock.Mock() + plugin_base._get_keystone.service_catalog.get_endpoints = ( + mock.MagicMock(return_value={'network': mock.ANY})) class TestLBPoolPollster(_BaseTestLBPollster): diff --git a/ceilometer/tests/network/services/test_vpnaas.py b/ceilometer/tests/network/services/test_vpnaas.py index 65b9f1a6f..d8cf0bc56 100644 --- a/ceilometer/tests/network/services/test_vpnaas.py +++ b/ceilometer/tests/network/services/test_vpnaas.py @@ -19,8 +19,8 @@ import mock from oslotest import base from oslotest import mockpatch -from ceilometer.central import manager -from ceilometer.central import plugin +from ceilometer.agent import manager +from ceilometer.agent import plugin_base from ceilometer.network.services import discovery from ceilometer.network.services import vpnaas from ceilometer.openstack.common import context @@ -34,9 +34,9 @@ class _BaseTestVPNPollster(base.BaseTestCase): self.addCleanup(mock.patch.stopall) self.context = context.get_admin_context() self.manager = manager.AgentManager() - plugin._get_keystone = mock.Mock() - plugin._get_keystone.service_catalog.get_endpoints = mock.MagicMock( - return_value={'network': mock.ANY}) + plugin_base._get_keystone = mock.Mock() + plugin_base._get_keystone.service_catalog.get_endpoints = ( + mock.MagicMock(return_value={'network': mock.ANY})) class TestVPNServicesPollster(_BaseTestVPNPollster): diff --git a/ceilometer/tests/network/test_floatingip.py b/ceilometer/tests/network/test_floatingip.py index 3248b1643..7cf77cdce 100644 --- a/ceilometer/tests/network/test_floatingip.py +++ b/ceilometer/tests/network/test_floatingip.py @@ -22,7 +22,7 @@ import mock from oslotest import base -from ceilometer.central import manager +from ceilometer.agent import manager from ceilometer.network import floatingip from ceilometer.openstack.common import context diff --git a/ceilometer/tests/objectstore/test_swift.py b/ceilometer/tests/objectstore/test_swift.py index 0a5ebe690..be32aabb5 100644 --- a/ceilometer/tests/objectstore/test_swift.py +++ b/ceilometer/tests/objectstore/test_swift.py @@ -25,7 +25,7 @@ from oslotest import mockpatch from swiftclient import client as swift_client import testscenarios.testcase -from ceilometer.central import manager +from ceilometer.agent import manager from ceilometer.objectstore import swift HEAD_ACCOUNTS = [('tenant-000', {'x-account-object-count': 12, diff --git a/ceilometer/volume/notifications.py b/ceilometer/volume/notifications.py index e9106bcb7..ea9638d4b 100644 --- a/ceilometer/volume/notifications.py +++ b/ceilometer/volume/notifications.py @@ -21,7 +21,7 @@ events. from oslo.config import cfg import oslo.messaging -from ceilometer import plugin +from ceilometer.agent import plugin_base from ceilometer import sample OPTS = [ @@ -34,7 +34,7 @@ OPTS = [ cfg.CONF.register_opts(OPTS) -class VolumeBase(plugin.NotificationBase): +class VolumeBase(plugin_base.NotificationBase): """Convert volume/snapshot notification into Counters.""" @staticmethod @@ -149,4 +149,4 @@ class SnapshotSize(SnapshotCRUDBase): user_id=message['payload']['user_id'], project_id=message['payload']['tenant_id'], resource_id=message['payload']['snapshot_id'], - message=message) \ No newline at end of file + message=message) diff --git a/setup.cfg b/setup.cfg index aaa61bef1..3476f6f19 100755 --- a/setup.cfg +++ b/setup.cfg @@ -93,8 +93,8 @@ ceilometer.notification = ceilometer.discover = local_instances = ceilometer.compute.discovery:InstanceDiscovery - endpoint = ceilometer.central.discovery:EndpointDiscovery - tenant = ceilometer.central.discovery:TenantDiscovery + endpoint = ceilometer.agent.discovery.endpoint:EndpointDiscovery + tenant = ceilometer.agent.discovery.tenant:TenantDiscovery lb_pools = ceilometer.network.services.discovery:LBPoolsDiscovery lb_vips = ceilometer.network.services.discovery:LBVipsDiscovery lb_members = ceilometer.network.services.discovery:LBMembersDiscovery