use of com.vmware.photon.controller.model.resources.ComputeService.ComputeState in project photon-model by vmware.
the class TestVSphereProvisionWithCloudConfigTask method deployFromTemplateUsingCloudConfig.
@Test
public void deployFromTemplateUsingCloudConfig() throws Throwable {
ComputeState vm = null;
try {
// Create a resource pool where the VM will be housed
this.resourcePool = createResourcePool();
this.auth = createAuth();
this.computeHostDescription = createComputeHostDescription();
this.computeHost = createComputeHost();
// enumerate all resources hoping to find the template
doRefresh();
// find the template by vm name
// template must have vm-tools and cloud-config installed
ComputeState template = findTemplate();
// create instance by cloning
ComputeDescription vmDescription = createVmDescription();
vm = createVmState(vmDescription, template.documentSelfLink);
// kick off a provision task to do the actual VM creation
ProvisionComputeTaskState outTask = createProvisionTask(vm);
awaitTaskEnd(outTask);
vm = getComputeState(vm);
} finally {
if (vm != null) {
deleteVmAndWait(vm);
}
}
}
use of com.vmware.photon.controller.model.resources.ComputeService.ComputeState in project photon-model by vmware.
the class TestVSphereProvisionWithMissingDatacenter method createPlacementHost.
private ComputeState createPlacementHost() throws Throwable {
ComputeState computeState = new ComputeState();
computeState.id = "place here";
computeState.documentSelfLink = computeState.id;
computeState.descriptionLink = this.computeHostDescription.documentSelfLink;
computeState.resourcePoolLink = this.resourcePool.documentSelfLink;
computeState.adapterManagementReference = getAdapterManagementReference();
computeState.name = "placement host";
computeState.powerState = PowerState.ON;
computeState.parentLink = this.computeHost.documentSelfLink;
CustomProperties.of(computeState).put(ComputeProperties.RESOURCE_GROUP_NAME, this.vcFolder).put(CustomProperties.MOREF, VimNames.TYPE_CLUSTER_COMPUTE_RESOURCE + ":c123");
CustomProperties.of(computeState).put(ComputeProperties.RESOURCE_GROUP_NAME, this.vcFolder);
ComputeState returnState = TestUtils.doPost(this.host, computeState, ComputeState.class, UriUtils.buildUri(this.host, ComputeService.FACTORY_LINK));
return returnState;
}
use of com.vmware.photon.controller.model.resources.ComputeService.ComputeState in project photon-model by vmware.
the class TestVSphereProvisionWithStaticIpTask method createComputeHost.
/**
* Create a compute host representing a vcenter server
*/
private ComputeState createComputeHost() throws Throwable {
ComputeState computeState = new ComputeState();
computeState.id = UUID.randomUUID().toString();
computeState.name = this.computeHostDescription.name;
computeState.documentSelfLink = computeState.id;
computeState.descriptionLink = this.computeHostDescription.documentSelfLink;
computeState.resourcePoolLink = this.resourcePool.documentSelfLink;
computeState.adapterManagementReference = getAdapterManagementReference();
ComputeState returnState = TestUtils.doPost(this.host, computeState, ComputeState.class, UriUtils.buildUri(this.host, ComputeService.FACTORY_LINK));
return returnState;
}
use of com.vmware.photon.controller.model.resources.ComputeService.ComputeState in project photon-model by vmware.
the class TestVSphereProvisionWithStaticIpTask method findTemplate.
private ComputeState findTemplate() throws InterruptedException, ExecutionException, TimeoutException {
String templateVmName = System.getProperty("vc.templateVmName");
QuerySpecification qs = new QuerySpecification();
qs.options.add(QueryOption.EXPAND_CONTENT);
qs.query.addBooleanClause(Query.Builder.create().addFieldClause(ComputeState.FIELD_NAME_NAME, templateVmName).addFieldClause(ServiceDocument.FIELD_NAME_KIND, Utils.buildKind(ComputeState.class)).build());
QueryTask qt = QueryTask.create(qs).setDirect(true);
Operation op = QueryUtils.createQueryTaskOperation(this.host, qt, ServiceTypeCluster.INVENTORY_SERVICE);
QueryTask result = this.host.sendWithFuture(op).thenApply(o -> o.getBody(QueryTask.class)).get(10, TimeUnit.SECONDS);
return Utils.fromJson(result.results.documents.values().iterator().next(), ComputeState.class);
}
use of com.vmware.photon.controller.model.resources.ComputeService.ComputeState in project photon-model by vmware.
the class TestVSphereStatsTask method createComputeHost.
/**
* Create a compute host representing a vcenter server
*/
private ComputeState createComputeHost() throws Throwable {
ComputeState computeState = new ComputeState();
computeState.id = nextName("host");
computeState.name = this.computeHostDescription.name;
computeState.documentSelfLink = computeState.id;
computeState.descriptionLink = this.computeHostDescription.documentSelfLink;
// computeState.resourcePoolLink = this.resourcePool.documentSelfLink;
computeState.adapterManagementReference = getAdapterManagementReference();
ComputeState returnState = TestUtils.doPost(this.host, computeState, ComputeState.class, UriUtils.buildUri(this.host, ComputeService.FACTORY_LINK));
return returnState;
}
Aggregations