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