Search in sources :

Example 66 with ComputeDescription

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

the class VsphereComputeResourceEnumerationHelper method makeDescriptionForCluster.

private static ComputeDescription makeDescriptionForCluster(VSphereIncrementalEnumerationService service, EnumerationProgress enumerationProgress, ComputeResourceOverlay cr) {
    ComputeDescription res = new ComputeDescription();
    res.name = cr.getName();
    res.documentSelfLink = buildUriPath(ComputeDescriptionService.FACTORY_LINK, service.getHost().nextUUID());
    res.cpuCount = cr.getTotalCpuCores();
    if (cr.getTotalCpuCores() != 0) {
        res.cpuMhzPerCore = cr.getTotalCpuMhz() / cr.getTotalCpuCores();
    }
    res.totalMemoryBytes = cr.getTotalMemoryBytes();
    res.supportedChildren = Collections.singletonList(ComputeType.VM_GUEST.name());
    res.endpointLink = enumerationProgress.getRequest().endpointLink;
    AdapterUtils.addToEndpointLinks(res, enumerationProgress.getRequest().endpointLink);
    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();
    return res;
}
Also used : ComputeDescription(com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription)

Example 67 with ComputeDescription

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

the class VsphereComputeResourceEnumerationHelper method updateCluster.

private static void updateCluster(VSphereIncrementalEnumerationService service, ComputeState oldDocument, EnumerationProgress enumerationProgress, ComputeResourceOverlay cr, EnumerationClient client, boolean fullUpdate) throws InvalidPropertyFaultMsg, RuntimeFaultFaultMsg {
    ComputeState state;
    if (fullUpdate) {
        state = makeComputeResourceFromResults(enumerationProgress, cr, client);
    } else {
        state = makeComputeResourceFromChanges(enumerationProgress, cr, client);
    }
    state.documentSelfLink = oldDocument.documentSelfLink;
    state.resourcePoolLink = null;
    if (oldDocument.tenantLinks == null) {
        state.tenantLinks = enumerationProgress.getTenantLinks();
    }
    service.logInfo(() -> String.format("Syncing ComputeResource %s", oldDocument.documentSelfLink));
    Operation.createPatch(PhotonModelUriUtils.createInventoryUri(service.getHost(), oldDocument.documentSelfLink)).setBody(state).setCompletion((o, e) -> {
        trackComputeResource(enumerationProgress, cr).handle(o, e);
        if (e == null) {
            submitWorkToVSpherePool(service, () -> {
                service.logInfo("Syncing tags for cluster %s", oldDocument.documentSelfLink);
                updateLocalTags(service, enumerationProgress, cr, o.getBody(ResourceState.class));
            });
        }
    }).sendWith(service);
    ComputeDescription desc;
    if (fullUpdate) {
        desc = makeDescriptionForCluster(service, enumerationProgress, cr);
    } else {
        desc = makeDescriptionFromChanges(enumerationProgress, cr);
    }
    desc.documentSelfLink = oldDocument.descriptionLink;
    Operation.createPatch(PhotonModelUriUtils.createInventoryUri(service.getHost(), desc.documentSelfLink)).setBody(desc).sendWith(service);
}
Also used : PowerState(com.vmware.photon.controller.model.resources.ComputeService.PowerState) ComputeProperties(com.vmware.photon.controller.model.ComputeProperties) ComputeEnumerateResourceRequest(com.vmware.photon.controller.model.adapterapi.ComputeEnumerateResourceRequest) PhotonModelUriUtils(com.vmware.photon.controller.model.util.PhotonModelUriUtils) QueryTask(com.vmware.xenon.services.common.QueryTask) ObjectUpdateKind(com.vmware.vim25.ObjectUpdateKind) ComputeDescriptionService(com.vmware.photon.controller.model.resources.ComputeDescriptionService) RuntimeFaultFaultMsg(com.vmware.vim25.RuntimeFaultFaultMsg) ArrayList(java.util.ArrayList) ComputeType(com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription.ComputeType) Utils(com.vmware.xenon.common.Utils) ComputeState(com.vmware.photon.controller.model.resources.ComputeService.ComputeState) VsphereEnumerationHelper.convertOnlyResultToDocument(com.vmware.photon.controller.model.adapters.vsphere.VsphereEnumerationHelper.convertOnlyResultToDocument) TYPE_SERVER_DISK(com.vmware.photon.controller.model.adapters.vsphere.util.VimNames.TYPE_SERVER_DISK) AdapterUtils(com.vmware.photon.controller.model.adapters.util.AdapterUtils) ResourceState(com.vmware.photon.controller.model.resources.ResourceState) ComputeDescription(com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription) VsanHostConfigInfo(com.vmware.vim25.VsanHostConfigInfo) Operation(com.vmware.xenon.common.Operation) QueryUtils(com.vmware.photon.controller.model.query.QueryUtils) VsphereEnumerationHelper.getConnectedDatastoresAndNetworks(com.vmware.photon.controller.model.adapters.vsphere.VsphereEnumerationHelper.getConnectedDatastoresAndNetworks) ManagedObjectReference(com.vmware.vim25.ManagedObjectReference) VsphereEnumerationHelper.updateLocalTags(com.vmware.photon.controller.model.adapters.vsphere.VsphereEnumerationHelper.updateLocalTags) List(java.util.List) VsphereEnumerationHelper.submitWorkToVSpherePool(com.vmware.photon.controller.model.adapters.vsphere.VsphereEnumerationHelper.submitWorkToVSpherePool) UriUtils.buildUriPath(com.vmware.xenon.common.UriUtils.buildUriPath) HostScsiDisk(com.vmware.vim25.HostScsiDisk) InvalidPropertyFaultMsg(com.vmware.vim25.InvalidPropertyFaultMsg) CompletionHandler(com.vmware.xenon.common.Operation.CompletionHandler) ComputeService(com.vmware.photon.controller.model.resources.ComputeService) VsphereEnumerationHelper.withTaskResults(com.vmware.photon.controller.model.adapters.vsphere.VsphereEnumerationHelper.withTaskResults) Builder(com.vmware.xenon.services.common.QueryTask.Query.Builder) DiskService(com.vmware.photon.controller.model.resources.DiskService) Collections(java.util.Collections) ComputeState(com.vmware.photon.controller.model.resources.ComputeService.ComputeState) ComputeDescription(com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription)

Example 68 with ComputeDescription

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

the class VsphereComputeResourceEnumerationHelper method makeDescriptionFromChanges.

private static ComputeDescription makeDescriptionFromChanges(EnumerationProgress enumerationProgress, ComputeResourceOverlay cr) {
    ComputeDescription res = new ComputeDescription();
    res.name = cr.getNameOrNull();
    res.cpuCount = cr.getTotalCpuCoresOrZero();
    if (cr.getTotalCpuCoresOrZero() != 0 && cr.getTotalCpuMhzOrZero() != 0) {
        res.cpuMhzPerCore = cr.getTotalCpuMhzOrZero() / cr.getTotalCpuCoresOrZero();
    }
    return res;
}
Also used : ComputeDescription(com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription)

Example 69 with ComputeDescription

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

the class VSphereHostSystemEnumerationHelper method makeDescriptionForHostFromChange.

private static ComputeDescription makeDescriptionForHostFromChange(HostSystemOverlay hs) {
    ComputeDescription res = new ComputeDescription();
    res.name = hs.getNameOrNull();
    return res;
}
Also used : ComputeDescription(com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription)

Example 70 with ComputeDescription

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

the class VSphereResourcePoolEnumerationHelper method createNewResourcePool.

private static void createNewResourcePool(VSphereIncrementalEnumerationService service, EnumerationProgress enumerationProgress, String ownerName, String selfLink, ResourcePoolOverlay rp, EnumerationClient client) throws InvalidPropertyFaultMsg, RuntimeFaultFaultMsg {
    ComputeState state = makeResourcePoolFromResults(enumerationProgress, rp, selfLink, client);
    state.name = rp.makeUserFriendlyName(ownerName);
    state.tenantLinks = enumerationProgress.getTenantLinks();
    ComputeDescription desc = makeDescriptionForResourcePool(enumerationProgress, rp, selfLink);
    desc.tenantLinks = enumerationProgress.getTenantLinks();
    state.descriptionLink = desc.documentSelfLink;
    service.logFine(() -> String.format("Found new ResourcePool %s", state.name));
    Operation.createPost(PhotonModelUriUtils.createInventoryUri(service.getHost(), ComputeService.FACTORY_LINK)).setBody(state).setCompletion(trackResourcePool(enumerationProgress, rp)).sendWith(service);
    Operation.createPost(PhotonModelUriUtils.createInventoryUri(service.getHost(), ComputeDescriptionService.FACTORY_LINK)).setBody(desc).sendWith(service);
}
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