Search in sources :

Example 76 with ComputeDescription

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;
}
Also used : ComputeStateWithDescription(com.vmware.photon.controller.model.resources.ComputeService.ComputeStateWithDescription) ComputeDescription(com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription) URI(java.net.URI) HashSet(java.util.HashSet)

Example 77 with ComputeDescription

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);
        }
    }));
}
Also used : Service(com.vmware.xenon.common.Service) ServiceTypeCluster(com.vmware.photon.controller.model.util.ClusterUtil.ServiceTypeCluster) QueryTask(com.vmware.xenon.services.common.QueryTask) ServiceDocument(com.vmware.xenon.common.ServiceDocument) AggregationType(com.vmware.xenon.common.ServiceStats.TimeSeriesStats.AggregationType) MatchType(com.vmware.xenon.services.common.QueryTask.QueryTerm.MatchType) SingleResourceStatsCollectionTaskState(com.vmware.photon.controller.model.tasks.monitoring.SingleResourceStatsCollectionTaskService.SingleResourceStatsCollectionTaskState) Utils(com.vmware.xenon.common.Utils) TaskFactoryService(com.vmware.xenon.services.common.TaskFactoryService) Map(java.util.Map) URI(java.net.URI) EnumSet(java.util.EnumSet) ComputeDescription(com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription) ComputeStatsRequest(com.vmware.photon.controller.model.adapterapi.ComputeStatsRequest) ServiceStats(com.vmware.xenon.common.ServiceStats) List(java.util.List) TimeSeriesStats(com.vmware.xenon.common.ServiceStats.TimeSeriesStats) UriUtils(com.vmware.xenon.common.UriUtils) Entry(java.util.Map.Entry) QueryOption(com.vmware.xenon.services.common.QueryTask.QuerySpecification.QueryOption) TaskState(com.vmware.xenon.common.TaskState) TaskOption(com.vmware.photon.controller.model.tasks.TaskOption) FactoryService(com.vmware.xenon.common.FactoryService) NumericRange(com.vmware.xenon.services.common.QueryTask.NumericRange) TaskService(com.vmware.xenon.services.common.TaskService) ResourceMetrics(com.vmware.photon.controller.model.monitoring.ResourceMetricsService.ResourceMetrics) TaskUtils(com.vmware.photon.controller.model.tasks.TaskUtils) InMemoryResourceMetric(com.vmware.photon.controller.model.monitoring.InMemoryResourceMetricService.InMemoryResourceMetric) HashMap(java.util.HashMap) PhotonModelUtils(com.vmware.photon.controller.model.resources.util.PhotonModelUtils) ResourceMetricsService(com.vmware.photon.controller.model.monitoring.ResourceMetricsService) ArrayList(java.util.ArrayList) ServiceUriPaths(com.vmware.xenon.services.common.ServiceUriPaths) Query(com.vmware.xenon.services.common.QueryTask.Query) UriPaths(com.vmware.photon.controller.model.UriPaths) PropertyUsageOption(com.vmware.xenon.common.ServiceDocumentDescription.PropertyUsageOption) ComputeStats(com.vmware.photon.controller.model.adapterapi.ComputeStatsResponse.ComputeStats) OperationSequence(com.vmware.xenon.common.OperationSequence) Operation(com.vmware.xenon.common.Operation) QueryUtils(com.vmware.photon.controller.model.query.QueryUtils) TypeName(com.vmware.xenon.common.ServiceDocumentDescription.TypeName) ServiceStat(com.vmware.xenon.common.ServiceStats.ServiceStat) TaskStage(com.vmware.xenon.common.TaskState.TaskStage) TimeUnit(java.util.concurrent.TimeUnit) InMemoryResourceMetricService(com.vmware.photon.controller.model.monitoring.InMemoryResourceMetricService) ClusterUtil(com.vmware.photon.controller.model.util.ClusterUtil) ComputeStateWithDescription(com.vmware.photon.controller.model.resources.ComputeService.ComputeStateWithDescription) PhotonModelConstants(com.vmware.photon.controller.model.constants.PhotonModelConstants) Comparator(java.util.Comparator) QuerySpecification(com.vmware.xenon.services.common.QueryTask.QuerySpecification) ComputeStatsRequest(com.vmware.photon.controller.model.adapterapi.ComputeStatsRequest) ComputeStateWithDescription(com.vmware.photon.controller.model.resources.ComputeService.ComputeStateWithDescription) ComputeDescription(com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription) SingleResourceStatsCollectionTaskState(com.vmware.photon.controller.model.tasks.monitoring.SingleResourceStatsCollectionTaskService.SingleResourceStatsCollectionTaskState) List(java.util.List) ArrayList(java.util.ArrayList) URI(java.net.URI) SingleResourceStatsCollectionTaskState(com.vmware.photon.controller.model.tasks.monitoring.SingleResourceStatsCollectionTaskService.SingleResourceStatsCollectionTaskState) TaskState(com.vmware.xenon.common.TaskState)

Example 78 with ComputeDescription

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;
}
Also used : ComputeDescription(com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription)

Aggregations

ComputeDescription (com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription)78 ComputeState (com.vmware.photon.controller.model.resources.ComputeService.ComputeState)39 Operation (com.vmware.xenon.common.Operation)21 ArrayList (java.util.ArrayList)21 QueryTask (com.vmware.xenon.services.common.QueryTask)17 Test (org.junit.Test)17 ComputeDescriptionService (com.vmware.photon.controller.model.resources.ComputeDescriptionService)15 ComputeService (com.vmware.photon.controller.model.resources.ComputeService)15 HashMap (java.util.HashMap)15 HashSet (java.util.HashSet)15 List (java.util.List)15 Utils (com.vmware.xenon.common.Utils)14 AuthCredentialsServiceState (com.vmware.xenon.services.common.AuthCredentialsService.AuthCredentialsServiceState)14 URI (java.net.URI)14 QueryUtils (com.vmware.photon.controller.model.query.QueryUtils)13 ResourcePoolState (com.vmware.photon.controller.model.resources.ResourcePoolService.ResourcePoolState)12 ServiceDocumentQueryResult (com.vmware.xenon.common.ServiceDocumentQueryResult)12 UriUtils (com.vmware.xenon.common.UriUtils)12 ComputeType (com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription.ComputeType)11 EndpointState (com.vmware.photon.controller.model.resources.EndpointService.EndpointState)11