def on_main(self, checkpoint, resource, context, parameters, **kwargs):
        resource_id = resource.id
        bank_section = checkpoint.get_resource_bank_section(resource_id)
        resource_metadata = bank_section.get_object('metadata')
        cinder_client = ClientFactory.create_client('cinder', context)
        LOG.info('Verifying the volume backup, volume_id: %s', resource_id)

        update_method = partial(
            utils.update_resource_verify_result,
            kwargs.get('verify'), resource.type, resource_id)

        backup_id = resource_metadata['backup_id']
        try:
            volume_backup = cinder_client.backups.get(backup_id)
            backup_status = volume_backup.status
        except Exception as ex:
            LOG.error('Error get volume backup (backup_id: %(backup_id)s): '
                      '%(reason)s', {'backup_id': backup_id, 'reason': ex})
            reason = 'Error getting volume backup.'
            update_method(constants.RESOURCE_STATUS_ERROR, reason)
            raise

        if backup_status == 'available':
            update_method(constants.RESOURCE_STATUS_AVAILABLE)
        else:
            reason = (
                'The status of volume backup status is %s.' % backup_status)
            update_method(backup_status, reason)
            raise exception.VerifyResourceFailed(
                name="Volume Backup",
                reason=reason,
                resource_id=resource_id,
                resource_type=resource.type
            )
示例#2
0
    def on_main(self, checkpoint, resource, context, parameters, **kwargs):
        original_pod_id = resource.id
        bank_section = checkpoint.get_resource_bank_section(original_pod_id)
        LOG.info('Verifying the pod backup, pod_id: %s.', original_pod_id)

        update_method = partial(utils.update_resource_verify_result,
                                kwargs.get('verify'), resource.type,
                                original_pod_id)

        backup_status = bank_section.get_object("status")

        if backup_status == constants.RESOURCE_STATUS_AVAILABLE:
            update_method(constants.RESOURCE_STATUS_AVAILABLE)
        else:
            reason = ('The status of pod backup status is %s.' % backup_status)
            update_method(backup_status, reason)
            raise exception.VerifyResourceFailed(name="Pod backup",
                                                 reason=reason,
                                                 resource_id=original_pod_id,
                                                 resource_type=resource.type)
示例#3
0
    def on_main(self, checkpoint, resource, context, parameters, **kwargs):
        original_volume_id = resource.id
        bank_section = checkpoint.get_resource_bank_section(original_volume_id)
        cinder_client = ClientFactory.create_client('cinder', context)
        resource_metadata = bank_section.get_object('metadata')
        LOG.info('Verifying the volume snapshot, volume_id: %s',
                 original_volume_id)

        update_method = partial(utils.update_resource_verify_result,
                                kwargs.get('verify'), resource.type,
                                original_volume_id)

        snapshot_id = resource_metadata['snapshot_id']
        try:
            volume_snapshot = cinder_client.volume_snapshots.get(snapshot_id)
            snapshot_status = volume_snapshot.status
        except Exception as ex:
            LOG.error(
                'Getting volume snapshot (snapshot_id: %(snapshot_id)s):'
                '%(reason)s fails', {
                    'snapshot_id': snapshot_id,
                    'reason': ex
                })
            reason = 'Getting volume backup fails.'
            update_method(constants.RESOURCE_STATUS_ERROR, reason)
            raise

        if snapshot_status == 'available':
            update_method(constants.RESOURCE_STATUS_AVAILABLE)
        else:
            reason = ('The status of volume snapshot status is %s.' %
                      snapshot_status)
            update_method(snapshot_status, reason)
            raise exception.VerifyResourceFailed(
                name="Volume snapshot",
                reason=reason,
                resource_id=original_volume_id,
                resource_type=resource.type)
示例#4
0
    def on_main(self, checkpoint, resource, context, parameters, **kwargs):
        original_instance_id = resource.id
        bank_section = checkpoint.get_resource_bank_section(
            original_instance_id)
        trove_client = ClientFactory.create_client('trove', context)
        resource_metadata = bank_section.get_object('metadata')
        LOG.info('Verifying the database instance, instance_id: %s',
                 original_instance_id)

        update_method = partial(
            utils.update_resource_verify_result,
            kwargs.get('verify'), resource.type, original_instance_id)

        backup_id = resource_metadata['backup_id']
        try:
            instance_backup = trove_client.backups.get(backup_id)
            backup_status = instance_backup.status
        except Exception as ex:
            LOG.error('Getting database backup (backup_id: %(backup_id)s):'
                      '%(reason)s fails',
                      {'backup_id': backup_id, 'reason': ex})
            reason = 'Getting database backup fails.'
            update_method(constants.RESOURCE_STATUS_ERROR, reason)
            raise

        if backup_status == 'COMPLETED':
            update_method(constants.RESOURCE_STATUS_AVAILABLE)
        else:
            reason = ('The status of database backup status is %s.'
                      % backup_status)
            update_method(backup_status, reason)
            raise exception.VerifyResourceFailed(
                name="Database backup",
                reason=reason,
                resource_id=original_instance_id,
                resource_type=resource.type)