diff options
| author | Joe Gordon <jogo@cloudscaling.com> | 2013-03-08 02:17:22 +0000 |
|---|---|---|
| committer | Joe Gordon <jogo@cloudscaling.com> | 2013-03-18 14:38:19 -0700 |
| commit | 84b73cf3d46200fef6521d79c8aa59ccb7a96224 (patch) | |
| tree | de6e7d4a13143794f5ba0b81eddebb5451ea4a43 /nova/api | |
| parent | 2d7b7a10b672ede6aa04b42b2efce24c6459f699 (diff) | |
| download | nova-84b73cf3d46200fef6521d79c8aa59ccb7a96224.tar.gz nova-84b73cf3d46200fef6521d79c8aa59ccb7a96224.tar.xz nova-84b73cf3d46200fef6521d79c8aa59ccb7a96224.zip | |
Prevent volume-attach/detach from instances in rescue state
Rescue is supposed to just be a way to log into a wayward instance
if something goes wrong with the base image that may have had some data
(logfiles etc.) and make it possible to grab that - block devices are
assumed to be accessible by re-attaching them, and are considered
persistant so no need for rescue there.
Since there is no need to attach a volume in rescue mode, and detaching a
volume that was previously attached doesn't work, just ban volume
attach/detach in rescue state.
Fixes bug 1126187
Change-Id: Ifdf164155942cdeb2bbdfcd1dce0dd2e125b507c
Diffstat (limited to 'nova/api')
| -rw-r--r-- | nova/api/openstack/compute/contrib/volumes.py | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/nova/api/openstack/compute/contrib/volumes.py b/nova/api/openstack/compute/contrib/volumes.py index 760dc953a..b58a7b442 100644 --- a/nova/api/openstack/compute/contrib/volumes.py +++ b/nova/api/openstack/compute/contrib/volumes.py @@ -402,6 +402,9 @@ class VolumeAttachmentController(wsgi.Controller): volume_id, device) except exception.NotFound: raise exc.HTTPNotFound() + except exception.InstanceInvalidState as state_error: + common.raise_http_conflict_for_instance_invalid_state(state_error, + 'attach_volume') # The attach is async attachment = {} @@ -446,12 +449,16 @@ class VolumeAttachmentController(wsgi.Controller): raise exc.HTTPNotFound() found = False - for bdm in bdms: - if bdm['volume_id'] == volume_id: - self.compute_api.detach_volume(context, - volume_id=volume_id) - found = True - break + try: + for bdm in bdms: + if bdm['volume_id'] == volume_id: + self.compute_api.detach_volume(context, + volume_id=volume_id) + found = True + break + except exception.InstanceInvalidState as state_error: + common.raise_http_conflict_for_instance_invalid_state(state_error, + 'detach_volume') if not found: raise exc.HTTPNotFound() |
