Search in sources :

Example 41 with ComputeDescription

use of com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription in project photon-model by vmware.

the class BaseVSphereAdapterTest method createComputeDescription.

protected ComputeDescription createComputeDescription() throws Throwable {
    ComputeDescription computeDesc = new ComputeDescription();
    computeDesc.id = UUID.randomUUID().toString();
    computeDesc.name = computeDesc.id;
    computeDesc.documentSelfLink = computeDesc.id;
    computeDesc.supportedChildren = new ArrayList<>();
    computeDesc.supportedChildren.add(ComputeType.VM_GUEST.name());
    configureAdapters(computeDesc);
    computeDesc.authCredentialsLink = this.auth.documentSelfLink;
    computeDesc.regionId = this.datacenterId;
    return TestUtils.doPost(this.host, computeDesc, ComputeDescription.class, UriUtils.buildUri(this.host, ComputeDescriptionService.FACTORY_LINK));
}
Also used : ComputeDescription(com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription)

Example 42 with ComputeDescription

use of com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription in project photon-model by vmware.

the class VSphereHostSystemEnumerationHelper method updateHostSystem.

private static void updateHostSystem(VSphereIncrementalEnumerationService service, ComputeState oldDocument, EnumerationProgress enumerationProgress, HostSystemOverlay hs, boolean fullUpdate, EnumerationClient client) throws InvalidPropertyFaultMsg, RuntimeFaultFaultMsg {
    ComputeState state;
    if (fullUpdate) {
        state = makeHostSystemFromResults(enumerationProgress, hs, client);
    } else {
        state = makeHostSystemFromChanges(enumerationProgress, hs, client);
    }
    state.documentSelfLink = oldDocument.documentSelfLink;
    state.resourcePoolLink = null;
    if (oldDocument.tenantLinks == null) {
        state.tenantLinks = enumerationProgress.getTenantLinks();
    }
    service.logFine(() -> String.format("Syncing HostSystem %s", oldDocument.documentSelfLink));
    Operation.createPatch(PhotonModelUriUtils.createInventoryUri(service.getHost(), state.documentSelfLink)).setBody(state).setCompletion((o, e) -> {
        trackHostSystem(enumerationProgress, hs).handle(o, e);
        if (e == null) {
            VsphereEnumerationHelper.submitWorkToVSpherePool(service, () -> VsphereEnumerationHelper.updateLocalTags(service, enumerationProgress, hs, o.getBody(ResourceState.class)));
        }
    }).sendWith(service);
    ComputeDescription desc;
    if (fullUpdate) {
        desc = makeDescriptionForHost(service, enumerationProgress, hs);
    } else {
        desc = makeDescriptionForHostFromChange(hs);
    }
    desc.documentSelfLink = oldDocument.descriptionLink;
    Operation.createPatch(PhotonModelUriUtils.createInventoryUri(service.getHost(), desc.documentSelfLink)).setBody(desc).sendWith(service);
}
Also used : AdapterUtils(com.vmware.photon.controller.model.adapters.util.AdapterUtils) PowerState(com.vmware.photon.controller.model.resources.ComputeService.PowerState) ResourceState(com.vmware.photon.controller.model.resources.ResourceState) ComputeEnumerateResourceRequest(com.vmware.photon.controller.model.adapterapi.ComputeEnumerateResourceRequest) ComputeDescription(com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription) PhotonModelUriUtils(com.vmware.photon.controller.model.util.PhotonModelUriUtils) Operation(com.vmware.xenon.common.Operation) QueryTask(com.vmware.xenon.services.common.QueryTask) QueryUtils(com.vmware.photon.controller.model.query.QueryUtils) ObjectUpdateKind(com.vmware.vim25.ObjectUpdateKind) ComputeDescriptionService(com.vmware.photon.controller.model.resources.ComputeDescriptionService) RuntimeFaultFaultMsg(com.vmware.vim25.RuntimeFaultFaultMsg) ComputeType(com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription.ComputeType) List(java.util.List) UriUtils.buildUriPath(com.vmware.xenon.common.UriUtils.buildUriPath) InvalidPropertyFaultMsg(com.vmware.vim25.InvalidPropertyFaultMsg) ComputeState(com.vmware.photon.controller.model.resources.ComputeService.ComputeState) VsphereEnumerationHelper.convertOnlyResultToDocument(com.vmware.photon.controller.model.adapters.vsphere.VsphereEnumerationHelper.convertOnlyResultToDocument) CompletionHandler(com.vmware.xenon.common.Operation.CompletionHandler) ComputeService(com.vmware.photon.controller.model.resources.ComputeService) QueryOption(com.vmware.xenon.services.common.QueryTask.QuerySpecification.QueryOption) VsphereEnumerationHelper.withTaskResults(com.vmware.photon.controller.model.adapters.vsphere.VsphereEnumerationHelper.withTaskResults) Builder(com.vmware.xenon.services.common.QueryTask.Query.Builder) Collections(java.util.Collections) ComputeState(com.vmware.photon.controller.model.resources.ComputeService.ComputeState) ComputeDescription(com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription) ResourceState(com.vmware.photon.controller.model.resources.ResourceState)

Example 43 with ComputeDescription

use of com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription in project photon-model by vmware.

the class VSphereHostSystemEnumerationHelper method makeDescriptionForHost.

private static ComputeDescription makeDescriptionForHost(VSphereIncrementalEnumerationService service, EnumerationProgress enumerationProgress, HostSystemOverlay hs) {
    ComputeDescription res = new ComputeDescription();
    res.name = hs.getName();
    res.documentSelfLink = buildUriPath(ComputeDescriptionService.FACTORY_LINK, service.getHost().nextUUID());
    res.cpuCount = hs.getCoreCount();
    res.endpointLink = enumerationProgress.getRequest().endpointLink;
    AdapterUtils.addToEndpointLinks(res, enumerationProgress.getRequest().endpointLink);
    res.cpuMhzPerCore = hs.getCpuMhz();
    res.totalMemoryBytes = hs.getTotalMemoryBytes();
    res.supportedChildren = Collections.singletonList(ComputeType.VM_GUEST.name());
    res.instanceAdapterReference = enumerationProgress.getParent().description.instanceAdapterReference;
    res.enumerationAdapterReference = enumerationProgress.getParent().description.enumerationAdapterReference;
    res.statsAdapterReference = enumerationProgress.getParent().description.statsAdapterReference;
    res.diskAdapterReference = enumerationProgress.getParent().description.diskAdapterReference;
    res.regionId = enumerationProgress.getRegionId();
    VsphereEnumerationHelper.populateResourceStateWithAdditionalProps(res, enumerationProgress.getVcUuid(), hs.getId());
    return res;
}
Also used : ComputeDescription(com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription)

Example 44 with ComputeDescription

use of com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription in project photon-model by vmware.

the class VSphereHostSystemEnumerationHelper method createNewHostSystem.

private static void createNewHostSystem(VSphereIncrementalEnumerationService service, EnumerationProgress enumerationProgress, HostSystemOverlay hs, EnumerationClient client) throws InvalidPropertyFaultMsg, RuntimeFaultFaultMsg {
    ComputeDescription desc = makeDescriptionForHost(service, enumerationProgress, hs);
    desc.tenantLinks = enumerationProgress.getTenantLinks();
    Operation.createPost(PhotonModelUriUtils.createInventoryUri(service.getHost(), ComputeDescriptionService.FACTORY_LINK)).setBody(desc).sendWith(service);
    ComputeState state = makeHostSystemFromResults(enumerationProgress, hs, client);
    state.descriptionLink = desc.documentSelfLink;
    state.tenantLinks = enumerationProgress.getTenantLinks();
    VsphereEnumerationHelper.submitWorkToVSpherePool(service, () -> {
        VsphereEnumerationHelper.populateTags(service, enumerationProgress, hs, state);
        service.logFine(() -> String.format("Found new HostSystem %s", hs.getName()));
        Operation.createPost(PhotonModelUriUtils.createInventoryUri(service.getHost(), ComputeService.FACTORY_LINK)).setBody(state).setCompletion(trackHostSystem(enumerationProgress, hs)).sendWith(service);
    });
}
Also used : ComputeState(com.vmware.photon.controller.model.resources.ComputeService.ComputeState) ComputeDescription(com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription)

Example 45 with ComputeDescription

use of com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription in project photon-model by vmware.

the class AWSLoadBalancerServiceTest method createComputeState.

private ComputeState createComputeState(String id) throws Throwable {
    ComputeDescription computeDescription = new ComputeDescription();
    computeDescription.id = id;
    computeDescription = postServiceSynchronously(ComputeDescriptionService.FACTORY_LINK, computeDescription, ComputeDescription.class);
    ComputeState computeState = new ComputeState();
    computeState.descriptionLink = computeDescription.documentSelfLink;
    computeState.id = id;
    return postServiceSynchronously(ComputeService.FACTORY_LINK, computeState, ComputeState.class);
}
Also used : ComputeState(com.vmware.photon.controller.model.resources.ComputeService.ComputeState) 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