Add ceilometer api and the tests for it

Adding ceilometer api basic function wrappers.
Adding Class wrapper of each ceilometer object.

Adding ceilometer general usage wrappers for common statistics over
list of Resources and ResourceAggregates.

Adding specific table statistics wrappers.

Adding tests and test data for Ceilometer API.

Best to be tested with commit for resource usage panel at:
https://review.openstack.org/#/c/35590/ - this commit is for the
test purpose only.

Link to bp: https://blueprints.launchpad.net/horizon/+spec/ceilometer

Implements bp ceilometer.
Change-Id: I5b3392de8bae2be8cbcba7a580af669676e54052
This commit is contained in:
Ladislav Smola 2013-01-11 21:08:33 +08:00
parent 3a483384fc
commit 0f5c35ecd8
2 changed files with 14 additions and 0 deletions

View File

@ -34,6 +34,7 @@ shouldn't need to understand the finer details of APIs for
Keystone/Nova/Glance/Swift et. al.
"""
from openstack_dashboard.api import base
from openstack_dashboard.api import ceilometer
from openstack_dashboard.api import cinder
from openstack_dashboard.api import glance
from openstack_dashboard.api import heat
@ -54,3 +55,4 @@ assert nova
assert neutron
assert lbaas
assert swift
assert ceilometer

View File

@ -30,6 +30,7 @@ from django.test.client import RequestFactory # noqa
from django.utils.importlib import import_module # noqa
from django.utils import unittest
from ceilometerclient.v2 import client as ceilometer_client
from cinderclient import client as cinder_client
import glanceclient
from heatclient import client as heat_client
@ -262,6 +263,7 @@ class APITestCase(TestCase):
self._original_neutronclient = api.neutron.neutronclient
self._original_cinderclient = api.cinder.cinderclient
self._original_heatclient = api.heat.heatclient
self._original_ceilometerclient = api.ceilometer.ceilometerclient
# Replace the clients with our stubs.
api.glance.glanceclient = lambda request: self.stub_glanceclient()
@ -270,6 +272,8 @@ class APITestCase(TestCase):
api.neutron.neutronclient = lambda request: self.stub_neutronclient()
api.cinder.cinderclient = lambda request: self.stub_cinderclient()
api.heat.heatclient = lambda request: self.stub_heatclient()
api.ceilometer.ceilometerclient = lambda request: \
self.stub_ceilometerclient()
def tearDown(self):
super(APITestCase, self).tearDown()
@ -279,6 +283,7 @@ class APITestCase(TestCase):
api.neutron.neutronclient = self._original_neutronclient
api.cinder.cinderclient = self._original_cinderclient
api.heat.heatclient = self._original_heatclient
api.ceilometer.ceilometerclient = self._original_ceilometerclient
def stub_novaclient(self):
if not hasattr(self, "novaclient"):
@ -336,6 +341,13 @@ class APITestCase(TestCase):
self.heatclient = self.mox.CreateMock(heat_client.Client)
return self.heatclient
def stub_ceilometerclient(self):
if not hasattr(self, "ceilometerclient"):
self.mox.StubOutWithMock(ceilometer_client, 'Client')
self.ceilometerclient = self.mox.\
CreateMock(ceilometer_client.Client)
return self.ceilometerclient
@unittest.skipUnless(os.environ.get('WITH_SELENIUM', False),
"The WITH_SELENIUM env variable is not set.")