bc1f004f8f
Move user_id and project_id into the Counter since the polling code has to pull those values from the instance object. Convert the libvirt polling code to plugins. Have the agent manager load the plugins and run them as part of its periodic task step. Change-Id: Id59a696beb33c7c9a232460ce52e272f5408e70d
60 lines
1.9 KiB
Python
60 lines
1.9 KiB
Python
#!/usr/bin/env python
|
|
# -*- encoding: utf-8 -*-
|
|
#
|
|
# Copyright © 2012 eNovance <licensing@enovance.com>
|
|
#
|
|
# Author: Julien Danjou <julien@danjou.info>
|
|
#
|
|
# 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 manager.
|
|
"""
|
|
|
|
# import unittest
|
|
# import mox
|
|
# import stubout
|
|
|
|
# import nova.tests.fakelibvirt as libvirt
|
|
from nova import context
|
|
from nova import flags
|
|
from nova import test
|
|
from nova import db
|
|
|
|
from ceilometer.compute import libvirt
|
|
from ceilometer.agent import manager
|
|
|
|
|
|
class TestDiskIOPollster(test.TestCase):
|
|
|
|
def setUp(self):
|
|
self.context = context.RequestContext('admin', 'admin', is_admin=True)
|
|
self.manager = manager.AgentManager()
|
|
self.pollster = libvirt.DiskIOPollster()
|
|
super(TestDiskIOPollster, self).setUp()
|
|
|
|
def test_fetch_diskio(self):
|
|
list(self.pollster.get_counters(self.manager, self.context))
|
|
|
|
def test_fetch_diskio_with_libvirt_non_existent_instance(self):
|
|
flags.FLAGS.connection_type = 'libvirt'
|
|
|
|
instance = db.instance_create(self.context, {})
|
|
|
|
self.mox.StubOutWithMock(self.manager.db, 'instance_get_all_by_host')
|
|
self.manager.db.instance_get_all_by_host(self.context,
|
|
self.manager.host,
|
|
).AndReturn([instance])
|
|
|
|
self.mox.ReplayAll()
|
|
|
|
list(self.pollster.get_counters(self.manager, self.context))
|