diff --git a/ceilometer/compute/notifications/instance.py b/ceilometer/compute/notifications/instance.py index 7ee1fd4d..de75571d 100644 --- a/ceilometer/compute/notifications/instance.py +++ b/ceilometer/compute/notifications/instance.py @@ -89,58 +89,6 @@ class Instance(ComputeInstanceNotificationBase, message=message) -class Memory(ComputeInstanceNotificationBase): - def get_sample(self, message): - yield sample.Sample.from_notification( - name='memory', - type=sample.TYPE_GAUGE, - unit='MB', - volume=message['payload']['memory_mb'], - user_id=message['payload']['user_id'], - project_id=message['payload']['tenant_id'], - resource_id=message['payload']['instance_id'], - message=message) - - -class VCpus(ComputeInstanceNotificationBase): - def get_sample(self, message): - yield sample.Sample.from_notification( - name='vcpus', - type=sample.TYPE_GAUGE, - unit='vcpu', - volume=message['payload']['vcpus'], - user_id=message['payload']['user_id'], - project_id=message['payload']['tenant_id'], - resource_id=message['payload']['instance_id'], - message=message) - - -class RootDiskSize(ComputeInstanceNotificationBase): - def get_sample(self, message): - yield sample.Sample.from_notification( - name='disk.root.size', - type=sample.TYPE_GAUGE, - unit='GB', - volume=message['payload']['root_gb'], - user_id=message['payload']['user_id'], - project_id=message['payload']['tenant_id'], - resource_id=message['payload']['instance_id'], - message=message) - - -class EphemeralDiskSize(ComputeInstanceNotificationBase): - def get_sample(self, message): - yield sample.Sample.from_notification( - name='disk.ephemeral.size', - type=sample.TYPE_GAUGE, - unit='GB', - volume=message['payload']['ephemeral_gb'], - user_id=message['payload']['user_id'], - project_id=message['payload']['tenant_id'], - resource_id=message['payload']['instance_id'], - message=message) - - class InstanceDelete(ComputeInstanceNotificationBase): """Handle the messages sent by the nova notifier plugin. diff --git a/ceilometer/exchange_control.py b/ceilometer/exchange_control.py index 2639b5eb..d8bd0214 100644 --- a/ceilometer/exchange_control.py +++ b/ceilometer/exchange_control.py @@ -32,4 +32,7 @@ EXCHANGE_OPTS = [ cfg.StrOpt('sahara_control_exchange', default='sahara', help="Exchange name for Data Processing notifications."), + cfg.StrOpt('swift_control_exchange', + default='swift', + help="Exchange name for Swift notifications."), ] diff --git a/ceilometer/meter/data/meters.yaml b/ceilometer/meter/data/meters.yaml index d3708d13..ad65ef13 100644 --- a/ceilometer/meter/data/meters.yaml +++ b/ceilometer/meter/data/meters.yaml @@ -78,6 +78,49 @@ metric: project_id: payload.initiator.project_id multi: ['name', 'unit', 'volume'] + - name: 'memory' + event_type: 'compute.instance.*' + type: 'gauge' + unit: 'MB' + volume: payload.memory_mb + user_id: payload.user_id + project_id: payload.tenant_id + resource_id: payload.instance_id + + - name: 'vcpus' + event_type: 'compute.instance.*' + type: 'gauge' + unit: 'vcpu' + volume: payload.vcpus + user_id: payload.user_id + project_id: payload.tenant_id + resource_id: payload.instance_id + + - name: 'disk.root.size' + event_type: 'compute.instance.*' + type: 'gauge' + unit: 'GB' + volume: payload.root_gb + user_id: payload.user_id + project_id: payload.tenant_id + resource_id: payload.instance_id + + - name: 'disk.ephemeral.size' + event_type: 'compute.instance.*' + type: 'gauge' + unit: 'GB' + volume: payload.ephemeral_gb + user_id: payload.user_id + project_id: payload.tenant_id + resource_id: payload.instance_id + + - name: 'bandwidth' + event_type: 'l3.meter' + type: 'delta' + unit: 'B' + volume: payload.bytes + project_id: payload.tenant_id + resource_id: payload.label_id # NOTE: non-metric meters are generally events/existence meters # These are expected to be DEPRECATED in future releases @@ -575,3 +618,13 @@ metric: - 'identity.trust.deleted' resource_id: payload.resource_info user_id: payload.initiator.id + + - name: 'storage.api.request' + type: 'delta' + unit: 'request' + volume: 1 + event_type: + - 'objectstore.http.request' + resource_id: payload.target.id + user_id: payload.initiator.id + project_id: payload.initiator.project_id diff --git a/ceilometer/network/notifications.py b/ceilometer/network/notifications.py index e61a9f8a..9d8d61bc 100644 --- a/ceilometer/network/notifications.py +++ b/ceilometer/network/notifications.py @@ -153,25 +153,6 @@ class FloatingIP(NetworkNotificationBase, unit = 'ip' -class Bandwidth(NetworkNotificationBase): - """Listen for Neutron notifications. - - Listen in order to mediate with the metering framework. - """ - event_types = ['l3.meter'] - - def process_notification(self, message): - yield sample.Sample.from_notification( - name='bandwidth', - type=sample.TYPE_DELTA, - unit='B', - volume=message['payload']['bytes'], - user_id=None, - project_id=message['payload']['tenant_id'], - resource_id=message['payload']['label_id'], - message=message) - - class Pool(NetworkNotificationBase, plugin_base.NonMetricNotificationBase): """Listen for Neutron notifications. diff --git a/ceilometer/objectstore/notifications.py b/ceilometer/objectstore/notifications.py deleted file mode 100644 index 6e58420e..00000000 --- a/ceilometer/objectstore/notifications.py +++ /dev/null @@ -1,62 +0,0 @@ -# -# Copyright 2015 Red Hat. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from oslo_config import cfg -import oslo_messaging - -from ceilometer.agent import plugin_base -from ceilometer import sample - -OPTS = [ - cfg.StrOpt('swift_control_exchange', - default='swift', - help="Exchange name for Swift notifications."), -] - - -cfg.CONF.register_opts(OPTS) - - -class _Base(plugin_base.NotificationBase): - """Convert objectstore notification into Samples.""" - - @staticmethod - def get_targets(conf): - """Return a sequence of oslo_messaging.Target - - Sequence defining the exchange and topics to be connected for this - plugin. - """ - return [oslo_messaging.Target(topic=topic, - exchange=conf.swift_control_exchange) - for topic in conf.notification_topics] - - -class SwiftWsgiMiddleware(_Base, plugin_base.NonMetricNotificationBase): - - @property - def event_types(self): - return ['objectstore.http.request'] - - def process_notification(self, message): - yield sample.Sample.from_notification( - name='storage.api.request', - type=sample.TYPE_DELTA, - unit='request', - volume=1, - resource_id=message['payload']['target']['id'], - user_id=message['payload']['initiator']['id'], - project_id=message['payload']['initiator']['project_id'], - message=message) diff --git a/ceilometer/tests/unit/compute/notifications/test_instance.py b/ceilometer/tests/unit/compute/notifications/test_instance.py index aa61162d..3f61a38a 100644 --- a/ceilometer/tests/unit/compute/notifications/test_instance.py +++ b/ceilometer/tests/unit/compute/notifications/test_instance.py @@ -631,35 +631,6 @@ class TestNotifications(base.BaseTestCase): c = counters[0] self.assertEqual(1, c.volume) - def test_instance_create_memory(self): - ic = instance.Memory(None) - counters = list(ic.process_notification(INSTANCE_CREATE_END)) - self.assertEqual(1, len(counters)) - c = counters[0] - self.assertEqual(INSTANCE_CREATE_END['payload']['memory_mb'], c.volume) - - def test_instance_create_vcpus(self): - ic = instance.VCpus(None) - counters = list(ic.process_notification(INSTANCE_CREATE_END)) - self.assertEqual(1, len(counters)) - c = counters[0] - self.assertEqual(INSTANCE_CREATE_END['payload']['vcpus'], c.volume) - - def test_instance_create_root_disk_size(self): - ic = instance.RootDiskSize(None) - counters = list(ic.process_notification(INSTANCE_CREATE_END)) - self.assertEqual(1, len(counters)) - c = counters[0] - self.assertEqual(INSTANCE_CREATE_END['payload']['root_gb'], c.volume) - - def test_instance_create_ephemeral_disk_size(self): - ic = instance.EphemeralDiskSize(None) - counters = list(ic.process_notification(INSTANCE_CREATE_END)) - self.assertEqual(1, len(counters)) - c = counters[0] - self.assertEqual(INSTANCE_CREATE_END['payload']['ephemeral_gb'], - c.volume) - def test_instance_exists_instance(self): ic = instance.Instance(None) counters = list(ic.process_notification(INSTANCE_EXISTS)) @@ -683,24 +654,6 @@ class TestNotifications(base.BaseTestCase): self.assertEqual(1, c.volume) self._verify_user_metadata(c.resource_metadata) - def test_instance_finish_resize_memory(self): - ic = instance.Memory(None) - counters = list(ic.process_notification(INSTANCE_FINISH_RESIZE_END)) - self.assertEqual(1, len(counters)) - c = counters[0] - self.assertEqual(INSTANCE_FINISH_RESIZE_END['payload']['memory_mb'], - c.volume) - self._verify_user_metadata(c.resource_metadata) - - def test_instance_finish_resize_vcpus(self): - ic = instance.VCpus(None) - counters = list(ic.process_notification(INSTANCE_FINISH_RESIZE_END)) - self.assertEqual(1, len(counters)) - c = counters[0] - self.assertEqual(INSTANCE_FINISH_RESIZE_END['payload']['vcpus'], - c.volume) - self._verify_user_metadata(c.resource_metadata) - def test_instance_resize_finish_instance(self): ic = instance.Instance(None) counters = list(ic.process_notification(INSTANCE_FINISH_RESIZE_END)) @@ -709,24 +662,6 @@ class TestNotifications(base.BaseTestCase): self.assertEqual(1, c.volume) self._verify_user_metadata(c.resource_metadata) - def test_instance_resize_finish_memory(self): - ic = instance.Memory(None) - counters = list(ic.process_notification(INSTANCE_RESIZE_REVERT_END)) - self.assertEqual(1, len(counters)) - c = counters[0] - self.assertEqual(INSTANCE_RESIZE_REVERT_END['payload']['memory_mb'], - c.volume) - self._verify_user_metadata(c.resource_metadata) - - def test_instance_resize_finish_vcpus(self): - ic = instance.VCpus(None) - counters = list(ic.process_notification(INSTANCE_RESIZE_REVERT_END)) - self.assertEqual(1, len(counters)) - c = counters[0] - self.assertEqual(INSTANCE_RESIZE_REVERT_END['payload']['vcpus'], - c.volume) - self._verify_user_metadata(c.resource_metadata) - def test_instance_delete_samples(self): ic = instance.InstanceDelete(None) counters = list(ic.process_notification(INSTANCE_DELETE_SAMPLES)) diff --git a/ceilometer/tests/unit/network/test_notifications.py b/ceilometer/tests/unit/network/test_notifications.py index fce78483..80eda675 100644 --- a/ceilometer/tests/unit/network/test_notifications.py +++ b/ceilometer/tests/unit/network/test_notifications.py @@ -381,30 +381,6 @@ NOTIFICATION_FLOATINGIP_UPDATE_START = { } -NOTIFICATION_L3_METER = { - u'_context_roles': [u'admin'], - u'_context_read_deleted': u'no', - u'event_type': u'l3.meter', - u'timestamp': u'2013-08-22 13:14:06.880304', - u'_context_tenant_id': None, - u'payload': {u'first_update': 1377176476, - u'bytes': 0, - u'label_id': u'383244a7-e99b-433a-b4a1-d37cf5b17d15', - u'last_update': 1377177246, - u'host': u'precise64', - u'tenant_id': u'admin', - u'time': 30, - u'pkts': 0}, - u'priority': u'INFO', - u'_context_is_admin': True, - u'_context_timestamp': u'2013-08-22 13:01:06.614635', - u'_context_user_id': None, - u'publisher_id': u'metering.precise64', - u'message_id': u'd7aee6e8-c7eb-4d47-9338-f60920d708e4', - u'_unique_id': u'd5a3bdacdcc24644b84e67a4c10e886a', - u'_context_project_id': None} - - NOTIFICATION_POOL_CREATE = { "_context_roles": ["heat_stack_owner", "admin"], "_context_request_id": "req-10715057-7590-4529-8020-b994295ee6f4", @@ -1295,12 +1271,6 @@ class TestNotifications(test.BaseTestCase): self.assertEqual(len(samples), 2) self.assertEqual("ip.floating", samples[0].name) - def test_metering_report(self): - v = notifications.Bandwidth(mock.Mock()) - samples = list(v.process_notification(NOTIFICATION_L3_METER)) - self.assertEqual(1, len(samples)) - self.assertEqual("bandwidth", samples[0].name) - def test_pool_create(self): v = notifications.Pool(mock.Mock()) samples = list(v.process_notification(NOTIFICATION_POOL_CREATE)) @@ -1475,9 +1445,6 @@ class TestEventTypes(test.BaseTestCase): def test_floatingip(self): self.assertTrue(notifications.FloatingIP(mock.Mock()).event_types) - def test_bandwidth(self): - self.assertTrue(notifications.Bandwidth(mock.Mock()).event_types) - def test_pool(self): self.assertTrue(notifications.Pool(mock.Mock()).event_types) diff --git a/ceilometer/tests/unit/objectstore/test_notifications.py b/ceilometer/tests/unit/objectstore/test_notifications.py deleted file mode 100644 index d6e1d928..00000000 --- a/ceilometer/tests/unit/objectstore/test_notifications.py +++ /dev/null @@ -1,100 +0,0 @@ -# -# 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. -"""Tests for swift notification events.""" -import mock - -from ceilometer.objectstore import notifications -from ceilometer.tests import base as test - - -MIDDLEWARE_EVENT = { - u'_context_request_id': u'req-a8bfa89b-d28b-4b95-9e4b-7d7875275650', - u'_context_quota_class': None, - u'event_type': u'objectstore.http.request', - u'_context_service_catalog': [], - u'_context_auth_token': None, - u'_context_user_id': None, - u'priority': u'INFO', - u'_context_is_admin': True, - u'_context_user': None, - u'publisher_id': u'ceilometermiddleware', - u'message_id': u'6eccedba-120e-4db8-9735-2ad5f061e5ee', - u'_context_remote_address': None, - u'_context_roles': [], - u'timestamp': u'2013-07-29 06:51:34.474815', - u'_context_timestamp': u'2013-07-29T06:51:34.348091', - u'_unique_id': u'0ee26117077648e18d88ac76e28a72e2', - u'_context_project_name': None, - u'_context_read_deleted': u'no', - u'_context_tenant': None, - u'_context_instance_lock_checked': False, - u'_context_project_id': None, - u'_context_user_name': None, - u'payload': { - 'typeURI': 'http: //schemas.dmtf.org/cloud/audit/1.0/event', - 'eventTime': '2015-01-30T16: 38: 43.233621', - 'target': { - 'action': 'get', - 'typeURI': 'service/storage/object', - 'id': 'account', - 'metadata': { - 'path': '/1.0/CUSTOM_account/container/obj', - 'version': '1.0', - 'container': 'container', - 'object': 'obj' - } - }, - 'observer': { - 'id': 'target' - }, - 'eventType': 'activity', - 'measurements': [ - { - 'metric': { - 'metricId': 'openstack: uuid', - 'name': 'storage.objects.outgoing.bytes', - 'unit': 'B' - }, - 'result': 28 - }, - { - 'metric': { - 'metricId': 'openstack: uuid2', - 'name': 'storage.objects.incoming.bytes', - 'unit': 'B' - }, - 'result': 1 - } - ], - 'initiator': { - 'typeURI': 'service/security/account/user', - 'project_id': None, - 'id': 'openstack: 288f6260-bf37-4737-a178-5038c84ba244' - }, - 'action': 'read', - 'outcome': 'success', - 'id': 'openstack: 69972bb6-14dd-46e4-bdaf-3148014363dc' - } -} - - -class TestMiddlewareNotifications(test.BaseTestCase): - def test_middleware_event(self): - v = notifications.SwiftWsgiMiddleware(mock.Mock()) - samples = list(v.process_notification(MIDDLEWARE_EVENT)) - self.assertEqual(1, len(samples)) - target = MIDDLEWARE_EVENT['payload']['target'] - initiator = MIDDLEWARE_EVENT['payload']['initiator'] - self.assertEqual(target['id'], samples[0].resource_id) - self.assertEqual(initiator['id'], samples[0].user_id) - self.assertEqual(initiator['project_id'], samples[0].project_id) diff --git a/setup.cfg b/setup.cfg index 5570c4dd..514581b3 100644 --- a/setup.cfg +++ b/setup.cfg @@ -31,10 +31,6 @@ ceilometer.notification = instance = ceilometer.compute.notifications.instance:Instance instance_delete = ceilometer.compute.notifications.instance:InstanceDelete instance_scheduled = ceilometer.compute.notifications.instance:InstanceScheduled - memory = ceilometer.compute.notifications.instance:Memory - vcpus = ceilometer.compute.notifications.instance:VCpus - disk_root_size = ceilometer.compute.notifications.instance:RootDiskSize - disk_ephemeral_size = ceilometer.compute.notifications.instance:EphemeralDiskSize cpu_frequency = ceilometer.compute.notifications.cpu:CpuFrequency cpu_user_time = ceilometer.compute.notifications.cpu:CpuUserTime cpu_kernel_time = ceilometer.compute.notifications.cpu:CpuKernelTime @@ -50,7 +46,6 @@ ceilometer.notification = port = ceilometer.network.notifications:Port router = ceilometer.network.notifications:Router floatingip = ceilometer.network.notifications:FloatingIP - bandwidth = ceilometer.network.notifications:Bandwidth http.request = ceilometer.middleware:HTTPRequest http.response = ceilometer.middleware:HTTPResponse profiler = ceilometer.profiler.notifications:ProfilerNotifications @@ -69,7 +64,6 @@ ceilometer.notification = network.services.vpn.ipsecpolicy = ceilometer.network.notifications:IPSecPolicy network.services.vpn.ikepolicy = ceilometer.network.notifications:IKEPolicy network.services.vpn.connections = ceilometer.network.notifications:IPSecSiteConnection - objectstore.request = ceilometer.objectstore.notifications:SwiftWsgiMiddleware _sample = ceilometer.telemetry.notifications:TelemetryApiPost trove.instance.exists = ceilometer.database.notifications:InstanceExists dns.domain.exists = ceilometer.dns.notifications:DomainExists