From c2cfd732b5576f1b263f9506dc4d238c7c7ca8ae Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Wed, 17 Jul 2013 15:53:07 +0200 Subject: [PATCH] Rename ceilometer.counter to ceilometer.sample Change-Id: Id5e943cffd59bd439c235630ca040035128a919f Blueprint: remove-counter --- bin/ceilometer-send-counter | 6 +-- ceilometer/agent.py | 2 +- ceilometer/api/controllers/v2.py | 14 +++--- ceilometer/collector/service.py | 2 +- ceilometer/compute/notifications.py | 42 ++++++++-------- ceilometer/compute/pollsters/cpu.py | 4 +- ceilometer/compute/pollsters/disk.py | 10 ++-- ceilometer/compute/pollsters/instance.py | 6 +-- ceilometer/compute/pollsters/net.py | 12 ++--- ceilometer/compute/pollsters/util.py | 4 +- ceilometer/energy/kwapi.py | 10 ++-- ceilometer/image/glance.py | 10 ++-- ceilometer/image/notifications.py | 22 ++++---- ceilometer/network/floatingip.py | 6 +-- ceilometer/network/notifications.py | 10 ++-- ceilometer/notifier.py | 4 +- ceilometer/objectstore/swift.py | 14 +++--- ceilometer/objectstore/swift_middleware.py | 16 +++--- ceilometer/{counter.py => sample.py} | 45 +++++++++-------- ceilometer/transformer/conversions.py | 6 +-- ceilometer/volume/notifications.py | 10 ++-- etc/ceilometer/ceilometer.conf.sample | 16 +++--- nova_tests/test_notifier.py | 8 +-- tests/agentbase.py | 6 +-- tests/api/v1/test_list_events_scenarios.py | 8 +-- tests/api/v1/test_list_meters_scenarios.py | 12 ++--- tests/api/v1/test_list_projects_scenarios.py | 6 +-- tests/api/v1/test_list_resources_scenarios.py | 10 ++-- tests/api/v1/test_list_users_scenarios.py | 6 +-- .../v1/test_max_project_volume_scenarios.py | 4 +- .../v1/test_max_resource_volume_scenarios.py | 4 +- .../v1/test_sum_project_volume_scenarios.py | 4 +- .../v1/test_sum_resource_volume_scenarios.py | 4 +- tests/api/v2/test_acl_scenarios.py | 6 +-- tests/api/v2/test_list_events_scenarios.py | 6 +-- tests/api/v2/test_list_meters_scenarios.py | 12 ++--- tests/api/v2/test_list_resources_scenarios.py | 36 ++++++------- tests/api/v2/test_statistics_scenarios.py | 10 ++-- tests/collector/test_service.py | 4 +- tests/compute/test_notifications.py | 4 +- tests/image/test_notifications.py | 24 ++++----- tests/publisher/test_file.py | 14 +++--- tests/publisher/test_rpc_publisher.py | 41 ++++++++------- tests/publisher/test_udp.py | 22 ++++---- tests/storage/base.py | 34 ++++++------- tests/storage/test_impl_mongodb.py | 4 +- tests/test_pipeline.py | 50 +++++++++---------- tools/make_test_data.py | 4 +- 48 files changed, 307 insertions(+), 307 deletions(-) rename ceilometer/{counter.py => sample.py} (64%) diff --git a/bin/ceilometer-send-counter b/bin/ceilometer-send-counter index e1ff8d2df..a98a90ecc 100755 --- a/bin/ceilometer-send-counter +++ b/bin/ceilometer-send-counter @@ -25,7 +25,7 @@ import sys from oslo.config import cfg -from ceilometer import counter +from ceilometer import sample from ceilometer import pipeline from ceilometer import service from ceilometer import transformer @@ -88,8 +88,8 @@ pipeline_manager = pipeline.setup_pipeline( ) with pipeline_manager.publisher(context.get_admin_context(), - cfg.CONF.counter_source) as p: - p([counter.Counter( + cfg.CONF.sample_source) as p: + p([sample.Sample( name=cfg.CONF.counter_name, type=cfg.CONF.counter_type, unit=cfg.CONF.counter_unit, diff --git a/ceilometer/agent.py b/ceilometer/agent.py index 524b6faff..6cc85cd32 100644 --- a/ceilometer/agent.py +++ b/ceilometer/agent.py @@ -40,7 +40,7 @@ class PollingTask(object): self.pollsters = set() self.publish_context = pipeline.PublishContext( agent_manager.context, - cfg.CONF.counter_source) + cfg.CONF.sample_source) def add(self, pollster, pipelines): self.publish_context.add_pipelines(pipelines) diff --git a/ceilometer/api/controllers/v2.py b/ceilometer/api/controllers/v2.py index cd2795006..3a9ef263f 100644 --- a/ceilometer/api/controllers/v2.py +++ b/ceilometer/api/controllers/v2.py @@ -41,7 +41,7 @@ from wsme import types as wtypes from ceilometer.openstack.common import context from ceilometer.openstack.common import log from ceilometer.openstack.common import timeutils -from ceilometer import counter +from ceilometer import sample from ceilometer import pipeline from ceilometer import storage from ceilometer.api import acl @@ -491,7 +491,7 @@ class MeterController(rest.RestController): def get_consistent_source(): '''Find a source that can be applied across the sample group or raise InvalidInput if the sources are inconsistent. - If all are None - use the configured counter_source + If all are None - use the configured sample_source If any sample has source set then the others must be the same or None. ''' @@ -504,7 +504,7 @@ class MeterController(rest.RestController): 'with different sources') if s.source and not source: source = s.source - return source or pecan.request.cfg.counter_source + return source or pecan.request.cfg.sample_source samples = [Sample(**b) for b in body] now = timeutils.utcnow() @@ -534,7 +534,7 @@ class MeterController(rest.RestController): source, pecan.request.pipeline_manager.pipelines, ) as publisher: - publisher([counter.Counter( + publisher([sample.Sample( name=s.counter_name, type=s.counter_type, unit=s.counter_unit, @@ -585,9 +585,9 @@ class Meter(_Base): name = wtypes.text "The unique name for the meter" - type = wtypes.Enum(str, counter.TYPE_GAUGE, - counter.TYPE_CUMULATIVE, - counter.TYPE_DELTA) + type = wtypes.Enum(str, sample.TYPE_GAUGE, + sample.TYPE_CUMULATIVE, + sample.TYPE_DELTA) "The meter type (see :ref:`measurements`)" unit = wtypes.text diff --git a/ceilometer/collector/service.py b/ceilometer/collector/service.py index f920a4f39..eea642b2e 100644 --- a/ceilometer/collector/service.py +++ b/ceilometer/collector/service.py @@ -251,7 +251,7 @@ class CollectorService(rpc_service.Service): if notification['event_type'] in handler.get_event_types(): ctxt = context.get_admin_context() with self.pipeline_manager.publisher(ctxt, - cfg.CONF.counter_source) as p: + cfg.CONF.sample_source) as p: # FIXME(dhellmann): Spawn green thread? p(list(handler.process_notification(notification))) diff --git a/ceilometer/compute/notifications.py b/ceilometer/compute/notifications.py index ed9c97662..e68168da2 100644 --- a/ceilometer/compute/notifications.py +++ b/ceilometer/compute/notifications.py @@ -22,7 +22,7 @@ from oslo.config import cfg -from ceilometer import counter +from ceilometer import sample from ceilometer import plugin @@ -56,9 +56,9 @@ class InstanceScheduled(ComputeNotificationBase): return ['scheduler.run_instance.scheduled'] def process_notification(self, message): - yield counter.Counter.from_notification( + yield sample.Sample.from_notification( name='instance.scheduled', - type=counter.TYPE_DELTA, + type=sample.TYPE_DELTA, volume=1, unit='instance', user_id=None, @@ -86,9 +86,9 @@ class ComputeInstanceNotificationBase(ComputeNotificationBase): class Instance(ComputeInstanceNotificationBase): def process_notification(self, message): - yield counter.Counter.from_notification( + yield sample.Sample.from_notification( name='instance', - type=counter.TYPE_GAUGE, + type=sample.TYPE_GAUGE, unit='instance', volume=1, user_id=message['payload']['user_id'], @@ -99,9 +99,9 @@ class Instance(ComputeInstanceNotificationBase): class Memory(ComputeInstanceNotificationBase): def process_notification(self, message): - yield counter.Counter.from_notification( + yield sample.Sample.from_notification( name='memory', - type=counter.TYPE_GAUGE, + type=sample.TYPE_GAUGE, unit='MB', volume=message['payload']['memory_mb'], user_id=message['payload']['user_id'], @@ -112,9 +112,9 @@ class Memory(ComputeInstanceNotificationBase): class VCpus(ComputeInstanceNotificationBase): def process_notification(self, message): - yield counter.Counter.from_notification( + yield sample.Sample.from_notification( name='vcpus', - type=counter.TYPE_GAUGE, + type=sample.TYPE_GAUGE, unit='vcpu', volume=message['payload']['vcpus'], user_id=message['payload']['user_id'], @@ -125,9 +125,9 @@ class VCpus(ComputeInstanceNotificationBase): class RootDiskSize(ComputeInstanceNotificationBase): def process_notification(self, message): - yield counter.Counter.from_notification( + yield sample.Sample.from_notification( name='disk.root.size', - type=counter.TYPE_GAUGE, + type=sample.TYPE_GAUGE, unit='GB', volume=message['payload']['root_gb'], user_id=message['payload']['user_id'], @@ -138,9 +138,9 @@ class RootDiskSize(ComputeInstanceNotificationBase): class EphemeralDiskSize(ComputeInstanceNotificationBase): def process_notification(self, message): - yield counter.Counter.from_notification( + yield sample.Sample.from_notification( name='disk.ephemeral.size', - type=counter.TYPE_GAUGE, + type=sample.TYPE_GAUGE, unit='GB', volume=message['payload']['ephemeral_gb'], user_id=message['payload']['user_id'], @@ -153,9 +153,9 @@ class InstanceFlavor(ComputeInstanceNotificationBase): def process_notification(self, message): instance_type = message.get('payload', {}).get('instance_type') if instance_type: - yield counter.Counter.from_notification( + yield sample.Sample.from_notification( name='instance:%s' % instance_type, - type=counter.TYPE_GAUGE, + type=sample.TYPE_GAUGE, unit='instance', volume=1, user_id=message['payload']['user_id'], @@ -174,12 +174,12 @@ class InstanceDelete(ComputeInstanceNotificationBase): return ['compute.instance.delete.samples'] def process_notification(self, message): - for sample in message['payload'].get('samples', []): - yield counter.Counter.from_notification( - name=sample['name'], - type=sample['type'], - unit=sample['unit'], - volume=sample['volume'], + for s in message['payload'].get('samples', []): + yield sample.Sample.from_notification( + name=s['name'], + type=s['type'], + unit=s['unit'], + volume=s['volume'], user_id=message['payload']['user_id'], project_id=message['payload']['tenant_id'], resource_id=message['payload']['instance_id'], diff --git a/ceilometer/compute/pollsters/cpu.py b/ceilometer/compute/pollsters/cpu.py index 2e980c4a9..887fc73aa 100644 --- a/ceilometer/compute/pollsters/cpu.py +++ b/ceilometer/compute/pollsters/cpu.py @@ -18,7 +18,7 @@ # License for the specific language governing permissions and limitations # under the License. -from ceilometer import counter +from ceilometer import sample from ceilometer.compute import plugin from ceilometer.compute.pollsters import util from ceilometer.openstack.common import log @@ -39,7 +39,7 @@ class CPUPollster(plugin.ComputePollster): yield util.make_counter_from_instance( instance, name='cpu', - type=counter.TYPE_CUMULATIVE, + type=sample.TYPE_CUMULATIVE, unit='ns', volume=cpu_info.time, additional_metadata=cpu_num, diff --git a/ceilometer/compute/pollsters/disk.py b/ceilometer/compute/pollsters/disk.py index 1bf1bbf25..2417400c1 100644 --- a/ceilometer/compute/pollsters/disk.py +++ b/ceilometer/compute/pollsters/disk.py @@ -21,7 +21,7 @@ import abc import collections -from ceilometer import counter +from ceilometer import sample from ceilometer.compute import plugin from ceilometer.compute.pollsters import util from ceilometer.openstack.common import log @@ -99,7 +99,7 @@ class ReadRequestsPollster(_Base): return util.make_counter_from_instance( instance, name='disk.read.requests', - type=counter.TYPE_CUMULATIVE, + type=sample.TYPE_CUMULATIVE, unit='request', volume=c_data.r_requests, ) @@ -112,7 +112,7 @@ class ReadBytesPollster(_Base): return util.make_counter_from_instance( instance, name='disk.read.bytes', - type=counter.TYPE_CUMULATIVE, + type=sample.TYPE_CUMULATIVE, unit='B', volume=c_data.r_bytes, ) @@ -125,7 +125,7 @@ class WriteRequestsPollster(_Base): return util.make_counter_from_instance( instance, name='disk.write.requests', - type=counter.TYPE_CUMULATIVE, + type=sample.TYPE_CUMULATIVE, unit='request', volume=c_data.w_requests, ) @@ -138,7 +138,7 @@ class WriteBytesPollster(_Base): return util.make_counter_from_instance( instance, name='disk.write.bytes', - type=counter.TYPE_CUMULATIVE, + type=sample.TYPE_CUMULATIVE, unit='B', volume=c_data.w_bytes, ) diff --git a/ceilometer/compute/pollsters/instance.py b/ceilometer/compute/pollsters/instance.py index 79848b21b..3c928f644 100644 --- a/ceilometer/compute/pollsters/instance.py +++ b/ceilometer/compute/pollsters/instance.py @@ -18,7 +18,7 @@ # License for the specific language governing permissions and limitations # under the License. -from ceilometer import counter +from ceilometer import sample from ceilometer.compute import plugin from ceilometer.compute.pollsters import util @@ -30,7 +30,7 @@ class InstancePollster(plugin.ComputePollster): yield util.make_counter_from_instance( instance, name='instance', - type=counter.TYPE_GAUGE, + type=sample.TYPE_GAUGE, unit='instance', volume=1, ) @@ -45,7 +45,7 @@ class InstanceFlavorPollster(plugin.ComputePollster): # Use the "meter name + variable" syntax name='instance:%s' % instance.flavor['name'], - type=counter.TYPE_GAUGE, + type=sample.TYPE_GAUGE, unit='instance', volume=1, ) diff --git a/ceilometer/compute/pollsters/net.py b/ceilometer/compute/pollsters/net.py index 2874bc1b9..77a77fcd9 100644 --- a/ceilometer/compute/pollsters/net.py +++ b/ceilometer/compute/pollsters/net.py @@ -20,7 +20,7 @@ import copy -from ceilometer import counter +from ceilometer import sample from ceilometer.compute import plugin from ceilometer.compute.pollsters import util from ceilometer.openstack.common import log @@ -48,7 +48,7 @@ class _Base(plugin.ComputePollster): instance_name = util.instance_name(instance) rid = "%s-%s-%s" % (instance_name, instance.id, vnic_data.name) - return counter.Counter( + return sample.Sample( name=name, type=type, unit=unit, @@ -95,7 +95,7 @@ class IncomingBytesPollster(_Base): return self.make_vnic_counter( instance, name='network.incoming.bytes', - type=counter.TYPE_CUMULATIVE, + type=sample.TYPE_CUMULATIVE, unit='B', volume=info.rx_bytes, vnic_data=vnic, @@ -108,7 +108,7 @@ class IncomingPacketsPollster(_Base): return self.make_vnic_counter( instance, name='network.incoming.packets', - type=counter.TYPE_CUMULATIVE, + type=sample.TYPE_CUMULATIVE, unit='packet', volume=info.rx_packets, vnic_data=vnic, @@ -121,7 +121,7 @@ class OutgoingBytesPollster(_Base): return self.make_vnic_counter( instance, name='network.outgoing.bytes', - type=counter.TYPE_CUMULATIVE, + type=sample.TYPE_CUMULATIVE, unit='B', volume=info.tx_bytes, vnic_data=vnic, @@ -134,7 +134,7 @@ class OutgoingPacketsPollster(_Base): return self.make_vnic_counter( instance, name='network.outgoing.packets', - type=counter.TYPE_CUMULATIVE, + type=sample.TYPE_CUMULATIVE, unit='packet', volume=info.tx_packets, vnic_data=vnic, diff --git a/ceilometer/compute/pollsters/util.py b/ceilometer/compute/pollsters/util.py index 97b2c8da0..1a94cbcbe 100644 --- a/ceilometer/compute/pollsters/util.py +++ b/ceilometer/compute/pollsters/util.py @@ -20,7 +20,7 @@ from oslo.config import cfg -from ceilometer import counter +from ceilometer import sample from ceilometer.openstack.common import timeutils @@ -100,7 +100,7 @@ def make_counter_from_instance(instance, name, type, unit, volume, additional_metadata={}): resource_metadata = _get_metadata_from_object(instance) resource_metadata.update(additional_metadata) - return counter.Counter( + return sample.Sample( name=name, type=type, unit=unit, diff --git a/ceilometer/energy/kwapi.py b/ceilometer/energy/kwapi.py index e664f3d11..0b9985250 100644 --- a/ceilometer/energy/kwapi.py +++ b/ceilometer/energy/kwapi.py @@ -20,7 +20,7 @@ from keystoneclient import exceptions import requests from ceilometer.central import plugin -from ceilometer import counter +from ceilometer import sample from ceilometer.openstack.common.gettextutils import _ from ceilometer.openstack.common import log @@ -84,9 +84,9 @@ class EnergyPollster(_Base): def get_counters(self, manager, cache): """Returns all counters.""" for probe in self._iter_probes(manager.keystone, cache): - yield counter.Counter( + yield sample.Sample( name='energy', - type=counter.TYPE_CUMULATIVE, + type=sample.TYPE_CUMULATIVE, unit='kWh', volume=probe['kwh'], user_id=None, @@ -104,9 +104,9 @@ class PowerPollster(_Base): def get_counters(self, manager, cache): """Returns all counters.""" for probe in self._iter_probes(manager.keystone, cache): - yield counter.Counter( + yield sample.Sample( name='power', - type=counter.TYPE_GAUGE, + type=sample.TYPE_GAUGE, unit='W', volume=probe['w'], user_id=None, diff --git a/ceilometer/image/glance.py b/ceilometer/image/glance.py index 19f47ef8c..8cf486480 100644 --- a/ceilometer/image/glance.py +++ b/ceilometer/image/glance.py @@ -23,7 +23,7 @@ from __future__ import absolute_import import itertools import glanceclient -from ceilometer import counter +from ceilometer import sample from ceilometer.openstack.common import timeutils from ceilometer import plugin @@ -102,9 +102,9 @@ class ImagePollster(_Base): def get_counters(self, manager, cache): for image in self._iter_images(manager.keystone, cache): - yield counter.Counter( + yield sample.Sample( name='image', - type=counter.TYPE_GAUGE, + type=sample.TYPE_GAUGE, unit='image', volume=1, user_id=None, @@ -119,9 +119,9 @@ class ImageSizePollster(_Base): def get_counters(self, manager, cache): for image in self._iter_images(manager.keystone, cache): - yield counter.Counter( + yield sample.Sample( name='image.size', - type=counter.TYPE_GAUGE, + type=sample.TYPE_GAUGE, unit='B', volume=image.size, user_id=None, diff --git a/ceilometer/image/notifications.py b/ceilometer/image/notifications.py index a601bd277..35bd755cb 100644 --- a/ceilometer/image/notifications.py +++ b/ceilometer/image/notifications.py @@ -21,7 +21,7 @@ from oslo.config import cfg -from ceilometer import counter +from ceilometer import sample from ceilometer import plugin OPTS = [ @@ -62,9 +62,9 @@ class ImageCRUDBase(ImageBase): class ImageCRUD(ImageCRUDBase): def process_notification(self, message): - yield counter.Counter.from_notification( + yield sample.Sample.from_notification( name=message['event_type'], - type=counter.TYPE_DELTA, + type=sample.TYPE_DELTA, unit='image', volume=1, resource_id=message['payload']['id'], @@ -75,9 +75,9 @@ class ImageCRUD(ImageCRUDBase): class Image(ImageCRUDBase): def process_notification(self, message): - yield counter.Counter.from_notification( + yield sample.Sample.from_notification( name='image', - type=counter.TYPE_GAUGE, + type=sample.TYPE_GAUGE, unit='image', volume=1, resource_id=message['payload']['id'], @@ -88,9 +88,9 @@ class Image(ImageCRUDBase): class ImageSize(ImageCRUDBase): def process_notification(self, message): - yield counter.Counter.from_notification( + yield sample.Sample.from_notification( name='image.size', - type=counter.TYPE_GAUGE, + type=sample.TYPE_GAUGE, unit='B', volume=message['payload']['size'], resource_id=message['payload']['id'], @@ -108,9 +108,9 @@ class ImageDownload(ImageBase): ] def process_notification(self, message): - yield counter.Counter.from_notification( + yield sample.Sample.from_notification( name='image.download', - type=counter.TYPE_DELTA, + type=sample.TYPE_DELTA, unit='B', volume=message['payload']['bytes_sent'], resource_id=message['payload']['image_id'], @@ -128,9 +128,9 @@ class ImageServe(ImageBase): ] def process_notification(self, message): - yield counter.Counter.from_notification( + yield sample.Sample.from_notification( name='image.serve', - type=counter.TYPE_DELTA, + type=sample.TYPE_DELTA, unit='B', volume=message['payload']['bytes_sent'], resource_id=message['payload']['image_id'], diff --git a/ceilometer/network/floatingip.py b/ceilometer/network/floatingip.py index c570a27b4..4e74740ed 100644 --- a/ceilometer/network/floatingip.py +++ b/ceilometer/network/floatingip.py @@ -23,7 +23,7 @@ from ceilometer.openstack.common import log from ceilometer.openstack.common import timeutils from ceilometer.central import plugin -from ceilometer import counter +from ceilometer import sample from ceilometer import nova_client @@ -47,9 +47,9 @@ class FloatingIPPollster(plugin.CentralPollster): # attributes were used by Ceilometer, such as project id, host. # In this fix, those attributes usage will be removed temporarily. # And they will be back after fix the Nova bug 1174802. - yield counter.Counter( + yield sample.Sample( name='ip.floating', - type=counter.TYPE_GAUGE, + type=sample.TYPE_GAUGE, unit='ip', volume=1, user_id=None, diff --git a/ceilometer/network/notifications.py b/ceilometer/network/notifications.py index 26ba0dd52..3cc3dfc0c 100644 --- a/ceilometer/network/notifications.py +++ b/ceilometer/network/notifications.py @@ -22,7 +22,7 @@ from oslo.config import cfg -from ceilometer import counter +from ceilometer import sample from ceilometer.openstack.common import log from ceilometer import plugin @@ -75,9 +75,9 @@ class NetworkNotificationBase(plugin.NotificationBase): counter_name = getattr(self, 'counter_name', self.resource_name) unit_value = getattr(self, 'unit', self.resource_name) - yield counter.Counter.from_notification( + yield sample.Sample.from_notification( name=counter_name, - type=counter.TYPE_GAUGE, + type=sample.TYPE_GAUGE, unit=unit_value, volume=1, user_id=message['_context_user_id'], @@ -87,10 +87,10 @@ class NetworkNotificationBase(plugin.NotificationBase): event_type_split = message['event_type'].split('.') if len(event_type_split) > 2: - yield counter.Counter.from_notification( + yield sample.Sample.from_notification( name=counter_name + "." + event_type_split[1], - type=counter.TYPE_DELTA, + type=sample.TYPE_DELTA, unit=unit_value, volume=1, user_id=message['_context_user_id'], diff --git a/ceilometer/notifier.py b/ceilometer/notifier.py index 8ec78eee4..eae2d4ada 100644 --- a/ceilometer/notifier.py +++ b/ceilometer/notifier.py @@ -26,7 +26,7 @@ from stevedore import extension LOG = logging.getLogger(__name__) -cfg.CONF.import_opt('counter_source', 'ceilometer.counter') +cfg.CONF.import_opt('sample_source', 'ceilometer.sample') _notification_manager = None @@ -64,7 +64,7 @@ def _process_notification_for_ext(ext, context, notification): if notification['event_type'] in handler.get_event_types(): with _pipeline_manager.publisher(context, - cfg.CONF.counter_source) as p: + cfg.CONF.sample_source) as p: # FIXME(dhellmann): Spawn green thread? p(list(handler.process_notification(notification))) diff --git a/ceilometer/objectstore/swift.py b/ceilometer/objectstore/swift.py index 595044b39..14229c836 100644 --- a/ceilometer/objectstore/swift.py +++ b/ceilometer/objectstore/swift.py @@ -24,7 +24,7 @@ from oslo.config import cfg from swiftclient import client as swift from keystoneclient import exceptions -from ceilometer import counter +from ceilometer import sample from ceilometer.openstack.common.gettextutils import _ from ceilometer.openstack.common import log from ceilometer.openstack.common import timeutils @@ -91,9 +91,9 @@ class ObjectsPollster(_Base): def get_counters(self, manager, cache): for tenant, account in self._iter_accounts(manager.keystone, cache): - yield counter.Counter( + yield sample.Sample( name='storage.objects', - type=counter.TYPE_GAUGE, + type=sample.TYPE_GAUGE, volume=int(account['x-account-object-count']), unit='object', user_id=None, @@ -110,9 +110,9 @@ class ObjectsSizePollster(_Base): def get_counters(self, manager, cache): for tenant, account in self._iter_accounts(manager.keystone, cache): - yield counter.Counter( + yield sample.Sample( name='storage.objects.size', - type=counter.TYPE_GAUGE, + type=sample.TYPE_GAUGE, volume=int(account['x-account-bytes-used']), unit='B', user_id=None, @@ -129,9 +129,9 @@ class ObjectsContainersPollster(_Base): def get_counters(self, manager, cache): for tenant, account in self._iter_accounts(manager.keystone, cache): - yield counter.Counter( + yield sample.Sample( name='storage.objects.containers', - type=counter.TYPE_GAUGE, + type=sample.TYPE_GAUGE, volume=int(account['x-account-container-count']), unit='container', user_id=None, diff --git a/ceilometer/objectstore/swift_middleware.py b/ceilometer/objectstore/swift_middleware.py index 152f51fa1..e1ef5fcec 100644 --- a/ceilometer/objectstore/swift_middleware.py +++ b/ceilometer/objectstore/swift_middleware.py @@ -56,7 +56,7 @@ except ImportError: # Swift <= 1.7.5 ... module exists and has class. from swift.common.middleware.proxy_logging import InputProxy -from ceilometer import counter +from ceilometer import sample from ceilometer.openstack.common import context from ceilometer.openstack.common import timeutils from ceilometer import pipeline @@ -132,13 +132,13 @@ class CeilometerMiddleware(object): with pipeline.PublishContext( context.get_admin_context(), - cfg.CONF.counter_source, + cfg.CONF.sample_source, self.pipeline_manager.pipelines, ) as publisher: if bytes_received: - publisher([counter.Counter( + publisher([sample.Sample( name='storage.objects.incoming.bytes', - type=counter.TYPE_DELTA, + type=sample.TYPE_DELTA, unit='B', volume=bytes_received, user_id=env.get('HTTP_X_USER_ID'), @@ -148,9 +148,9 @@ class CeilometerMiddleware(object): resource_metadata=resource_metadata)]) if bytes_sent: - publisher([counter.Counter( + publisher([sample.Sample( name='storage.objects.outgoing.bytes', - type=counter.TYPE_DELTA, + type=sample.TYPE_DELTA, unit='B', volume=bytes_sent, user_id=env.get('HTTP_X_USER_ID'), @@ -162,9 +162,9 @@ class CeilometerMiddleware(object): # publish the event for each request # request method will be recorded in the metadata resource_metadata['method'] = req.method.lower() - publisher([counter.Counter( + publisher([sample.Sample( name='storage.api.request', - type=counter.TYPE_DELTA, + type=sample.TYPE_DELTA, unit='request', volume=1, user_id=env.get('HTTP_X_USER_ID'), diff --git a/ceilometer/counter.py b/ceilometer/sample.py similarity index 64% rename from ceilometer/counter.py rename to ceilometer/sample.py index 48737760a..60c63b677 100644 --- a/ceilometer/counter.py +++ b/ceilometer/sample.py @@ -15,9 +15,9 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -"""Counter class for holding data about a metering event. +"""Sample class for holding data about a metering event. -A Counter doesn't really do anything, but we need a way to +A Sample doesn't really do anything, but we need a way to ensure that all of the appropriate fields have been filled in by the plugins that create them. """ @@ -29,9 +29,10 @@ from oslo.config import cfg OPTS = [ - cfg.StrOpt('counter_source', + cfg.StrOpt('sample_source', default='openstack', - help='Source for counters emited on this instance'), + deprecated_name='counter_source', + help='Source for samples emited on this instance'), ] cfg.CONF.register_opts(OPTS) @@ -39,30 +40,30 @@ cfg.CONF.register_opts(OPTS) # Fields explanation: # -# Name: the name of the counter, must be unique -# Type: the type of the counter, must be either: +# Name: the name of the meter, must be unique +# Type: the type of the meter, must be either: # - cumulative: the value is incremented and never reset to 0 # - delta: the value is reset to 0 each time it is sent # - gauge: the value is an absolute value and is not a counter -# Unit: the unit of the counter -# Volume: the counter value +# Unit: the unit of the meter +# Volume: the sample value # User ID: the user ID # Project ID: the project ID # Resource ID: the resource ID -# Timestamp: when the counter has been read +# Timestamp: when the sample has been read # Resource metadata: various metadata -Counter = collections.namedtuple('Counter', - ' '.join([ - 'name', - 'type', - 'unit', - 'volume', - 'user_id', - 'project_id', - 'resource_id', - 'timestamp', - 'resource_metadata', - ])) +Sample = collections.namedtuple('Sample', + ' '.join([ + 'name', + 'type', + 'unit', + 'volume', + 'user_id', + 'project_id', + 'resource_id', + 'timestamp', + 'resource_metadata', + ])) TYPE_GAUGE = 'gauge' @@ -87,4 +88,4 @@ def from_notification(cls, name, type, volume, unit, resource_metadata=metadata) -Counter.from_notification = classmethod(from_notification) +Sample.from_notification = classmethod(from_notification) diff --git a/ceilometer/transformer/conversions.py b/ceilometer/transformer/conversions.py index 1e5bc5f95..257552b71 100644 --- a/ceilometer/transformer/conversions.py +++ b/ceilometer/transformer/conversions.py @@ -18,7 +18,7 @@ from collections import defaultdict -from ceilometer import counter as ceilocounter +from ceilometer import sample from ceilometer.openstack.common import log from ceilometer.openstack.common import timeutils from ceilometer import transformer @@ -81,7 +81,7 @@ class ScalingTransformer(transformer.TransformerBase): """Transform the appropriate counter fields. """ scale = self.target.get('scale') - return ceilocounter.Counter( + return sample.Sample( name=self.target.get('name', counter.name), unit=self.target.get('unit', counter.unit), type=self.target.get('type', counter.type), @@ -132,7 +132,7 @@ class RateOfChangeTransformer(ScalingTransformer): # so that the current volume gives a lower bound on growth volume_delta = (counter.volume - prev_volume if (prev_volume <= counter.volume or - counter.type != ceilocounter.TYPE_CUMULATIVE) + counter.type != sample.TYPE_CUMULATIVE) else counter.volume) rate_of_change = ((1.0 * volume_delta / time_delta) if time_delta else 0.0) diff --git a/ceilometer/volume/notifications.py b/ceilometer/volume/notifications.py index 003c7e583..6f02c3506 100644 --- a/ceilometer/volume/notifications.py +++ b/ceilometer/volume/notifications.py @@ -21,7 +21,7 @@ events. from oslo.config import cfg -from ceilometer import counter +from ceilometer import sample from ceilometer import plugin @@ -59,9 +59,9 @@ class _Base(plugin.NotificationBase): class Volume(_Base): def process_notification(self, message): - yield counter.Counter.from_notification( + yield sample.Sample.from_notification( name='volume', - type=counter.TYPE_GAUGE, + type=sample.TYPE_GAUGE, unit='volume', volume=1, user_id=message['payload']['user_id'], @@ -72,9 +72,9 @@ class Volume(_Base): class VolumeSize(_Base): def process_notification(self, message): - yield counter.Counter.from_notification( + yield sample.Sample.from_notification( name='volume.size', - type=counter.TYPE_GAUGE, + type=sample.TYPE_GAUGE, unit='GB', volume=message['payload']['size'], user_id=message['payload']['user_id'], diff --git a/etc/ceilometer/ceilometer.conf.sample b/etc/ceilometer/ceilometer.conf.sample index 861f1f826..fb5bf11fa 100644 --- a/etc/ceilometer/ceilometer.conf.sample +++ b/etc/ceilometer/ceilometer.conf.sample @@ -1,13 +1,5 @@ [DEFAULT] -# -# Options defined in ceilometer.counter -# - -# Source for counters emited on this instance (string value) -#counter_source=openstack - - # # Options defined in ceilometer.pipeline # @@ -16,6 +8,14 @@ #pipeline_cfg_file=pipeline.yaml +# +# Options defined in ceilometer.sample +# + +# Source for samples emited on this instance (string value) +#sample_source=openstack + + # # Options defined in ceilometer.api.app # diff --git a/nova_tests/test_notifier.py b/nova_tests/test_notifier.py index d383b408c..bbd2e900e 100644 --- a/nova_tests/test_notifier.py +++ b/nova_tests/test_notifier.py @@ -53,7 +53,7 @@ config.cfg.CONF.import_opt('compute_manager', 'nova.service') # nova's version of oslo to be used instead of ceilometer's. from ceilometer.compute import nova_notifier -from ceilometer import counter +from ceilometer import sample from ceilometer.tests import base LOG = logging.getLogger(__name__) @@ -64,9 +64,9 @@ class TestNovaNotifier(base.TestCase): class Pollster(object): instances = [] - test_data = counter.Counter( + test_data = sample.Sample( name='test', - type=counter.TYPE_CUMULATIVE, + type=sample.TYPE_CUMULATIVE, unit='units-go-here', volume=1, user_id='test', @@ -220,7 +220,7 @@ class TestNovaNotifier(base.TestCase): self.assertEqual(len(samples), 1) s = payload['samples'][0] self.assertEqual(s, {'name': 'test', - 'type': counter.TYPE_CUMULATIVE, + 'type': sample.TYPE_CUMULATIVE, 'unit': 'units-go-here', 'volume': 1, }) diff --git a/tests/agentbase.py b/tests/agentbase.py index e37b20206..3bd89f93f 100644 --- a/tests/agentbase.py +++ b/tests/agentbase.py @@ -26,15 +26,15 @@ import mock from stevedore import extension from stevedore.tests import manager as extension_tests -from ceilometer import counter +from ceilometer import sample from ceilometer import pipeline from ceilometer.tests import base from ceilometer import transformer -default_test_data = counter.Counter( +default_test_data = sample.Sample( name='test', - type=counter.TYPE_CUMULATIVE, + type=sample.TYPE_CUMULATIVE, unit='', volume=1, user_id='test', diff --git a/tests/api/v1/test_list_events_scenarios.py b/tests/api/v1/test_list_events_scenarios.py index 2b198ac13..6505cd423 100644 --- a/tests/api/v1/test_list_events_scenarios.py +++ b/tests/api/v1/test_list_events_scenarios.py @@ -25,7 +25,7 @@ import testscenarios from oslo.config import cfg from ceilometer.publisher import rpc -from ceilometer import counter +from ceilometer import sample from ceilometer.tests import api as tests_api from ceilometer.tests import db as tests_db @@ -39,7 +39,7 @@ class TestListEvents(tests_api.TestBase, def setUp(self): super(TestListEvents, self).setUp() for cnt in [ - counter.Counter( + sample.Sample( 'instance', 'cumulative', '', @@ -51,7 +51,7 @@ class TestListEvents(tests_api.TestBase, resource_metadata={'display_name': 'test-server', 'tag': 'self.counter'} ), - counter.Counter( + sample.Sample( 'instance', 'cumulative', '', @@ -63,7 +63,7 @@ class TestListEvents(tests_api.TestBase, resource_metadata={'display_name': 'test-server', 'tag': 'self.counter'} ), - counter.Counter( + sample.Sample( 'instance', 'cumulative', '', diff --git a/tests/api/v1/test_list_meters_scenarios.py b/tests/api/v1/test_list_meters_scenarios.py index 139a81f46..7d9531851 100644 --- a/tests/api/v1/test_list_meters_scenarios.py +++ b/tests/api/v1/test_list_meters_scenarios.py @@ -26,7 +26,7 @@ import testscenarios from oslo.config import cfg from ceilometer.publisher import rpc -from ceilometer import counter +from ceilometer import sample from ceilometer.tests import api as tests_api from ceilometer.tests import db as tests_db @@ -51,7 +51,7 @@ class TestListMeters(tests_api.TestBase, super(TestListMeters, self).setUp() for cnt in [ - counter.Counter( + sample.Sample( 'meter.test', 'cumulative', '', @@ -62,7 +62,7 @@ class TestListMeters(tests_api.TestBase, timestamp=datetime.datetime(2012, 7, 2, 10, 40), resource_metadata={'display_name': 'test-server', 'tag': 'self.counter'}), - counter.Counter( + sample.Sample( 'meter.test', 'cumulative', '', @@ -73,7 +73,7 @@ class TestListMeters(tests_api.TestBase, timestamp=datetime.datetime(2012, 7, 2, 11, 40), resource_metadata={'display_name': 'test-server', 'tag': 'self.counter'}), - counter.Counter( + sample.Sample( 'meter.mine', 'gauge', '', @@ -84,7 +84,7 @@ class TestListMeters(tests_api.TestBase, timestamp=datetime.datetime(2012, 7, 2, 10, 41), resource_metadata={'display_name': 'test-server', 'tag': 'two.counter'}), - counter.Counter( + sample.Sample( 'meter.test', 'cumulative', '', @@ -95,7 +95,7 @@ class TestListMeters(tests_api.TestBase, timestamp=datetime.datetime(2012, 7, 2, 10, 42), resource_metadata={'display_name': 'test-server', 'tag': 'three.counter'}), - counter.Counter( + sample.Sample( 'meter.mine', 'gauge', '', diff --git a/tests/api/v1/test_list_projects_scenarios.py b/tests/api/v1/test_list_projects_scenarios.py index 5de2ec9ea..949f58973 100644 --- a/tests/api/v1/test_list_projects_scenarios.py +++ b/tests/api/v1/test_list_projects_scenarios.py @@ -26,7 +26,7 @@ import testscenarios from oslo.config import cfg from ceilometer.publisher import rpc -from ceilometer import counter +from ceilometer import sample from ceilometer.tests import api as tests_api from ceilometer.tests import db as tests_db @@ -49,7 +49,7 @@ class TestListProjects(tests_api.TestBase, def setUp(self): super(TestListProjects, self).setUp() - counter1 = counter.Counter( + counter1 = sample.Sample( 'instance', 'cumulative', 'instance', @@ -68,7 +68,7 @@ class TestListProjects(tests_api.TestBase, ) self.conn.record_metering_data(msg) - counter2 = counter.Counter( + counter2 = sample.Sample( 'instance', 'cumulative', 'instance', diff --git a/tests/api/v1/test_list_resources_scenarios.py b/tests/api/v1/test_list_resources_scenarios.py index 1ad081a05..074164598 100644 --- a/tests/api/v1/test_list_resources_scenarios.py +++ b/tests/api/v1/test_list_resources_scenarios.py @@ -26,7 +26,7 @@ import testscenarios from oslo.config import cfg from ceilometer.publisher import rpc -from ceilometer import counter +from ceilometer import sample from ceilometer.tests import api as tests_api from ceilometer.tests import db as tests_db @@ -51,7 +51,7 @@ class TestListResourcesBase(tests_api.TestBase, super(TestListResourcesBase, self).setUp() for cnt in [ - counter.Counter( + sample.Sample( 'instance', 'cumulative', '', @@ -63,7 +63,7 @@ class TestListResourcesBase(tests_api.TestBase, resource_metadata={'display_name': 'test-server', 'tag': 'self.counter'}, ), - counter.Counter( + sample.Sample( 'instance', 'cumulative', '', @@ -75,7 +75,7 @@ class TestListResourcesBase(tests_api.TestBase, resource_metadata={'display_name': 'test-server', 'tag': 'self.counter2'}, ), - counter.Counter( + sample.Sample( 'instance', 'cumulative', '', @@ -87,7 +87,7 @@ class TestListResourcesBase(tests_api.TestBase, resource_metadata={'display_name': 'test-server', 'tag': 'self.counter3'}, ), - counter.Counter( + sample.Sample( 'instance', 'cumulative', '', diff --git a/tests/api/v1/test_list_users_scenarios.py b/tests/api/v1/test_list_users_scenarios.py index ab2f14544..37b775a04 100644 --- a/tests/api/v1/test_list_users_scenarios.py +++ b/tests/api/v1/test_list_users_scenarios.py @@ -26,7 +26,7 @@ import testscenarios from oslo.config import cfg from ceilometer.publisher import rpc -from ceilometer import counter +from ceilometer import sample from ceilometer.tests import api as tests_api from ceilometer.tests import db as tests_db @@ -50,7 +50,7 @@ class TestListUsers(tests_api.TestBase, def setUp(self): super(TestListUsers, self).setUp() - counter1 = counter.Counter( + counter1 = sample.Sample( 'instance', 'cumulative', 'instance', @@ -70,7 +70,7 @@ class TestListUsers(tests_api.TestBase, ) self.conn.record_metering_data(msg) - counter2 = counter.Counter( + counter2 = sample.Sample( 'instance', 'cumulative', '', diff --git a/tests/api/v1/test_max_project_volume_scenarios.py b/tests/api/v1/test_max_project_volume_scenarios.py index 4c2901ed6..ffe8e3af2 100644 --- a/tests/api/v1/test_max_project_volume_scenarios.py +++ b/tests/api/v1/test_max_project_volume_scenarios.py @@ -25,7 +25,7 @@ import testscenarios from oslo.config import cfg from ceilometer.publisher import rpc -from ceilometer import counter +from ceilometer import sample from ceilometer.tests import api as tests_api from ceilometer.tests import db as tests_db @@ -41,7 +41,7 @@ class TestMaxProjectVolume(tests_api.TestBase, self.counters = [] for i in range(3): - c = counter.Counter( + c = sample.Sample( 'volume.size', 'gauge', 'GiB', diff --git a/tests/api/v1/test_max_resource_volume_scenarios.py b/tests/api/v1/test_max_resource_volume_scenarios.py index 11c6d07b0..16baf00b4 100644 --- a/tests/api/v1/test_max_resource_volume_scenarios.py +++ b/tests/api/v1/test_max_resource_volume_scenarios.py @@ -24,7 +24,7 @@ import testscenarios from oslo.config import cfg from ceilometer.publisher import rpc -from ceilometer import counter +from ceilometer import sample from ceilometer.tests import api as tests_api from ceilometer.tests import db as tests_db @@ -40,7 +40,7 @@ class TestMaxResourceVolume(tests_api.TestBase, self.counters = [] for i in range(3): - c = counter.Counter( + c = sample.Sample( 'volume.size', 'gauge', 'GiB', diff --git a/tests/api/v1/test_sum_project_volume_scenarios.py b/tests/api/v1/test_sum_project_volume_scenarios.py index 06dc0a31d..c734cc460 100644 --- a/tests/api/v1/test_sum_project_volume_scenarios.py +++ b/tests/api/v1/test_sum_project_volume_scenarios.py @@ -25,7 +25,7 @@ import testscenarios from oslo.config import cfg from ceilometer.publisher import rpc -from ceilometer import counter +from ceilometer import sample from ceilometer.tests import api as tests_api from ceilometer.tests import db as tests_db @@ -41,7 +41,7 @@ class TestSumProjectVolume(tests_api.TestBase, self.counters = [] for i in range(3): - c = counter.Counter( + c = sample.Sample( 'volume.size', 'gauge', 'GiB', diff --git a/tests/api/v1/test_sum_resource_volume_scenarios.py b/tests/api/v1/test_sum_resource_volume_scenarios.py index 496358f11..9d1e162a0 100644 --- a/tests/api/v1/test_sum_resource_volume_scenarios.py +++ b/tests/api/v1/test_sum_resource_volume_scenarios.py @@ -25,7 +25,7 @@ import testscenarios from oslo.config import cfg from ceilometer.publisher import rpc -from ceilometer import counter +from ceilometer import sample from ceilometer.tests import api as tests_api from ceilometer.tests import db as tests_db @@ -41,7 +41,7 @@ class TestSumResourceVolume(tests_api.TestBase, self.counters = [] for i in range(3): - c = counter.Counter( + c = sample.Sample( 'volume.size', 'gauge', 'GiB', diff --git a/tests/api/v2/test_acl_scenarios.py b/tests/api/v2/test_acl_scenarios.py index 67eb777b6..b0bb2a044 100644 --- a/tests/api/v2/test_acl_scenarios.py +++ b/tests/api/v2/test_acl_scenarios.py @@ -23,7 +23,7 @@ import testscenarios from oslo.config import cfg -from ceilometer import counter +from ceilometer import sample from ceilometer.api import acl from ceilometer.publisher import rpc from ceilometer.tests import db as tests_db @@ -83,7 +83,7 @@ class TestAPIACL(FunctionalTest, self.environ = {'fake.cache': FakeMemcache()} for cnt in [ - counter.Counter( + sample.Sample( 'meter.test', 'cumulative', '', @@ -94,7 +94,7 @@ class TestAPIACL(FunctionalTest, timestamp=datetime.datetime(2012, 7, 2, 10, 40), resource_metadata={'display_name': 'test-server', 'tag': 'self.counter'}), - counter.Counter( + sample.Sample( 'meter.mine', 'gauge', '', diff --git a/tests/api/v2/test_list_events_scenarios.py b/tests/api/v2/test_list_events_scenarios.py index 3e934ab23..d7291a0b8 100644 --- a/tests/api/v2/test_list_events_scenarios.py +++ b/tests/api/v2/test_list_events_scenarios.py @@ -26,7 +26,7 @@ import testscenarios from oslo.config import cfg from ceilometer.publisher import rpc -from ceilometer import counter +from ceilometer import sample from ceilometer.tests import db as tests_db from .base import FunctionalTest @@ -41,7 +41,7 @@ class TestListEvents(FunctionalTest, def setUp(self): super(TestListEvents, self).setUp() - self.counter1 = counter.Counter( + self.counter1 = sample.Sample( 'instance', 'cumulative', '', @@ -63,7 +63,7 @@ class TestListEvents(FunctionalTest, ) self.conn.record_metering_data(msg) - self.counter2 = counter.Counter( + self.counter2 = sample.Sample( 'instance', 'cumulative', '', diff --git a/tests/api/v2/test_list_meters_scenarios.py b/tests/api/v2/test_list_meters_scenarios.py index acf22bd4d..9febc3367 100644 --- a/tests/api/v2/test_list_meters_scenarios.py +++ b/tests/api/v2/test_list_meters_scenarios.py @@ -25,7 +25,7 @@ import testscenarios from oslo.config import cfg from ceilometer.publisher import rpc -from ceilometer import counter +from ceilometer import sample from ceilometer.tests import db as tests_db from .base import FunctionalTest @@ -50,7 +50,7 @@ class TestListMeters(FunctionalTest, super(TestListMeters, self).setUp() for cnt in [ - counter.Counter( + sample.Sample( 'meter.test', 'cumulative', '', @@ -61,7 +61,7 @@ class TestListMeters(FunctionalTest, timestamp=datetime.datetime(2012, 7, 2, 10, 40), resource_metadata={'display_name': 'test-server', 'tag': 'self.counter'}), - counter.Counter( + sample.Sample( 'meter.test', 'cumulative', '', @@ -72,7 +72,7 @@ class TestListMeters(FunctionalTest, timestamp=datetime.datetime(2012, 7, 2, 11, 40), resource_metadata={'display_name': 'test-server', 'tag': 'self.counter'}), - counter.Counter( + sample.Sample( 'meter.mine', 'gauge', '', @@ -83,7 +83,7 @@ class TestListMeters(FunctionalTest, timestamp=datetime.datetime(2012, 7, 2, 10, 41), resource_metadata={'display_name': 'test-server', 'tag': 'self.counter2'}), - counter.Counter( + sample.Sample( 'meter.test', 'cumulative', '', @@ -94,7 +94,7 @@ class TestListMeters(FunctionalTest, timestamp=datetime.datetime(2012, 7, 2, 10, 42), resource_metadata={'display_name': 'test-server', 'tag': 'self.counter3'}), - counter.Counter( + sample.Sample( 'meter.mine', 'gauge', '', diff --git a/tests/api/v2/test_list_resources_scenarios.py b/tests/api/v2/test_list_resources_scenarios.py index 26ca10561..eaa4ecbca 100644 --- a/tests/api/v2/test_list_resources_scenarios.py +++ b/tests/api/v2/test_list_resources_scenarios.py @@ -25,7 +25,7 @@ import testscenarios from oslo.config import cfg from ceilometer.publisher import rpc -from ceilometer import counter +from ceilometer import sample from ceilometer.tests import db as tests_db from .base import FunctionalTest @@ -45,7 +45,7 @@ class TestListResources(FunctionalTest, self.assertEquals([], data) def test_instance_no_metadata(self): - counter1 = counter.Counter( + counter1 = sample.Sample( 'instance', 'cumulative', '', @@ -67,7 +67,7 @@ class TestListResources(FunctionalTest, self.assertEquals(1, len(data)) def test_instances(self): - counter1 = counter.Counter( + counter1 = sample.Sample( 'instance', 'cumulative', '', @@ -87,7 +87,7 @@ class TestListResources(FunctionalTest, ) self.conn.record_metering_data(msg) - counter2 = counter.Counter( + counter2 = sample.Sample( 'instance', 'cumulative', '', @@ -111,7 +111,7 @@ class TestListResources(FunctionalTest, self.assertEquals(2, len(data)) def test_instances_one(self): - counter1 = counter.Counter( + counter1 = sample.Sample( 'instance', 'cumulative', '', @@ -131,7 +131,7 @@ class TestListResources(FunctionalTest, ) self.conn.record_metering_data(msg) - counter2 = counter.Counter( + counter2 = sample.Sample( 'instance', 'cumulative', '', @@ -155,7 +155,7 @@ class TestListResources(FunctionalTest, self.assertEquals('resource-id', data['resource_id']) def test_with_source(self): - counter1 = counter.Counter( + counter1 = sample.Sample( 'instance', 'cumulative', '', @@ -175,7 +175,7 @@ class TestListResources(FunctionalTest, ) self.conn.record_metering_data(msg) - counter2 = counter.Counter( + counter2 = sample.Sample( 'instance', 'cumulative', '', @@ -202,7 +202,7 @@ class TestListResources(FunctionalTest, self.assertEquals(['resource-id'], ids) def test_with_invalid_resource_id(self): - counter1 = counter.Counter( + counter1 = sample.Sample( 'instance', 'cumulative', '', @@ -222,7 +222,7 @@ class TestListResources(FunctionalTest, ) self.conn.record_metering_data(msg) - counter2 = counter.Counter( + counter2 = sample.Sample( 'instance', 'cumulative', '', @@ -252,7 +252,7 @@ class TestListResources(FunctionalTest, self.assertEquals(resp3.status_code, 400) def test_with_user(self): - counter1 = counter.Counter( + counter1 = sample.Sample( 'instance', 'cumulative', '', @@ -272,7 +272,7 @@ class TestListResources(FunctionalTest, ) self.conn.record_metering_data(msg) - counter2 = counter.Counter( + counter2 = sample.Sample( 'instance', 'cumulative', '', @@ -299,7 +299,7 @@ class TestListResources(FunctionalTest, self.assertEquals(['resource-id'], ids) def test_with_project(self): - counter1 = counter.Counter( + counter1 = sample.Sample( 'instance', 'cumulative', '', @@ -319,7 +319,7 @@ class TestListResources(FunctionalTest, ) self.conn.record_metering_data(msg) - counter2 = counter.Counter( + counter2 = sample.Sample( 'instance', 'cumulative', '', @@ -346,7 +346,7 @@ class TestListResources(FunctionalTest, self.assertEquals(['resource-id'], ids) def test_with_user_non_admin(self): - counter1 = counter.Counter( + counter1 = sample.Sample( 'instance', 'cumulative', '', @@ -373,7 +373,7 @@ class TestListResources(FunctionalTest, self.assertEquals(set(['resource-id-alternate']), ids) def test_with_user_wrong_tenant(self): - counter1 = counter.Counter( + counter1 = sample.Sample( 'instance', 'cumulative', '', @@ -400,7 +400,7 @@ class TestListResources(FunctionalTest, self.assertEquals(set(), ids) def test_metadata(self): - counter1 = counter.Counter( + counter1 = sample.Sample( 'instance', 'cumulative', '', @@ -431,7 +431,7 @@ class TestListResources(FunctionalTest, ]) def test_resource_meter_links(self): - counter1 = counter.Counter( + counter1 = sample.Sample( 'instance', 'cumulative', '', diff --git a/tests/api/v2/test_statistics_scenarios.py b/tests/api/v2/test_statistics_scenarios.py index 604b6aff2..1c5d8f761 100644 --- a/tests/api/v2/test_statistics_scenarios.py +++ b/tests/api/v2/test_statistics_scenarios.py @@ -23,7 +23,7 @@ import testscenarios from oslo.config import cfg from . import base -from ceilometer import counter +from ceilometer import sample from ceilometer.publisher import rpc from ceilometer.tests import db as tests_db @@ -40,7 +40,7 @@ class TestMaxProjectVolume(base.FunctionalTest, self.counters = [] for i in range(3): - c = counter.Counter( + c = sample.Sample( 'volume.size', 'gauge', 'GiB', @@ -141,7 +141,7 @@ class TestMaxResourceVolume(base.FunctionalTest, self.counters = [] for i in range(3): - c = counter.Counter( + c = sample.Sample( 'volume.size', 'gauge', 'GiB', @@ -258,7 +258,7 @@ class TestSumProjectVolume(base.FunctionalTest, self.counters = [] for i in range(3): - c = counter.Counter( + c = sample.Sample( 'volume.size', 'gauge', 'GiB', @@ -361,7 +361,7 @@ class TestSumResourceVolume(base.FunctionalTest, self.counters = [] for i in range(3): - c = counter.Counter( + c = sample.Sample( 'volume.size', 'gauge', 'GiB', diff --git a/tests/collector/test_service.py b/tests/collector/test_service.py index a0fb18c4b..127dd86ec 100644 --- a/tests/collector/test_service.py +++ b/tests/collector/test_service.py @@ -28,7 +28,7 @@ from oslo.config import cfg from stevedore import extension from stevedore.tests import manager as test_manager -from ceilometer import counter +from ceilometer import sample from ceilometer.openstack.common import timeutils from ceilometer.collector import service from ceilometer.storage import base @@ -115,7 +115,7 @@ class TestUDPCollectorService(TestCollector): def setUp(self): super(TestUDPCollectorService, self).setUp() self.srv = service.UDPCollectorService() - self.counter = dict(counter.Counter( + self.counter = dict(sample.Sample( name='foobar', type='bad', unit='F', diff --git a/tests/compute/test_notifications.py b/tests/compute/test_notifications.py index b2db04903..8cc4fba61 100644 --- a/tests/compute/test_notifications.py +++ b/tests/compute/test_notifications.py @@ -23,7 +23,7 @@ notification events. from ceilometer.tests import base from ceilometer.compute import notifications -from ceilometer import counter +from ceilometer import sample INSTANCE_CREATE_END = { @@ -406,7 +406,7 @@ class TestNotifications(base.TestCase): ))[0] for name, actual, expected in [ ('counter_name', info.name, 'instance'), - ('counter_type', info.type, counter.TYPE_GAUGE), + ('counter_type', info.type, sample.TYPE_GAUGE), ('counter_volume', info.volume, 1), ('timestamp', info.timestamp, INSTANCE_CREATE_END['timestamp']), diff --git a/tests/image/test_notifications.py b/tests/image/test_notifications.py index cd6b4877d..692aea1b9 100644 --- a/tests/image/test_notifications.py +++ b/tests/image/test_notifications.py @@ -20,7 +20,7 @@ from datetime import datetime from ceilometer.image import notifications -from ceilometer import counter +from ceilometer import sample from ceilometer.tests import base @@ -108,7 +108,7 @@ class TestNotification(base.TestCase): self._verify_common_counter(download, 'image.download', 42) self.assertEqual(download.user_id, fake_uuid('d')) self.assertEqual(download.project_id, fake_uuid('b')) - self.assertEqual(download.type, counter.TYPE_DELTA) + self.assertEqual(download.type, sample.TYPE_DELTA) def test_image_serve(self): handler = notifications.ImageServe() @@ -121,7 +121,7 @@ class TestNotification(base.TestCase): fake_uuid('d')) self.assertEquals(serve.resource_metadata.get('receiver_tenant_id'), fake_uuid('b')) - self.assertEqual(serve.type, counter.TYPE_DELTA) + self.assertEqual(serve.type, sample.TYPE_DELTA) def test_image_crud_on_update(self): handler = notifications.ImageCRUD() @@ -129,7 +129,7 @@ class TestNotification(base.TestCase): self.assertEqual(len(counters), 1) update = counters[0] self._verify_common_counter(update, 'image.update', 1) - self.assertEqual(update.type, counter.TYPE_DELTA) + self.assertEqual(update.type, sample.TYPE_DELTA) def test_image_on_update(self): handler = notifications.Image() @@ -137,7 +137,7 @@ class TestNotification(base.TestCase): self.assertEqual(len(counters), 1) update = counters[0] self._verify_common_counter(update, 'image', 1) - self.assertEqual(update.type, counter.TYPE_GAUGE) + self.assertEqual(update.type, sample.TYPE_GAUGE) def test_image_size_on_update(self): handler = notifications.ImageSize() @@ -146,7 +146,7 @@ class TestNotification(base.TestCase): update = counters[0] self._verify_common_counter(update, 'image.size', IMAGE_META['size']) - self.assertEqual(update.type, counter.TYPE_GAUGE) + self.assertEqual(update.type, sample.TYPE_GAUGE) def test_image_crud_on_upload(self): handler = notifications.ImageCRUD() @@ -154,7 +154,7 @@ class TestNotification(base.TestCase): self.assertEqual(len(counters), 1) upload = counters[0] self._verify_common_counter(upload, 'image.upload', 1) - self.assertEqual(upload.type, counter.TYPE_DELTA) + self.assertEqual(upload.type, sample.TYPE_DELTA) def test_image_on_upload(self): handler = notifications.Image() @@ -162,7 +162,7 @@ class TestNotification(base.TestCase): self.assertEqual(len(counters), 1) upload = counters[0] self._verify_common_counter(upload, 'image', 1) - self.assertEqual(upload.type, counter.TYPE_GAUGE) + self.assertEqual(upload.type, sample.TYPE_GAUGE) def test_image_size_on_upload(self): handler = notifications.ImageSize() @@ -171,7 +171,7 @@ class TestNotification(base.TestCase): upload = counters[0] self._verify_common_counter(upload, 'image.size', IMAGE_META['size']) - self.assertEqual(upload.type, counter.TYPE_GAUGE) + self.assertEqual(upload.type, sample.TYPE_GAUGE) def test_image_crud_on_delete(self): handler = notifications.ImageCRUD() @@ -179,7 +179,7 @@ class TestNotification(base.TestCase): self.assertEqual(len(counters), 1) delete = counters[0] self._verify_common_counter(delete, 'image.delete', 1) - self.assertEqual(delete.type, counter.TYPE_DELTA) + self.assertEqual(delete.type, sample.TYPE_DELTA) def test_image_on_delete(self): handler = notifications.Image() @@ -187,7 +187,7 @@ class TestNotification(base.TestCase): self.assertEqual(len(counters), 1) delete = counters[0] self._verify_common_counter(delete, 'image', 1) - self.assertEqual(delete.type, counter.TYPE_GAUGE) + self.assertEqual(delete.type, sample.TYPE_GAUGE) def test_image_size_on_delete(self): handler = notifications.ImageSize() @@ -196,4 +196,4 @@ class TestNotification(base.TestCase): delete = counters[0] self._verify_common_counter(delete, 'image.size', IMAGE_META['size']) - self.assertEqual(delete.type, counter.TYPE_GAUGE) + self.assertEqual(delete.type, sample.TYPE_GAUGE) diff --git a/tests/publisher/test_file.py b/tests/publisher/test_file.py index caf6aad8e..bf895602e 100644 --- a/tests/publisher/test_file.py +++ b/tests/publisher/test_file.py @@ -22,7 +22,7 @@ import datetime import os import logging import logging.handlers -from ceilometer import counter +from ceilometer import sample from ceilometer.publisher import file from ceilometer.tests import base from ceilometer.openstack.common.network_utils import urlsplit @@ -31,9 +31,9 @@ from ceilometer.openstack.common.network_utils import urlsplit class TestFilePublisher(base.TestCase): test_data = [ - counter.Counter( + sample.Sample( name='test', - type=counter.TYPE_CUMULATIVE, + type=sample.TYPE_CUMULATIVE, unit='', volume=1, user_id='test', @@ -42,9 +42,9 @@ class TestFilePublisher(base.TestCase): timestamp=datetime.datetime.utcnow().isoformat(), resource_metadata={'name': 'TestPublish'}, ), - counter.Counter( + sample.Sample( name='test2', - type=counter.TYPE_CUMULATIVE, + type=sample.TYPE_CUMULATIVE, unit='', volume=1, user_id='test', @@ -53,9 +53,9 @@ class TestFilePublisher(base.TestCase): timestamp=datetime.datetime.utcnow().isoformat(), resource_metadata={'name': 'TestPublish'}, ), - counter.Counter( + sample.Sample( name='test2', - type=counter.TYPE_CUMULATIVE, + type=sample.TYPE_CUMULATIVE, unit='', volume=1, user_id='test', diff --git a/tests/publisher/test_rpc_publisher.py b/tests/publisher/test_rpc_publisher.py index e79f4d9cd..d3474e7c7 100644 --- a/tests/publisher/test_rpc_publisher.py +++ b/tests/publisher/test_rpc_publisher.py @@ -22,7 +22,7 @@ import datetime from oslo.config import cfg -from ceilometer import counter +from ceilometer import sample from ceilometer.openstack.common import jsonutils from ceilometer.openstack.common import network_utils from ceilometer.openstack.common import rpc as oslo_rpc @@ -111,16 +111,15 @@ class TestSignature(base.TestCase): class TestCounter(base.TestCase): - TEST_COUNTER = counter.Counter(name='name', - type='typ', - unit='', - volume=1, - user_id='user', - project_id='project', - resource_id=2, - timestamp='today', - resource_metadata={'key': 'value'}, - ) + TEST_COUNTER = sample.Sample(name='name', + type='typ', + unit='', + volume=1, + user_id='user', + project_id='project', + resource_id=2, + timestamp='today', + resource_metadata={'key': 'value'}) def test_meter_message_from_counter_signed(self): msg = rpc.meter_message_from_counter(self.TEST_COUNTER, @@ -146,9 +145,9 @@ class TestCounter(base.TestCase): class TestPublish(base.TestCase): test_data = [ - counter.Counter( + sample.Sample( name='test', - type=counter.TYPE_CUMULATIVE, + type=sample.TYPE_CUMULATIVE, unit='', volume=1, user_id='test', @@ -157,9 +156,9 @@ class TestPublish(base.TestCase): timestamp=datetime.datetime.utcnow().isoformat(), resource_metadata={'name': 'TestPublish'}, ), - counter.Counter( + sample.Sample( name='test', - type=counter.TYPE_CUMULATIVE, + type=sample.TYPE_CUMULATIVE, unit='', volume=1, user_id='test', @@ -168,9 +167,9 @@ class TestPublish(base.TestCase): timestamp=datetime.datetime.utcnow().isoformat(), resource_metadata={'name': 'TestPublish'}, ), - counter.Counter( + sample.Sample( name='test2', - type=counter.TYPE_CUMULATIVE, + type=sample.TYPE_CUMULATIVE, unit='', volume=1, user_id='test', @@ -179,9 +178,9 @@ class TestPublish(base.TestCase): timestamp=datetime.datetime.utcnow().isoformat(), resource_metadata={'name': 'TestPublish'}, ), - counter.Counter( + sample.Sample( name='test2', - type=counter.TYPE_CUMULATIVE, + type=sample.TYPE_CUMULATIVE, unit='', volume=1, user_id='test', @@ -190,9 +189,9 @@ class TestPublish(base.TestCase): timestamp=datetime.datetime.utcnow().isoformat(), resource_metadata={'name': 'TestPublish'}, ), - counter.Counter( + sample.Sample( name='test3', - type=counter.TYPE_CUMULATIVE, + type=sample.TYPE_CUMULATIVE, unit='', volume=1, user_id='test', diff --git a/tests/publisher/test_udp.py b/tests/publisher/test_udp.py index e77fb9cc0..5678900b2 100644 --- a/tests/publisher/test_udp.py +++ b/tests/publisher/test_udp.py @@ -23,7 +23,7 @@ import mock import msgpack from oslo.config import cfg -from ceilometer import counter +from ceilometer import sample from ceilometer.publisher import udp from ceilometer.tests import base from ceilometer.openstack.common import network_utils @@ -32,9 +32,9 @@ from ceilometer.openstack.common import network_utils class TestUDPPublisher(base.TestCase): test_data = [ - counter.Counter( + sample.Sample( name='test', - type=counter.TYPE_CUMULATIVE, + type=sample.TYPE_CUMULATIVE, unit='', volume=1, user_id='test', @@ -43,9 +43,9 @@ class TestUDPPublisher(base.TestCase): timestamp=datetime.datetime.utcnow().isoformat(), resource_metadata={'name': 'TestPublish'}, ), - counter.Counter( + sample.Sample( name='test', - type=counter.TYPE_CUMULATIVE, + type=sample.TYPE_CUMULATIVE, unit='', volume=1, user_id='test', @@ -54,9 +54,9 @@ class TestUDPPublisher(base.TestCase): timestamp=datetime.datetime.utcnow().isoformat(), resource_metadata={'name': 'TestPublish'}, ), - counter.Counter( + sample.Sample( name='test2', - type=counter.TYPE_CUMULATIVE, + type=sample.TYPE_CUMULATIVE, unit='', volume=1, user_id='test', @@ -65,9 +65,9 @@ class TestUDPPublisher(base.TestCase): timestamp=datetime.datetime.utcnow().isoformat(), resource_metadata={'name': 'TestPublish'}, ), - counter.Counter( + sample.Sample( name='test2', - type=counter.TYPE_CUMULATIVE, + type=sample.TYPE_CUMULATIVE, unit='', volume=1, user_id='test', @@ -76,9 +76,9 @@ class TestUDPPublisher(base.TestCase): timestamp=datetime.datetime.utcnow().isoformat(), resource_metadata={'name': 'TestPublish'}, ), - counter.Counter( + sample.Sample( name='test3', - type=counter.TYPE_CUMULATIVE, + type=sample.TYPE_CUMULATIVE, unit='', volume=1, user_id='test', diff --git a/tests/storage/base.py b/tests/storage/base.py index 98c904caa..56718a731 100644 --- a/tests/storage/base.py +++ b/tests/storage/base.py @@ -27,7 +27,7 @@ from oslo.config import cfg from ceilometer.publisher import rpc from ceilometer.openstack.common import timeutils -from ceilometer import counter +from ceilometer import sample from ceilometer import storage from ceilometer.tests import db as test_db from ceilometer.storage import models @@ -58,9 +58,9 @@ class DBTestBase(test_db.TestBase): timestamps_for_test_samples_default_order) self.msgs = [] - self.counter = counter.Counter( + self.counter = sample.Sample( 'instance', - counter.TYPE_CUMULATIVE, + sample.TYPE_CUMULATIVE, unit='', volume=1, user_id='user-id', @@ -79,9 +79,9 @@ class DBTestBase(test_db.TestBase): self.conn.record_metering_data(self.msg1) self.msgs.append(self.msg1) - self.counter2 = counter.Counter( + self.counter2 = sample.Sample( 'instance', - counter.TYPE_CUMULATIVE, + sample.TYPE_CUMULATIVE, unit='', volume=1, user_id='user-id', @@ -100,9 +100,9 @@ class DBTestBase(test_db.TestBase): self.conn.record_metering_data(self.msg2) self.msgs.append(self.msg2) - self.counter3 = counter.Counter( + self.counter3 = sample.Sample( 'instance', - counter.TYPE_CUMULATIVE, + sample.TYPE_CUMULATIVE, unit='', volume=1, user_id='user-id-alternate', @@ -126,9 +126,9 @@ class DBTestBase(test_db.TestBase): for i, ts in zip(range(start_idx - 1, end_idx - 1), timestamp_list[start_idx:end_idx]): - c = counter.Counter( + c = sample.Sample( 'instance', - counter.TYPE_CUMULATIVE, + sample.TYPE_CUMULATIVE, unit='', volume=1, user_id='user-id-%s' % i, @@ -547,7 +547,7 @@ class StatisticsTest(DBTestBase): def prepare_data(self): self.counters = [] for i in range(3): - c = counter.Counter( + c = sample.Sample( 'volume.size', 'gauge', 'GiB', @@ -568,7 +568,7 @@ class StatisticsTest(DBTestBase): ) self.conn.record_metering_data(msg) for i in range(3): - c = counter.Counter( + c = sample.Sample( 'volume.size', 'gauge', 'GiB', @@ -754,9 +754,9 @@ class StatisticsTest(DBTestBase): class CounterDataTypeTest(DBTestBase): def prepare_data(self): - c = counter.Counter( + c = sample.Sample( 'dummyBigCounter', - counter.TYPE_CUMULATIVE, + sample.TYPE_CUMULATIVE, unit='', volume=3372036854775807, user_id='user-id', @@ -773,9 +773,9 @@ class CounterDataTypeTest(DBTestBase): self.conn.record_metering_data(msg) - c = counter.Counter( + c = sample.Sample( 'dummySmallCounter', - counter.TYPE_CUMULATIVE, + sample.TYPE_CUMULATIVE, unit='', volume=-3372036854775807, user_id='user-id', @@ -791,9 +791,9 @@ class CounterDataTypeTest(DBTestBase): ) self.conn.record_metering_data(msg) - c = counter.Counter( + c = sample.Sample( 'floatCounter', - counter.TYPE_CUMULATIVE, + sample.TYPE_CUMULATIVE, unit='', volume=1938495037.53697, user_id='user-id', diff --git a/tests/storage/test_impl_mongodb.py b/tests/storage/test_impl_mongodb.py index 5449272e5..1ce40ddd9 100644 --- a/tests/storage/test_impl_mongodb.py +++ b/tests/storage/test_impl_mongodb.py @@ -33,7 +33,7 @@ from oslo.config import cfg from tests.storage import base from ceilometer.publisher import rpc -from ceilometer import counter +from ceilometer import sample from ceilometer.storage import impl_mongodb from ceilometer.storage import models @@ -223,7 +223,7 @@ class CompatibilityTest(MongoDBEngineTestBase): 'record_metering_data', old_record_metering_data) self.counters = [] - c = counter.Counter( + c = sample.Sample( 'volume.size', 'gauge', 'GiB', diff --git a/tests/test_pipeline.py b/tests/test_pipeline.py index d2892f872..80e9ca454 100644 --- a/tests/test_pipeline.py +++ b/tests/test_pipeline.py @@ -21,7 +21,7 @@ import datetime from stevedore import extension -from ceilometer import counter +from ceilometer import sample from ceilometer import publisher from ceilometer.publisher import test as test_publisher from ceilometer import transformer @@ -101,9 +101,9 @@ class TestPipeline(base.TestCase): def setUp(self): super(TestPipeline, self).setUp() - self.test_counter = counter.Counter( + self.test_counter = sample.Sample( name='a', - type=counter.TYPE_GAUGE, + type=sample.TYPE_GAUGE, volume=1, unit='B', user_id="test_user", @@ -653,9 +653,9 @@ class TestPipeline(base.TestCase): ] self.pipeline_cfg[0]['counters'] = ['cpu'] counters = [ - counter.Counter( + sample.Sample( name='cpu', - type=counter.TYPE_CUMULATIVE, + type=sample.TYPE_CUMULATIVE, volume=1200000000, unit='ns', user_id='test_user', @@ -678,7 +678,7 @@ class TestPipeline(base.TestCase): cpu_mins = publisher.counters[-1] self.assertEquals(getattr(cpu_mins, 'name'), 'cpu_mins') self.assertEquals(getattr(cpu_mins, 'unit'), 'min') - self.assertEquals(getattr(cpu_mins, 'type'), counter.TYPE_CUMULATIVE) + self.assertEquals(getattr(cpu_mins, 'type'), sample.TYPE_CUMULATIVE) self.assertEquals(getattr(cpu_mins, 'volume'), 20) def test_unit_identified_source_unit_conversion(self): @@ -695,9 +695,9 @@ class TestPipeline(base.TestCase): self.pipeline_cfg[0]['counters'] = ['core_temperature', 'ambient_temperature'] counters = [ - counter.Counter( + sample.Sample( name='core_temperature', - type=counter.TYPE_GAUGE, + type=sample.TYPE_GAUGE, volume=36.0, unit='°C', user_id='test_user', @@ -706,9 +706,9 @@ class TestPipeline(base.TestCase): timestamp=timeutils.utcnow().isoformat(), resource_metadata={} ), - counter.Counter( + sample.Sample( name='ambient_temperature', - type=counter.TYPE_GAUGE, + type=sample.TYPE_GAUGE, volume=88.8, unit='°F', user_id='test_user', @@ -748,7 +748,7 @@ class TestPipeline(base.TestCase): 'source': {}, 'target': {'name': 'cpu_util', 'unit': '%', - 'type': counter.TYPE_GAUGE, + 'type': sample.TYPE_GAUGE, 'scale': s}, } }, @@ -758,7 +758,7 @@ class TestPipeline(base.TestCase): later = now + datetime.timedelta(minutes=offset) um = {'autoscaling_weight': weight} if weight else {} counters = [ - counter.Counter( + sample.Sample( name='cpu', type=type, volume=prev, @@ -770,7 +770,7 @@ class TestPipeline(base.TestCase): resource_metadata={'cpu_number': 4, 'user_metadata': um}, ), - counter.Counter( + sample.Sample( name='cpu', type=type, volume=prev, @@ -782,7 +782,7 @@ class TestPipeline(base.TestCase): resource_metadata={'cpu_number': 2, 'user_metadata': um}, ), - counter.Counter( + sample.Sample( name='cpu', type=type, volume=curr, @@ -794,7 +794,7 @@ class TestPipeline(base.TestCase): resource_metadata={'cpu_number': 4, 'user_metadata': um}, ), - counter.Counter( + sample.Sample( name='cpu', type=type, volume=curr, @@ -821,44 +821,44 @@ class TestPipeline(base.TestCase): self.assertEquals(getattr(cpu_util, 'name'), 'cpu_util') self.assertEquals(getattr(cpu_util, 'resource_id'), 'test_resource') self.assertEquals(getattr(cpu_util, 'unit'), '%') - self.assertEquals(getattr(cpu_util, 'type'), counter.TYPE_GAUGE) + self.assertEquals(getattr(cpu_util, 'type'), sample.TYPE_GAUGE) self.assertEquals(getattr(cpu_util, 'volume'), expected) cpu_util = publisher.counters[1] self.assertEquals(getattr(cpu_util, 'name'), 'cpu_util') self.assertEquals(getattr(cpu_util, 'resource_id'), 'test_resource2') self.assertEquals(getattr(cpu_util, 'unit'), '%') - self.assertEquals(getattr(cpu_util, 'type'), counter.TYPE_GAUGE) + self.assertEquals(getattr(cpu_util, 'type'), sample.TYPE_GAUGE) self.assertEquals(getattr(cpu_util, 'volume'), expected * 2) def test_rate_of_change_conversion(self): self._do_test_rate_of_change_conversion(120000000000, 180000000000, - counter.TYPE_CUMULATIVE, + sample.TYPE_CUMULATIVE, 25.0) def test_rate_of_change_conversion_weight(self): self._do_test_rate_of_change_conversion(120000000000, 180000000000, - counter.TYPE_CUMULATIVE, + sample.TYPE_CUMULATIVE, 27.5, weight=1.1) def test_rate_of_change_conversion_negative_cumulative_delta(self): self._do_test_rate_of_change_conversion(180000000000, 120000000000, - counter.TYPE_CUMULATIVE, + sample.TYPE_CUMULATIVE, 50.0) def test_rate_of_change_conversion_negative_gauge_delta(self): self._do_test_rate_of_change_conversion(180000000000, 120000000000, - counter.TYPE_GAUGE, + sample.TYPE_GAUGE, -25.0) def test_rate_of_change_conversion_zero_delay(self): self._do_test_rate_of_change_conversion(120000000000, 120000000000, - counter.TYPE_CUMULATIVE, + sample.TYPE_CUMULATIVE, 0.0, offset=0) @@ -871,7 +871,7 @@ class TestPipeline(base.TestCase): 'source': {}, 'target': {'name': 'cpu_util', 'unit': '%', - 'type': counter.TYPE_GAUGE, + 'type': sample.TYPE_GAUGE, 'scale': s} } }, @@ -879,9 +879,9 @@ class TestPipeline(base.TestCase): self.pipeline_cfg[0]['counters'] = ['cpu'] now = timeutils.utcnow() counters = [ - counter.Counter( + sample.Sample( name='cpu', - type=counter.TYPE_CUMULATIVE, + type=sample.TYPE_CUMULATIVE, volume=120000000000, unit='ns', user_id='test_user', diff --git a/tools/make_test_data.py b/tools/make_test_data.py index bd1af6c1d..5068ef7d6 100755 --- a/tools/make_test_data.py +++ b/tools/make_test_data.py @@ -28,7 +28,7 @@ import sys from oslo.config import cfg from ceilometer.publisher import rpc -from ceilometer import counter +from ceilometer import sample from ceilometer import storage from ceilometer.openstack.common import timeutils @@ -119,7 +119,7 @@ def main(): # Generate events n = 0 while timestamp <= end: - c = counter.Counter(name=args.counter, + c = sample.Sample(name=args.counter, type=args.type, unit=args.unit, volume=args.volume,