Search in sources :

Example 1 with ProvisionSubnetTaskState

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

the class TestVSpherePortgroupProvisioning method deleteThePortgroup.

protected void deleteThePortgroup(SubnetState subnet) throws Throwable {
    ProvisionSubnetTaskState removalTask = new ProvisionSubnetTaskState();
    removalTask.options = createOptions();
    removalTask.requestType = InstanceRequestType.DELETE;
    removalTask.subnetLink = subnet.documentSelfLink;
    removalTask = TestUtils.doPost(this.host, removalTask, ProvisionSubnetTaskState.class, UriUtils.buildUri(this.host, ProvisionSubnetTaskService.FACTORY_LINK));
    awaitTaskEnd(removalTask);
}
Also used : ProvisionSubnetTaskState(com.vmware.photon.controller.model.tasks.ProvisionSubnetTaskService.ProvisionSubnetTaskState)

Example 2 with ProvisionSubnetTaskState

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

the class ProvisionSubnetTaskService method sendSelfPatch.

private void sendSelfPatch(TaskState.TaskStage stage, Throwable e) {
    ProvisionSubnetTaskState body = new ProvisionSubnetTaskState();
    body.taskInfo = new TaskState();
    if (e == null) {
        body.taskInfo.stage = stage;
    } else {
        body.taskInfo.stage = TaskState.TaskStage.FAILED;
        body.taskInfo.failure = Utils.toServiceErrorResponse(e);
        logWarning(() -> String.format("Patching to failed: %s", Utils.toString(e)));
    }
    sendSelfPatch(body);
}
Also used : ProvisionSubnetTaskState(com.vmware.photon.controller.model.tasks.ProvisionSubnetTaskService.ProvisionSubnetTaskState) ProvisionSubnetTaskState(com.vmware.photon.controller.model.tasks.ProvisionSubnetTaskService.ProvisionSubnetTaskState) TaskState(com.vmware.xenon.common.TaskState)

Example 3 with ProvisionSubnetTaskState

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

the class ProvisionSubnetTaskServiceTest method buildStartState.

private static ProvisionSubnetTaskState buildStartState(BaseModelTest test, SubnetInstanceRequest.InstanceRequestType requestType, InstanceAdapterTestTypes instanceAdapterType) throws Throwable {
    SubnetState state = new SubnetState();
    state.name = "subnet1-name";
    state.networkLink = "networkLink";
    state.gatewayAddress = "192.168.21.1";
    state.subnetCIDR = "192.168.21.0/28";
    switch(instanceAdapterType) {
        case SUCCESS:
            state.instanceAdapterReference = UriUtils.buildUri(test.getHost(), MockAdapter.MockSubnetInstanceSuccessAdapter.SELF_LINK);
            break;
        case FAILURE:
            state.instanceAdapterReference = UriUtils.buildUri(test.getHost(), MockAdapter.MockSubnetInstanceFailureAdapter.SELF_LINK);
            break;
        default:
            state.instanceAdapterReference = null;
    }
    state.id = UUID.randomUUID().toString();
    SubnetState returnState = test.postServiceSynchronously(SubnetService.FACTORY_LINK, state, SubnetState.class);
    ProvisionSubnetTaskState startState = new ProvisionSubnetTaskState();
    startState.requestType = requestType;
    startState.subnetLink = returnState.documentSelfLink;
    startState.options = EnumSet.of(TaskOption.IS_MOCK);
    return startState;
}
Also used : ProvisionSubnetTaskState(com.vmware.photon.controller.model.tasks.ProvisionSubnetTaskService.ProvisionSubnetTaskState) SubnetState(com.vmware.photon.controller.model.resources.SubnetService.SubnetState)

Example 4 with ProvisionSubnetTaskState

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

the class AzureSubnetTaskServiceTest 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 5 with ProvisionSubnetTaskState

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

the class AzureSubnetTaskServiceTest method testCreateSubnetDuplicatedCIDR.

@Test
public void testCreateSubnetDuplicatedCIDR() throws Throwable {
    Assume.assumeFalse(this.isMock);
    // Provision subnet in Azure.
    SubnetState subnetState = createSubnetState(null);
    kickOffSubnetProvision(InstanceRequestType.CREATE, subnetState, TaskStage.FINISHED);
    subnetState.name += "new";
    patchServiceSynchronously(subnetState.documentSelfLink, subnetState);
    // Try to provision the same subnet second time.
    ProvisionSubnetTaskState state = kickOffSubnetProvision(InstanceRequestType.CREATE, subnetState, TaskStage.FAILED);
    assertTrue(state.taskInfo.failure.message.contains(STATUS_SUBNET_NOT_VALID));
}
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)

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