Merge "Fix az parameter handling which blocks the integration test"

This commit is contained in:
Jenkins 2016-06-19 04:05:00 +00:00 committed by Gerrit Code Review
commit 1f4d505b84
3 changed files with 20 additions and 10 deletions

View File

@ -52,13 +52,10 @@ class VolumeController(rest.RestController):
pecan.abort(400, _('Volume not found in request body'))
return
if 'availability_zone' not in kw['volume']:
pecan.abort(400, _('Availability zone not set in request'))
return
az = kw['volume'].get('availability_zone', '')
pod, pod_az = az_ag.get_pod_by_az_tenant(
context,
az_name=kw['volume']['availability_zone'],
az_name=az,
tenant_id=self.tenant_id)
if not pod:
pecan.abort(500, _('Pod not configured or scheduling failure'))

View File

@ -120,14 +120,27 @@ def get_pod_by_az_tenant(context, az_name, tenant_id):
pod = core.get_resource(context,
models.Pod,
pod_b['pod_id'])
if pod['az_name'] == az_name:
if az_name and pod['az_name'] == az_name:
return pod, pod['pod_az_name']
elif az_name == '' and pod['az_name'] != '':
# if the az_name is not specified, a defult bottom
# pod will be selected
return pod, pod['pod_az_name']
else:
pass
# TODO(joehuang): schedule one dynamically in the future
filters = [{'key': 'az_name', 'comparator': 'eq', 'value': az_name}]
if az_name != '':
filters = [{'key': 'az_name', 'comparator': 'eq', 'value': az_name}]
else:
filters = None
# if az_name is valid, select a pod under this az_name
# if az_name is '', select the first valid bottom pod.
# change to dynamic schedluing in the future
pods = db_api.list_pods(context, filters=filters)
for pod in pods:
if pod['pod_name'] != '':
if pod['pod_name'] != '' and pod['az_name'] != '':
try:
with context.session.begin():
core.create_resource(

View File

@ -255,7 +255,7 @@ class TestVolumeController(CinderVolumeFunctionalTest):
"project_id": 'my_tenant_id',
"metadata": {}
},
"expected_error": 400
"expected_error": 202
},
# incorrect AZ parameter
@ -575,7 +575,7 @@ class TestVolumeController(CinderVolumeFunctionalTest):
elif test_vol.get('volume_xxx'):
response = self.app.post_json(
'/v2/' + tenant_id + '/volumes',
dict(volume=test_vol['volume_xxx']),
dict(volume_xxx=test_vol['volume_xxx']),
expect_errors=True)
else:
return