Handle the metrics sent by nova notifier
Nova compute node can now get metrics from monitors and send notifications to message bus. So, add listeners to handle the metrics in ceilometer. This patch changes the directory layout for compute notifications, because there will be other metrics (e.g. network and cache Qos) to be added. The deployer can also add the metrics they want. It's better to make a classification of these metrics. Nova blueprint utilization-aware-scheduling Change-Id: I6f54ef18035c437370360bbaff6d71666d0323fe
This commit is contained in:
parent
5591e6a980
commit
d2dfb1b146
45
ceilometer/compute/notifications/__init__.py
Normal file
45
ceilometer/compute/notifications/__init__.py
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
# -*- encoding: utf-8 -*-
|
||||||
|
#
|
||||||
|
# Copyright © 2013 Intel
|
||||||
|
#
|
||||||
|
# Author: Shuangtai Tian <shuangtai.tian@intel.com>
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
|
||||||
|
from oslo.config import cfg
|
||||||
|
|
||||||
|
from ceilometer import plugin
|
||||||
|
|
||||||
|
|
||||||
|
OPTS = [
|
||||||
|
cfg.StrOpt('nova_control_exchange',
|
||||||
|
default='nova',
|
||||||
|
help="Exchange name for Nova notifications"),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
cfg.CONF.register_opts(OPTS)
|
||||||
|
|
||||||
|
|
||||||
|
class ComputeNotificationBase(plugin.NotificationBase):
|
||||||
|
@staticmethod
|
||||||
|
def get_exchange_topics(conf):
|
||||||
|
"""Return a sequence of ExchangeTopics defining the exchange and
|
||||||
|
topics to be connected for this plugin.
|
||||||
|
"""
|
||||||
|
return [
|
||||||
|
plugin.ExchangeTopics(
|
||||||
|
exchange=conf.nova_control_exchange,
|
||||||
|
topics=set(topic + ".info"
|
||||||
|
for topic in conf.notification_topics)),
|
||||||
|
]
|
140
ceilometer/compute/notifications/cpu.py
Normal file
140
ceilometer/compute/notifications/cpu.py
Normal file
@ -0,0 +1,140 @@
|
|||||||
|
# -*- encoding: utf-8 -*-
|
||||||
|
#
|
||||||
|
# Copyright © 2013 Intel
|
||||||
|
#
|
||||||
|
# Author: Shuangtai Tian <shuangtai.tian@intel.com>
|
||||||
|
#
|
||||||
|
# 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 compute CPU sample messages from notification
|
||||||
|
events.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from ceilometer.compute import notifications
|
||||||
|
from ceilometer.openstack.common.gettextutils import _ # noqa
|
||||||
|
from ceilometer.openstack.common import log
|
||||||
|
from ceilometer.openstack.common import timeutils
|
||||||
|
from ceilometer import sample
|
||||||
|
|
||||||
|
LOG = log.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class ComputeMetricsNotificationBase(notifications.ComputeNotificationBase):
|
||||||
|
"""Convert compute.metrics.update notifications into Samples
|
||||||
|
"""
|
||||||
|
event_types = ['compute.metrics.update']
|
||||||
|
metric = None
|
||||||
|
sample_type = None
|
||||||
|
unit = None
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _get_sample(message, name):
|
||||||
|
try:
|
||||||
|
for metric in message['payload']['metrics']:
|
||||||
|
if name == metric['name']:
|
||||||
|
info = {}
|
||||||
|
info['payload'] = metric
|
||||||
|
info['event_type'] = message['event_type']
|
||||||
|
info['publisher_id'] = message['publisher_id']
|
||||||
|
info['resource_id'] = '%s_%s' % (
|
||||||
|
message['payload']['host'],
|
||||||
|
message['payload']['nodename'])
|
||||||
|
info['timestamp'] = str(timeutils.parse_strtime(
|
||||||
|
metric['timestamp']))
|
||||||
|
return info
|
||||||
|
except Exception as err:
|
||||||
|
LOG.warning(_('An error occurred while building %(m)s '
|
||||||
|
'sample: %(e)s') % {'m': name, 'e': err})
|
||||||
|
|
||||||
|
def process_notification(self, message):
|
||||||
|
info = self._get_sample(message, self.metric)
|
||||||
|
if info:
|
||||||
|
yield sample.Sample.from_notification(
|
||||||
|
name='compute.node.%s' % self.metric,
|
||||||
|
type=self.sample_type,
|
||||||
|
unit=self.unit,
|
||||||
|
volume=(info['payload']['value'] * 100 if self.unit == '%'
|
||||||
|
else info['payload']['value']),
|
||||||
|
user_id=None,
|
||||||
|
project_id=None,
|
||||||
|
resource_id=info['resource_id'],
|
||||||
|
message=info)
|
||||||
|
|
||||||
|
|
||||||
|
class CpuFrequency(ComputeMetricsNotificationBase):
|
||||||
|
"""Handle CPU current frequency message."""
|
||||||
|
metric = 'cpu.frequency'
|
||||||
|
sample_type = sample.TYPE_GAUGE,
|
||||||
|
unit = 'MHz'
|
||||||
|
|
||||||
|
|
||||||
|
class CpuUserTime(ComputeMetricsNotificationBase):
|
||||||
|
"""Handle CPU user mode time message."""
|
||||||
|
metric = 'cpu.user.time'
|
||||||
|
sample_type = sample.TYPE_CUMULATIVE,
|
||||||
|
unit = 'ns'
|
||||||
|
|
||||||
|
|
||||||
|
class CpuKernelTime(ComputeMetricsNotificationBase):
|
||||||
|
"""Handle CPU kernel time message."""
|
||||||
|
metric = 'cpu.kernel.time'
|
||||||
|
unit = 'ns'
|
||||||
|
sample_type = sample.TYPE_CUMULATIVE,
|
||||||
|
|
||||||
|
|
||||||
|
class CpuIdleTime(ComputeMetricsNotificationBase):
|
||||||
|
"""Handle CPU idle time message."""
|
||||||
|
metric = 'cpu.idle.time'
|
||||||
|
unit = 'ns'
|
||||||
|
sample_type = sample.TYPE_CUMULATIVE,
|
||||||
|
|
||||||
|
|
||||||
|
class CpuIowaitTime(ComputeMetricsNotificationBase):
|
||||||
|
"""Handle CPU I/O wait time message."""
|
||||||
|
metric = 'cpu.iowait.time'
|
||||||
|
unit = 'ns'
|
||||||
|
sample_type = sample.TYPE_CUMULATIVE,
|
||||||
|
|
||||||
|
|
||||||
|
class CpuKernelPercent(ComputeMetricsNotificationBase):
|
||||||
|
"""Handle CPU kernel percentage message."""
|
||||||
|
metric = 'cpu.kernel.percent'
|
||||||
|
unit = '%'
|
||||||
|
sample_type = sample.TYPE_GAUGE,
|
||||||
|
|
||||||
|
|
||||||
|
class CpuIdlePercent(ComputeMetricsNotificationBase):
|
||||||
|
"""Handle CPU idle percentage message."""
|
||||||
|
metric = 'cpu.idle.percent'
|
||||||
|
unit = '%'
|
||||||
|
sample_type = sample.TYPE_GAUGE,
|
||||||
|
|
||||||
|
|
||||||
|
class CpuUserPercent(ComputeMetricsNotificationBase):
|
||||||
|
"""Handle CPU user mode percentage message."""
|
||||||
|
metric = 'cpu.user.percent'
|
||||||
|
unit = '%'
|
||||||
|
sample_type = sample.TYPE_GAUGE,
|
||||||
|
|
||||||
|
|
||||||
|
class CpuIowaitPercent(ComputeMetricsNotificationBase):
|
||||||
|
"""Handle CPU I/O wait percentage message."""
|
||||||
|
metric = 'cpu.iowait.percent'
|
||||||
|
unit = '%'
|
||||||
|
sample_type = sample.TYPE_GAUGE,
|
||||||
|
|
||||||
|
|
||||||
|
class CpuPercent(ComputeMetricsNotificationBase):
|
||||||
|
"""Handle generic CPU utilization message."""
|
||||||
|
metric = 'cpu.percent'
|
||||||
|
unit = '%'
|
||||||
|
sample_type = sample.TYPE_GAUGE,
|
@ -20,37 +20,11 @@
|
|||||||
"""Converters for producing compute sample messages from notification events.
|
"""Converters for producing compute sample messages from notification events.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from oslo.config import cfg
|
from ceilometer.compute import notifications
|
||||||
|
|
||||||
from ceilometer import plugin
|
|
||||||
from ceilometer import sample
|
from ceilometer import sample
|
||||||
|
|
||||||
|
|
||||||
OPTS = [
|
class InstanceScheduled(notifications.ComputeNotificationBase):
|
||||||
cfg.StrOpt('nova_control_exchange',
|
|
||||||
default='nova',
|
|
||||||
help="Exchange name for Nova notifications"),
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
cfg.CONF.register_opts(OPTS)
|
|
||||||
|
|
||||||
|
|
||||||
class ComputeNotificationBase(plugin.NotificationBase):
|
|
||||||
@staticmethod
|
|
||||||
def get_exchange_topics(conf):
|
|
||||||
"""Return a sequence of ExchangeTopics defining the exchange and
|
|
||||||
topics to be connected for this plugin.
|
|
||||||
"""
|
|
||||||
return [
|
|
||||||
plugin.ExchangeTopics(
|
|
||||||
exchange=conf.nova_control_exchange,
|
|
||||||
topics=set(topic + ".info"
|
|
||||||
for topic in conf.notification_topics)),
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
class InstanceScheduled(ComputeNotificationBase):
|
|
||||||
event_types = ['scheduler.run_instance.scheduled']
|
event_types = ['scheduler.run_instance.scheduled']
|
||||||
|
|
||||||
def process_notification(self, message):
|
def process_notification(self, message):
|
||||||
@ -67,7 +41,7 @@ class InstanceScheduled(ComputeNotificationBase):
|
|||||||
message=message)
|
message=message)
|
||||||
|
|
||||||
|
|
||||||
class ComputeInstanceNotificationBase(ComputeNotificationBase):
|
class ComputeInstanceNotificationBase(notifications.ComputeNotificationBase):
|
||||||
"""Convert compute.instance.* notifications into Samples
|
"""Convert compute.instance.* notifications into Samples
|
||||||
"""
|
"""
|
||||||
event_types = ['compute.instance.*']
|
event_types = ['compute.instance.*']
|
0
ceilometer/tests/compute/notifications/__init__.py
Normal file
0
ceilometer/tests/compute/notifications/__init__.py
Normal file
159
ceilometer/tests/compute/notifications/test_cpu.py
Normal file
159
ceilometer/tests/compute/notifications/test_cpu.py
Normal file
@ -0,0 +1,159 @@
|
|||||||
|
# -*- encoding: utf-8 -*-
|
||||||
|
#
|
||||||
|
# Copyright © 2013 Intel
|
||||||
|
#
|
||||||
|
# Author: Shuangtai Tian <Shuangtai.tian@intel.com>
|
||||||
|
#
|
||||||
|
# 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 converters for producing compute counter messages from
|
||||||
|
notification events.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import copy
|
||||||
|
|
||||||
|
from ceilometer.compute.notifications import cpu
|
||||||
|
from ceilometer.openstack.common import test
|
||||||
|
|
||||||
|
|
||||||
|
METRICS_UPDATE = {
|
||||||
|
u'_context_request_id': u'req-a8bfa89b-d28b-4b95-9e4b-7d7875275650',
|
||||||
|
u'_context_quota_class': None,
|
||||||
|
u'event_type': u'compute.metrics.update',
|
||||||
|
u'_context_service_catalog': [],
|
||||||
|
u'_context_auth_token': None,
|
||||||
|
u'_context_user_id': None,
|
||||||
|
u'payload': {
|
||||||
|
u'metrics': [
|
||||||
|
{'timestamp': u'2013-07-29T06:51:34.472416',
|
||||||
|
'name': 'cpu.frequency', 'value': 1600,
|
||||||
|
'source': 'libvirt.LibvirtDriver'},
|
||||||
|
{'timestamp': u'2013-07-29T06:51:34.472416',
|
||||||
|
'name': 'cpu.user.time', 'value': 17421440000000L,
|
||||||
|
'source': 'libvirt.LibvirtDriver'},
|
||||||
|
{'timestamp': u'2013-07-29T06:51:34.472416',
|
||||||
|
'name': 'cpu.kernel.time', 'value': 7852600000000L,
|
||||||
|
'source': 'libvirt.LibvirtDriver'},
|
||||||
|
{'timestamp': u'2013-07-29T06:51:34.472416',
|
||||||
|
'name': 'cpu.idle.time', 'value': 1307374400000000L,
|
||||||
|
'source': 'libvirt.LibvirtDriver'},
|
||||||
|
{'timestamp': u'2013-07-29T06:51:34.472416',
|
||||||
|
'name': 'cpu.iowait.time', 'value': 11697470000000L,
|
||||||
|
'source': 'libvirt.LibvirtDriver'},
|
||||||
|
{'timestamp': u'2013-07-29T06:51:34.472416',
|
||||||
|
'name': 'cpu.user.percent', 'value': 0.012959045637294348,
|
||||||
|
'source': 'libvirt.LibvirtDriver'},
|
||||||
|
{'timestamp': u'2013-07-29T06:51:34.472416',
|
||||||
|
'name': 'cpu.kernel.percent', 'value': 0.005841204961898534,
|
||||||
|
'source': 'libvirt.LibvirtDriver'},
|
||||||
|
{'timestamp': u'2013-07-29T06:51:34.472416',
|
||||||
|
'name': 'cpu.idle.percent', 'value': 0.9724985141658965,
|
||||||
|
'source': 'libvirt.LibvirtDriver'},
|
||||||
|
{'timestamp': u'2013-07-29T06:51:34.472416',
|
||||||
|
'name': 'cpu.iowait.percent', 'value': 0.008701235234910634,
|
||||||
|
'source': 'libvirt.LibvirtDriver'},
|
||||||
|
{'timestamp': u'2013-07-29T06:51:34.472416',
|
||||||
|
'name': 'cpu.percent', 'value': 0.027501485834103515,
|
||||||
|
'source': 'libvirt.LibvirtDriver'}],
|
||||||
|
u'nodename': u'tianst.sh.intel.com',
|
||||||
|
u'host': u'tianst',
|
||||||
|
u'host_id': u'10.0.1.1'},
|
||||||
|
u'priority': u'INFO',
|
||||||
|
u'_context_is_admin': True,
|
||||||
|
u'_context_user': None,
|
||||||
|
u'publisher_id': u'compute.tianst.sh.intel.com',
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
RES_ID = '%s_%s' % (METRICS_UPDATE['payload']['host'],
|
||||||
|
METRICS_UPDATE['payload']['nodename'])
|
||||||
|
|
||||||
|
|
||||||
|
class TestMetricsNotifications(test.BaseTestCase):
|
||||||
|
def _process_notification(self, ic):
|
||||||
|
self.assertIn(METRICS_UPDATE['event_type'],
|
||||||
|
ic.event_types)
|
||||||
|
samples = list(ic.process_notification(METRICS_UPDATE))
|
||||||
|
self.assertEqual(samples[0].resource_id, RES_ID)
|
||||||
|
return samples[0]
|
||||||
|
|
||||||
|
def test_compute_metrics(self):
|
||||||
|
ERROR_METRICS = copy.copy(METRICS_UPDATE)
|
||||||
|
ERROR_METRICS['payload'] = {"metric_err": []}
|
||||||
|
ic = cpu.CpuFrequency()
|
||||||
|
info = ic._get_sample(METRICS_UPDATE, 'cpu.frequency')
|
||||||
|
info_none = ic._get_sample(METRICS_UPDATE, 'abc.efg')
|
||||||
|
info_error = ic._get_sample(ERROR_METRICS, 'cpu.frequency')
|
||||||
|
self.assertEqual(info['payload']['name'], 'cpu.frequency')
|
||||||
|
self.assertEqual(info_none, None)
|
||||||
|
self.assertEqual(info_error, None)
|
||||||
|
|
||||||
|
def test_compute_cpu_frequency(self):
|
||||||
|
c = self._process_notification(cpu.CpuFrequency())
|
||||||
|
self.assertEqual(c.name, 'compute.node.cpu.frequency')
|
||||||
|
self.assertEqual(c.volume, 1600)
|
||||||
|
|
||||||
|
def test_compute_cpu_user_time(self):
|
||||||
|
c = self._process_notification(cpu.CpuUserTime())
|
||||||
|
self.assertEqual(c.name, 'compute.node.cpu.user.time')
|
||||||
|
self.assertEqual(c.volume, 17421440000000L)
|
||||||
|
|
||||||
|
def test_compute_cpu_kernel_time(self):
|
||||||
|
c = self._process_notification(cpu.CpuKernelTime())
|
||||||
|
self.assertEqual(c.name, 'compute.node.cpu.kernel.time')
|
||||||
|
self.assertEqual(c.volume, 7852600000000L)
|
||||||
|
|
||||||
|
def test_compute_cpu_idle_time(self):
|
||||||
|
c = self._process_notification(cpu.CpuIdleTime())
|
||||||
|
self.assertEqual(c.name, 'compute.node.cpu.idle.time')
|
||||||
|
self.assertEqual(c.volume, 1307374400000000L)
|
||||||
|
|
||||||
|
def test_compute_cpu_iowait_time(self):
|
||||||
|
c = self._process_notification(cpu.CpuIowaitTime())
|
||||||
|
self.assertEqual(c.name, 'compute.node.cpu.iowait.time')
|
||||||
|
self.assertEqual(c.volume, 11697470000000L)
|
||||||
|
|
||||||
|
def test_compute_cpu_kernel_percent(self):
|
||||||
|
c = self._process_notification(cpu.CpuKernelPercent())
|
||||||
|
self.assertEqual(c.name, 'compute.node.cpu.kernel.percent')
|
||||||
|
self.assertEqual(c.volume, 0.5841204961898534)
|
||||||
|
|
||||||
|
def test_compute_cpu_idle_percent(self):
|
||||||
|
c = self._process_notification(cpu.CpuIdlePercent())
|
||||||
|
self.assertEqual(c.name, 'compute.node.cpu.idle.percent')
|
||||||
|
self.assertEqual(c.volume, 97.24985141658965)
|
||||||
|
|
||||||
|
def test_compute_cpu_user_percent(self):
|
||||||
|
c = self._process_notification(cpu.CpuUserPercent())
|
||||||
|
self.assertEqual(c.name, 'compute.node.cpu.user.percent')
|
||||||
|
self.assertEqual(c.volume, 1.2959045637294348)
|
||||||
|
|
||||||
|
def test_compute_cpu_iowait_percent(self):
|
||||||
|
c = self._process_notification(cpu.CpuIowaitPercent())
|
||||||
|
self.assertEqual(c.name, 'compute.node.cpu.iowait.percent')
|
||||||
|
self.assertEqual(c.volume, 0.8701235234910634)
|
||||||
|
|
||||||
|
def test_compute_cpu_percent(self):
|
||||||
|
c = self._process_notification(cpu.CpuPercent())
|
||||||
|
self.assertEqual(c.name, 'compute.node.cpu.percent')
|
||||||
|
self.assertEqual(c.volume, 2.7501485834103515)
|
@ -21,7 +21,7 @@
|
|||||||
notification events.
|
notification events.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from ceilometer.compute import notifications
|
from ceilometer.compute.notifications import instance
|
||||||
from ceilometer.openstack.common import test
|
from ceilometer.openstack.common import test
|
||||||
from ceilometer import sample
|
from ceilometer import sample
|
||||||
|
|
||||||
@ -401,7 +401,7 @@ INSTANCE_SCHEDULED = {
|
|||||||
class TestNotifications(test.BaseTestCase):
|
class TestNotifications(test.BaseTestCase):
|
||||||
|
|
||||||
def test_process_notification(self):
|
def test_process_notification(self):
|
||||||
info = list(notifications.Instance().process_notification(
|
info = list(instance.Instance().process_notification(
|
||||||
INSTANCE_CREATE_END
|
INSTANCE_CREATE_END
|
||||||
))[0]
|
))[0]
|
||||||
for name, actual, expected in [
|
for name, actual, expected in [
|
||||||
@ -425,42 +425,42 @@ class TestNotifications(test.BaseTestCase):
|
|||||||
return filter(lambda counter: counter.name == name, counters)[0]
|
return filter(lambda counter: counter.name == name, counters)[0]
|
||||||
|
|
||||||
def test_instance_create_instance(self):
|
def test_instance_create_instance(self):
|
||||||
ic = notifications.Instance()
|
ic = instance.Instance()
|
||||||
counters = list(ic.process_notification(INSTANCE_CREATE_END))
|
counters = list(ic.process_notification(INSTANCE_CREATE_END))
|
||||||
self.assertEqual(len(counters), 1)
|
self.assertEqual(len(counters), 1)
|
||||||
c = counters[0]
|
c = counters[0]
|
||||||
self.assertEqual(c.volume, 1)
|
self.assertEqual(c.volume, 1)
|
||||||
|
|
||||||
def test_instance_create_flavor(self):
|
def test_instance_create_flavor(self):
|
||||||
ic = notifications.InstanceFlavor()
|
ic = instance.InstanceFlavor()
|
||||||
counters = list(ic.process_notification(INSTANCE_CREATE_END))
|
counters = list(ic.process_notification(INSTANCE_CREATE_END))
|
||||||
self.assertEqual(len(counters), 1)
|
self.assertEqual(len(counters), 1)
|
||||||
c = counters[0]
|
c = counters[0]
|
||||||
self.assertEqual(c.volume, 1)
|
self.assertEqual(c.volume, 1)
|
||||||
|
|
||||||
def test_instance_create_memory(self):
|
def test_instance_create_memory(self):
|
||||||
ic = notifications.Memory()
|
ic = instance.Memory()
|
||||||
counters = list(ic.process_notification(INSTANCE_CREATE_END))
|
counters = list(ic.process_notification(INSTANCE_CREATE_END))
|
||||||
self.assertEqual(len(counters), 1)
|
self.assertEqual(len(counters), 1)
|
||||||
c = counters[0]
|
c = counters[0]
|
||||||
self.assertEqual(c.volume, INSTANCE_CREATE_END['payload']['memory_mb'])
|
self.assertEqual(c.volume, INSTANCE_CREATE_END['payload']['memory_mb'])
|
||||||
|
|
||||||
def test_instance_create_vcpus(self):
|
def test_instance_create_vcpus(self):
|
||||||
ic = notifications.VCpus()
|
ic = instance.VCpus()
|
||||||
counters = list(ic.process_notification(INSTANCE_CREATE_END))
|
counters = list(ic.process_notification(INSTANCE_CREATE_END))
|
||||||
self.assertEqual(len(counters), 1)
|
self.assertEqual(len(counters), 1)
|
||||||
c = counters[0]
|
c = counters[0]
|
||||||
self.assertEqual(c.volume, INSTANCE_CREATE_END['payload']['vcpus'])
|
self.assertEqual(c.volume, INSTANCE_CREATE_END['payload']['vcpus'])
|
||||||
|
|
||||||
def test_instance_create_root_disk_size(self):
|
def test_instance_create_root_disk_size(self):
|
||||||
ic = notifications.RootDiskSize()
|
ic = instance.RootDiskSize()
|
||||||
counters = list(ic.process_notification(INSTANCE_CREATE_END))
|
counters = list(ic.process_notification(INSTANCE_CREATE_END))
|
||||||
self.assertEqual(len(counters), 1)
|
self.assertEqual(len(counters), 1)
|
||||||
c = counters[0]
|
c = counters[0]
|
||||||
self.assertEqual(c.volume, INSTANCE_CREATE_END['payload']['root_gb'])
|
self.assertEqual(c.volume, INSTANCE_CREATE_END['payload']['root_gb'])
|
||||||
|
|
||||||
def test_instance_create_ephemeral_disk_size(self):
|
def test_instance_create_ephemeral_disk_size(self):
|
||||||
ic = notifications.EphemeralDiskSize()
|
ic = instance.EphemeralDiskSize()
|
||||||
counters = list(ic.process_notification(INSTANCE_CREATE_END))
|
counters = list(ic.process_notification(INSTANCE_CREATE_END))
|
||||||
self.assertEqual(len(counters), 1)
|
self.assertEqual(len(counters), 1)
|
||||||
c = counters[0]
|
c = counters[0]
|
||||||
@ -468,34 +468,34 @@ class TestNotifications(test.BaseTestCase):
|
|||||||
INSTANCE_CREATE_END['payload']['ephemeral_gb'])
|
INSTANCE_CREATE_END['payload']['ephemeral_gb'])
|
||||||
|
|
||||||
def test_instance_exists_instance(self):
|
def test_instance_exists_instance(self):
|
||||||
ic = notifications.Instance()
|
ic = instance.Instance()
|
||||||
counters = list(ic.process_notification(INSTANCE_EXISTS))
|
counters = list(ic.process_notification(INSTANCE_EXISTS))
|
||||||
self.assertEqual(len(counters), 1)
|
self.assertEqual(len(counters), 1)
|
||||||
|
|
||||||
def test_instance_exists_flavor(self):
|
def test_instance_exists_flavor(self):
|
||||||
ic = notifications.Instance()
|
ic = instance.Instance()
|
||||||
counters = list(ic.process_notification(INSTANCE_EXISTS))
|
counters = list(ic.process_notification(INSTANCE_EXISTS))
|
||||||
self.assertEqual(len(counters), 1)
|
self.assertEqual(len(counters), 1)
|
||||||
|
|
||||||
def test_instance_delete_instance(self):
|
def test_instance_delete_instance(self):
|
||||||
ic = notifications.Instance()
|
ic = instance.Instance()
|
||||||
counters = list(ic.process_notification(INSTANCE_DELETE_START))
|
counters = list(ic.process_notification(INSTANCE_DELETE_START))
|
||||||
self.assertEqual(len(counters), 1)
|
self.assertEqual(len(counters), 1)
|
||||||
|
|
||||||
def test_instance_delete_flavor(self):
|
def test_instance_delete_flavor(self):
|
||||||
ic = notifications.Instance()
|
ic = instance.Instance()
|
||||||
counters = list(ic.process_notification(INSTANCE_DELETE_START))
|
counters = list(ic.process_notification(INSTANCE_DELETE_START))
|
||||||
self.assertEqual(len(counters), 1)
|
self.assertEqual(len(counters), 1)
|
||||||
|
|
||||||
def test_instance_finish_resize_instance(self):
|
def test_instance_finish_resize_instance(self):
|
||||||
ic = notifications.Instance()
|
ic = instance.Instance()
|
||||||
counters = list(ic.process_notification(INSTANCE_FINISH_RESIZE_END))
|
counters = list(ic.process_notification(INSTANCE_FINISH_RESIZE_END))
|
||||||
self.assertEqual(len(counters), 1)
|
self.assertEqual(len(counters), 1)
|
||||||
c = counters[0]
|
c = counters[0]
|
||||||
self.assertEqual(c.volume, 1)
|
self.assertEqual(c.volume, 1)
|
||||||
|
|
||||||
def test_instance_finish_resize_flavor(self):
|
def test_instance_finish_resize_flavor(self):
|
||||||
ic = notifications.InstanceFlavor()
|
ic = instance.InstanceFlavor()
|
||||||
counters = list(ic.process_notification(INSTANCE_FINISH_RESIZE_END))
|
counters = list(ic.process_notification(INSTANCE_FINISH_RESIZE_END))
|
||||||
self.assertEqual(len(counters), 1)
|
self.assertEqual(len(counters), 1)
|
||||||
c = counters[0]
|
c = counters[0]
|
||||||
@ -503,7 +503,7 @@ class TestNotifications(test.BaseTestCase):
|
|||||||
self.assertEqual(c.name, 'instance:m1.small')
|
self.assertEqual(c.name, 'instance:m1.small')
|
||||||
|
|
||||||
def test_instance_finish_resize_memory(self):
|
def test_instance_finish_resize_memory(self):
|
||||||
ic = notifications.Memory()
|
ic = instance.Memory()
|
||||||
counters = list(ic.process_notification(INSTANCE_FINISH_RESIZE_END))
|
counters = list(ic.process_notification(INSTANCE_FINISH_RESIZE_END))
|
||||||
self.assertEqual(len(counters), 1)
|
self.assertEqual(len(counters), 1)
|
||||||
c = counters[0]
|
c = counters[0]
|
||||||
@ -511,7 +511,7 @@ class TestNotifications(test.BaseTestCase):
|
|||||||
INSTANCE_FINISH_RESIZE_END['payload']['memory_mb'])
|
INSTANCE_FINISH_RESIZE_END['payload']['memory_mb'])
|
||||||
|
|
||||||
def test_instance_finish_resize_vcpus(self):
|
def test_instance_finish_resize_vcpus(self):
|
||||||
ic = notifications.VCpus()
|
ic = instance.VCpus()
|
||||||
counters = list(ic.process_notification(INSTANCE_FINISH_RESIZE_END))
|
counters = list(ic.process_notification(INSTANCE_FINISH_RESIZE_END))
|
||||||
self.assertEqual(len(counters), 1)
|
self.assertEqual(len(counters), 1)
|
||||||
c = counters[0]
|
c = counters[0]
|
||||||
@ -519,14 +519,14 @@ class TestNotifications(test.BaseTestCase):
|
|||||||
INSTANCE_FINISH_RESIZE_END['payload']['vcpus'])
|
INSTANCE_FINISH_RESIZE_END['payload']['vcpus'])
|
||||||
|
|
||||||
def test_instance_resize_finish_instance(self):
|
def test_instance_resize_finish_instance(self):
|
||||||
ic = notifications.Instance()
|
ic = instance.Instance()
|
||||||
counters = list(ic.process_notification(INSTANCE_FINISH_RESIZE_END))
|
counters = list(ic.process_notification(INSTANCE_FINISH_RESIZE_END))
|
||||||
self.assertEqual(len(counters), 1)
|
self.assertEqual(len(counters), 1)
|
||||||
c = counters[0]
|
c = counters[0]
|
||||||
self.assertEqual(c.volume, 1)
|
self.assertEqual(c.volume, 1)
|
||||||
|
|
||||||
def test_instance_resize_finish_flavor(self):
|
def test_instance_resize_finish_flavor(self):
|
||||||
ic = notifications.InstanceFlavor()
|
ic = instance.InstanceFlavor()
|
||||||
counters = list(ic.process_notification(INSTANCE_RESIZE_REVERT_END))
|
counters = list(ic.process_notification(INSTANCE_RESIZE_REVERT_END))
|
||||||
self.assertEqual(len(counters), 1)
|
self.assertEqual(len(counters), 1)
|
||||||
c = counters[0]
|
c = counters[0]
|
||||||
@ -534,7 +534,7 @@ class TestNotifications(test.BaseTestCase):
|
|||||||
self.assertEqual(c.name, 'instance:m1.tiny')
|
self.assertEqual(c.name, 'instance:m1.tiny')
|
||||||
|
|
||||||
def test_instance_resize_finish_memory(self):
|
def test_instance_resize_finish_memory(self):
|
||||||
ic = notifications.Memory()
|
ic = instance.Memory()
|
||||||
counters = list(ic.process_notification(INSTANCE_RESIZE_REVERT_END))
|
counters = list(ic.process_notification(INSTANCE_RESIZE_REVERT_END))
|
||||||
self.assertEqual(len(counters), 1)
|
self.assertEqual(len(counters), 1)
|
||||||
c = counters[0]
|
c = counters[0]
|
||||||
@ -542,7 +542,7 @@ class TestNotifications(test.BaseTestCase):
|
|||||||
INSTANCE_RESIZE_REVERT_END['payload']['memory_mb'])
|
INSTANCE_RESIZE_REVERT_END['payload']['memory_mb'])
|
||||||
|
|
||||||
def test_instance_resize_finish_vcpus(self):
|
def test_instance_resize_finish_vcpus(self):
|
||||||
ic = notifications.VCpus()
|
ic = instance.VCpus()
|
||||||
counters = list(ic.process_notification(INSTANCE_RESIZE_REVERT_END))
|
counters = list(ic.process_notification(INSTANCE_RESIZE_REVERT_END))
|
||||||
self.assertEqual(len(counters), 1)
|
self.assertEqual(len(counters), 1)
|
||||||
c = counters[0]
|
c = counters[0]
|
||||||
@ -550,14 +550,14 @@ class TestNotifications(test.BaseTestCase):
|
|||||||
INSTANCE_RESIZE_REVERT_END['payload']['vcpus'])
|
INSTANCE_RESIZE_REVERT_END['payload']['vcpus'])
|
||||||
|
|
||||||
def test_instance_delete_samples(self):
|
def test_instance_delete_samples(self):
|
||||||
ic = notifications.InstanceDelete()
|
ic = instance.InstanceDelete()
|
||||||
counters = list(ic.process_notification(INSTANCE_DELETE_SAMPLES))
|
counters = list(ic.process_notification(INSTANCE_DELETE_SAMPLES))
|
||||||
self.assertEqual(len(counters), 2)
|
self.assertEqual(len(counters), 2)
|
||||||
names = [c.name for c in counters]
|
names = [c.name for c in counters]
|
||||||
self.assertEqual(names, ['sample-name1', 'sample-name2'])
|
self.assertEqual(names, ['sample-name1', 'sample-name2'])
|
||||||
|
|
||||||
def test_instance_scheduled(self):
|
def test_instance_scheduled(self):
|
||||||
ic = notifications.InstanceScheduled()
|
ic = instance.InstanceScheduled()
|
||||||
|
|
||||||
self.assertIn(INSTANCE_SCHEDULED['event_type'],
|
self.assertIn(INSTANCE_SCHEDULED['event_type'],
|
||||||
ic.event_types)
|
ic.event_types)
|
@ -23,7 +23,7 @@ import mock
|
|||||||
from stevedore import extension
|
from stevedore import extension
|
||||||
from stevedore.tests import manager as test_manager
|
from stevedore.tests import manager as test_manager
|
||||||
|
|
||||||
from ceilometer.compute import notifications
|
from ceilometer.compute.notifications import instance
|
||||||
from ceilometer import notification
|
from ceilometer import notification
|
||||||
from ceilometer.openstack.common.fixture import config
|
from ceilometer.openstack.common.fixture import config
|
||||||
from ceilometer.openstack.common import timeutils
|
from ceilometer.openstack.common import timeutils
|
||||||
@ -101,7 +101,7 @@ class TestNotification(tests_base.BaseTestCase):
|
|||||||
[extension.Extension('test',
|
[extension.Extension('test',
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
notifications.Instance(),
|
instance.Instance(),
|
||||||
),
|
),
|
||||||
])
|
])
|
||||||
self.srv.process_notification(TEST_NOTICE)
|
self.srv.process_notification(TEST_NOTICE)
|
||||||
|
26
setup.cfg
26
setup.cfg
@ -29,14 +29,24 @@ packages =
|
|||||||
|
|
||||||
[entry_points]
|
[entry_points]
|
||||||
ceilometer.notification =
|
ceilometer.notification =
|
||||||
instance = ceilometer.compute.notifications:Instance
|
instance = ceilometer.compute.notifications.instance:Instance
|
||||||
instance_flavor = ceilometer.compute.notifications:InstanceFlavor
|
instance_flavor = ceilometer.compute.notifications.instance:InstanceFlavor
|
||||||
instance_delete = ceilometer.compute.notifications:InstanceDelete
|
instance_delete = ceilometer.compute.notifications.instance:InstanceDelete
|
||||||
instance_scheduled = ceilometer.compute.notifications:InstanceScheduled
|
instance_scheduled = ceilometer.compute.notifications.instance:InstanceScheduled
|
||||||
memory = ceilometer.compute.notifications:Memory
|
memory = ceilometer.compute.notifications.instance:Memory
|
||||||
vcpus = ceilometer.compute.notifications:VCpus
|
vcpus = ceilometer.compute.notifications.instance:VCpus
|
||||||
disk_root_size = ceilometer.compute.notifications:RootDiskSize
|
disk_root_size = ceilometer.compute.notifications.instance:RootDiskSize
|
||||||
disk_ephemeral_size = ceilometer.compute.notifications:EphemeralDiskSize
|
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
|
||||||
|
cpu_idle_time = ceilometer.compute.notifications.cpu:CpuIdleTime
|
||||||
|
cpu_iowait_time = ceilometer.compute.notifications.cpu:CpuIowaitTime
|
||||||
|
cpu_kernel_percent = ceilometer.compute.notifications.cpu:CpuKernelPercent
|
||||||
|
cpu_idle_percent = ceilometer.compute.notifications.cpu:CpuIdlePercent
|
||||||
|
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 = ceilometer.volume.notifications:Volume
|
||||||
volume_size = ceilometer.volume.notifications:VolumeSize
|
volume_size = ceilometer.volume.notifications:VolumeSize
|
||||||
image_crud = ceilometer.image.notifications:ImageCRUD
|
image_crud = ceilometer.image.notifications:ImageCRUD
|
||||||
|
Loading…
Reference in New Issue
Block a user