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