Ejemplo n.º 1
0
    def delete_backup(self, cntxt, checkpoint, **kwargs):
        resource_node = kwargs.get("node")
        image_id = resource_node.value.id
        bank_section = checkpoint.get_resource_bank_section(image_id)

        LOG.info(_LI("deleting image backup failed, 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(_LE("delete image backup failed, image_id: %s."),
                      image_id)
            bank_section.update_object("status",
                                       constants.RESOURCE_STATUS_ERROR)
            raise exception.DeleteBackupFailed(
                reason=err,
                resource_id=image_id,
                resource_type=constants.IMAGE_RESOURCE_TYPE)
Ejemplo n.º 2
0
    def delete_backup(self, cntxt, checkpoint, **kwargs):
        resource_node = kwargs.get("node")
        resource_id = resource_node.value.id

        bank_section = checkpoint.get_resource_bank_section(resource_id)
        cinder_client = self._cinder_client(cntxt)
        LOG.info(_LI("deleting volume backup, volume_id: %s."), resource_id)
        try:
            bank_section.update_object("status",
                                       constants.RESOURCE_STATUS_DELETING)
            resource_definition = bank_section.get_object("metadata")
            backup_id = resource_definition["backup_id"]
            cinder_client.backups.delete(backup_id)
            bank_section.delete_object("metadata")
            self.protection_resource_map[resource_id] = {
                "bank_section": bank_section,
                "backup_id": backup_id,
                "cinder_client": cinder_client,
                "operation": "delete"
            }
        except Exception as e:
            LOG.error(_LE("delete volume backup failed, volume_id: %s."),
                      resource_id)
            bank_section.update_object("status",
                                       constants.CHECKPOINT_STATUS_ERROR)

            raise exception.DeleteBackupFailed(
                reason=six.text_type(e),
                resource_id=resource_id,
                resource_type=constants.VOLUME_RESOURCE_TYPE)
Ejemplo n.º 3
0
    def on_main(self, checkpoint, resource, cntxt, parameters, **kwargs):
        network_id = self._get_network_id(cntxt)
        bank_section = checkpoint.get_resource_bank_section(network_id)

        LOG.info("Deleting network backup, network_id: %s.", network_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:
            # update resource_definition backup_status
            LOG.error("Delete backup failed, network_id: %s.", network_id)
            bank_section.update_object("status",
                                       constants.RESOURCE_STATUS_ERROR)
            raise exception.DeleteBackupFailed(
                reason=err,
                resource_id=network_id,
                resource_type=self._SUPPORT_RESOURCE_TYPES)
Ejemplo n.º 4
0
    def on_main(self, checkpoint, resource, context, parameters, **kwargs):
        resource_id = resource.id
        bank_section = checkpoint.get_resource_bank_section(resource_id)

        LOG.info("deleting server backup, server_id: %s.", resource_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)
            LOG.info("finish delete server, server_id: %s.", resource_id)
        except Exception as err:
            # update resource_definition backup_status
            LOG.error("Delete backup failed, server_id: %s.", resource_id)
            bank_section.update_object("status",
                                       constants.RESOURCE_STATUS_ERROR)
            raise exception.DeleteBackupFailed(
                reason=err,
                resource_id=resource_id,
                resource_type=constants.SERVER_RESOURCE_TYPE)
Ejemplo n.º 5
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 failed, 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.DeleteBackupFailed(
                reason=err,
                resource_id=image_id,
                resource_type=constants.IMAGE_RESOURCE_TYPE)
Ejemplo n.º 6
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']
         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.DeleteBackupFailed(
             reason=six.text_type(e),
             resource_id=resource_id,
             resource_type=constants.VOLUME_RESOURCE_TYPE)