Search in sources :

Example 11 with ProvisionComputeTaskState

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");
}
Also used : ComputeState(com.vmware.photon.controller.model.resources.ComputeService.ComputeState) ProvisionComputeTaskState(com.vmware.photon.controller.model.tasks.ProvisionComputeTaskService.ProvisionComputeTaskState) ComputeDescription(com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription) Operation(com.vmware.xenon.common.Operation) Test(org.junit.Test)

Example 12 with ProvisionComputeTaskState

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);
        }
    }
}
Also used : NetworkInterfaceDescription(com.vmware.photon.controller.model.resources.NetworkInterfaceDescriptionService.NetworkInterfaceDescription) ComputeState(com.vmware.photon.controller.model.resources.ComputeService.ComputeState) ProvisionComputeTaskState(com.vmware.photon.controller.model.tasks.ProvisionComputeTaskService.ProvisionComputeTaskState) ComputeDescription(com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription) Operation(com.vmware.xenon.common.Operation) SubnetState(com.vmware.photon.controller.model.resources.SubnetService.SubnetState) Test(org.junit.Test)

Example 13 with ProvisionComputeTaskState

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);
}
Also used : ProvisionComputeTaskState(com.vmware.photon.controller.model.tasks.ProvisionComputeTaskService.ProvisionComputeTaskState)

Example 14 with ProvisionComputeTaskState

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());
}
Also used : ProvisionComputeTaskState(com.vmware.photon.controller.model.tasks.ProvisionComputeTaskService.ProvisionComputeTaskState)

Example 15 with ProvisionComputeTaskState

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));
}
Also used : ComputeState(com.vmware.photon.controller.model.resources.ComputeService.ComputeState) ProvisionComputeTaskState(com.vmware.photon.controller.model.tasks.ProvisionComputeTaskService.ProvisionComputeTaskState)

Aggregations

ProvisionComputeTaskState (com.vmware.photon.controller.model.tasks.ProvisionComputeTaskService.ProvisionComputeTaskState)17 ComputeState (com.vmware.photon.controller.model.resources.ComputeService.ComputeState)10 ComputeDescription (com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription)7 Test (org.junit.Test)7 EndpointState (com.vmware.photon.controller.model.resources.EndpointService.EndpointState)5 Operation (com.vmware.xenon.common.Operation)5 ProvisionComputeTaskService (com.vmware.photon.controller.model.tasks.ProvisionComputeTaskService)4 PhotonModelServices (com.vmware.photon.controller.model.PhotonModelServices)3 PhotonModelAdaptersRegistryAdapters (com.vmware.photon.controller.model.adapters.registry.PhotonModelAdaptersRegistryAdapters)3 PhotonModelConstants (com.vmware.photon.controller.model.constants.PhotonModelConstants)3 ComputeService (com.vmware.photon.controller.model.resources.ComputeService)3 DiskService (com.vmware.photon.controller.model.resources.DiskService)3 DiskState (com.vmware.photon.controller.model.resources.DiskService.DiskState)3 NetworkInterfaceState (com.vmware.photon.controller.model.resources.NetworkInterfaceService.NetworkInterfaceState)3 ResourcePoolState (com.vmware.photon.controller.model.resources.ResourcePoolService.ResourcePoolState)3 TagService (com.vmware.photon.controller.model.resources.TagService)3 TagState (com.vmware.photon.controller.model.resources.TagService.TagState)3 PhotonModelTaskServices (com.vmware.photon.controller.model.tasks.PhotonModelTaskServices)3 ProvisioningUtils (com.vmware.photon.controller.model.tasks.ProvisioningUtils)3 TestUtils (com.vmware.photon.controller.model.tasks.TestUtils)3