use of com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription in project photon-model by vmware.
the class TestVSphereProvisionWithCloudConfigTask method createComputeHostDescription.
private ComputeDescription createComputeHostDescription() throws Throwable {
ComputeDescription computeDesc = new ComputeDescription();
computeDesc.id = nextName("host");
computeDesc.name = computeDesc.id;
computeDesc.documentSelfLink = computeDesc.id;
computeDesc.supportedChildren = new ArrayList<>();
computeDesc.supportedChildren.add(ComputeType.VM_GUEST.name());
computeDesc.instanceAdapterReference = UriUtils.buildUri(this.host, VSphereUriPaths.INSTANCE_SERVICE);
computeDesc.authCredentialsLink = this.auth.documentSelfLink;
computeDesc.enumerationAdapterReference = UriUtils.buildUri(this.host, VSphereUriPaths.ENUMERATION_SERVICE);
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 TestVSphereProvisionWithMissingDatacenter method createCloneDescription.
@SuppressWarnings("unused")
private ComputeDescription createCloneDescription(String templateComputeLink) throws Throwable {
ComputeDescription computeDesc = new ComputeDescription();
computeDesc.id = "cloned-" + UUID.randomUUID().toString();
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;
CustomProperties.of(computeDesc).put(CustomProperties.TEMPLATE_LINK, templateComputeLink);
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 TestVSphereProvisionWithMissingDatacenter method createVmDescription.
private ComputeDescription createVmDescription() throws Throwable {
ComputeDescription computeDesc = new ComputeDescription();
computeDesc.id = nextName("vm");
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;
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 TestVSphereProvisionWithMissingDatacenter method createInstanceFromTemplate.
@Test
public void createInstanceFromTemplate() throws Throwable {
this.auth = createAuth();
this.resourcePool = createResourcePool();
if (isMock()) {
// this test makes no sense in mock mode as the adapter doesn't process mock requests at all
return;
}
// clear the datacenterId to cause misconfiguration
this.datacenterId = null;
this.computeHostDescription = createComputeDescription();
this.computeHost = createComputeHost(this.computeHostDescription);
ComputeDescription vmDescription = createVmDescription();
ComputeState vm = createVmState(vmDescription);
// kick off a provision task to do the actual VM creation
ProvisionComputeTaskState provisionTask = createProvisionTask(vm);
try {
awaitTaskEnd(provisionTask);
} catch (AssertionError e) {
Operation operation = this.host.waitForResponse(Operation.createGet(this.host, provisionTask.documentSelfLink));
ProvisionComputeTaskState task = operation.getBody(ProvisionComputeTaskState.class);
assertTrue(task.taskInfo.failure.message.contains("regionId"));
return;
}
fail("Task should have failed");
}
use of com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription in project photon-model by vmware.
the class TestVSphereProvisionWithStaticIpTask method deployByCloningWithCustomization.
@Test
public void deployByCloningWithCustomization() throws Throwable {
ComputeState vm = null;
try {
this.nicDescription = new NetworkInterfaceDescription();
this.nicDescription.assignment = IpAssignment.STATIC;
this.nicDescription.address = "10.0.0.2";
// Create a resource pool where the VM will be housed
this.resourcePool = createResourcePool();
this.auth = createAuth();
this.computeHostDescription = createComputeDescription();
this.computeHost = createComputeHost();
// enumerate all resources hoping to find the template
doRefresh();
snapshotFactoryState("networks", NetworkService.class);
snapshotFactoryState("computes", ComputeService.class);
// find the template by vm name
// template must have vm-tools and cloud-config installed
ComputeState template = findTemplate();
this.subnet = fetchServiceState(SubnetState.class, findPortGroup(networkId));
this.subnet.dnsSearchDomains = Arrays.asList("local");
this.subnet.gatewayAddress = "10.0.0.1";
this.subnet.dnsServerAddresses = Arrays.asList("8.8.8.8");
this.subnet.domain = "local";
this.subnet.subnetCIDR = "10.0.0.0/24";
// modify the subnet
Operation patch = Operation.createPatch(this.host, this.subnet.documentSelfLink).setBody(this.subnet);
patch = this.host.waitForResponse(patch);
this.subnet = patch.getBody(SubnetState.class);
// 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);
if (!isMock()) {
assertEquals(vm.address, this.nicDescription.address);
}
} finally {
if (vm != null) {
deleteVmAndWait(vm);
}
}
}
Aggregations