Merge "Convert identity, sahara and volume to meters yaml"

This commit is contained in:
Jenkins 2015-08-07 14:11:44 +00:00 committed by Gerrit Code Review
commit 74d7c39923
16 changed files with 475 additions and 1174 deletions

View File

@ -1,71 +0,0 @@
# Copyright (c) 2014 Mirantis 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.
from oslo_config import cfg
import oslo_messaging
from ceilometer.agent import plugin_base
from ceilometer import sample
OPTS = [
cfg.StrOpt('sahara_control_exchange',
default='sahara',
help="Exchange name for Data Processing notifications."),
]
cfg.CONF.register_opts(OPTS)
SERVICE = 'sahara'
class DataProcessing(plugin_base.NotificationBase,
plugin_base.NonMetricNotificationBase):
resource_name = '%s.cluster' % SERVICE
@property
def event_types(self):
return [
'%s.create' % self.resource_name,
'%s.update' % self.resource_name,
'%s.delete' % self.resource_name,
]
@staticmethod
def get_targets(conf):
"""Return a sequence of oslo_messaging.Target
It is defining the exchange and topics to be connected for this plugin.
"""
return [oslo_messaging.Target(topic=topic,
exchange=conf.sahara_control_exchange)
for topic in conf.notification_topics]
def process_notification(self, message):
name = message['event_type'].replace(self.resource_name, 'cluster')
project_id = message['payload']['project_id']
user_id = message['_context_user_id']
yield sample.Sample.from_notification(
name=name,
type=sample.TYPE_DELTA,
unit='cluster',
volume=1,
resource_id=message['payload']['cluster_id'],
user_id=user_id,
project_id=project_id,
message=message)

View File

@ -23,4 +23,13 @@ EXCHANGE_OPTS = [
cfg.StrOpt('magnetodb_control_exchange',
default='magnetodb',
help="Exchange name for Magnetodb notifications."),
cfg.StrOpt('keystone_control_exchange',
default='keystone',
help="Exchange name for Keystone notifications."),
cfg.StrOpt('cinder_control_exchange',
default='cinder',
help="Exchange name for Cinder notifications."),
cfg.StrOpt('sahara_control_exchange',
default='sahara',
help="Exchange name for Data Processing notifications."),
]

View File

@ -1,172 +0,0 @@
# Copyright 2014 Mirantis 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.
from oslo_config import cfg
import oslo_messaging
from ceilometer.agent import plugin_base
from ceilometer import sample
OPTS = [
cfg.StrOpt('keystone_control_exchange',
default='keystone',
help="Exchange name for Keystone notifications."),
]
cfg.CONF.register_opts(OPTS)
SERVICE = 'identity'
class _Base(plugin_base.NotificationBase,
plugin_base.NonMetricNotificationBase):
"""Convert identity notification into Samples."""
resource_type = None
resource_name = None
@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.keystone_control_exchange)
for topic in conf.notification_topics]
class IdentityCRUD(_Base):
def process_notification(self, message):
user_id = message['payload'].get("initiator", {}).get("id")
yield sample.Sample.from_notification(
name=message['event_type'],
type=sample.TYPE_DELTA,
unit=self.resource_type,
volume=1,
resource_id=message['payload']['resource_info'],
user_id=user_id,
project_id=None,
message=message)
class User(IdentityCRUD):
resource_type = 'user'
resource_name = '%s.%s' % (SERVICE, resource_type)
@property
def event_types(self):
return ['%s.*' % self.resource_name]
class Group(IdentityCRUD):
resource_type = 'group'
resource_name = '%s.%s' % (SERVICE, resource_type)
@property
def event_types(self):
return ['%s.*' % self.resource_name]
class Project(IdentityCRUD):
resource_type = 'project'
resource_name = '%s.%s' % (SERVICE, resource_type)
@property
def event_types(self):
return ['%s.*' % self.resource_name]
class Role(IdentityCRUD):
resource_type = 'role'
resource_name = '%s.%s' % (SERVICE, resource_type)
@property
def event_types(self):
return ['%s\..*' % self.resource_name]
class Trust(IdentityCRUD):
resource_type = 'OS-TRUST:trust'
resource_name = '%s.%s' % (SERVICE, resource_type)
@property
def event_types(self):
return [
'%s.created' % self.resource_name,
'%s.deleted' % self.resource_name,
]
class Authenticate(_Base):
"""Convert identity authentication notifications into Samples."""
resource_type = 'authenticate'
event_name = '%s.%s' % (SERVICE, resource_type)
def process_notification(self, message):
outcome = message['payload']['outcome']
meter_name = '%s.%s.%s' % (SERVICE, self.resource_type, outcome)
yield sample.Sample.from_notification(
name=meter_name,
type=sample.TYPE_DELTA,
unit='user',
volume=1,
resource_id=message['payload']['initiator']['id'],
user_id=message['payload']['initiator']['id'],
project_id=None,
message=message)
@property
def event_types(self):
return [self.event_name]
class RoleAssignment(_Base):
"""Convert role assignment notifications into Samples."""
resource_type = 'role_assignment'
resource_name = '%s.%s' % (SERVICE, resource_type)
def process_notification(self, message):
# NOTE(stevemar): action is created.role_assignment
action = message['payload']['action']
event, resource_type = action.split(".")
# NOTE(stevemar): meter_name is identity.role_assignment.created
meter_name = '%s.%s.%s' % (SERVICE, resource_type, event)
yield sample.Sample.from_notification(
name=meter_name,
type=sample.TYPE_DELTA,
unit=self.resource_type,
volume=1,
resource_id=message['payload']['role'],
user_id=message['payload']['initiator']['id'],
project_id=None,
message=message)
@property
def event_types(self):
return [
'%s.created' % self.resource_name,
'%s.deleted' % self.resource_name,
]

View File

@ -39,6 +39,33 @@ metric:
resource_id: payload.table_uuid
user_id: _context_user
- name: 'volume.size'
event_type:
- 'volume.exists'
- 'volume.create.*'
- 'volume.delete.*'
- 'volume.resize.*'
- 'volume.attach.*'
- 'volume.detach.*'
- 'volume.update.*'
type: 'gauge'
unit: 'GB'
volume: payload.size
user_id: payload.user_id
project_id: payload.tenant_id
resource_id: payload.volume_id
- name: 'snapshot.size'
event_type:
- 'snapshot.exists'
- 'snapshot.create.*'
- 'snapshot.delete.*'
type: 'gauge'
unit: 'GB'
volume: payload.volume_size
user_id: payload.user_id
project_id: payload.tenant_id
resource_id: payload.snapshot_id
# NOTE: non-metric meters are generally events/existence meters
# These are expected to be DEPRECATED in future releases
@ -46,9 +73,9 @@ metric:
# Image
- name: "image"
event_type:
- "image.upload"
- "image.delete"
- "image.update"
- "image.upload"
- "image.delete"
- "image.update"
type: "gauge"
unit: 'image'
volume: 1
@ -124,3 +151,415 @@ metric:
resource_id: payload.table_uuid
user_id: _context_user
project_id: _context_tenant
# Volume
- name: 'volume'
type: 'gauge'
unit: 'volume'
volume: 1
event_type:
- 'volume.exists'
- 'volume.create.*'
- 'volume.delete.*'
- 'volume.resize.*'
- 'volume.attach.*'
- 'volume.detach.*'
- 'volume.update.*'
resource_id: payload.volume_id
user_id: payload.user_id
project_id: payload.tenant_id
- name: 'volume.exists'
type: 'delta'
unit: 'volume'
volume: 1
event_type:
- 'volume.exists'
resource_id: payload.volume_id
user_id: payload.user_id
project_id: payload.tenant_id
- name: 'volume.create.start'
type: 'delta'
unit: 'volume'
volume: 1
event_type:
- 'volume.create.start'
resource_id: payload.volume_id
user_id: payload.user_id
project_id: payload.tenant_id
- name: 'volume.create.end'
type: 'delta'
unit: 'volume'
volume: 1
event_type:
- 'volume.create.end'
resource_id: payload.volume_id
user_id: payload.user_id
project_id: payload.tenant_id
- name: 'volume.delete.start'
type: 'delta'
unit: 'volume'
volume: 1
event_type:
- 'volume.delete.start'
resource_id: payload.volume_id
user_id: payload.user_id
project_id: payload.tenant_id
- name: 'volume.delete.end'
type: 'delta'
unit: 'volume'
volume: 1
event_type:
- 'volume.delete.end'
resource_id: payload.volume_id
user_id: payload.user_id
project_id: payload.tenant_id
- name: 'volume.update.end'
type: 'delta'
unit: 'volume'
volume: 1
event_type:
- 'volume.update.end'
resource_id: payload.volume_id
user_id: payload.user_id
project_id: payload.tenant_id
- name: 'volume.update.start'
type: 'delta'
unit: 'volume'
volume: 1
event_type:
- 'volume.update.start'
resource_id: payload.volume_id
user_id: payload.user_id
project_id: payload.tenant_id
- name: 'volume.resize.end'
type: 'delta'
unit: 'volume'
volume: 1
event_type:
- 'volume.resize.end'
resource_id: payload.volume_id
user_id: payload.user_id
project_id: payload.tenant_id
- name: 'volume.resize.start'
type: 'delta'
unit: 'volume'
volume: 1
event_type:
- 'volume.resize.start'
resource_id: payload.volume_id
user_id: payload.user_id
project_id: payload.tenant_id
- name: 'volume.attach.end'
type: 'delta'
unit: 'volume'
volume: 1
event_type:
- 'volume.attach.end'
resource_id: payload.volume_id
user_id: payload.user_id
project_id: payload.tenant_id
- name: 'volume.attach.start'
type: 'delta'
unit: 'volume'
volume: 1
event_type:
- 'volume.attach.start'
resource_id: payload.volume_id
user_id: payload.user_id
project_id: payload.tenant_id
- name: 'volume.detach.end'
type: 'delta'
unit: 'volume'
volume: 1
event_type:
- 'volume.detach.end'
resource_id: payload.volume_id
user_id: payload.user_id
project_id: payload.tenant_id
- name: 'volume.detach.start'
type: 'delta'
unit: 'volume'
volume: 1
event_type:
- 'volume.detach.start'
resource_id: payload.volume_id
user_id: payload.user_id
project_id: payload.tenant_id
# Volume Snapshot
- name: 'snapshot'
type: 'gauge'
unit: 'snapshot'
volume: 1
event_type:
- 'snapshot.exists'
- 'snapshot.create.*'
- 'snapshot.delete.*'
resource_id: payload.snapshot_id
user_id: payload.user_id
project_id: payload.tenant_id
- name: 'snapshot.exists'
type: 'delta'
unit: 'snapshot'
volume: 1
event_type:
- 'snapshot.exists'
resource_id: payload.snapshot_id
user_id: payload.user_id
project_id: payload.tenant_id
- name: 'snapshot.create.start'
type: 'delta'
unit: 'snapshot'
volume: 1
event_type:
- 'snapshot.create.start'
resource_id: payload.snapshot_id
user_id: payload.user_id
project_id: payload.tenant_id
- name: 'snapshot.create.end'
type: 'delta'
unit: 'snapshot'
volume: 1
event_type:
- 'snapshot.create.end'
resource_id: payload.snapshot_id
user_id: payload.user_id
project_id: payload.tenant_id
- name: 'snapshot.delete.start'
type: 'delta'
unit: 'snapshot'
volume: 1
event_type:
- 'snapshot.delete.start'
resource_id: payload.snapshot_id
user_id: payload.user_id
project_id: payload.tenant_id
- name: 'snapshot.delete.end'
type: 'delta'
unit: 'snapshot'
volume: 1
event_type:
- 'snapshot.delete.end'
resource_id: payload.snapshot_id
user_id: payload.user_id
project_id: payload.tenant_id
# Sahara
- name: 'cluster.create'
type: 'delta'
unit: 'cluster'
volume: 1
event_type:
- 'sahara.cluster.create'
resource_id: payload.cluster_id
project_id: payload.project_id
- name: 'cluster.update'
type: 'delta'
unit: 'cluster'
volume: 1
event_type:
- 'sahara.cluster.update'
resource_id: payload.cluster_id
project_id: payload.project_id
- name: 'cluster.delete'
type: 'delta'
unit: 'cluster'
volume: 1
event_type:
- 'sahara.cluster.delete'
resource_id: payload.cluster_id
project_id: payload.project_id
# Identity
- name: 'identity.user.created'
type: 'delta'
unit: 'user'
volume: 1
event_type:
- 'identity.user.created'
resource_id: payload.resource_info
user_id: payload.initiator.id
- name: 'identity.user.updated'
type: 'delta'
unit: 'user'
volume: 1
event_type:
- 'identity.user.updated'
resource_id: payload.resource_info
user_id: payload.initiator.id
- name: 'identity.user.deleted'
type: 'delta'
unit: 'user'
volume: 1
event_type:
- 'identity.user.deleted'
resource_id: payload.resource_info
user_id: payload.initiator.id
- name: 'identity.group.created'
type: 'delta'
unit: 'group'
volume: 1
event_type:
- 'identity.group.created'
resource_id: payload.resource_info
user_id: payload.initiator.id
- name: 'identity.group.updated'
type: 'delta'
unit: 'group'
volume: 1
event_type:
- 'identity.group.updated'
resource_id: payload.resource_info
user_id: payload.initiator.id
- name: 'identity.group.deleted'
type: 'delta'
unit: 'group'
volume: 1
event_type:
- 'identity.group.deleted'
resource_id: payload.resource_info
user_id: payload.initiator.id
- name: 'identity.project.created'
type: 'delta'
unit: 'project'
volume: 1
event_type:
- 'identity.project.created'
resource_id: payload.resource_info
user_id: payload.initiator.id
- name: 'identity.project.updated'
type: 'delta'
unit: 'project'
volume: 1
event_type:
- 'identity.project.updated'
resource_id: payload.resource_info
user_id: payload.initiator.id
- name: 'identity.project.deleted'
type: 'delta'
unit: 'project'
volume: 1
event_type:
- 'identity.project.deleted'
resource_id: payload.resource_info
user_id: payload.initiator.id
- name: 'identity.role.created'
type: 'delta'
unit: 'role'
volume: 1
event_type:
- 'identity.role.created'
resource_id: payload.resource_info
user_id: payload.initiator.id
- name: 'identity.role.updated'
type: 'delta'
unit: 'role'
volume: 1
event_type:
- 'identity.role.updated'
resource_id: payload.resource_info
user_id: payload.initiator.id
- name: 'identity.role.deleted'
type: 'delta'
unit: 'role'
volume: 1
event_type:
- 'identity.role.deleted'
resource_id: payload.resource_info
user_id: payload.initiator.id
- name: 'identity.role_assignment.created'
type: 'delta'
unit: 'role_assignment'
volume: 1
event_type:
- 'identity.role_assignment.created'
resource_id: payload.role
user_id: payload.initiator.id
- name: 'identity.role_assignment.deleted'
type: 'delta'
unit: 'role_assignment'
volume: 1
event_type:
- 'identity.role_assignment.deleted'
resource_id: payload.role
user_id: payload.initiator.id
- name: 'identity.authenticate.success'
type: 'delta'
unit: 'user'
volume: 1
event_type:
- 'identity.authenticate'
resource_id: payload.initiator.id
user_id: payload.initiator.id
- name: 'identity.authenticate.pending'
type: 'delta'
unit: 'user'
volume: 1
event_type:
- 'identity.authenticate'
resource_id: payload.initiator.id
user_id: payload.initiator.id
- name: 'identity.authenticate.failure'
type: 'delta'
unit: 'user'
volume: 1
event_type:
- 'identity.authenticate'
resource_id: payload.initiator.id
user_id: payload.initiator.id
- name: 'identity.trust.created'
type: 'delta'
unit: 'trust'
volume: 1
event_type:
- 'identity.trust.created'
resource_id: payload.resource_info
user_id: payload.initiator.id
- name: 'identity.trust.deleted'
type: 'delta'
unit: 'trust'
volume: 1
event_type:
- 'identity.trust.deleted'
resource_id: payload.resource_info
user_id: payload.initiator.id

View File

@ -26,7 +26,7 @@ cfg.CONF.import_opt('glance_control_exchange',
cfg.CONF.import_opt('neutron_control_exchange',
'ceilometer.network.notifications')
cfg.CONF.import_opt('cinder_control_exchange',
'ceilometer.volume.notifications')
'ceilometer.notification')
OPTS = [
cfg.MultiStrOpt('http_control_exchanges',

View File

@ -30,13 +30,11 @@ import ceilometer.compute.virt.libvirt.inspector
import ceilometer.compute.virt.vmware.inspector
import ceilometer.compute.virt.xenapi.inspector
import ceilometer.coordination
import ceilometer.data_processing.notifications
import ceilometer.dispatcher
import ceilometer.dispatcher.file
import ceilometer.energy.kwapi
import ceilometer.event.converter
import ceilometer.hardware.discovery
import ceilometer.identity.notifications
import ceilometer.image.glance
import ceilometer.ipmi.notifications.ironic
import ceilometer.ipmi.platform.intel_node_manager
@ -56,7 +54,6 @@ import ceilometer.sample
import ceilometer.service
import ceilometer.storage
import ceilometer.utils
import ceilometer.volume.notifications
def list_opts():
@ -69,9 +66,7 @@ def list_opts():
ceilometer.compute.util.OPTS,
ceilometer.compute.virt.inspector.OPTS,
ceilometer.compute.virt.libvirt.inspector.OPTS,
ceilometer.data_processing.notifications.OPTS,
ceilometer.dispatcher.OPTS,
ceilometer.identity.notifications.OPTS,
ceilometer.image.glance.OPTS,
ceilometer.ipmi.notifications.ironic.OPTS,
ceilometer.middleware.OPTS,
@ -83,8 +78,7 @@ def list_opts():
ceilometer.sample.OPTS,
ceilometer.service.OPTS,
ceilometer.storage.OLD_OPTS,
ceilometer.utils.OPTS,
ceilometer.volume.notifications.OPTS,)),
ceilometer.utils.OPTS,)),
('alarm',
itertools.chain(ceilometer.alarm.notifier.rest.OPTS,
ceilometer.alarm.service.OPTS,

View File

@ -32,7 +32,7 @@ OPTS = [
cfg.CONF.register_opts(OPTS)
# TODO(boris-42): remove after adding keystone audit plugins.
cfg.CONF.import_opt('keystone_control_exchange',
'ceilometer.identity.notifications')
'ceilometer.notification')
class ProfilerNotifications(plugin_base.NotificationBase,

View File

@ -1,101 +0,0 @@
# Copyright (c) 2014 Mirantis 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 datetime
import mock
from oslo_config import cfg
from oslo_log import log
from oslotest import base
from ceilometer.data_processing import notifications
from ceilometer import sample
NOW = datetime.datetime.isoformat(datetime.datetime.utcnow())
TENANT_ID = u'4c35985848bf4419b3f3d52c22e5792d'
CLUSTER_NAME = u'AS1-ASGroup-53sqbo7sor7i'
CLUSTER_ID = u'cb4a6fd1-1f5d-4002-ae91-9b91573cfb03'
USER_NAME = u'demo'
USER_ID = u'2e61f25ec63a4f6c954a6245421448a4'
CLUSTER_STATUS = u'Active'
PROJECT_ID = TENANT_ID
RESOURCE_ID = CLUSTER_ID
PUBLISHER_ID = u'data_processing.node-n5x66lxdy67d'
CONF = cfg.CONF
log.register_options(CONF)
CONF.set_override('use_stderr', True)
LOG = log.getLogger(__name__)
def _dp_notification_for(operation):
return {
u'event_type': '%s.cluster.%s' % (notifications.SERVICE,
operation),
u'_context_roles': [
u'Member',
],
u'_context_auth_uri': u'http://0.1.0.1:1010/v2.0',
u'timestamp': NOW,
u'_context_tenant_id': TENANT_ID,
u'payload': {
u'cluster_id': CLUSTER_ID,
u'cluster_name': CLUSTER_NAME,
u'cluster_status': CLUSTER_STATUS,
u'project_id': TENANT_ID,
u'user_id': USER_ID,
},
u'_context_username': USER_NAME,
u'_context_token': u'MIISAwYJKoZIhvcNAQcCoII...',
u'_context_user_id': USER_ID,
u'_context_tenant_name': USER_NAME,
u'priority': u'INFO',
u'_context_is_admin': False,
u'publisher_id': PUBLISHER_ID,
u'message_id': u'ef921faa-7f7b-4854-8b86-a424ab93c96e',
}
class TestNotification(base.BaseTestCase):
def _verify_common_sample(self, actual, operation):
self.assertIsNotNone(actual)
self.assertEqual('cluster.%s' % operation, actual.name)
self.assertEqual(NOW, actual.timestamp)
self.assertEqual(sample.TYPE_DELTA, actual.type)
self.assertEqual(PROJECT_ID, actual.project_id)
self.assertEqual(RESOURCE_ID, actual.resource_id)
self.assertEqual(USER_ID, actual.user_id)
metadata = actual.resource_metadata
self.assertEqual(PUBLISHER_ID, metadata.get('host'))
def _test_operation(self, operation):
notif = _dp_notification_for(operation)
handler = notifications.DataProcessing(mock.Mock())
data = list(handler.process_notification(notif))
self.assertEqual(1, len(data))
self._verify_common_sample(data[0], operation)
def test_create(self):
self._test_operation('create')
def test_update(self):
self._test_operation('update')
def test_delete(self):
self._test_operation('delete')

View File

@ -1,310 +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.
import datetime
import mock
from oslotest import base
from ceilometer.identity import notifications
from ceilometer import sample
NOW = datetime.datetime.isoformat(datetime.datetime.utcnow())
PROJECT_ID = u'project_id'
DOMAIN_ID = u'domain_id'
USER_ID = u'user_id'
ROLE_ID = u'role_id'
GROUP_ID = u'group_id'
TRUST_ID = u'trust_id'
PUBLISHER_ID = u'identity.node-n5x66lxdy67d'
ROLE_ASSIGNMENT = 'role_assignment'
def notification_for(resource_type, operation, resource_id):
return {
u'event_type': '%s.%s.%s' % (notifications.SERVICE, resource_type,
operation),
u'message_id': u'ef921faa-7f7b-4854-8b86-a424ab93c96e',
u'payload': {
u'resource_info': resource_id
},
u'priority': u'INFO',
u'publisher_id': PUBLISHER_ID,
u'timestamp': NOW
}
def cadf_format_notification():
return {
u'event_type': u'some_identity_event',
u'message_id': u'1371a590-d5fd-448f-b3bb-a14dead6f4cb',
u'payload': {
u'typeURI': u'http://schemas.dmtf.org/cloud/audit/1.0/event',
u'initiator': {
u'typeURI': u'service/security/account/user',
u'host': {
u'agent': u'python-keystoneclient',
u'address': u'10.0.2.15'
},
u'id': USER_ID,
u'name': u'openstack:demo_user'
},
u'target': {
u'typeURI': u'service/security/account/user',
u'id': u'openstack:44b3d8cb-5f16-46e9-9b1b-ac90b64c2530'
},
u'observer': {
u'typeURI': u'service/security',
u'id': u'openstack:55a9e88c-a4b1-4864-9339-62b7e6ecb6a7'
},
u'eventType': u'activity',
u'eventTime': u'2014-08-04T05:38:59.978898+0000',
u'action': u'action_name',
u'outcome': 'success',
u'id': u'openstack:eca02fef-9394-4008-8fb3-c434133ca4b2'
},
u'priority': u'INFO',
u'publisher_id': PUBLISHER_ID,
u'timestamp': NOW
}
def cadf_crud_notification_for(resource_type, operation, resource_id):
base = cadf_format_notification()
event_type = '%s.%s.%s' % (notifications.SERVICE, resource_type,
operation)
base['event_type'] = event_type
base['payload']['action'] = '%s.%s' % (operation, resource_type)
base['payload']['resource_info'] = resource_id
return base
def authn_notification_for(outcome):
base = cadf_format_notification()
base['event_type'] = 'identity.authenticate'
base['payload']['action'] = 'authenticate'
base['payload']['outcome'] = outcome
return base
def notification_for_role_change(action, project, user):
"""Create a notifications for a role_assignment
In this case, action is either 'created' or 'deleted'. Also
in a role_assignment notifications, in the payload portion,
there may be a 'domain' key or a 'project' key, never both.
The same holds for the 'user' key and 'group' key.
There must always be a 'role'.
"""
base = cadf_format_notification()
# NOTE(stevemar): i.e. created.role_assignment
action_name = '%s.%s' % (action, ROLE_ASSIGNMENT)
event, resource_type = action_name.split(".")
# NOTE(stevemar): i.e. identity.role_assignment.created
event_name = '%s.%s.%s' % (notifications.SERVICE, resource_type, event)
base['event_type'] = event_name
base['payload']['action'] = action_name
base['payload']['role'] = ROLE_ID
base['payload']['inherited_to_projects'] = False
if project:
base['payload']['project'] = PROJECT_ID
else:
base['payload']['domain'] = DOMAIN_ID
if user:
base['payload']['user'] = USER_ID
else:
base['payload']['group'] = GROUP_ID
return base
class TestCRUDNotification(base.BaseTestCase):
def _verify_common_sample(self, s):
self.assertIsNotNone(s)
self.assertEqual(NOW, s.timestamp)
self.assertEqual(sample.TYPE_DELTA, s.type)
self.assertIsNone(s.project_id)
metadata = s.resource_metadata
self.assertEqual(PUBLISHER_ID, metadata.get('host'))
def _verify_common_operations(self, data, resource_type, operation,
resource_id):
self.assertEqual(1, len(data))
self.assertEqual(resource_id, data[0].resource_id)
name = '%s.%s.%s' % (notifications.SERVICE, resource_type, operation)
self.assertEqual(name, data[0].name)
def _test_operation(self, resource_type, operation, resource_id,
notification_class):
notif = notification_for(resource_type, operation, resource_id)
handler = notification_class(mock.Mock())
data = list(handler.process_notification(notif))
self.assertIsNone(data[0].user_id)
self._verify_common_operations(data, resource_type, operation,
resource_id)
self._verify_common_sample(data[0])
def _test_audit_operation(self, resource_type, operation, resource_id,
notification_class):
notif = cadf_crud_notification_for(resource_type, operation,
resource_id)
handler = notification_class(mock.Mock())
data = list(handler.process_notification(notif))
self.assertEqual(USER_ID, data[0].user_id)
self._verify_common_operations(data, resource_type, operation,
resource_id)
self._verify_common_sample(data[0])
def test_create_user(self):
self._test_operation('user', 'created', USER_ID, notifications.User)
self._test_audit_operation('user', 'created', USER_ID,
notifications.User)
def test_delete_user(self):
self._test_operation('user', 'deleted', USER_ID, notifications.User)
self._test_audit_operation('user', 'deleted', USER_ID,
notifications.User)
def test_update_user(self):
self._test_operation('user', 'updated', USER_ID, notifications.User)
self._test_audit_operation('user', 'updated', USER_ID,
notifications.User)
def test_create_group(self):
self._test_operation('group', 'created', GROUP_ID, notifications.Group)
self._test_audit_operation('group', 'created', GROUP_ID,
notifications.Group)
def test_update_group(self):
self._test_operation('group', 'updated', GROUP_ID, notifications.Group)
self._test_audit_operation('group', 'updated', GROUP_ID,
notifications.Group)
def test_delete_group(self):
self._test_operation('group', 'deleted', GROUP_ID, notifications.Group)
self._test_audit_operation('group', 'deleted', GROUP_ID,
notifications.Group)
def test_create_project(self):
self._test_operation('project', 'created', PROJECT_ID,
notifications.Project)
self._test_audit_operation('project', 'created', PROJECT_ID,
notifications.Project)
def test_update_project(self):
self._test_operation('project', 'updated', PROJECT_ID,
notifications.Project)
self._test_audit_operation('project', 'updated', PROJECT_ID,
notifications.Project)
def test_delete_project(self):
self._test_operation('project', 'deleted', PROJECT_ID,
notifications.Project)
self._test_audit_operation('project', 'deleted', PROJECT_ID,
notifications.Project)
def test_create_role(self):
self._test_operation('role', 'deleted', ROLE_ID, notifications.Role)
self._test_audit_operation('role', 'deleted', ROLE_ID,
notifications.Role)
def test_update_role(self):
self._test_operation('role', 'updated', ROLE_ID, notifications.Role)
self._test_audit_operation('role', 'updated', ROLE_ID,
notifications.Role)
def test_delete_role(self):
self._test_operation('role', 'deleted', ROLE_ID, notifications.Role)
self._test_audit_operation('role', 'deleted', ROLE_ID,
notifications.Role)
def test_create_trust(self):
self._test_operation('trust', 'created', TRUST_ID, notifications.Trust)
self._test_audit_operation('trust', 'created', TRUST_ID,
notifications.Trust)
def test_delete_trust(self):
self._test_operation('trust', 'deleted', TRUST_ID, notifications.Trust)
self._test_audit_operation('trust', 'deleted', TRUST_ID,
notifications.Trust)
class TestAuthenticationNotification(base.BaseTestCase):
def _verify_common_sample(self, s):
self.assertIsNotNone(s)
self.assertEqual(NOW, s.timestamp)
self.assertEqual(sample.TYPE_DELTA, s.type)
self.assertIsNone(s.project_id)
self.assertEqual(USER_ID, s.user_id)
self.assertEqual(1, s.volume)
metadata = s.resource_metadata
self.assertEqual(PUBLISHER_ID, metadata.get('host'))
def _test_authn_operation(self, outcome):
notif = authn_notification_for(outcome)
handler = notifications.Authenticate(mock.Mock())
data = list(handler.process_notification(notif))
self.assertEqual(1, len(data))
name = '%s.%s.%s' % (notifications.SERVICE, 'authenticate', outcome)
self.assertEqual(name, data[0].name)
self.assertEqual(USER_ID, data[0].resource_id)
self.assertEqual('user', data[0].unit)
self._verify_common_sample(data[0])
def _test_role_assignment_operation(self, action, project, user):
notif = notification_for_role_change(action, project, user)
handler = notifications.RoleAssignment(mock.Mock())
data = list(handler.process_notification(notif))
self.assertEqual(1, len(data))
name = '%s.%s.%s' % (notifications.SERVICE, ROLE_ASSIGNMENT, action)
self.assertEqual(name, data[0].name)
self.assertEqual(ROLE_ID, data[0].resource_id)
self.assertEqual(ROLE_ASSIGNMENT, data[0].unit)
metadata = data[0].resource_metadata
if project:
self.assertEqual(PROJECT_ID, metadata.get('project'))
else:
self.assertEqual(DOMAIN_ID, metadata.get('domain'))
if user:
self.assertEqual(USER_ID, metadata.get('user'))
else:
self.assertEqual(GROUP_ID, metadata.get('group'))
self._verify_common_sample(data[0])
def test_authn_success(self):
self._test_authn_operation('success')
def test_authn_failure(self):
self._test_authn_operation('failure')
def test_authn_pending(self):
self._test_authn_operation('pending')
def test_create_role_assignment_group_domain(self):
self._test_role_assignment_operation('created', False, False)
def test_delete_role_assignment_group_domain(self):
self._test_role_assignment_operation('deleted', False, False)
def test_create_role_assignment_user_project(self):
self._test_role_assignment_operation('created', True, True)
def test_delete_role_assignment_user_project(self):
self._test_role_assignment_operation('deleted', True, True)

View File

@ -150,3 +150,24 @@ class TestMeterProcessing(test.BaseTestCase):
self.__setup_meter_def_file(cfg))
c = list(self.handler.process_notification(NOTIFICATION))
self.assertEqual(1, len(c))
def test_multi_match_event_meter(self):
cfg = yaml.dump(
{'metric': [dict(name="test1",
event_type="test.create",
type="delta",
unit="B",
volume="payload.volume",
resource_id="payload.resource_id",
project_id="payload.project_id"),
dict(name="test2",
event_type="test.create",
type="delta",
unit="B",
volume="payload.volume",
resource_id="payload.resource_id",
project_id="payload.project_id")]})
self.handler.definitions = notifications.load_definitions(
self.__setup_meter_def_file(cfg))
c = list(self.handler.process_notification(NOTIFICATION))
self.assertEqual(2, len(c))

View File

@ -1,345 +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.
import datetime
import mock
from oslotest import base
from ceilometer import sample
from ceilometer.volume import notifications
def fake_uuid(x):
return '%s-%s-%s-%s' % (x * 8, x * 4, x * 4, x * 12)
NOW = datetime.datetime.isoformat(datetime.datetime.utcnow())
VOLUME_META = {u'status': u'exists',
u'instance_uuid': None,
u'user_id': u'bcb7746c7a41472d88a1ffac89ba6a9b',
u'availability_zone': u'nova',
u'tenant_id': u'7ffe17a15c724e2aa79fc839540aec15',
u'created_at': u'2014-10-28 09:31:20',
u'volume_id': fake_uuid('c'),
u'volume_type': u'3a9a398b-7e3b-40da-b09e-2115ad8cd68b',
u'replication_extended_status': None,
u'host': u'volumes.example.com',
u'snapshot_id': None,
u'replication_status': u'disabled',
u'size': 1,
u'display_name': u'2'}
NOTIFICATION_VOLUME_EXISTS = {
"message_id": "0c65cb9c-018c-11e2-bc91-5453ed1bbb5f",
"publisher_id": "volumes.example.com",
"event_type": "volume.exists",
"priority": "info",
"payload": VOLUME_META,
"timestamp": NOW}
NOTIFICATION_VOLUME_CREATE_START = {
"message_id": "0c65cb9c-018c-11e2-bc91-5453ed1bbb5f",
"publisher_id": "volumes.example.com",
"event_type": "volume.create.start",
"priority": "info",
"payload": VOLUME_META,
"timestamp": NOW}
NOTIFICATION_VOLUME_CREATE_END = {
"message_id": "0c65cb9c-018c-11e2-bc91-5453ed1bbb5f",
"publisher_id": "volumes.example.com",
"event_type": "volume.create.end",
"priority": "info",
"payload": VOLUME_META,
"timestamp": NOW}
NOTIFICATION_VOLUME_DELETE_START = {
"message_id": "0c65cb9c-018c-11e2-bc91-5453ed1bbb5f",
"publisher_id": "volumes.example.com",
"event_type": "volume.delete.start",
"priority": "info",
"payload": VOLUME_META,
"timestamp": NOW}
NOTIFICATION_VOLUME_DELETE_END = {
"message_id": "0c65cb9c-018c-11e2-bc91-5453ed1bbb5f",
"publisher_id": "volumes.example.com",
"event_type": "volume.delete.end",
"priority": "info",
"payload": VOLUME_META,
"timestamp": NOW}
NOTIFICATION_VOLUME_RESIZE_START = {
"message_id": "0c65cb9c-018c-11e2-bc91-5453ed1bbb5f",
"publisher_id": "volumes.example.com",
"event_type": "volume.resize.start",
"priority": "info",
"payload": VOLUME_META,
"timestamp": NOW}
NOTIFICATION_VOLUME_RESIZE_END = {
"message_id": "0c65cb9c-018c-11e2-bc91-5453ed1bbb5f",
"publisher_id": "volumes.example.com",
"event_type": "volume.resize.end",
"priority": "info",
"payload": VOLUME_META,
"timestamp": NOW}
NOTIFICATION_VOLUME_ATTACH_START = {
"message_id": "0c65cb9c-018c-11e2-bc91-5453ed1bbb5f",
"publisher_id": "volumes.example.com",
"event_type": "volume.attach.start",
"priority": "info",
"payload": VOLUME_META,
"timestamp": NOW}
NOTIFICATION_VOLUME_ATTACH_END = {
"message_id": "0c65cb9c-018c-11e2-bc91-5453ed1bbb5f",
"publisher_id": "volumes.example.com",
"event_type": "volume.attach.end",
"priority": "info",
"payload": VOLUME_META,
"timestamp": NOW}
NOTIFICATION_VOLUME_DETACH_START = {
"message_id": "0c65cb9c-018c-11e2-bc91-5453ed1bbb5f",
"publisher_id": "volumes.example.com",
"event_type": "volume.detach.start",
"priority": "info",
"payload": VOLUME_META,
"timestamp": NOW}
NOTIFICATION_VOLUME_DETACH_END = {
"message_id": "0c65cb9c-018c-11e2-bc91-5453ed1bbb5f",
"publisher_id": "volumes.example.com",
"event_type": "volume.detach.end",
"priority": "info",
"payload": VOLUME_META,
"timestamp": NOW}
NOTIFICATION_VOLUME_UPDATE_START = {
"message_id": "0c65cb9c-018c-11e2-bc91-5453ed1bbb5f",
"publisher_id": "volumes.example.com",
"event_type": "volume.update.start",
"priority": "info",
"payload": VOLUME_META,
"timestamp": NOW}
NOTIFICATION_VOLUME_UPDATE_END = {
"message_id": "0c65cb9c-018c-11e2-bc91-5453ed1bbb5f",
"publisher_id": "volumes.example.com",
"event_type": "volume.update.end",
"priority": "info",
"payload": VOLUME_META,
"timestamp": NOW}
SNAPSHOT_META = {u'status': u'creating',
u'user_id': u'bcb7746c7a41472d88a1ffac89ba6a9b',
u'availability_zone': u'nova',
u'deleted': u'',
u'tenant_id': u'7ffe17a15c724e2aa79fc839540aec15',
u'created_at': u'2014-10-28 09:49:07',
u'snapshot_id': fake_uuid('c'),
u'volume_size': 1,
u'volume_id': u'2925bb3b-2b51-496a-bb6e-01a20e950e07',
u'display_name': u'11'}
NOTIFICATION_SNAPSHOT_EXISTS = {
"message_id": "1d2944f9-f8e9-4b2b-8df1-465f759a63e8",
"publisher_id": "snapshots.example.com",
"event_type": "snapshot.exists",
"priority": "info",
"payload": SNAPSHOT_META,
"timestamp": NOW}
NOTIFICATION_SNAPSHOT_CREATE_START = {
"message_id": "1d2944f9-f8e9-4b2b-8df1-465f759a63e8",
"publisher_id": "snapshots.example.com",
"event_type": "snapshot.create.start",
"priority": "info",
"payload": SNAPSHOT_META,
"timestamp": NOW}
NOTIFICATION_SNAPSHOT_CREATE_END = {
"message_id": "1d2944f9-f8e9-4b2b-8df1-465f759a63e8",
"publisher_id": "snapshots.example.com",
"event_type": "snapshot.create.end",
"priority": "info",
"payload": SNAPSHOT_META,
"timestamp": NOW}
NOTIFICATION_SNAPSHOT_DELETE_START = {
"message_id": "1d2944f9-f8e9-4b2b-8df1-465f759a63e8",
"publisher_id": "snapshots.example.com",
"event_type": "snapshot.delete.start",
"priority": "info",
"payload": SNAPSHOT_META,
"timestamp": NOW}
NOTIFICATION_SNAPSHOT_DELETE_END = {
"message_id": "1d2944f9-f8e9-4b2b-8df1-465f759a63e8",
"publisher_id": "snapshots.example.com",
"event_type": "snapshot.delete.end",
"priority": "info",
"payload": SNAPSHOT_META,
"timestamp": NOW}
class TestNotifications(base.BaseTestCase):
def setUp(self):
super(TestNotifications, self).setUp()
self.host = None
self.handler_crud = None
self.handler = None
self.handler_size = None
self.name = None
self.name_size = None
self.size = None
def _verify_common_counter(self, c, name, volume):
self.assertIsNotNone(c)
self.assertEqual(name, c.name)
self.assertEqual(fake_uuid('c'), c.resource_id)
self.assertEqual(NOW, c.timestamp)
self.assertEqual(volume, c.volume)
metadata = c.resource_metadata
self.assertEqual(self.host, metadata.get('host'))
def _check_crud(self, notification_type, notification_name):
counters = list(self.handler_crud.process_notification(
notification_type))
self.assertEqual(1, len(counters))
notification = counters[0]
self._verify_common_counter(
notification, notification_name, 1)
self.assertEqual(sample.TYPE_DELTA, notification.type)
def _check(self, notification_type):
counters = list(self.handler.process_notification(notification_type))
self.assertEqual(1, len(counters))
notification = counters[0]
self._verify_common_counter(notification, self.name, 1)
self.assertEqual(sample.TYPE_GAUGE, notification.type)
def _check_size(self, notification_type):
counters = list(self.handler_size.process_notification(
notification_type))
self.assertEqual(1, len(counters))
notification = counters[0]
self._verify_common_counter(
notification, self.name_size, self.size)
self.assertEqual(sample.TYPE_GAUGE, notification.type)
class TestVolumeNotifications(TestNotifications):
def setUp(self):
super(TestVolumeNotifications, self).setUp()
self.host = 'volumes.example.com'
self.handler_crud = notifications.VolumeCRUD(mock.Mock())
self.handler = notifications.Volume(mock.Mock())
self.handler_size = notifications.VolumeSize(mock.Mock())
self.name = 'volume'
self.name_size = 'volume.size'
self.size = VOLUME_META['size']
def test_volume_notifications(self):
self._check_crud(
NOTIFICATION_VOLUME_EXISTS, 'volume.exists')
self._check_crud(
NOTIFICATION_VOLUME_CREATE_START, 'volume.create.start')
self._check_crud(
NOTIFICATION_VOLUME_CREATE_END, 'volume.create.end')
self._check_crud(
NOTIFICATION_VOLUME_DELETE_START, 'volume.delete.start')
self._check_crud(
NOTIFICATION_VOLUME_DELETE_END, 'volume.delete.end')
self._check_crud(
NOTIFICATION_VOLUME_RESIZE_START, 'volume.resize.start')
self._check_crud(
NOTIFICATION_VOLUME_RESIZE_END, 'volume.resize.end')
self._check_crud(
NOTIFICATION_VOLUME_ATTACH_START, 'volume.attach.start')
self._check_crud(
NOTIFICATION_VOLUME_ATTACH_END, 'volume.attach.end')
self._check_crud(
NOTIFICATION_VOLUME_DETACH_START, 'volume.detach.start')
self._check_crud(
NOTIFICATION_VOLUME_DETACH_END, 'volume.detach.end')
self._check_crud(
NOTIFICATION_VOLUME_UPDATE_START, 'volume.update.start')
self._check_crud(
NOTIFICATION_VOLUME_UPDATE_END, 'volume.update.end')
self._check(NOTIFICATION_VOLUME_EXISTS)
self._check(NOTIFICATION_VOLUME_CREATE_START)
self._check(NOTIFICATION_VOLUME_CREATE_END)
self._check(NOTIFICATION_VOLUME_DELETE_START)
self._check(NOTIFICATION_VOLUME_DELETE_END)
self._check(NOTIFICATION_VOLUME_RESIZE_START)
self._check(NOTIFICATION_VOLUME_RESIZE_END)
self._check(NOTIFICATION_VOLUME_ATTACH_START)
self._check(NOTIFICATION_VOLUME_ATTACH_END)
self._check(NOTIFICATION_VOLUME_DETACH_START)
self._check(NOTIFICATION_VOLUME_DETACH_END)
self._check(NOTIFICATION_VOLUME_UPDATE_START)
self._check(NOTIFICATION_VOLUME_UPDATE_END)
self._check_size(NOTIFICATION_VOLUME_EXISTS)
self._check_size(NOTIFICATION_VOLUME_CREATE_START)
self._check_size(NOTIFICATION_VOLUME_CREATE_END)
self._check_size(NOTIFICATION_VOLUME_DELETE_START)
self._check_size(NOTIFICATION_VOLUME_DELETE_END)
self._check_size(NOTIFICATION_VOLUME_RESIZE_START)
self._check_size(NOTIFICATION_VOLUME_RESIZE_END)
self._check_size(NOTIFICATION_VOLUME_ATTACH_START)
self._check_size(NOTIFICATION_VOLUME_ATTACH_END)
self._check_size(NOTIFICATION_VOLUME_DETACH_START)
self._check_size(NOTIFICATION_VOLUME_DETACH_END)
self._check_size(NOTIFICATION_VOLUME_UPDATE_START)
self._check_size(NOTIFICATION_VOLUME_UPDATE_END)
class TestSnapshotNotifications(TestNotifications):
def setUp(self):
super(TestSnapshotNotifications, self).setUp()
self.host = 'snapshots.example.com'
self.handler_crud = notifications.SnapshotCRUD(mock.Mock())
self.handler = notifications.Snapshot(mock.Mock())
self.handler_size = notifications.SnapshotSize(mock.Mock())
self.name = 'snapshot'
self.name_size = 'snapshot.size'
self.size = SNAPSHOT_META['volume_size']
def test_snapshot_notifications(self):
self._check_crud(
NOTIFICATION_SNAPSHOT_EXISTS, 'snapshot.exists')
self._check_crud(
NOTIFICATION_SNAPSHOT_CREATE_START, 'snapshot.create.start')
self._check_crud(
NOTIFICATION_SNAPSHOT_CREATE_END, 'snapshot.create.end')
self._check_crud(
NOTIFICATION_SNAPSHOT_DELETE_START, 'snapshot.delete.start')
self._check_crud(
NOTIFICATION_SNAPSHOT_DELETE_END, 'snapshot.delete.end')
self._check(NOTIFICATION_SNAPSHOT_EXISTS)
self._check(NOTIFICATION_SNAPSHOT_CREATE_START)
self._check(NOTIFICATION_SNAPSHOT_CREATE_END)
self._check(NOTIFICATION_SNAPSHOT_DELETE_START)
self._check(NOTIFICATION_SNAPSHOT_DELETE_END)
self._check_size(NOTIFICATION_SNAPSHOT_EXISTS)
self._check_size(NOTIFICATION_SNAPSHOT_CREATE_START)
self._check_size(NOTIFICATION_SNAPSHOT_CREATE_END)
self._check_size(NOTIFICATION_SNAPSHOT_DELETE_START)
self._check_size(NOTIFICATION_SNAPSHOT_DELETE_END)

View File

@ -1,149 +0,0 @@
#
# Copyright 2012 New Dream Network, LLC (DreamHost)
#
# 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.
"""Converters for producing volume counter messages from cinder notification
events.
"""
from oslo_config import cfg
import oslo_messaging
from ceilometer.agent import plugin_base
from ceilometer import sample
OPTS = [
cfg.StrOpt('cinder_control_exchange',
default='cinder',
help="Exchange name for Cinder notifications."),
]
cfg.CONF.register_opts(OPTS)
class VolumeBase(plugin_base.NotificationBase):
"""Convert volume/snapshot notification into Counters."""
@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.cinder_control_exchange)
for topic in conf.notification_topics]
class VolumeCRUDBase(VolumeBase):
"""Convert volume notifications into Counters."""
event_types = [
'volume.exists',
'volume.create.*',
'volume.delete.*',
'volume.resize.*',
'volume.attach.*',
'volume.detach.*',
'volume.update.*'
]
class VolumeCRUD(VolumeCRUDBase, plugin_base.NonMetricNotificationBase):
def process_notification(self, message):
yield sample.Sample.from_notification(
name=message['event_type'],
type=sample.TYPE_DELTA,
unit='volume',
volume=1,
user_id=message['payload']['user_id'],
project_id=message['payload']['tenant_id'],
resource_id=message['payload']['volume_id'],
message=message)
class Volume(VolumeCRUDBase, plugin_base.NonMetricNotificationBase):
def process_notification(self, message):
yield sample.Sample.from_notification(
name='volume',
type=sample.TYPE_GAUGE,
unit='volume',
volume=1,
user_id=message['payload']['user_id'],
project_id=message['payload']['tenant_id'],
resource_id=message['payload']['volume_id'],
message=message)
class VolumeSize(VolumeCRUDBase):
def process_notification(self, message):
yield sample.Sample.from_notification(
name='volume.size',
type=sample.TYPE_GAUGE,
unit='GB',
volume=message['payload']['size'],
user_id=message['payload']['user_id'],
project_id=message['payload']['tenant_id'],
resource_id=message['payload']['volume_id'],
message=message)
class SnapshotCRUDBase(VolumeBase):
"""Convert snapshot notifications into Counters."""
event_types = [
'snapshot.exists',
'snapshot.create.*',
'snapshot.delete.*',
]
class SnapshotCRUD(SnapshotCRUDBase, plugin_base.NonMetricNotificationBase):
def process_notification(self, message):
yield sample.Sample.from_notification(
name=message['event_type'],
type=sample.TYPE_DELTA,
unit='snapshot',
volume=1,
user_id=message['payload']['user_id'],
project_id=message['payload']['tenant_id'],
resource_id=message['payload']['snapshot_id'],
message=message)
class Snapshot(SnapshotCRUDBase, plugin_base.NonMetricNotificationBase):
def process_notification(self, message):
yield sample.Sample.from_notification(
name='snapshot',
type=sample.TYPE_GAUGE,
unit='snapshot',
volume=1,
user_id=message['payload']['user_id'],
project_id=message['payload']['tenant_id'],
resource_id=message['payload']['snapshot_id'],
message=message)
class SnapshotSize(SnapshotCRUDBase):
def process_notification(self, message):
yield sample.Sample.from_notification(
name='snapshot.size',
type=sample.TYPE_GAUGE,
unit='GB',
volume=message['payload']['volume_size'],
user_id=message['payload']['user_id'],
project_id=message['payload']['tenant_id'],
resource_id=message['payload']['snapshot_id'],
message=message)

View File

@ -46,19 +46,6 @@ ceilometer.notification =
cpu_user_percent = ceilometer.compute.notifications.cpu:CpuUserPercent
cpu_iowait_percent = ceilometer.compute.notifications.cpu:CpuIowaitPercent
cpu_percent = ceilometer.compute.notifications.cpu:CpuPercent
volume = ceilometer.volume.notifications:Volume
volume_size = ceilometer.volume.notifications:VolumeSize
volume_crud = ceilometer.volume.notifications:VolumeCRUD
snapshot = ceilometer.volume.notifications:Snapshot
snapshot_size = ceilometer.volume.notifications:SnapshotSize
snapshot_crud = ceilometer.volume.notifications:SnapshotCRUD
authenticate = ceilometer.identity.notifications:Authenticate
user = ceilometer.identity.notifications:User
group = ceilometer.identity.notifications:Group
role = ceilometer.identity.notifications:Role
project = ceilometer.identity.notifications:Project
trust = ceilometer.identity.notifications:Trust
role_assignment = ceilometer.identity.notifications:RoleAssignment
network = ceilometer.network.notifications:Network
subnet = ceilometer.network.notifications:Subnet
port = ceilometer.network.notifications:Port
@ -67,7 +54,6 @@ ceilometer.notification =
bandwidth = ceilometer.network.notifications:Bandwidth
http.request = ceilometer.middleware:HTTPRequest
http.response = ceilometer.middleware:HTTPResponse
data_processing = ceilometer.data_processing.notifications:DataProcessing
profiler = ceilometer.profiler.notifications:ProfilerNotifications
hardware.ipmi.temperature = ceilometer.ipmi.notifications.ironic:TemperatureSensorNotification
hardware.ipmi.voltage = ceilometer.ipmi.notifications.ironic:VoltageSensorNotification