network: emit router meter

This fixes bug #1070009

Change-Id: Ica5611d00984c8ca25e382bb8b54fbe9c87f5282
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2012-10-24 15:31:27 +02:00
parent 70442dc8da
commit 52eed63c65
4 changed files with 51 additions and 0 deletions

View File

@ -153,3 +153,19 @@ class Port(NetworkNotificationBase):
]
resource_name = 'port'
class Router(NetworkNotificationBase):
"""Listen for Quantum notifications in order to mediate with the
metering framework.
"""
metadata_keys = [
"status",
"external_gateway_info",
"admin_state_up",
"name",
]
resource_name = 'router'

View File

@ -73,6 +73,9 @@ subnet.update Delta request subnt ID Update requests for thi
port Gauge 1 port ID Duration of port
port.create Delta request port ID Creation requests for this port
port.update Delta request port ID Update requests for this port
router Gauge 1 rtr ID Duration of router
router.create Delta request rtr ID Creation requests for this router
router.update Delta request rtr ID Update requests for this router
ip.floating Gauge 1 ip ID Duration of floating ip
======================== ========== ======= ======== =======================================================

View File

@ -94,6 +94,7 @@ setuptools.setup(
network = ceilometer.network.notifications:Network
subnet = ceilometer.network.notifications:Subnet
port = ceilometer.network.notifications:Port
router = ceilometer.network.notifications:Router
[ceilometer.poll.compute]
libvirt_diskio = ceilometer.compute.libvirt:DiskIOPollster

View File

@ -157,6 +157,29 @@ NOTIFICATION_NETWORK_EXISTS = {
u'message_id': u'9e839576-cc47-4c60-a7d8-5743681213b1'}
NOTIFICATION_ROUTER_EXISTS = {
u'_context_roles': [u'anotherrole',
u'Member'],
u'_context_read_deleted': u'no',
u'event_type': u'router.exists',
u'timestamp': u'2012-09-27 14:11:27.086575',
u'_context_tenant_id': u'82ed0c40ebe64d0bb3310027039c8ed2',
u'payload': {u'router':
{'status': u'ACTIVE',
'external_gateway_info':
{'network_id': u'89d55642-4dec-43a4-a617-6cec051393b5'},
'name': u'router1',
'admin_state_up': True,
'tenant_id': u'bb04a2b769c94917b57ba49df7783cfd',
'id': u'ab8bb3ed-df23-4ca0-8f03-b887abcd5c23'}},
u'priority': u'INFO',
u'_context_is_admin': False,
u'_context_timestamp': u'2012-09-27 14:11:26.924779',
u'_context_user_id': u'b44b7ce67fc84414a5c1660a92a1b862',
u'publisher_id': u'network.ubuntu-VirtualBox',
u'message_id': u'9e839576-cc47-4c60-a7d8-5743681213b1'}
class TestNotifications(unittest.TestCase):
def test_network_create(self):
v = notifications.Network()
@ -183,6 +206,11 @@ class TestNotifications(unittest.TestCase):
counters = v.process_notification(NOTIFICATION_NETWORK_EXISTS)
self.assertEqual(len(list(counters)), 1)
def test_router_exists(self):
v = notifications.Router()
counters = v.process_notification(NOTIFICATION_ROUTER_EXISTS)
self.assertEqual(len(list(counters)), 1)
class TestEventTypes(unittest.TestCase):
@ -200,3 +228,6 @@ class TestEventTypes(unittest.TestCase):
v = notifications.Port()
events = v.get_event_types()
assert events
def test_router(self):
assert notifications.Router().get_event_types()