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);
}
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));
}
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);
}
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;
}
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);
}
Aggregations