예제 #1
0
 def _clean_volume_attachment(context, id):
     attachments = (
         db.volume_attachment_get_all_by_volume_id(context, id))
     for attachment in attachments:
         db.volume_detached(context.elevated(), id, attachment.id)
     db.volume_admin_metadata_delete(context.elevated(), id,
                                     'attached_mode')
예제 #2
0
 def _clean_volume_attachment(context, id):
     attachments = (
         db.volume_attachment_get_all_by_volume_id(context, id))
     for attachment in attachments:
         db.volume_detached(context, id, attachment.id)
     db.volume_admin_metadata_delete(context, id,
                                     'attached_mode')
예제 #3
0
    def delete_all(self, vol_id):
        """
        Delete the admin_metadata created for given volume.

        :param vol_id: OpenStack Volume ID.

        """
        admin_context = context.get_admin_context()
        admin_meta = self.get_all(vol_id)
        for key in admin_meta.keys():
            db.volume_admin_metadata_delete(admin_context, vol_id, key)
예제 #4
0
    def finish_detach(self, attachment_id):
        with self.obj_as_admin():
            volume_updates, attachment_updates = (
                db.volume_detached(self._context, self.id, attachment_id))
            db.volume_admin_metadata_delete(self._context, self.id,
                                            'attached_mode')
            self.admin_metadata.pop('attached_mode', None)
        # Remove attachment in volume only when this field is loaded.
        if attachment_updates and self.obj_attr_is_set('volume_attachment'):
            for i, attachment in enumerate(self.volume_attachment):
                if attachment.id == attachment_id:
                    del self.volume_attachment.objects[i]
                    break

        self.update(volume_updates)
        self.obj_reset_changes(
            list(volume_updates.keys()) +
            ['volume_attachment', 'admin_metadata'])
예제 #5
0
파일: volume.py 프로젝트: mahak/cinder
    def finish_detach(self, attachment_id):
        with self.obj_as_admin():
            volume_updates, attachment_updates = (
                db.volume_detached(self._context, self.id, attachment_id))
            db.volume_admin_metadata_delete(self._context, self.id,
                                            'attached_mode')
            self.admin_metadata.pop('attached_mode', None)
        # Remove attachment in volume only when this field is loaded.
        if attachment_updates and self.obj_attr_is_set('volume_attachment'):
            for i, attachment in enumerate(self.volume_attachment):
                if attachment.id == attachment_id:
                    del self.volume_attachment.objects[i]
                    break

        self.update(volume_updates)
        self.obj_reset_changes(
            list(volume_updates.keys()) +
            ['volume_attachment', 'admin_metadata'])