Automatically get pools capabilities for flavor
For Zaqar API v2, admin user can't set the capabilities for flavor manually. So the field was always empty. This patch fixes the issue. Closes-Bug: #1679891 Change-Id: I2c9068c849cbfc7b5d2651627a5db7f9025d1473
This commit is contained in:
parent
14d730a0f4
commit
5b7c69fab9
@ -132,12 +132,11 @@ class TestFlavorsMongoDB(base.V2Base):
|
|||||||
body=jsonutils.dumps({'pool_group': pool_group}))
|
body=jsonutils.dumps({'pool_group': pool_group}))
|
||||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||||
|
|
||||||
@ddt.data(-1, 'wee', [])
|
def test_put_auto_get_capabilities(self):
|
||||||
def test_put_raises_if_invalid_capabilities(self, capabilities):
|
|
||||||
path = self.url_prefix + '/flavors/' + str(uuid.uuid1())
|
path = self.url_prefix + '/flavors/' + str(uuid.uuid1())
|
||||||
doc = {'pool_group': 'a', 'capabilities': capabilities}
|
doc = {'pool_group': self.pool_group}
|
||||||
self.simulate_put(path, body=jsonutils.dumps(doc))
|
self.simulate_put(path, body=jsonutils.dumps(doc))
|
||||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
self.assertEqual(falcon.HTTP_201, self.srmock.status)
|
||||||
|
|
||||||
def test_put_existing_overwrites(self):
|
def test_put_existing_overwrites(self):
|
||||||
# NOTE(cabrera): setUp creates default flavor
|
# NOTE(cabrera): setUp creates default flavor
|
||||||
|
@ -182,10 +182,12 @@ class Resource(object):
|
|||||||
data = wsgi_utils.load(request)
|
data = wsgi_utils.load(request)
|
||||||
wsgi_utils.validate(self._validators['create'], data)
|
wsgi_utils.validate(self._validators['create'], data)
|
||||||
pool_group = data.get('pool_group') or data.get('pool')
|
pool_group = data.get('pool_group') or data.get('pool')
|
||||||
|
capabilities = self._pools_ctrl.capabilities(pool_group)
|
||||||
try:
|
try:
|
||||||
self._ctrl.create(flavor,
|
self._ctrl.create(flavor,
|
||||||
pool_group=pool_group,
|
pool_group=pool_group,
|
||||||
project=project_id)
|
project=project_id,
|
||||||
|
capabilities=capabilities)
|
||||||
response.status = falcon.HTTP_201
|
response.status = falcon.HTTP_201
|
||||||
response.location = request.path
|
response.location = request.path
|
||||||
except errors.PoolGroupDoesNotExist as ex:
|
except errors.PoolGroupDoesNotExist as ex:
|
||||||
|
Loading…
Reference in New Issue
Block a user