Enable POST samples API when gnocchi enabled

Currently, if we enabled gnocchi, the every API of meters, resources,
samples will be disabled and 410 response will be returned. The posting
samples API shouldn't be diabled.

Change-Id: I142e4470a69a0782cabb6b1b4160faac0d48f0df
Closes-Bug: #1505283
This commit is contained in:
liusheng 2015-10-13 15:05:33 +08:00
parent 130b8519df
commit e973877166
2 changed files with 10 additions and 0 deletions

View File

@ -156,6 +156,8 @@ class V2Controller(object):
def _lookup(self, kind, *remainder):
if (kind in ['meters', 'resources', 'samples']
and self.gnocchi_is_enabled):
if kind == 'meters' and pecan.request.method == 'POST':
return meters.MetersController(), remainder
gnocchi_abort()
elif kind == 'meters':
return meters.MetersController(), remainder

View File

@ -65,6 +65,14 @@ class TestAPIUpgradePath(v2.FunctionalTest):
"limit": 3
}, status=410)
self.assertIn(b'Gnocchi API', response.body)
self.post_json('/meters/fake_counter',
params=[{
"counter_type": "gauge",
"counter_name": "fake_counter",
"resource_id": "fake_resource_id",
"counter_unit": "fake_unit",
"counter_volume": "1"
}], status=201)
def _do_test_alarm_redirect(self):
response = self.app.get(self.PATH_PREFIX + '/alarms',