use of com.vmware.photon.controller.model.tasks.ProvisionComputeTaskService.ProvisionComputeTaskState 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.tasks.ProvisionComputeTaskService.ProvisionComputeTaskState 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);
}
}
}
use of com.vmware.photon.controller.model.tasks.ProvisionComputeTaskService.ProvisionComputeTaskState in project photon-model by vmware.
the class AzureComputeDiskDay2ServiceTest method kickOffComputeVmProvisioning.
private void kickOffComputeVmProvisioning() throws Throwable {
ProvisionComputeTaskState provisionComputeTaskState = new ProvisionComputeTaskState();
provisionComputeTaskState.computeLink = this.vmState.documentSelfLink;
provisionComputeTaskState.bootAdapterReference = this.vmState.bootAdapterReference;
provisionComputeTaskState.instanceAdapterReference = this.vmState.instanceAdapterReference;
provisionComputeTaskState.taskSubStage = ProvisionComputeTaskState.SubStage.CREATING_HOST;
provisionComputeTaskState.isMockRequest = this.isMock;
provisionComputeTaskState = TestUtils.doPost(this.host, provisionComputeTaskState, ProvisionComputeTaskState.class, UriUtils.buildUri(this.host, ProvisionComputeTaskService.FACTORY_LINK));
this.host.waitForFinishedTask(ProvisionComputeTaskState.class, provisionComputeTaskState.documentSelfLink);
}
use of com.vmware.photon.controller.model.tasks.ProvisionComputeTaskService.ProvisionComputeTaskState in project photon-model by vmware.
the class AzureLoadBalancerServiceTest method kickOffComputeProvision.
// kick off a provision task to do the actual VM creation
private void kickOffComputeProvision() {
this.vmStates = vmStates.parallelStream().map(computeState -> {
ProvisionComputeTaskState provisionTask = new ProvisionComputeTaskState();
provisionTask.computeLink = computeState.documentSelfLink;
provisionTask.isMockRequest = this.isMock;
provisionTask.taskSubStage = SubStage.CREATING_HOST;
try {
provisionTask = postServiceSynchronously(ProvisionComputeTaskService.FACTORY_LINK, provisionTask, ProvisionComputeTaskState.class);
} catch (Throwable e) {
throw new RuntimeException(e);
}
getHost().waitForFinishedTask(ProvisionComputeTaskState.class, provisionTask.documentSelfLink);
return getHost().getServiceState(null, ComputeState.class, UriUtils.buildUri(getHost(), computeState.documentSelfLink));
}).collect(Collectors.toList());
}
use of com.vmware.photon.controller.model.tasks.ProvisionComputeTaskService.ProvisionComputeTaskState in project photon-model by vmware.
the class TestAzureProvisionTask method kickOffProvisionTask.
// kick off a provision task to do the actual VM creation
private void kickOffProvisionTask() throws Throwable {
ProvisionComputeTaskState provisionTask = new ProvisionComputeTaskState();
provisionTask.computeLink = this.vmState.documentSelfLink;
provisionTask.isMockRequest = this.isMock;
provisionTask.taskSubStage = ProvisionComputeTaskState.SubStage.CREATING_HOST;
provisionTask = TestUtils.doPost(getHost(), provisionTask, ProvisionComputeTaskState.class, UriUtils.buildUri(getHost(), ProvisionComputeTaskService.FACTORY_LINK));
getHost().waitForFinishedTask(ProvisionComputeTaskState.class, provisionTask.documentSelfLink);
this.vmState = getHost().getServiceState(null, ComputeState.class, UriUtils.buildUri(getHost(), this.vmState.documentSelfLink));
}
Aggregations