Search in sources :

Example 1 with CertificateInfoServiceErrorResponse

use of com.vmware.photon.controller.model.support.CertificateInfoServiceErrorResponse in project photon-model by vmware.

the class EndpointAllocationTaskService method validateCredentials.

private void validateCredentials(EndpointAllocationTaskState currentState, SubStage next) {
    EndpointConfigRequest req = new EndpointConfigRequest();
    req.requestType = RequestType.VALIDATE;
    req.endpointProperties = currentState.endpointState.endpointProperties;
    req.tenantLinks = currentState.tenantLinks;
    req.checkForEndpointUniqueness = currentState.checkForEndpointUniqueness;
    if (currentState.endpointState.documentSelfLink != null) {
        req.resourceReference = UriUtils.extendUri(ClusterUtil.getClusterUri(getHost(), ServiceTypeCluster.INVENTORY_SERVICE), currentState.endpointState.documentSelfLink);
    }
    req.isMockRequest = currentState.options.contains(TaskOption.IS_MOCK);
    Operation.createPatch(currentState.adapterReference).setBody(req).setCompletion((o, e) -> {
        if (e != null) {
            logWarning(() -> e.getMessage());
            sendFailurePatch(this, currentState, e);
            return;
        }
        EndpointAllocationTaskState st = createUpdateSubStageTask(next);
        if (o.hasBody() && currentState.taskSubStage == SubStage.VALIDATE_CREDENTIALS) {
            CertificateInfoServiceErrorResponse errorResponse = o.getBody(CertificateInfoServiceErrorResponse.class);
            if (CertificateInfoServiceErrorResponse.KIND.equals(errorResponse.documentKind)) {
                st.taskInfo.failure = errorResponse;
                st.taskInfo.stage = TaskStage.FAILED;
                if (errorResponse.certificateInfo != null) {
                    st.certificateInfo = errorResponse.certificateInfo;
                }
            }
        }
        sendSelfPatch(st);
    }).sendWith(this);
}
Also used : AuthCredentialsServiceState(com.vmware.xenon.services.common.AuthCredentialsService.AuthCredentialsServiceState) CertificateInfoServiceErrorResponse(com.vmware.photon.controller.model.support.CertificateInfoServiceErrorResponse) ServiceTypeCluster(com.vmware.photon.controller.model.util.ClusterUtil.ServiceTypeCluster) ServiceDocument(com.vmware.xenon.common.ServiceDocument) Utils(com.vmware.xenon.common.Utils) EndpointService(com.vmware.photon.controller.model.resources.EndpointService) Map(java.util.Map) CUSTOM_PROP_ENDPOINT_LINK(com.vmware.photon.controller.model.constants.PhotonModelConstants.CUSTOM_PROP_ENDPOINT_LINK) ResourcePoolService(com.vmware.photon.controller.model.resources.ResourcePoolService) URI(java.net.URI) SINGLE_ASSIGNMENT(com.vmware.xenon.common.ServiceDocumentDescription.PropertyUsageOption.SINGLE_ASSIGNMENT) EnumSet(java.util.EnumSet) EndpointState(com.vmware.photon.controller.model.resources.EndpointService.EndpointState) ComputeDescription(com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription) ENDPOINT_LINK_PROP_NAME(com.vmware.photon.controller.model.ComputeProperties.ENDPOINT_LINK_PROP_NAME) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) ServiceHost(com.vmware.xenon.common.ServiceHost) PhotonModelAdaptersConfigAccessService(com.vmware.photon.controller.model.adapters.registry.PhotonModelAdaptersConfigAccessService) OPTIONAL(com.vmware.xenon.common.ServiceDocumentDescription.PropertyUsageOption.OPTIONAL) List(java.util.List) RequestType(com.vmware.photon.controller.model.adapterapi.EndpointConfigRequest.RequestType) TaskUtils.sendFailurePatch(com.vmware.photon.controller.model.tasks.TaskUtils.sendFailurePatch) CompletionHandler(com.vmware.xenon.common.Operation.CompletionHandler) SOURCE_TASK_LINK(com.vmware.photon.controller.model.constants.PhotonModelConstants.SOURCE_TASK_LINK) DeferredResult(com.vmware.xenon.common.DeferredResult) UriUtils(com.vmware.xenon.common.UriUtils) ComputeService(com.vmware.photon.controller.model.resources.ComputeService) TaskState(com.vmware.xenon.common.TaskState) TaskService(com.vmware.xenon.services.common.TaskService) AdapterTypePath(com.vmware.photon.controller.model.UriPaths.AdapterTypePath) STORE_ONLY(com.vmware.xenon.common.ServiceDocumentDescription.PropertyIndexingOption.STORE_ONLY) ResourcePoolState(com.vmware.photon.controller.model.resources.ResourcePoolService.ResourcePoolState) HashMap(java.util.HashMap) ComputeDescriptionService(com.vmware.photon.controller.model.resources.ComputeDescriptionService) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) EndpointConfigRequest(com.vmware.photon.controller.model.adapterapi.EndpointConfigRequest) AuthCredentialsService(com.vmware.xenon.services.common.AuthCredentialsService) UriPaths(com.vmware.photon.controller.model.UriPaths) ComputeState(com.vmware.photon.controller.model.resources.ComputeService.ComputeState) OperationSequence(com.vmware.xenon.common.OperationSequence) SERVICE_USE(com.vmware.xenon.common.ServiceDocumentDescription.PropertyUsageOption.SERVICE_USE) ResourceEnumerationTaskState(com.vmware.photon.controller.model.tasks.ResourceEnumerationTaskService.ResourceEnumerationTaskState) Operation(com.vmware.xenon.common.Operation) CertificateInfo(com.vmware.photon.controller.model.support.CertificateInfo) ScheduledTaskState(com.vmware.photon.controller.model.tasks.ScheduledTaskService.ScheduledTaskState) TaskStage(com.vmware.xenon.common.TaskState.TaskStage) TimeUnit(java.util.concurrent.TimeUnit) PhotonModelAdapterConfig(com.vmware.photon.controller.model.adapters.registry.PhotonModelAdaptersRegistryService.PhotonModelAdapterConfig) ClusterUtil(com.vmware.photon.controller.model.util.ClusterUtil) LocalizableValidationException(com.vmware.xenon.common.LocalizableValidationException) PropertyIndexingOption(com.vmware.xenon.common.ServiceDocumentDescription.PropertyIndexingOption) OperationJoin(com.vmware.xenon.common.OperationJoin) PhotonModelUriUtils.createInventoryUri(com.vmware.photon.controller.model.util.PhotonModelUriUtils.createInventoryUri) EndpointConfigRequest(com.vmware.photon.controller.model.adapterapi.EndpointConfigRequest) CertificateInfoServiceErrorResponse(com.vmware.photon.controller.model.support.CertificateInfoServiceErrorResponse)

Aggregations

ENDPOINT_LINK_PROP_NAME (com.vmware.photon.controller.model.ComputeProperties.ENDPOINT_LINK_PROP_NAME)1 UriPaths (com.vmware.photon.controller.model.UriPaths)1 AdapterTypePath (com.vmware.photon.controller.model.UriPaths.AdapterTypePath)1 EndpointConfigRequest (com.vmware.photon.controller.model.adapterapi.EndpointConfigRequest)1 RequestType (com.vmware.photon.controller.model.adapterapi.EndpointConfigRequest.RequestType)1 PhotonModelAdaptersConfigAccessService (com.vmware.photon.controller.model.adapters.registry.PhotonModelAdaptersConfigAccessService)1 PhotonModelAdapterConfig (com.vmware.photon.controller.model.adapters.registry.PhotonModelAdaptersRegistryService.PhotonModelAdapterConfig)1 CUSTOM_PROP_ENDPOINT_LINK (com.vmware.photon.controller.model.constants.PhotonModelConstants.CUSTOM_PROP_ENDPOINT_LINK)1 SOURCE_TASK_LINK (com.vmware.photon.controller.model.constants.PhotonModelConstants.SOURCE_TASK_LINK)1 ComputeDescriptionService (com.vmware.photon.controller.model.resources.ComputeDescriptionService)1 ComputeDescription (com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription)1 ComputeService (com.vmware.photon.controller.model.resources.ComputeService)1 ComputeState (com.vmware.photon.controller.model.resources.ComputeService.ComputeState)1 EndpointService (com.vmware.photon.controller.model.resources.EndpointService)1 EndpointState (com.vmware.photon.controller.model.resources.EndpointService.EndpointState)1 ResourcePoolService (com.vmware.photon.controller.model.resources.ResourcePoolService)1 ResourcePoolState (com.vmware.photon.controller.model.resources.ResourcePoolService.ResourcePoolState)1 CertificateInfo (com.vmware.photon.controller.model.support.CertificateInfo)1 CertificateInfoServiceErrorResponse (com.vmware.photon.controller.model.support.CertificateInfoServiceErrorResponse)1 ResourceEnumerationTaskState (com.vmware.photon.controller.model.tasks.ResourceEnumerationTaskService.ResourceEnumerationTaskState)1