diff --git a/nova/api/openstack/compute/volumes.py b/nova/api/openstack/compute/volumes.py index 27b9af950293..faa2238e5e7d 100644 --- a/nova/api/openstack/compute/volumes.py +++ b/nova/api/openstack/compute/volumes.py @@ -433,7 +433,7 @@ class VolumeAttachmentController(wsgi.Controller): if bdm.is_root: msg = _("Cannot detach a root device volume") - raise exc.HTTPForbidden(explanation=msg) + raise exc.HTTPBadRequest(explanation=msg) try: self.compute_api.detach_volume(context, instance, volume) diff --git a/nova/tests/unit/api/openstack/compute/test_volumes.py b/nova/tests/unit/api/openstack/compute/test_volumes.py index ef47287a25a4..162d472034a5 100644 --- a/nova/tests/unit/api/openstack/compute/test_volumes.py +++ b/nova/tests/unit/api/openstack/compute/test_volumes.py @@ -541,7 +541,7 @@ class VolumeAttachTestsV21(test.NoDBTestCase): new_callable=mock.PropertyMock) def test_detach_vol_root(self, mock_isroot): mock_isroot.return_value = True - self.assertRaises(exc.HTTPForbidden, + self.assertRaises(exc.HTTPBadRequest, self.attachments.delete, self.req, FAKE_UUID,