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)
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',
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',