Redundant check in os-migrate_volume_completion
Remove the redundant check for 'migrate_volume_completion', and add the UT for it. Change-Id: I6b643dbf9ae1302cafe6748a361123d7d76c437f Closes-Bug: #1254963
This commit is contained in:
parent
7acdf51329
commit
a0693a91f5
|
@ -173,11 +173,7 @@ class VolumeAdminController(AdminController):
|
|||
volume = self._get(context, id)
|
||||
except exception.NotFound:
|
||||
raise exc.HTTPNotFound()
|
||||
try:
|
||||
params = body['os-migrate_volume_completion']
|
||||
except KeyError:
|
||||
raise exc.HTTPBadRequest("Body does not contain "
|
||||
"'os-migrate_volume_completion'")
|
||||
params = body['os-migrate_volume_completion']
|
||||
try:
|
||||
new_volume_id = params['new_volume']
|
||||
except KeyError:
|
||||
|
|
|
@ -653,12 +653,15 @@ class AdminActionsTest(test.TestCase):
|
|||
force_host_copy=1)
|
||||
|
||||
def _migrate_volume_comp_exec(self, ctx, volume, new_volume, error,
|
||||
expected_status, expected_id):
|
||||
expected_status, expected_id, no_body=False):
|
||||
req = webob.Request.blank('/v2/fake/volumes/%s/action' % volume['id'])
|
||||
req.method = 'POST'
|
||||
req.headers['content-type'] = 'application/json'
|
||||
body_dict = {'new_volume': new_volume['id'], 'error': error}
|
||||
req.body = jsonutils.dumps({'os-migrate_volume_completion': body_dict})
|
||||
body = {'new_volume': new_volume['id'], 'error': error}
|
||||
if no_body:
|
||||
req.body = jsonutils.dumps({'': body})
|
||||
else:
|
||||
req.body = jsonutils.dumps({'os-migrate_volume_completion': body})
|
||||
req.environ['cinder.context'] = ctx
|
||||
resp = req.get_response(app())
|
||||
resp_dict = ast.literal_eval(resp.body)
|
||||
|
@ -707,6 +710,16 @@ class AdminActionsTest(test.TestCase):
|
|||
volume = self._migrate_volume_comp_exec(ctx, volume1, volume2, False,
|
||||
expected_status, expected_id)
|
||||
|
||||
def test_migrate_volume_comp_no_action(self):
|
||||
admin_ctx = context.get_admin_context()
|
||||
volume = db.volume_create(admin_ctx, {'id': 'fake1'})
|
||||
new_volume = db.volume_create(admin_ctx, {'id': 'fake2'})
|
||||
expected_status = 400
|
||||
expected_id = None
|
||||
ctx = context.RequestContext('fake', 'fake')
|
||||
self._migrate_volume_comp_exec(ctx, volume, new_volume, False,
|
||||
expected_status, expected_id, True)
|
||||
|
||||
def test_migrate_volume_comp_from_nova(self):
|
||||
admin_ctx = context.get_admin_context()
|
||||
volume = db.volume_create(admin_ctx,
|
||||
|
|
Loading…
Reference in New Issue