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);
}));
}
Aggregations