separate base manager from pipeline
common agent for all Change-Id: I19a83d3d0e5c91ab5cb6e792ab7389e36f8ede55
This commit is contained in:
parent
124297b283
commit
50415c0d08
151
ceilometer/agent.py
Normal file
151
ceilometer/agent.py
Normal file
@ -0,0 +1,151 @@
|
||||
#
|
||||
# Copyright 2013 Intel Corp.
|
||||
# Copyright 2014 Red Hat, Inc
|
||||
#
|
||||
# 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.
|
||||
import hashlib
|
||||
import os
|
||||
import pkg_resources
|
||||
|
||||
from oslo_log import log
|
||||
from oslo_utils import fnmatch
|
||||
import six
|
||||
import yaml
|
||||
|
||||
LOG = log.getLogger(__name__)
|
||||
|
||||
|
||||
class ConfigException(Exception):
|
||||
def __init__(self, cfg_type, message, cfg):
|
||||
self.cfg_type = cfg_type
|
||||
self.msg = message
|
||||
self.cfg = cfg
|
||||
|
||||
def __str__(self):
|
||||
return '%s %s: %s' % (self.cfg_type, self.cfg, self.msg)
|
||||
|
||||
|
||||
class SourceException(Exception):
|
||||
def __init__(self, message, cfg):
|
||||
self.msg = message
|
||||
self.cfg = cfg
|
||||
|
||||
def __str__(self):
|
||||
return 'Source definition invalid: %s (%s)' % (self.msg, self.cfg)
|
||||
|
||||
|
||||
class ConfigManagerBase(object):
|
||||
"""Base class for managing configuration file refresh"""
|
||||
|
||||
def __init__(self, conf):
|
||||
self.conf = conf
|
||||
self.cfg_loc = None
|
||||
|
||||
def load_config(self, cfg_file, fallback_cfg_prefix='pipeline/data/'):
|
||||
"""Load a configuration file and set its refresh values."""
|
||||
if os.path.exists(cfg_file):
|
||||
self.cfg_loc = cfg_file
|
||||
else:
|
||||
self.cfg_loc = self.conf.find_file(cfg_file)
|
||||
if not self.cfg_loc and fallback_cfg_prefix is not None:
|
||||
LOG.debug("No pipeline definitions configuration file found! "
|
||||
"Using default config.")
|
||||
self.cfg_loc = pkg_resources.resource_filename(
|
||||
__name__, fallback_cfg_prefix + cfg_file)
|
||||
with open(self.cfg_loc) as fap:
|
||||
data = fap.read()
|
||||
conf = yaml.safe_load(data)
|
||||
self.cfg_mtime = self.get_cfg_mtime()
|
||||
self.cfg_hash = self.get_cfg_hash()
|
||||
LOG.info("Config file: %s", conf)
|
||||
return conf
|
||||
|
||||
def get_cfg_mtime(self):
|
||||
"""Return modification time of cfg file"""
|
||||
return os.path.getmtime(self.cfg_loc) if self.cfg_loc else None
|
||||
|
||||
def get_cfg_hash(self):
|
||||
"""Return hash of configuration file"""
|
||||
if not self.cfg_loc:
|
||||
return None
|
||||
|
||||
with open(self.cfg_loc) as fap:
|
||||
data = fap.read()
|
||||
if six.PY3:
|
||||
data = data.encode('utf-8')
|
||||
|
||||
file_hash = hashlib.md5(data).hexdigest()
|
||||
return file_hash
|
||||
|
||||
def cfg_changed(self):
|
||||
"""Returns hash of changed cfg else False."""
|
||||
mtime = self.get_cfg_mtime()
|
||||
if mtime > self.cfg_mtime:
|
||||
LOG.info('Configuration file has been updated.')
|
||||
self.cfg_mtime = mtime
|
||||
_hash = self.get_cfg_hash()
|
||||
if _hash != self.cfg_hash:
|
||||
LOG.info("Detected change in configuration.")
|
||||
return _hash
|
||||
return False
|
||||
|
||||
|
||||
class Source(object):
|
||||
"""Represents a generic source"""
|
||||
|
||||
def __init__(self, cfg):
|
||||
self.cfg = cfg
|
||||
try:
|
||||
self.name = cfg['name']
|
||||
except KeyError as err:
|
||||
raise SourceException(
|
||||
"Required field %s not specified" % err.args[0], cfg)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
def check_source_filtering(self, data, d_type):
|
||||
"""Source data rules checking
|
||||
|
||||
- At least one meaningful datapoint exist
|
||||
- Included type and excluded type can't co-exist on the same pipeline
|
||||
- Included type meter and wildcard can't co-exist at same pipeline
|
||||
"""
|
||||
if not data:
|
||||
raise SourceException('No %s specified' % d_type, self.cfg)
|
||||
|
||||
if ([x for x in data if x[0] not in '!*'] and
|
||||
[x for x in data if x[0] == '!']):
|
||||
raise SourceException(
|
||||
'Both included and excluded %s specified' % d_type,
|
||||
self.cfg)
|
||||
|
||||
if '*' in data and [x for x in data if x[0] not in '!*']:
|
||||
raise SourceException(
|
||||
'Included %s specified with wildcard' % d_type,
|
||||
self.cfg)
|
||||
|
||||
@staticmethod
|
||||
def is_supported(dataset, data_name):
|
||||
# Support wildcard like storage.* and !disk.*
|
||||
# Start with negation, we consider that the order is deny, allow
|
||||
if any(fnmatch.fnmatch(data_name, datapoint[1:])
|
||||
for datapoint in dataset if datapoint[0] == '!'):
|
||||
return False
|
||||
|
||||
if any(fnmatch.fnmatch(data_name, datapoint)
|
||||
for datapoint in dataset if datapoint[0] != '!'):
|
||||
return True
|
||||
|
||||
# if we only have negation, we suppose the default is allow
|
||||
return all(datapoint.startswith('!') for datapoint in dataset)
|
@ -19,7 +19,7 @@ from cotyledon import oslo_config_glue
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log
|
||||
|
||||
from ceilometer.agent import manager
|
||||
from ceilometer.polling import manager
|
||||
from ceilometer import service
|
||||
|
||||
LOG = log.getLogger(__name__)
|
||||
|
@ -30,9 +30,9 @@ try:
|
||||
except ImportError:
|
||||
libvirt = None
|
||||
|
||||
from ceilometer.agent import plugin_base
|
||||
from ceilometer.compute.virt.libvirt import utils as libvirt_utils
|
||||
from ceilometer import nova_client
|
||||
from ceilometer.polling import plugin_base
|
||||
|
||||
OPTS = [
|
||||
cfg.StrOpt('instance_discovery_method',
|
||||
|
@ -19,9 +19,9 @@ from oslo_log import log
|
||||
from oslo_utils import timeutils
|
||||
|
||||
import ceilometer
|
||||
from ceilometer.agent import plugin_base
|
||||
from ceilometer.compute.pollsters import util
|
||||
from ceilometer.compute.virt import inspector as virt_inspector
|
||||
from ceilometer.polling import plugin_base
|
||||
from ceilometer import sample
|
||||
|
||||
LOG = log.getLogger(__name__)
|
||||
|
@ -16,9 +16,8 @@ from oslo_config import cfg
|
||||
from oslo_log import log
|
||||
from oslo_utils import timeutils
|
||||
|
||||
from ceilometer.agent import plugin_base
|
||||
from ceilometer import nova_client
|
||||
|
||||
from ceilometer.polling import plugin_base
|
||||
|
||||
LOG = log.getLogger(__name__)
|
||||
|
||||
|
@ -21,11 +21,11 @@ from oslo_log import log
|
||||
from oslo_utils import netutils
|
||||
import six
|
||||
|
||||
from ceilometer.agent import plugin_base
|
||||
from ceilometer import declarative
|
||||
from ceilometer.hardware import inspector as insloader
|
||||
from ceilometer.hardware.pollsters import util
|
||||
from ceilometer.i18n import _
|
||||
from ceilometer.polling import plugin_base
|
||||
from ceilometer import sample
|
||||
|
||||
OPTS = [
|
||||
|
@ -14,8 +14,8 @@
|
||||
import glanceclient
|
||||
from oslo_config import cfg
|
||||
|
||||
from ceilometer.agent import plugin_base
|
||||
from ceilometer import keystone_client
|
||||
from ceilometer.polling import plugin_base
|
||||
|
||||
SERVICE_OPTS = [
|
||||
cfg.StrOpt('glance',
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
from ceilometer.agent import plugin_base
|
||||
from ceilometer.polling import plugin_base
|
||||
from ceilometer import sample
|
||||
|
||||
|
||||
|
@ -17,10 +17,10 @@ import abc
|
||||
from oslo_log import log
|
||||
import six
|
||||
|
||||
from ceilometer.agent import plugin_base
|
||||
from ceilometer.i18n import _
|
||||
from ceilometer.ipmi.platform import exception as nmexcept
|
||||
from ceilometer.ipmi.platform import intel_node_manager as node_manager
|
||||
from ceilometer.polling import plugin_base
|
||||
from ceilometer import sample
|
||||
|
||||
LOG = log.getLogger(__name__)
|
||||
|
@ -14,11 +14,11 @@
|
||||
|
||||
from oslo_log import log
|
||||
|
||||
from ceilometer.agent import plugin_base
|
||||
from ceilometer.i18n import _
|
||||
from ceilometer.ipmi.notifications import ironic as parser
|
||||
from ceilometer.ipmi.platform import exception as ipmiexcept
|
||||
from ceilometer.ipmi.platform import ipmi_sensor
|
||||
from ceilometer.polling import plugin_base
|
||||
from ceilometer import sample
|
||||
|
||||
LOG = log.getLogger(__name__)
|
||||
|
@ -13,7 +13,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from ceilometer.agent import plugin_base
|
||||
from ceilometer.polling import plugin_base
|
||||
|
||||
|
||||
# status map for converting metric status to volume int
|
||||
|
@ -13,8 +13,8 @@
|
||||
# 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.polling import plugin_base
|
||||
|
||||
|
||||
class _BaseServicesDiscovery(plugin_base.DiscoveryBase):
|
||||
|
@ -20,7 +20,7 @@ import six
|
||||
from six.moves.urllib import parse as urlparse
|
||||
from stevedore import driver as _driver
|
||||
|
||||
from ceilometer.agent import plugin_base
|
||||
from ceilometer.polling import plugin_base
|
||||
from ceilometer import sample
|
||||
|
||||
|
||||
|
@ -20,8 +20,8 @@ from oslo_config import cfg
|
||||
from oslo_log import log
|
||||
import six.moves.urllib.parse as urlparse
|
||||
|
||||
from ceilometer.agent import plugin_base
|
||||
from ceilometer import keystone_client
|
||||
from ceilometer.polling import plugin_base
|
||||
from ceilometer import sample
|
||||
|
||||
LOG = log.getLogger(__name__)
|
||||
|
@ -24,8 +24,8 @@ import six.moves.urllib.parse as urlparse
|
||||
from swiftclient import client as swift
|
||||
from swiftclient.exceptions import ClientException
|
||||
|
||||
from ceilometer.agent import plugin_base
|
||||
from ceilometer import keystone_client
|
||||
from ceilometer.polling import plugin_base
|
||||
from ceilometer import sample
|
||||
|
||||
|
||||
|
@ -17,7 +17,6 @@ import socket
|
||||
from keystoneauth1 import loading
|
||||
from oslo_config import cfg
|
||||
|
||||
import ceilometer.agent.manager
|
||||
import ceilometer.compute.discovery
|
||||
import ceilometer.compute.virt.inspector
|
||||
import ceilometer.compute.virt.libvirt.utils
|
||||
@ -38,6 +37,7 @@ import ceilometer.nova_client
|
||||
import ceilometer.objectstore.rgw
|
||||
import ceilometer.objectstore.swift
|
||||
import ceilometer.pipeline
|
||||
import ceilometer.polling.manager
|
||||
import ceilometer.publisher.messaging
|
||||
import ceilometer.publisher.utils
|
||||
import ceilometer.sample
|
||||
@ -70,7 +70,7 @@ def list_opts():
|
||||
# This have been removed due to a recursive import issue
|
||||
return [
|
||||
('DEFAULT',
|
||||
itertools.chain(ceilometer.agent.manager.OPTS,
|
||||
itertools.chain(ceilometer.polling.manager.OPTS,
|
||||
ceilometer.compute.virt.inspector.OPTS,
|
||||
ceilometer.compute.virt.libvirt.utils.OPTS,
|
||||
ceilometer.objectstore.swift.OPTS,
|
||||
@ -126,7 +126,7 @@ def list_opts():
|
||||
('notification',
|
||||
itertools.chain(ceilometer.notification.OPTS,
|
||||
ceilometer.notification.EXCHANGES_OPTS)),
|
||||
('polling', ceilometer.agent.manager.POLLING_OPTS),
|
||||
('polling', ceilometer.polling.manager.POLLING_OPTS),
|
||||
('publisher', ceilometer.publisher.utils.OPTS),
|
||||
('publisher_notifier', ceilometer.publisher.messaging.NOTIFIER_OPTS),
|
||||
('rgw_admin_credentials', ceilometer.objectstore.rgw.CREDENTIAL_OPTS),
|
||||
|
@ -15,21 +15,17 @@
|
||||
# under the License.
|
||||
|
||||
import abc
|
||||
import hashlib
|
||||
from itertools import chain
|
||||
from operator import methodcaller
|
||||
import os
|
||||
import pkg_resources
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log
|
||||
import oslo_messaging
|
||||
from oslo_utils import fnmatch
|
||||
from oslo_utils import timeutils
|
||||
import six
|
||||
from stevedore import extension
|
||||
import yaml
|
||||
|
||||
from ceilometer import agent
|
||||
from ceilometer.event import models
|
||||
from ceilometer import publisher
|
||||
from ceilometer.publisher import utils as publisher_utils
|
||||
@ -50,22 +46,12 @@ OPTS = [
|
||||
LOG = log.getLogger(__name__)
|
||||
|
||||
|
||||
class ConfigException(Exception):
|
||||
def __init__(self, cfg_type, message, cfg):
|
||||
self.cfg_type = cfg_type
|
||||
self.msg = message
|
||||
self.cfg = cfg
|
||||
|
||||
def __str__(self):
|
||||
return '%s %s: %s' % (self.cfg_type, self.cfg, self.msg)
|
||||
|
||||
|
||||
class PollingException(ConfigException):
|
||||
class PollingException(agent.ConfigException):
|
||||
def __init__(self, message, cfg):
|
||||
super(PollingException, self).__init__('Polling', message, cfg)
|
||||
|
||||
|
||||
class PipelineException(ConfigException):
|
||||
class PipelineException(agent.ConfigException):
|
||||
def __init__(self, message, cfg):
|
||||
super(PipelineException, self).__init__('Pipeline', message, cfg)
|
||||
|
||||
@ -219,62 +205,14 @@ class PublishContext(object):
|
||||
p.flush()
|
||||
|
||||
|
||||
class Source(object):
|
||||
"""Represents a generic source"""
|
||||
|
||||
def __init__(self, cfg):
|
||||
self.cfg = cfg
|
||||
try:
|
||||
self.name = cfg['name']
|
||||
except KeyError as err:
|
||||
raise PipelineException(
|
||||
"Required field %s not specified" % err.args[0], cfg)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
def check_source_filtering(self, data, d_type):
|
||||
"""Source data rules checking
|
||||
|
||||
- At least one meaningful datapoint exist
|
||||
- Included type and excluded type can't co-exist on the same pipeline
|
||||
- Included type meter and wildcard can't co-exist at same pipeline
|
||||
"""
|
||||
if not data:
|
||||
raise PipelineException('No %s specified' % d_type, self.cfg)
|
||||
|
||||
if ([x for x in data if x[0] not in '!*'] and
|
||||
[x for x in data if x[0] == '!']):
|
||||
raise PipelineException(
|
||||
'Both included and excluded %s specified' % d_type,
|
||||
cfg)
|
||||
|
||||
if '*' in data and [x for x in data if x[0] not in '!*']:
|
||||
raise PipelineException(
|
||||
'Included %s specified with wildcard' % d_type,
|
||||
self.cfg)
|
||||
|
||||
@staticmethod
|
||||
def is_supported(dataset, data_name):
|
||||
# Support wildcard like storage.* and !disk.*
|
||||
# Start with negation, we consider that the order is deny, allow
|
||||
if any(fnmatch.fnmatch(data_name, datapoint[1:])
|
||||
for datapoint in dataset if datapoint[0] == '!'):
|
||||
return False
|
||||
|
||||
if any(fnmatch.fnmatch(data_name, datapoint)
|
||||
for datapoint in dataset if datapoint[0] != '!'):
|
||||
return True
|
||||
|
||||
# if we only have negation, we suppose the default is allow
|
||||
return all(datapoint.startswith('!') for datapoint in dataset)
|
||||
|
||||
|
||||
class PipelineSource(Source):
|
||||
class PipelineSource(agent.Source):
|
||||
"""Represents a source of samples or events."""
|
||||
|
||||
def __init__(self, cfg):
|
||||
super(PipelineSource, self).__init__(cfg)
|
||||
try:
|
||||
super(PipelineSource, self).__init__(cfg)
|
||||
except agent.SourceException as err:
|
||||
raise PipelineException(err.msg, cfg)
|
||||
try:
|
||||
self.sinks = cfg['sinks']
|
||||
except KeyError as err:
|
||||
@ -303,7 +241,10 @@ class EventSource(PipelineSource):
|
||||
def __init__(self, cfg):
|
||||
super(EventSource, self).__init__(cfg)
|
||||
self.events = cfg.get('events')
|
||||
self.check_source_filtering(self.events, 'events')
|
||||
try:
|
||||
self.check_source_filtering(self.events, 'events')
|
||||
except agent.SourceException as err:
|
||||
raise PipelineException(err.msg, cfg)
|
||||
|
||||
def support_event(self, event_name):
|
||||
return self.is_supported(self.events, event_name)
|
||||
@ -323,13 +264,16 @@ class SampleSource(PipelineSource):
|
||||
self.meters = cfg['meters']
|
||||
except KeyError:
|
||||
raise PipelineException("Missing meters value", cfg)
|
||||
self.check_source_filtering(self.meters, 'meters')
|
||||
try:
|
||||
self.check_source_filtering(self.meters, 'meters')
|
||||
except agent.SourceException as err:
|
||||
raise PipelineException(err.msg, cfg)
|
||||
|
||||
def support_meter(self, meter_name):
|
||||
return self.is_supported(self.meters, meter_name)
|
||||
|
||||
|
||||
class PollingSource(Source):
|
||||
class PollingSource(agent.Source):
|
||||
"""Represents a source of pollsters
|
||||
|
||||
In effect it is a set of pollsters emitting
|
||||
@ -339,7 +283,10 @@ class PollingSource(Source):
|
||||
"""
|
||||
|
||||
def __init__(self, cfg):
|
||||
super(PollingSource, self).__init__(cfg)
|
||||
try:
|
||||
super(PollingSource, self).__init__(cfg)
|
||||
except agent.SourceException as err:
|
||||
raise PipelineException(err.msg, cfg)
|
||||
try:
|
||||
self.meters = cfg['meters']
|
||||
except KeyError:
|
||||
@ -360,7 +307,10 @@ class PollingSource(Source):
|
||||
self.discovery = cfg.get('discovery') or []
|
||||
if not isinstance(self.discovery, list):
|
||||
raise PipelineException("Discovery should be a list", cfg)
|
||||
self.check_source_filtering(self.meters, 'meters')
|
||||
try:
|
||||
self.check_source_filtering(self.meters, 'meters')
|
||||
except agent.SourceException as err:
|
||||
raise PipelineException(err.msg, cfg)
|
||||
|
||||
def get_interval(self):
|
||||
return self.interval
|
||||
@ -644,62 +594,6 @@ EVENT_TYPE = {'name': 'event',
|
||||
'sink': EventSink}
|
||||
|
||||
|
||||
class ConfigManagerBase(object):
|
||||
"""Base class for managing configuration file refresh"""
|
||||
|
||||
def __init__(self, conf):
|
||||
self.conf = conf
|
||||
self.cfg_loc = None
|
||||
|
||||
def load_config(self, cfg_file, fallback_cfg_prefix='data/'):
|
||||
"""Load a configuration file and set its refresh values."""
|
||||
if os.path.exists(cfg_file):
|
||||
self.cfg_loc = cfg_file
|
||||
else:
|
||||
self.cfg_loc = self.conf.find_file(cfg_file)
|
||||
if not self.cfg_loc and fallback_cfg_prefix is not None:
|
||||
LOG.debug("No pipeline definitions configuration file found! "
|
||||
"Using default config.")
|
||||
self.cfg_loc = pkg_resources.resource_filename(
|
||||
__name__, fallback_cfg_prefix + cfg_file)
|
||||
with open(self.cfg_loc) as fap:
|
||||
data = fap.read()
|
||||
conf = yaml.safe_load(data)
|
||||
self.cfg_mtime = self.get_cfg_mtime()
|
||||
self.cfg_hash = self.get_cfg_hash()
|
||||
LOG.info("Config file: %s", conf)
|
||||
return conf
|
||||
|
||||
def get_cfg_mtime(self):
|
||||
"""Return modification time of cfg file"""
|
||||
return os.path.getmtime(self.cfg_loc) if self.cfg_loc else None
|
||||
|
||||
def get_cfg_hash(self):
|
||||
"""Return hash of configuration file"""
|
||||
if not self.cfg_loc:
|
||||
return None
|
||||
|
||||
with open(self.cfg_loc) as fap:
|
||||
data = fap.read()
|
||||
if six.PY3:
|
||||
data = data.encode('utf-8')
|
||||
|
||||
file_hash = hashlib.md5(data).hexdigest()
|
||||
return file_hash
|
||||
|
||||
def cfg_changed(self):
|
||||
"""Returns hash of changed cfg else False."""
|
||||
mtime = self.get_cfg_mtime()
|
||||
if mtime > self.cfg_mtime:
|
||||
LOG.info('Configuration file has been updated.')
|
||||
self.cfg_mtime = mtime
|
||||
_hash = self.get_cfg_hash()
|
||||
if _hash != self.cfg_hash:
|
||||
LOG.info("Detected change in configuration.")
|
||||
return _hash
|
||||
return False
|
||||
|
||||
|
||||
class PublisherManager(object):
|
||||
def __init__(self, conf, purpose):
|
||||
self._loaded_publishers = {}
|
||||
@ -715,7 +609,7 @@ class PublisherManager(object):
|
||||
return self._loaded_publishers[url]
|
||||
|
||||
|
||||
class PipelineManager(ConfigManagerBase):
|
||||
class PipelineManager(agent.ConfigManagerBase):
|
||||
"""Pipeline Manager
|
||||
|
||||
Pipeline manager sets up pipelines according to config file
|
||||
@ -831,7 +725,7 @@ class PipelineManager(ConfigManagerBase):
|
||||
return PublishContext(self.pipelines)
|
||||
|
||||
|
||||
class PollingManager(ConfigManagerBase):
|
||||
class PollingManager(agent.ConfigManagerBase):
|
||||
"""Polling Manager
|
||||
|
||||
Polling manager sets up polling according to config file.
|
||||
|
@ -14,8 +14,8 @@
|
||||
|
||||
from oslo_log import log
|
||||
|
||||
from ceilometer.agent import plugin_base as plugin
|
||||
from ceilometer import keystone_client
|
||||
from ceilometer.polling import plugin_base as plugin
|
||||
|
||||
LOG = log.getLogger(__name__)
|
||||
|
@ -12,7 +12,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from ceilometer.agent import plugin_base
|
||||
from ceilometer.polling import plugin_base
|
||||
|
||||
|
||||
class LocalNodeDiscovery(plugin_base.DiscoveryBase):
|
@ -14,7 +14,7 @@
|
||||
|
||||
from oslo_log import log
|
||||
|
||||
from ceilometer.agent import plugin_base as plugin
|
||||
from ceilometer.polling import plugin_base as plugin
|
||||
|
||||
LOG = log.getLogger(__name__)
|
||||
|
@ -33,10 +33,10 @@ from six.moves.urllib import parse as urlparse
|
||||
from stevedore import extension
|
||||
from tooz import coordination
|
||||
|
||||
from ceilometer.agent import plugin_base
|
||||
from ceilometer import keystone_client
|
||||
from ceilometer import messaging
|
||||
from ceilometer import pipeline
|
||||
from ceilometer.polling import plugin_base
|
||||
from ceilometer.publisher import utils as publisher_utils
|
||||
from ceilometer import utils
|
||||
|
@ -18,9 +18,9 @@ import time
|
||||
|
||||
import mock
|
||||
|
||||
from ceilometer.agent import manager
|
||||
from ceilometer.compute.pollsters import instance_stats
|
||||
from ceilometer.compute.virt import inspector as virt_inspector
|
||||
from ceilometer.polling import manager
|
||||
from ceilometer.tests.unit.compute.pollsters import base
|
||||
|
||||
|
||||
|
@ -16,9 +16,9 @@
|
||||
# under the License.
|
||||
import mock
|
||||
|
||||
from ceilometer.agent import manager
|
||||
from ceilometer.compute.pollsters import disk
|
||||
from ceilometer.compute.virt import inspector as virt_inspector
|
||||
from ceilometer.polling import manager
|
||||
from ceilometer.tests.unit.compute.pollsters import base
|
||||
|
||||
|
||||
|
@ -20,8 +20,8 @@ import mock
|
||||
from oslotest import base
|
||||
import six
|
||||
|
||||
from ceilometer.agent import manager
|
||||
from ceilometer.compute.pollsters import util
|
||||
from ceilometer.polling import manager
|
||||
from ceilometer import service
|
||||
|
||||
|
||||
|
@ -15,10 +15,10 @@
|
||||
|
||||
import mock
|
||||
|
||||
from ceilometer.agent import manager
|
||||
from ceilometer.agent import plugin_base
|
||||
from ceilometer.compute.pollsters import instance_stats
|
||||
from ceilometer.compute.virt import inspector as virt_inspector
|
||||
from ceilometer.polling import manager
|
||||
from ceilometer.polling import plugin_base
|
||||
from ceilometer.tests.unit.compute.pollsters import base
|
||||
|
||||
|
||||
|
@ -16,9 +16,9 @@
|
||||
|
||||
import mock
|
||||
|
||||
from ceilometer.agent import manager
|
||||
from ceilometer.compute.pollsters import net
|
||||
from ceilometer.compute.virt import inspector as virt_inspector
|
||||
from ceilometer.polling import manager
|
||||
from ceilometer.tests.unit.compute.pollsters import base
|
||||
|
||||
|
||||
|
@ -14,10 +14,10 @@
|
||||
|
||||
import mock
|
||||
|
||||
from ceilometer.agent import manager
|
||||
from ceilometer.agent import plugin_base
|
||||
from ceilometer.compute.pollsters import instance_stats
|
||||
from ceilometer.compute.virt import inspector as virt_inspector
|
||||
from ceilometer.polling import manager
|
||||
from ceilometer.polling import plugin_base
|
||||
from ceilometer.tests.unit.compute.pollsters import base
|
||||
|
||||
|
||||
|
@ -15,8 +15,8 @@
|
||||
|
||||
import mock
|
||||
|
||||
from ceilometer.agent import manager
|
||||
from ceilometer.image import glance
|
||||
from ceilometer.polling import manager
|
||||
from ceilometer import service
|
||||
import ceilometer.tests.base as base
|
||||
|
||||
|
@ -18,7 +18,7 @@ import fixtures
|
||||
import mock
|
||||
import six
|
||||
|
||||
from ceilometer.agent import manager
|
||||
from ceilometer.polling import manager
|
||||
from ceilometer import service
|
||||
from ceilometer.tests import base
|
||||
|
||||
|
@ -17,10 +17,10 @@ import fixtures
|
||||
import mock
|
||||
from oslotest import base
|
||||
|
||||
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.polling import manager
|
||||
from ceilometer.polling import plugin_base
|
||||
from ceilometer import service
|
||||
|
||||
|
||||
|
@ -17,10 +17,10 @@ import fixtures
|
||||
import mock
|
||||
from oslotest import base
|
||||
|
||||
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.polling import manager
|
||||
from ceilometer.polling import plugin_base
|
||||
from ceilometer import service
|
||||
|
||||
|
||||
|
@ -16,10 +16,10 @@ import fixtures
|
||||
import mock
|
||||
from oslotest import base
|
||||
|
||||
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.polling import manager
|
||||
from ceilometer.polling import plugin_base
|
||||
from ceilometer import service
|
||||
|
||||
|
||||
|
@ -17,10 +17,10 @@ import fixtures
|
||||
import mock
|
||||
from oslotest import base
|
||||
|
||||
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.polling import manager
|
||||
from ceilometer.polling import plugin_base
|
||||
from ceilometer import service
|
||||
|
||||
|
||||
|
@ -18,10 +18,10 @@ import fixtures
|
||||
import mock
|
||||
from oslotest import base
|
||||
|
||||
from ceilometer.agent import manager
|
||||
from ceilometer.agent import plugin_base
|
||||
from ceilometer.network import floatingip
|
||||
from ceilometer.network.services import discovery
|
||||
from ceilometer.polling import manager
|
||||
from ceilometer.polling import plugin_base
|
||||
from ceilometer import service
|
||||
|
||||
|
||||
|
@ -20,9 +20,9 @@ import mock
|
||||
from oslotest import base
|
||||
import testscenarios.testcase
|
||||
|
||||
from ceilometer.agent import manager
|
||||
from ceilometer.objectstore import rgw
|
||||
from ceilometer.objectstore import rgw_client
|
||||
from ceilometer.polling import manager
|
||||
from ceilometer import service
|
||||
|
||||
bucket_list1 = [rgw_client.RGWAdminClient.Bucket('somefoo1', 10, 7)]
|
||||
|
@ -21,8 +21,8 @@ from oslotest import base
|
||||
from swiftclient import client as swift_client
|
||||
import testscenarios.testcase
|
||||
|
||||
from ceilometer.agent import manager
|
||||
from ceilometer.objectstore import swift
|
||||
from ceilometer.polling import manager
|
||||
from ceilometer import service
|
||||
|
||||
HEAD_ACCOUNTS = [('tenant-000', {'x-account-object-count': 12,
|
||||
|
@ -24,8 +24,8 @@ import mock
|
||||
import six
|
||||
from stevedore import extension
|
||||
|
||||
from ceilometer.agent import plugin_base
|
||||
from ceilometer import pipeline
|
||||
from ceilometer.polling import plugin_base
|
||||
from ceilometer import sample
|
||||
from ceilometer import service
|
||||
from ceilometer.tests import base
|
||||
@ -589,7 +589,7 @@ class BaseAgentManagerTestCase(base.BaseTestCase):
|
||||
mock.call('static_4'),
|
||||
], any_order=True)
|
||||
|
||||
@mock.patch('ceilometer.agent.manager.LOG')
|
||||
@mock.patch('ceilometer.polling.manager.LOG')
|
||||
def test_polling_and_notify_with_resources(self, LOG):
|
||||
self.setup_polling()
|
||||
polling_task = list(self.mgr.setup_polling_tasks().values())[0]
|
||||
@ -598,7 +598,7 @@ class BaseAgentManagerTestCase(base.BaseTestCase):
|
||||
'Polling pollster %(poll)s in the context of %(src)s',
|
||||
{'poll': 'test', 'src': 'test_polling'})
|
||||
|
||||
@mock.patch('ceilometer.agent.manager.LOG')
|
||||
@mock.patch('ceilometer.polling.manager.LOG')
|
||||
def test_skip_polling_and_notify_with_no_resources(self, LOG):
|
||||
self.polling_cfg['sources'][0]['resources'] = []
|
||||
self.setup_polling()
|
||||
@ -609,7 +609,7 @@ class BaseAgentManagerTestCase(base.BaseTestCase):
|
||||
'Skip pollster %(name)s, no %(p_context)sresources found this '
|
||||
'cycle', {'name': pollster.name, 'p_context': ''})
|
||||
|
||||
@mock.patch('ceilometer.agent.manager.LOG')
|
||||
@mock.patch('ceilometer.polling.manager.LOG')
|
||||
def test_skip_polling_polled_resources(self, LOG):
|
||||
self.polling_cfg['sources'].append({
|
||||
'name': 'test_polling_1',
|
@ -18,10 +18,10 @@
|
||||
import mock
|
||||
from oslotest import base
|
||||
|
||||
from ceilometer.agent.discovery import endpoint
|
||||
from ceilometer.agent.discovery import localnode
|
||||
from ceilometer.agent.discovery import tenant as project
|
||||
from ceilometer.hardware import discovery as hardware
|
||||
from ceilometer.polling.discovery import endpoint
|
||||
from ceilometer.polling.discovery import localnode
|
||||
from ceilometer.polling.discovery import tenant as project
|
||||
from ceilometer import service
|
||||
|
||||
|
@ -21,13 +21,13 @@ from oslotest import base
|
||||
import six
|
||||
from stevedore import extension
|
||||
|
||||
from ceilometer.agent import manager
|
||||
from ceilometer.agent import plugin_base
|
||||
from ceilometer.compute import discovery as nova_discover
|
||||
from ceilometer.hardware import discovery
|
||||
from ceilometer import pipeline
|
||||
from ceilometer.polling import manager
|
||||
from ceilometer.polling import plugin_base
|
||||
from ceilometer import service
|
||||
from ceilometer.tests.unit.agent import agentbase
|
||||
from ceilometer.tests.unit.polling import agentbase
|
||||
|
||||
|
||||
def fakedelayed(delay, target, *args, **kwargs):
|
||||
@ -70,7 +70,7 @@ class TestManager(base.BaseTestCase):
|
||||
mock.Mock(side_effect=plugin_base.ExtensionLoadError))
|
||||
@mock.patch('ceilometer.ipmi.pollsters.sensor.SensorPollster.__init__',
|
||||
mock.Mock(return_value=None))
|
||||
@mock.patch('ceilometer.agent.manager.LOG')
|
||||
@mock.patch('ceilometer.polling.manager.LOG')
|
||||
def test_load_failed_plugins(self, LOG):
|
||||
# Here we additionally check that namespaces will be converted to the
|
||||
# list if param was not set as a list.
|
||||
@ -274,7 +274,7 @@ class TestRunTasks(agentbase.BaseAgentManagerTestCase):
|
||||
self.assertFalse(self.PollsterKeystone.samples)
|
||||
self.assertFalse(self.notified_samples)
|
||||
|
||||
@mock.patch('ceilometer.agent.manager.LOG')
|
||||
@mock.patch('ceilometer.polling.manager.LOG')
|
||||
@mock.patch('ceilometer.nova_client.LOG')
|
||||
def test_hardware_discover_fail_minimize_logs(self, novalog, baselog):
|
||||
class PollsterHardware(agentbase.TestPollster):
|
||||
@ -319,7 +319,7 @@ class TestRunTasks(agentbase.BaseAgentManagerTestCase):
|
||||
self.assertEqual(1, novalog.exception.call_count)
|
||||
self.assertFalse(baselog.exception.called)
|
||||
|
||||
@mock.patch('ceilometer.agent.manager.LOG')
|
||||
@mock.patch('ceilometer.polling.manager.LOG')
|
||||
def test_polling_exception(self, LOG):
|
||||
source_name = 'test_pollingexception'
|
||||
res_list = ['test://']
|
||||
@ -352,7 +352,7 @@ class TestRunTasks(agentbase.BaseAgentManagerTestCase):
|
||||
dict(name=pollster.name, res_list=str(res_list),
|
||||
source=source_name))
|
||||
|
||||
@mock.patch('ceilometer.agent.manager.LOG')
|
||||
@mock.patch('ceilometer.polling.manager.LOG')
|
||||
def test_polling_novalike_exception(self, LOG):
|
||||
source_name = 'test_pollingexception'
|
||||
self.polling_cfg = {
|
@ -13,7 +13,7 @@
|
||||
|
||||
import mock
|
||||
|
||||
from ceilometer.agent import manager
|
||||
from ceilometer.polling import manager
|
||||
from ceilometer import service
|
||||
import ceilometer.tests.base as base
|
||||
from ceilometer.volume import cinder
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
from ceilometer.agent import plugin_base
|
||||
from ceilometer.polling import plugin_base
|
||||
from ceilometer import sample
|
||||
|
||||
|
||||
|
@ -14,8 +14,8 @@
|
||||
from cinderclient import client as cinder_client
|
||||
from oslo_config import cfg
|
||||
|
||||
from ceilometer.agent import plugin_base
|
||||
from ceilometer import keystone_client
|
||||
from ceilometer.polling import plugin_base
|
||||
|
||||
SERVICE_OPTS = [
|
||||
cfg.StrOpt('cinder', deprecated_name='cinderv2',
|
||||
|
@ -52,8 +52,8 @@ ceilometer.discover.compute =
|
||||
local_instances = ceilometer.compute.discovery:InstanceDiscovery
|
||||
|
||||
ceilometer.discover.central =
|
||||
endpoint = ceilometer.agent.discovery.endpoint:EndpointDiscovery
|
||||
tenant = ceilometer.agent.discovery.tenant:TenantDiscovery
|
||||
endpoint = ceilometer.polling.discovery.endpoint:EndpointDiscovery
|
||||
tenant = ceilometer.polling.discovery.tenant:TenantDiscovery
|
||||
lb_pools = ceilometer.network.services.discovery:LBPoolsDiscovery
|
||||
lb_vips = ceilometer.network.services.discovery:LBVipsDiscovery
|
||||
lb_members = ceilometer.network.services.discovery:LBMembersDiscovery
|
||||
@ -72,7 +72,7 @@ ceilometer.discover.central =
|
||||
volume_backups = ceilometer.volume.discovery:VolumeBackupsDiscovery
|
||||
|
||||
ceilometer.discover.ipmi =
|
||||
local_node = ceilometer.agent.discovery.localnode:LocalNodeDiscovery
|
||||
local_node = ceilometer.polling.discovery.localnode:LocalNodeDiscovery
|
||||
|
||||
ceilometer.poll.compute =
|
||||
disk.read.requests = ceilometer.compute.pollsters.disk:ReadRequestsPollster
|
||||
|
Loading…
Reference in New Issue
Block a user