Search in sources :

Example 6 with ProvisionSubnetTaskState

use of com.vmware.photon.controller.model.tasks.ProvisionSubnetTaskService.ProvisionSubnetTaskState in project photon-model by vmware.

the class AWSSubnetTaskServiceTest method kickOffSubnetProvision.

private ProvisionSubnetTaskState kickOffSubnetProvision(InstanceRequestType requestType, SubnetState subnetState, TaskStage expectedTaskState) throws Throwable {
    ProvisionSubnetTaskState taskState = new ProvisionSubnetTaskState();
    taskState.requestType = requestType;
    taskState.subnetLink = subnetState.documentSelfLink;
    taskState.options = this.isMock ? EnumSet.of(TaskOption.IS_MOCK) : EnumSet.noneOf(TaskOption.class);
    // Start/Post subnet provisioning task
    taskState = postServiceSynchronously(ProvisionSubnetTaskService.FACTORY_LINK, taskState, ProvisionSubnetTaskState.class);
    // Wait for image-enumeration task to complete
    return waitForServiceState(ProvisionSubnetTaskState.class, taskState.documentSelfLink, liveState -> expectedTaskState == liveState.taskInfo.stage);
}
Also used : ProvisionSubnetTaskState(com.vmware.photon.controller.model.tasks.ProvisionSubnetTaskService.ProvisionSubnetTaskState)

Example 7 with ProvisionSubnetTaskState

use of com.vmware.photon.controller.model.tasks.ProvisionSubnetTaskService.ProvisionSubnetTaskState in project photon-model by vmware.

the class AWSSubnetTaskServiceTest method testCreateSubnetDuplicatedCIDR.

@Test
public void testCreateSubnetDuplicatedCIDR() throws Throwable {
    Assume.assumeFalse(this.isMock);
    // Provision subnet in AWS.
    SubnetState subnetState = createSubnetState(null, AWS_NON_EXISTING_SUBNET_NAME, AWS_NON_EXISTING_SUBNET_CIDR, null);
    kickOffSubnetProvision(InstanceRequestType.CREATE, subnetState, TaskStage.FINISHED);
    // Try to provision the same subnet second time.
    ProvisionSubnetTaskState state = kickOffSubnetProvision(InstanceRequestType.CREATE, subnetState, TaskStage.FAILED);
    assertTrue(state.taskInfo.failure.message.contains(STATUS_CODE_SUBNET_CONFLICT));
}
Also used : ProvisionSubnetTaskState(com.vmware.photon.controller.model.tasks.ProvisionSubnetTaskService.ProvisionSubnetTaskState) SubnetState(com.vmware.photon.controller.model.resources.SubnetService.SubnetState) BaseModelTest(com.vmware.photon.controller.model.helpers.BaseModelTest) Test(org.junit.Test)

Example 8 with ProvisionSubnetTaskState

use of com.vmware.photon.controller.model.tasks.ProvisionSubnetTaskService.ProvisionSubnetTaskState in project photon-model by vmware.

the class TestVSpherePortgroupProvisioning method createPortgroup.

@Test
public void createPortgroup() throws Throwable {
    this.endpoint = createEndpoint(cs -> this.computeHost = cs, null);
    // enumerate all resources hoping to find the template
    doRefresh();
    snapshotFactoryState("networks", NetworkService.class);
    NetworkState dvsSwitch = fetchServiceState(NetworkState.class, findDvs(networkId));
    SubnetState subnet = new SubnetState();
    subnet.subnetCIDR = "0.0.0.0/0";
    subnet.networkLink = dvsSwitch.documentSelfLink;
    subnet.name = nextName("pg");
    subnet.instanceAdapterReference = UriUtils.buildUri(this.host, DvsNetworkService.SELF_LINK);
    subnet = TestUtils.doPost(this.host, subnet, SubnetState.class, UriUtils.buildUri(this.host, SubnetService.FACTORY_LINK));
    ProvisionSubnetTaskState createTask = new ProvisionSubnetTaskState();
    createTask.options = createOptions();
    createTask.requestType = InstanceRequestType.CREATE;
    createTask.subnetLink = subnet.documentSelfLink;
    createTask = TestUtils.doPost(this.host, createTask, ProvisionSubnetTaskState.class, UriUtils.buildUri(this.host, ProvisionSubnetTaskService.FACTORY_LINK));
    awaitTaskEnd(createTask);
    // refresh state
    subnet = getSubnetState(subnet);
    // delete the portgroup
    deleteThePortgroup(subnet);
}
Also used : SubnetService(com.vmware.photon.controller.model.resources.SubnetService) ProvisionSubnetTaskState(com.vmware.photon.controller.model.tasks.ProvisionSubnetTaskService.ProvisionSubnetTaskState) ServiceTypeCluster(com.vmware.photon.controller.model.util.ClusterUtil.ServiceTypeCluster) Operation(com.vmware.xenon.common.Operation) QueryTask(com.vmware.xenon.services.common.QueryTask) QueryUtils(com.vmware.photon.controller.model.query.QueryUtils) ProvisionSubnetTaskService(com.vmware.photon.controller.model.tasks.ProvisionSubnetTaskService) TestUtils(com.vmware.photon.controller.model.tasks.TestUtils) ServiceDocument(com.vmware.xenon.common.ServiceDocument) Test(org.junit.Test) VimNames(com.vmware.photon.controller.model.adapters.vsphere.util.VimNames) NetworkService(com.vmware.photon.controller.model.resources.NetworkService) Query(com.vmware.xenon.services.common.QueryTask.Query) Ignore(org.junit.Ignore) DvsNetworkService(com.vmware.photon.controller.model.adapters.vsphere.network.DvsNetworkService) ComputeState(com.vmware.photon.controller.model.resources.ComputeService.ComputeState) SubnetState(com.vmware.photon.controller.model.resources.SubnetService.SubnetState) UriUtils(com.vmware.xenon.common.UriUtils) InstanceRequestType(com.vmware.photon.controller.model.adapterapi.SubnetInstanceRequest.InstanceRequestType) TaskOption(com.vmware.photon.controller.model.tasks.TaskOption) NetworkState(com.vmware.photon.controller.model.resources.NetworkService.NetworkState) Assert(org.junit.Assert) EnumSet(java.util.EnumSet) EndpointState(com.vmware.photon.controller.model.resources.EndpointService.EndpointState) NetworkState(com.vmware.photon.controller.model.resources.NetworkService.NetworkState) ProvisionSubnetTaskState(com.vmware.photon.controller.model.tasks.ProvisionSubnetTaskService.ProvisionSubnetTaskState) SubnetState(com.vmware.photon.controller.model.resources.SubnetService.SubnetState) Test(org.junit.Test)

Example 9 with ProvisionSubnetTaskState

use of com.vmware.photon.controller.model.tasks.ProvisionSubnetTaskService.ProvisionSubnetTaskState in project photon-model by vmware.

the class ProvisionSubnetTaskServiceTest method postAndWaitForService.

private static ProvisionSubnetTaskState postAndWaitForService(BaseModelTest test, ProvisionSubnetTaskState startState) throws Throwable {
    ProvisionSubnetTaskState returnState = test.postServiceSynchronously(ProvisionSubnetTaskService.FACTORY_LINK, startState, ProvisionSubnetTaskState.class);
    ProvisionSubnetTaskState completeState = test.waitForServiceState(ProvisionSubnetTaskState.class, returnState.documentSelfLink, state -> TaskState.TaskStage.FINISHED.ordinal() <= state.taskInfo.stage.ordinal());
    return completeState;
}
Also used : ProvisionSubnetTaskState(com.vmware.photon.controller.model.tasks.ProvisionSubnetTaskService.ProvisionSubnetTaskState)

Example 10 with ProvisionSubnetTaskState

use of com.vmware.photon.controller.model.tasks.ProvisionSubnetTaskService.ProvisionSubnetTaskState in project photon-model by vmware.

the class AzureLoadBalancerServiceTest method kickOffSubnetProvision.

private ProvisionSubnetTaskState kickOffSubnetProvision(InstanceRequestType requestType, SubnetState subnetState, TaskStage expectedTaskState) throws Throwable {
    ProvisionSubnetTaskState taskState = new ProvisionSubnetTaskState();
    taskState.requestType = requestType;
    taskState.subnetLink = subnetState.documentSelfLink;
    taskState.options = this.isMock ? EnumSet.of(TaskOption.IS_MOCK) : EnumSet.noneOf(TaskOption.class);
    // Start/Post subnet provisioning task
    taskState = postServiceSynchronously(ProvisionSubnetTaskService.FACTORY_LINK, taskState, ProvisionSubnetTaskState.class);
    // Wait for subnet task to complete
    return waitForServiceState(ProvisionSubnetTaskState.class, taskState.documentSelfLink, liveState -> expectedTaskState == liveState.taskInfo.stage);
}
Also used : ProvisionSubnetTaskState(com.vmware.photon.controller.model.tasks.ProvisionSubnetTaskService.ProvisionSubnetTaskState)

Aggregations

ProvisionSubnetTaskState (com.vmware.photon.controller.model.tasks.ProvisionSubnetTaskService.ProvisionSubnetTaskState)12 SubnetState (com.vmware.photon.controller.model.resources.SubnetService.SubnetState)4 Test (org.junit.Test)3 BaseModelTest (com.vmware.photon.controller.model.helpers.BaseModelTest)2 TaskState (com.vmware.xenon.common.TaskState)2 InstanceRequestType (com.vmware.photon.controller.model.adapterapi.SubnetInstanceRequest.InstanceRequestType)1 DvsNetworkService (com.vmware.photon.controller.model.adapters.vsphere.network.DvsNetworkService)1 VimNames (com.vmware.photon.controller.model.adapters.vsphere.util.VimNames)1 QueryUtils (com.vmware.photon.controller.model.query.QueryUtils)1 ComputeState (com.vmware.photon.controller.model.resources.ComputeService.ComputeState)1 EndpointState (com.vmware.photon.controller.model.resources.EndpointService.EndpointState)1 NetworkService (com.vmware.photon.controller.model.resources.NetworkService)1 NetworkState (com.vmware.photon.controller.model.resources.NetworkService.NetworkState)1 SubnetService (com.vmware.photon.controller.model.resources.SubnetService)1 ProvisionSubnetTaskService (com.vmware.photon.controller.model.tasks.ProvisionSubnetTaskService)1 TaskOption (com.vmware.photon.controller.model.tasks.TaskOption)1 TestUtils (com.vmware.photon.controller.model.tasks.TestUtils)1 ServiceTypeCluster (com.vmware.photon.controller.model.util.ClusterUtil.ServiceTypeCluster)1 Operation (com.vmware.xenon.common.Operation)1 ServiceDocument (com.vmware.xenon.common.ServiceDocument)1