コード例 #1
0
ファイル: manager.py プロジェクト: QuantumEnergyE/karbor
    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)
コード例 #2
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)
コード例 #3
0
    def _provider_get(self, context, provider_id):
        if not uuidutils.is_uuid_like(provider_id):
            msg = _("Invalid provider id provided.")
            raise exc.HTTPBadRequest(explanation=msg)

        try:
            context.can(provider_policy.GET_POLICY)
        except exception.PolicyNotAuthorized:
            # raise ProviderNotFound instead to make sure karbor behaves
            # as it used to
            raise exception.ProviderNotFound(provider_id=provider_id)

        provider = self.protection_api.show_provider(context, provider_id)

        LOG.info("Provider info retrieved successfully.")
        return provider
コード例 #4
0
 def show_provider(self, provider_id):
     try:
         return self.providers[provider_id]
     except KeyError:
         raise exception.ProviderNotFound(provider_id=provider_id)