summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2012-09-07 21:51:35 +0000
committerGerrit Code Review <review@openstack.org>2012-09-07 21:51:35 +0000
commitf3d28abb2ed3ea4e3d8c3bf424ea9df8232cfa6a (patch)
treefadfcc8764df75f7317bcce899f73f7599980cd3
parent7741ac15e6304776488dde29fff4e84e96378269 (diff)
parent6fba30c8a979e2d85b5bcc4687f2ba00d2af329e (diff)
downloadnova-f3d28abb2ed3ea4e3d8c3bf424ea9df8232cfa6a.tar.gz
nova-f3d28abb2ed3ea4e3d8c3bf424ea9df8232cfa6a.tar.xz
nova-f3d28abb2ed3ea4e3d8c3bf424ea9df8232cfa6a.zip
Merge "Call driver for attach/detach_volume"
-rw-r--r--nova/volume/driver.py8
-rw-r--r--nova/volume/manager.py19
2 files changed, 27 insertions, 0 deletions
diff --git a/nova/volume/driver.py b/nova/volume/driver.py
index 8aa7fd595..bc577db26 100644
--- a/nova/volume/driver.py
+++ b/nova/volume/driver.py
@@ -240,6 +240,14 @@ class VolumeDriver(object):
"""Disallow connection from connector"""
raise NotImplementedError()
+ def attach_volume(self, context, volume_id, instance_uuid, mountpoint):
+ """ Callback for volume attached to instance."""
+ pass
+
+ def detach_volume(self, context, volume_id):
+ """ Callback for volume detached."""
+ pass
+
def get_volume_stats(self, refresh=False):
"""Return the current state of the volume service. If 'refresh' is
True, run the update first."""
diff --git a/nova/volume/manager.py b/nova/volume/manager.py
index eed73e212..77f4aee23 100644
--- a/nova/volume/manager.py
+++ b/nova/volume/manager.py
@@ -263,6 +263,17 @@ class VolumeManager(manager.SchedulerDependentManager):
if not utils.is_uuid_like(instance_uuid):
raise exception.InvalidUUID(instance_uuid)
+ try:
+ self.driver.attach_volume(context,
+ volume_id,
+ instance_uuid,
+ mountpoint)
+ except Exception:
+ with excutils.save_and_reraise_exception():
+ self.db.volume_update(context,
+ volume_id,
+ {'status': 'error_attaching'})
+
self.db.volume_attached(context,
volume_id,
instance_uuid,
@@ -271,6 +282,14 @@ class VolumeManager(manager.SchedulerDependentManager):
def detach_volume(self, context, volume_id):
"""Updates db to show volume is detached"""
# TODO(vish): refactor this into a more general "unreserve"
+ try:
+ self.driver.detach_volume(context, volume_id)
+ except Exception:
+ with excutils.save_and_reraise_exception():
+ self.db.volume_update(context,
+ volume_id,
+ {'status': 'error_detaching'})
+
self.db.volume_detached(context, volume_id)
def initialize_connection(self, context, volume_id, connector):