summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVishvananda Ishaya <vishvananda@gmail.com>2010-06-24 04:11:57 +0100
committerandy <github@anarkystic.com>2010-06-24 04:11:57 +0100
commit9ebd49fa098c8e5fc21244b1bc6254b39d38752f (patch)
treeffd8f0a99f6cd9db428a6dc50945dc51c4a815f4
parent9d5f9e12e2bb9e87804459e943a4e3484d5c1f1a (diff)
downloadnova-9ebd49fa098c8e5fc21244b1bc6254b39d38752f.tar.gz
nova-9ebd49fa098c8e5fc21244b1bc6254b39d38752f.tar.xz
nova-9ebd49fa098c8e5fc21244b1bc6254b39d38752f.zip
don't allow volumes to be attached to the same mountpoint
-rw-r--r--nova/endpoint/cloud.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/nova/endpoint/cloud.py b/nova/endpoint/cloud.py
index 5c30d6002..882ce5784 100644
--- a/nova/endpoint/cloud.py
+++ b/nova/endpoint/cloud.py
@@ -320,7 +320,11 @@ class CloudController(object):
def attach_volume(self, context, volume_id, instance_id, device, **kwargs):
volume = self._get_volume(context, volume_id)
if volume['status'] == "attached":
- raise exception.Error("Volume is already attached")
+ raise exception.ApiError("Volume is already attached")
+ # TODO(vish): looping through all volumes is slow. We should probably maintain an index
+ for vol in self.volumes:
+ if vol['instance_id'] == instance_id and vol['mountpoint'] == device:
+ raise exception.ApiError("Volume %s is already attachted to %s" % (vol.volume_id, vol['mountpoint']))
volume.start_attach(instance_id, device)
instance = self._get_instance(context, instance_id)
compute_node = instance['node_name']