Allow host and instance_uuid at attach
This patch removes the restriction on passing both host name and instance_uuid during os-attach call. Change-Id: I2a66920a76d3abfd6da384d2dd963f054ce61c03 Partial-Bug: #1471278
This commit is contained in:
parent
81f7986c16
commit
3632173486
|
@ -98,15 +98,7 @@ class VolumeActionsController(wsgi.Controller):
|
|||
else:
|
||||
mode = 'rw'
|
||||
|
||||
if instance_uuid and host_name:
|
||||
msg = _("Invalid request to attach volume to an "
|
||||
"instance %(instance_uuid)s and a "
|
||||
"host %(host_name)s simultaneously") % {
|
||||
'instance_uuid': instance_uuid,
|
||||
'host_name': host_name,
|
||||
}
|
||||
raise webob.exc.HTTPBadRequest(explanation=msg)
|
||||
elif instance_uuid is None and host_name is None:
|
||||
if instance_uuid is None and host_name is None:
|
||||
msg = _("Invalid request to attach volume to an invalid target")
|
||||
raise webob.exc.HTTPBadRequest(explanation=msg)
|
||||
|
||||
|
|
|
@ -179,6 +179,16 @@ class VolumeActionsTest(test.TestCase):
|
|||
res = req.get_response(fakes.wsgi_app())
|
||||
self.assertEqual(202, res.status_int)
|
||||
|
||||
body = {'os-attach': {'instance_uuid': 'fake',
|
||||
'host_name': 'fake_host',
|
||||
'mountpoint': '/dev/vdc'}}
|
||||
req = webob.Request.blank('/v2/fake/volumes/1/action')
|
||||
req.method = "POST"
|
||||
req.headers["content-type"] = "application/json"
|
||||
req.body = jsonutils.dumps(body)
|
||||
res = req.get_response(fakes.wsgi_app())
|
||||
self.assertEqual(202, res.status_int)
|
||||
|
||||
def test_attach_to_host(self):
|
||||
# using 'read-write' mode attach volume by default
|
||||
body = {'os-attach': {'host_name': 'fake_host',
|
||||
|
@ -277,17 +287,6 @@ class VolumeActionsTest(test.TestCase):
|
|||
res = req.get_response(fakes.wsgi_app())
|
||||
self.assertEqual(400, res.status_int)
|
||||
|
||||
# Invalid request to attach volume to an instance and a host
|
||||
body = {'os-attach': {'instance_uuid': 'fake',
|
||||
'host_name': 'fake_host',
|
||||
'mountpoint': '/dev/vdc'}}
|
||||
req = webob.Request.blank('/v2/fake/volumes/1/action')
|
||||
req.method = "POST"
|
||||
req.headers["content-type"] = "application/json"
|
||||
req.body = jsonutils.dumps(body)
|
||||
res = req.get_response(fakes.wsgi_app())
|
||||
self.assertEqual(400, res.status_int)
|
||||
|
||||
# Invalid request to attach volume with an invalid mode
|
||||
body = {'os-attach': {'instance_uuid': 'fake',
|
||||
'mountpoint': '/dev/vdc',
|
||||
|
|
Loading…
Reference in New Issue