Beispiel #1
0
 def on_main(self, checkpoint, resource, context, parameters, **kwargs):
     resource_id = resource.id
     bank_section = checkpoint.get_resource_bank_section(resource_id)
     backup_id = None
     try:
         bank_section.update_object('status',
                                    constants.RESOURCE_STATUS_DELETING)
         resource_metadata = bank_section.get_object('metadata')
         backup_id = resource_metadata['backup_id']
         trove_client = ClientFactory.create_client('trove', context)
         try:
             backup = trove_client.backups.get(backup_id)
             trove_client.backups.delete(backup)
         except trove_exc.NotFound:
             LOG.info('Backup id: %s not found. Assuming deleted',
                      backup_id)
         is_success = utils.status_poll(
             partial(get_backup_status, trove_client, backup_id),
             interval=self._interval,
             success_statuses={'not-found'},
             failure_statuses={'FAILED', 'DELETE_FAILED'},
             ignore_statuses={'COMPLETED'},
             ignore_unexpected=True)
         if not is_success:
             raise exception.NotFound()
         bank_section.delete_object('metadata')
         bank_section.update_object('status',
                                    constants.RESOURCE_STATUS_DELETED)
     except Exception as e:
         LOG.error('Delete Database instance Backup failed, backup_id: %s',
                   backup_id)
         bank_section.update_object('status',
                                    constants.RESOURCE_STATUS_ERROR)
         raise exception.DeleteResourceFailed(
             name="Database instance Backup",
             reason=six.text_type(e),
             resource_id=resource_id,
             resource_type=constants.DATABASE_RESOURCE_TYPE)
 def on_main(self, checkpoint, resource, context, parameters, **kwargs):
     resource_id = resource.id
     bank_section = checkpoint.get_resource_bank_section(resource_id)
     snapshot_id = None
     try:
         bank_section.update_object('status',
                                    constants.RESOURCE_STATUS_DELETING)
         resource_metadata = bank_section.get_object('metadata')
         snapshot_id = resource_metadata['snapshot_id']
         manila_client = ClientFactory.create_client('manila', context)
         try:
             snapshot = manila_client.share_snapshots.get(snapshot_id)
             manila_client.share_snapshots.delete(snapshot)
         except manila_exc.NotFound:
             LOG.info('Snapshot id: %s not found. Assuming deleted',
                      snapshot_id)
         is_success = utils.status_poll(
             partial(get_snapshot_status, manila_client, snapshot_id),
             interval=self._interval,
             success_statuses={'deleted', 'not-found'},
             failure_statuses={'error', 'error_deleting'},
             ignore_statuses={'deleting'},
             ignore_unexpected=True)
         if not is_success:
             raise exception.NotFound()
         bank_section.delete_object('metadata')
         bank_section.update_object('status',
                                    constants.RESOURCE_STATUS_DELETED)
     except Exception as e:
         LOG.error('Delete share snapshot failed, snapshot_id: %s',
                   snapshot_id)
         bank_section.update_object('status',
                                    constants.RESOURCE_STATUS_ERROR)
         raise exception.DeleteResourceFailed(
             name="Share Snapshot",
             reason=six.text_type(e),
             resource_id=resource_id,
             resource_type=constants.SHARE_RESOURCE_TYPE)
 def on_main(self, checkpoint, resource, context, parameters, **kwargs):
     resource_id = resource.id
     bank_section = checkpoint.get_resource_bank_section(resource_id)
     backup_id = None
     try:
         bank_section.update_object('status',
                                    constants.RESOURCE_STATUS_DELETING)
         resource_metadata = bank_section.get_object('metadata')
         backup_id = resource_metadata['backup_id']
         cinder_client = ClientFactory.create_client('cinder', context)
         try:
             backup = cinder_client.backups.get(backup_id)
             cinder_client.backups.delete(backup)
         except cinder_exc.NotFound:
             LOG.info('Backup id: %s not found. Assuming deleted',
                      backup_id)
         is_success = utils.status_poll(
             partial(get_backup_status, cinder_client, backup_id),
             interval=self._interval,
             success_statuses={'deleted', 'not-found'},
             failure_statuses={'error', 'error_deleting'},
             ignore_statuses={'deleting'},
         )
         if not is_success:
             raise exception.NotFound()
         bank_section.delete_object('metadata')
         bank_section.update_object('status',
                                    constants.RESOURCE_STATUS_DELETED)
     except Exception as e:
         LOG.error('delete volume backup failed, backup_id: %s', backup_id)
         bank_section.update_object('status',
                                    constants.RESOURCE_STATUS_ERROR)
         raise exception.DeleteResourceFailed(
             name="Volume Backup",
             reason=six.text_type(e),
             resource_id=resource_id,
             resource_type=constants.VOLUME_RESOURCE_TYPE
         )
Beispiel #4
0
    def on_main(self, checkpoint, resource, context, parameters, **kwargs):
        image_id = resource.id
        bank_section = checkpoint.get_resource_bank_section(image_id)

        LOG.info("Deleting image backup, image_id: %s.", image_id)
        try:
            bank_section.update_object("status",
                                       constants.RESOURCE_STATUS_DELETING)
            objects = bank_section.list_objects()
            for obj in objects:
                if obj == "status":
                    continue
                bank_section.delete_object(obj)
            bank_section.update_object("status",
                                       constants.RESOURCE_STATUS_DELETED)
        except Exception as err:
            LOG.error("delete image backup failed, image_id: %s.", image_id)
            bank_section.update_object("status",
                                       constants.RESOURCE_STATUS_ERROR)
            raise exception.DeleteResourceFailed(
                name="Image Backup",
                reason=err,
                resource_id=image_id,
                resource_type=constants.IMAGE_RESOURCE_TYPE)