From 4fb76509b1c188a7ec7a31d1d03ec0cd5ded3c15 Mon Sep 17 00:00:00 2001 From: Angus Salkeld Date: Wed, 1 May 2013 11:36:54 +1000 Subject: [PATCH] Enumerate the meter type in the API Meter class This uses the counter definitions as this is how the db is populated and thus will be consistent. Change-Id: I145600822cb89e65dd515e5d2075f1c44cc0b087 --- ceilometer/api/controllers/v2.py | 7 ++++--- tests/test_pipeline.py | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/ceilometer/api/controllers/v2.py b/ceilometer/api/controllers/v2.py index 0fba3ff91..e7f506dcf 100644 --- a/ceilometer/api/controllers/v2.py +++ b/ceilometer/api/controllers/v2.py @@ -40,9 +40,9 @@ from wsme import types as wtypes from ceilometer.openstack.common import log from ceilometer.openstack.common import timeutils +from ceilometer import counter from ceilometer import storage - LOG = log.getLogger(__name__) @@ -421,8 +421,9 @@ class Meter(_Base): name = wtypes.text "The unique name for the meter" - # FIXME(dhellmann): Make this an enum? - type = wtypes.text + type = wtypes.Enum(str, counter.TYPE_GAUGE, + counter.TYPE_CUMULATIVE, + counter.TYPE_DELTA) "The meter type (see :ref:`measurements`)" unit = wtypes.text diff --git a/tests/test_pipeline.py b/tests/test_pipeline.py index 0aa004451..c0d18bd2e 100644 --- a/tests/test_pipeline.py +++ b/tests/test_pipeline.py @@ -97,7 +97,7 @@ class TestPipeline(base.TestCase): self.test_counter = counter.Counter( name='a', - type='test_type', + type=counter.TYPE_GAUGE, volume=1, unit='B', user_id="test_user",