use of com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription in project photon-model by vmware.
the class TestAWSMissingEnumerationResourcesService method createPrimaryRootCompute.
public ComputeStateWithDescription createPrimaryRootCompute() {
ComputeStateWithDescription primaryRootCompute = new ComputeStateWithDescription();
primaryRootCompute.id = "456";
primaryRootCompute.name = "MOCK_ACC";
primaryRootCompute.type = ComputeType.ENDPOINT_HOST;
primaryRootCompute.documentSelfLink = "selfLink";
primaryRootCompute.description = new ComputeDescription();
Set<URI> statsAdapterReferences = new HashSet<>();
statsAdapterReferences.add(UriUtils.buildUri("stats-adapter-references"));
primaryRootCompute.description.statsAdapterReferences = statsAdapterReferences;
primaryRootCompute.creationTimeMicros = 1492610429910002L;
primaryRootCompute.endpointLink = UriUtils.buildUriPath(ComputeDescriptionService.FACTORY_LINK, generateUuidFromStr("endpointLink"));
primaryRootCompute.adapterManagementReference = UriUtils.buildUri("amazonaws.com");
primaryRootCompute.customProperties = new HashMap<>();
primaryRootCompute.customProperties.put(EndpointAllocationTaskService.CUSTOM_PROP_ENPOINT_TYPE, EndpointType.aws.name());
primaryRootCompute.resourcePoolLink = "resourcePoolLink";
return primaryRootCompute;
}
use of com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription in project photon-model by vmware.
the class SingleResourceStatsCollectionTaskService method getDescriptions.
private void getDescriptions(SingleResourceStatsCollectionTaskState currentState) {
URI computeDescUri = ComputeStateWithDescription.buildUri(UriUtils.extendUri(ClusterUtil.getClusterUri(getHost(), ServiceTypeCluster.INVENTORY_SERVICE), currentState.computeLink));
sendRequest(Operation.createGet(computeDescUri).setCompletion((getOp, getEx) -> {
if (getEx != null) {
TaskUtils.sendFailurePatch(this, currentState, getEx);
return;
}
ComputeStateWithDescription computeStateWithDesc = getOp.getBody(ComputeStateWithDescription.class);
ComputeStatsRequest statsRequest = new ComputeStatsRequest();
statsRequest.isMockRequest = currentState.options != null ? currentState.options.contains(TaskOption.IS_MOCK) : false;
URI patchUri = null;
Object patchBody = null;
ComputeDescription description = computeStateWithDesc.description;
URI statsAdapterReference = null;
List<String> tenantLinks = new ArrayList<>();
if (description != null) {
tenantLinks = description.tenantLinks;
// provided
if (currentState.statsAdapterReference == null) {
statsAdapterReference = description.statsAdapterReference;
} else if (description.statsAdapterReferences != null) {
for (URI uri : description.statsAdapterReferences) {
if (uri.getPath().equals(currentState.statsAdapterReference.getPath())) {
statsAdapterReference = currentState.statsAdapterReference;
break;
}
}
}
}
if (statsAdapterReference != null) {
statsRequest.nextStage = SingleResourceTaskCollectionStage.UPDATE_STATS.name();
statsRequest.resourceReference = UriUtils.extendUri(ClusterUtil.getClusterUri(getHost(), ServiceTypeCluster.INVENTORY_SERVICE), computeStateWithDesc.documentSelfLink);
statsRequest.taskReference = getUri();
patchUri = statsAdapterReference;
populateLastCollectionTimeForMetricsInStatsRequest(currentState, statsRequest, patchUri, tenantLinks);
} else {
// no adapter associated with this resource, just patch completion
SingleResourceStatsCollectionTaskState nextStageState = new SingleResourceStatsCollectionTaskState();
nextStageState.taskInfo = new TaskState();
nextStageState.taskInfo.stage = TaskStage.FINISHED;
patchUri = getUri();
patchBody = nextStageState;
sendStatsRequestToAdapter(currentState, patchUri, patchBody);
}
}));
}
use of com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription in project photon-model by vmware.
the class EndpointAllocationTaskService method configureDescriptionPatch.
private ComputeDescription configureDescriptionPatch(EndpointState state) {
ComputeDescription cd = new ComputeDescription();
cd.name = state.name;
if (cd.tenantLinks == null) {
cd.tenantLinks = new ArrayList<>();
}
cd.tenantLinks.addAll(state.tenantLinks);
return cd;
}
Aggregations