Search in sources :

Example 1 with RequestType

use of com.vmware.photon.controller.model.adapterapi.EndpointConfigRequest.RequestType in project photon-model by vmware.

the class EndpointAllocationTaskService method invokeAdapterForUniquenessCheck.

/**
 * RequestType = CHECK_IF_ACCOUNT_EXISTS
 * Invokes the cloud provider specific adapter with the passed in credentials to verify
 * if the cloud provider account has already been configured aprior. If it a compute host
 * has already been created corresponding to the given cloud account then it is updated
 * to reflect the endpointLink for the currently being configured endpoint.
 */
private void invokeAdapterForUniquenessCheck(EndpointAllocationTaskState currentState, SubStage nextStage) {
    EndpointConfigRequest req = new EndpointConfigRequest();
    req.isMockRequest = currentState.options.contains(TaskOption.IS_MOCK);
    req.requestType = RequestType.CHECK_IF_ACCOUNT_EXISTS;
    req.tenantLinks = currentState.tenantLinks;
    req.resourceReference = UriUtils.buildUri(getHost(), currentState.endpointState.documentSelfLink);
    req.taskReference = UriUtils.buildUri(this.getHost(), getSelfLink());
    req.endpointProperties = currentState.endpointState.endpointProperties;
    sendRequest(Operation.createPatch(currentState.adapterReference).setBody(req).setCompletion((o, e) -> {
        if (e != null) {
            logWarning("PATCH to endpoint config adapter service %s, failed: %s", o.getUri(), e.toString());
            sendFailurePatch(this, currentState, e);
            return;
        }
        EndpointConfigRequest returnedRequest = o.getBody(EndpointConfigRequest.class);
        EndpointAllocationTaskState state = createUpdateSubStageTask(nextStage);
        state.accountAlreadyExists = returnedRequest.accountAlreadyExists;
        state.existingComputeState = returnedRequest.existingComputeState;
        state.existingComputeDescription = returnedRequest.existingComputeDescription;
        sendSelfPatch(state);
    }));
}
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)

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