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