"""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."""
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.elevated(),
volume_id,
instance_uuid,
"""Updates db to show volume is detached"""
# TODO(vish): refactor this into a more general "unreserve"
# TODO(sleepsonthefloor): Is this 'elevated' appropriate?
+ 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.elevated(), volume_id)
def _copy_image_to_volume(self, context, volume, image_id):