Example #1
0
    def restore(self, context, restore, restore_auth):
        LOG.info("Starting restore service:restore action")

        checkpoint_id = restore["checkpoint_id"]
        provider_id = restore["provider_id"]
        provider = self.provider_registry.show_provider(provider_id)
        if not provider:
            raise exception.ProviderNotFound(provider_id=provider_id)

        checkpoint_collection = provider.get_checkpoint_collection()
        checkpoint = checkpoint_collection.get(checkpoint_id)

        if checkpoint.status != constants.CHECKPOINT_STATUS_AVAILABLE:
            raise exception.CheckpointNotAvailable(checkpoint_id=checkpoint_id)

        try:
            flow = self.worker.get_flow(
                context=context,
                operation_type=constants.OPERATION_RESTORE,
                checkpoint=checkpoint,
                provider=provider,
                restore=restore,
                restore_auth=restore_auth)
        except Exception:
            LOG.exception("Failed to create restore flow checkpoint: %s",
                          checkpoint_id)
            raise exception.FlowError(flow="restore",
                                      error=_("Failed to create flow"))
        self._spawn(self.worker.run_flow, flow)
Example #2
0
    def verification(self, context, verification):
        LOG.info("Starting verify service:verify action")

        checkpoint_id = verification["checkpoint_id"]
        provider_id = verification["provider_id"]
        provider = self.provider_registry.show_provider(provider_id)
        if not provider:
            raise exception.ProviderNotFound(provider_id=provider_id)

        self.validate_verify_parameters(verification, provider)

        checkpoint_collection = provider.get_checkpoint_collection()
        checkpoint = checkpoint_collection.get(checkpoint_id)

        if checkpoint.status != constants.CHECKPOINT_STATUS_AVAILABLE:
            raise exception.CheckpointNotAvailable(checkpoint_id=checkpoint_id)

        try:
            flow = self.worker.get_flow(
                context=context,
                operation_type=constants.OPERATION_VERIFY,
                checkpoint=checkpoint,
                provider=provider,
                verify=verification)
        except Exception:
            LOG.exception("Failed to create verify flow checkpoint: %s",
                          checkpoint_id)
            raise exception.FlowError(flow="verify",
                                      error=_("Failed to create flow"))
        self._spawn(self.worker.run_flow, flow)
Example #3
0
    def restore(self, context, restore, restore_auth):
        LOG.info(_LI("Starting restore service:restore action"))

        checkpoint_id = restore["checkpoint_id"]
        provider_id = restore["provider_id"]
        provider = self.provider_registry.show_provider(provider_id)
        try:
            checkpoint_collection = provider.get_checkpoint_collection()
            checkpoint = checkpoint_collection.get(checkpoint_id)
        except Exception:
            LOG.error(_LE("Invalid checkpoint id: %s"), checkpoint_id)
            raise exception.InvalidInput(reason=_("Invalid checkpoint id"))

        if checkpoint.status != constants.CHECKPOINT_STATUS_AVAILABLE:
            raise exception.CheckpointNotAvailable(checkpoint_id=checkpoint_id)

        try:
            restoration_flow = self.worker.get_restoration_flow(
                context, constants.OPERATION_RESTORE, checkpoint, provider,
                restore, restore_auth)
        except Exception:
            LOG.exception(
                _LE("Failed to create restoration flow checkpoint: %s"),
                checkpoint_id)
            raise exception.FlowError(flow="restore",
                                      error=_("Failed to create flow"))
        try:
            self.worker.run_flow(restoration_flow)
        except Exception:
            LOG.exception(_LE("Failed to run restoration flow checkpoint: %s"),
                          checkpoint_id)
            raise exception.FlowError(flow="restore",
                                      error=_("Failed to run flow"))