Merge "Fix attachment_delete for reserved case"

This commit is contained in:
Jenkins 2017-07-05 20:32:38 +00:00 committed by Gerrit Code Review
commit 30431abf2a

View File

@ -2003,7 +2003,12 @@ class API(base.Base):
def attachment_delete(self, ctxt, attachment):
volume = objects.Volume.get_by_id(ctxt, attachment.volume_id)
if attachment.attach_status == 'reserved':
attachment.destroy()
self.db.volume_detached(ctxt.elevated(), attachment.volume_id,
attachment.get('id'))
self.db.volume_admin_metadata_delete(ctxt.elevated(),
attachment.volume_id,
'attached_mode')
volume_utils.notify_about_volume_usage(ctxt, volume, "detach.end")
else:
self.volume_rpcapi.attachment_delete(ctxt,
attachment.id,