use of com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription in project photon-model by vmware.
the class TestVSphereProvisionFromImageLink method provisionVMAndGetState.
private ComputeState provisionVMAndGetState() throws Throwable {
if (isMock()) {
return null;
}
// Create a resource pool where the VM will be housed
this.resourcePool = createResourcePool();
this.auth = createAuth();
this.computeHostDescription = createComputeDescription();
this.computeHost = createComputeHost(this.computeHostDescription);
EndpointState ep = createEndpointState(this.computeHost, this.computeHostDescription);
this.endpoint = TestUtils.doPost(this.host, ep, EndpointState.class, UriUtils.buildUri(this.host, EndpointService.FACTORY_LINK));
enumerateComputes(this.computeHost, this.endpoint);
doRefresh();
snapshotFactoryState("images", ImageService.class);
String imageLink = findImage();
ComputeDescription desc = createVmDescription();
ComputeState vm = createVmState(desc, imageLink);
// kick off a provision task to do the actual VM creation
ProvisionComputeTaskState outTask = createProvisionTask(vm);
awaitTaskEnd(outTask);
return getComputeState(vm);
}
use of com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription in project photon-model by vmware.
the class TestVSphereProvisionWithCloudConfigTask method createVmDescription.
private ComputeDescription createVmDescription() throws Throwable {
ComputeDescription computeDesc = new ComputeDescription();
computeDesc.id = nextName("vm");
computeDesc.regionId = this.datacenterId;
computeDesc.documentSelfLink = computeDesc.id;
computeDesc.supportedChildren = new ArrayList<>();
computeDesc.instanceAdapterReference = UriUtils.buildUri(this.host, VSphereUriPaths.INSTANCE_SERVICE);
computeDesc.authCredentialsLink = this.auth.documentSelfLink;
computeDesc.name = computeDesc.id;
computeDesc.dataStoreId = this.dataStoreId;
computeDesc.cpuCount = 2L;
computeDesc.totalMemoryBytes = 1L * 1024 * 1024 * 1024;
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 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.ComputeDescriptionService.ComputeDescription in project photon-model by vmware.
the class TestVSphereProvisionWithStaticIpTask method createVmDescription.
private ComputeDescription createVmDescription() throws Throwable {
ComputeDescription computeDesc = new ComputeDescription();
computeDesc.id = nextName("vm");
computeDesc.regionId = this.datacenterId;
computeDesc.documentSelfLink = computeDesc.id;
computeDesc.supportedChildren = new ArrayList<>();
computeDesc.instanceAdapterReference = UriUtils.buildUri(this.host, VSphereUriPaths.INSTANCE_SERVICE);
computeDesc.authCredentialsLink = this.auth.documentSelfLink;
computeDesc.name = computeDesc.id;
computeDesc.dataStoreId = this.dataStoreId;
computeDesc.cpuCount = 2;
// 1G
computeDesc.totalMemoryBytes = 1024 * 1024 * 1024;
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 OvfParserTest method test.
@Test
public void test() throws IOException, SAXException {
OvfParser parser = new OvfParser();
Document ovfDoc = parser.retrieveDescriptor(new File("src/test/resources/vcenter.ovf").toURI());
ComputeDescription template = new ComputeDescription();
template.instanceAdapterReference = URI.create("http://test");
List<ComputeDescription> results = parser.parse(ovfDoc, template);
System.out.println(Utils.toJsonHtml(results));
// all hw configurations are converted
assertEquals(9, results.size());
// template properties are copied
for (ComputeDescription description : results) {
assertEquals(description.instanceAdapterReference, template.instanceAdapterReference);
}
// network, properties and hardware config translated
for (ComputeDescription description : results) {
assertTrue(description.customProperties.containsKey("ovf.prop:guestinfo.cis.appliance.net.addr.family"));
assertTrue(description.customProperties.containsKey("ovf.prop:guestinfo.cis.appliance.root.passwd"));
assertTrue(description.cpuCount > 0);
assertTrue(description.totalMemoryBytes > 0);
}
List<String> nets = parser.extractNetworks(ovfDoc);
assertEquals(1, nets.size());
assertEquals("Network 1", nets.get(0));
}
Aggregations