use of com.vmware.photon.controller.model.tasks.IPAddressAllocationTaskService.IPAddressAllocationTaskState in project photon-model by vmware.
the class IPAddressAllocationTaskServiceTest method createIpAddressDeallocationTask.
private static IPAddressAllocationTaskState createIpAddressDeallocationTask(List<String> ipAddressResourceLinks) {
IPAddressAllocationTaskState deallocationTask = new IPAddressAllocationTaskState();
deallocationTask.requestType = IPAddressAllocationTaskState.RequestType.DEALLOCATE;
deallocationTask.ipAddressLinks = ipAddressResourceLinks;
return deallocationTask;
}
use of com.vmware.photon.controller.model.tasks.IPAddressAllocationTaskService.IPAddressAllocationTaskState in project photon-model by vmware.
the class IPAddressAllocationTaskServiceTest method createIpAddressAllocationTask.
private static IPAddressAllocationTaskState createIpAddressAllocationTask(String subnetLink, String connectedResourceLink) {
IPAddressAllocationTaskState allocationTask = new IPAddressAllocationTaskState();
allocationTask.subnetLink = subnetLink;
allocationTask.requestType = IPAddressAllocationTaskState.RequestType.ALLOCATE;
allocationTask.connectedResourceToRequiredIpCountMap = new HashMap<>();
allocationTask.connectedResourceToRequiredIpCountMap.put(connectedResourceLink, 1);
return allocationTask;
}
use of com.vmware.photon.controller.model.tasks.IPAddressAllocationTaskService.IPAddressAllocationTaskState in project photon-model by vmware.
the class IPAddressAllocationTaskServiceTest method createIpAddressAllocationTask.
private static IPAddressAllocationTaskState createIpAddressAllocationTask(String subnetLink, Map<String, Integer> connectedResourceToRequiredIpCountMap) {
IPAddressAllocationTaskState allocationTask = new IPAddressAllocationTaskState();
allocationTask.subnetLink = subnetLink;
allocationTask.requestType = IPAddressAllocationTaskState.RequestType.ALLOCATE;
allocationTask.connectedResourceToRequiredIpCountMap = connectedResourceToRequiredIpCountMap;
return allocationTask;
}
use of com.vmware.photon.controller.model.tasks.IPAddressAllocationTaskService.IPAddressAllocationTaskState in project photon-model by vmware.
the class ResourceIPDeallocationTaskService method startDeallocatingIPs.
private void startDeallocatingIPs(ResourceIPDeallocationTaskState state, ResourceIPDeallocationContext ctx, String subTaskLink) {
if (subTaskLink == null) {
createSubTaskCallback(state, ctx, link -> startDeallocatingIPs(state, ctx, link));
return;
}
logFine("Starting deallocate of (%s) IPs for compute resource [%s] using sub task %s", ctx.networkInterfaceToIPAddressMap.size(), ctx.resourceLink, subTaskLink);
List<DeferredResult<Operation>> deallocateOperationDRs = new ArrayList<>();
ctx.networkInterfaceToIPAddressMap.keySet().forEach(networkInterfaceLink -> {
String ipAddressLink = ctx.networkInterfaceToIPAddressMap.get(networkInterfaceLink);
IPAddressAllocationTaskState deallocationTaskState = new IPAddressAllocationTaskState();
deallocationTaskState.serviceTaskCallback = ServiceTaskCallback.create(UriUtils.buildUri(getHost(), subTaskLink));
deallocationTaskState.serviceTaskCallback.onSuccessFinishTask();
// Similar to instance deletes - a failure for one network interface deallocate will fail the task
deallocationTaskState.serviceTaskCallback.onErrorFailTask();
deallocationTaskState.requestType = IPAddressAllocationTaskState.RequestType.DEALLOCATE;
deallocationTaskState.connectedResourceLink = networkInterfaceLink;
deallocationTaskState.ipAddressLinks = new ArrayList<>();
deallocationTaskState.ipAddressLinks.add(ipAddressLink);
deallocationTaskState.tenantLinks = state.tenantLinks;
Operation deallocateNisOperation = Operation.createPost(this, IPAddressAllocationTaskService.FACTORY_LINK).setBody(deallocationTaskState);
DeferredResult<Operation> deallocateOperationDR = sendWithDeferredResult(deallocateNisOperation);
deallocateOperationDRs.add(deallocateOperationDR);
});
DeferredResult.allOf(deallocateOperationDRs).exceptionally(t -> {
String msg = "Failure deallocating IP addresses for a computeResource: [%s]";
logWarning(msg, state.resourceLink, t.getMessage());
failTask(t, msg, state.resourceLink);
return null;
});
}
Aggregations