use of com.vmware.photon.controller.model.adapters.util.TaskManager in project photon-model by vmware.
the class AWSNetworkClient method deleteNATGateway.
/**
* Delete a NAT Gateway
* It waits for the NAT gateway to get into the Deleted state before returning.
*/
public DeferredResult<Void> deleteNATGateway(String natGatewayId, TaskManager taskManager, long taskExpirationMicros) {
DeleteNatGatewayRequest req = new DeleteNatGatewayRequest().withNatGatewayId(natGatewayId);
String message = "Delete AWS NAT Gateway with id [" + natGatewayId + "].";
AWSDeferredResultAsyncHandler<DeleteNatGatewayRequest, DeleteNatGatewayResult> handler = new AWSDeferredResultAsyncHandler<>(this.service, message);
this.client.deleteNatGatewayAsync(req, handler);
return handler.toDeferredResult().thenCompose(ignore -> waitForNatGatewayState(natGatewayId, taskManager, taskExpirationMicros, AWSTaskStatusChecker.AWS_DELETED_NAME)).thenApply(ignore -> null);
}
use of com.vmware.photon.controller.model.adapters.util.TaskManager in project photon-model by vmware.
the class AWSNetworkClient method waitForNatGatewayState.
/**
* Wait for NAT Gateway to go into the desired state
*/
private DeferredResult<String> waitForNatGatewayState(String natGatewayId, TaskManager taskManager, long taskExpirationMicros, String desiredState) {
DeferredResult<String> waitCompleted = new DeferredResult<>();
AWSTaskStatusChecker.create(this.client, natGatewayId, desiredState, (ignore) -> waitCompleted.complete(natGatewayId), taskManager, this.service, taskExpirationMicros).start(new NatGateway());
return waitCompleted;
}
use of com.vmware.photon.controller.model.adapters.util.TaskManager in project photon-model by vmware.
the class AWSCostStatsService method handlePatch.
@Override
public void handlePatch(Operation op) {
if (!op.hasBody()) {
op.fail(new IllegalArgumentException("body is required"));
return;
}
op.complete();
ComputeStatsRequest statsRequest = op.getBody(ComputeStatsRequest.class);
TaskManager taskManager = new TaskManager(this, statsRequest.taskReference, statsRequest.resourceLink());
if (statsRequest.isMockRequest) {
// patch status to parent task
taskManager.finishTask();
return;
}
AWSCostStatsCreationContext statsData = new AWSCostStatsCreationContext(statsRequest);
statsData.taskManager = taskManager;
handleCostStatsCreationRequest(statsData);
}
use of com.vmware.photon.controller.model.adapters.util.TaskManager in project photon-model by vmware.
the class AzureStatsService method handlePatch.
@Override
public void handlePatch(Operation op) {
if (!op.hasBody()) {
op.fail(new IllegalArgumentException("body is required"));
return;
}
ComputeStatsRequest statsRequest = op.getBody(ComputeStatsRequest.class);
op.complete();
TaskManager taskManager = new TaskManager(this, statsRequest.taskReference, statsRequest.resourceLink());
if (statsRequest.isMockRequest) {
// patch status to parent task
taskManager.finishTask();
return;
}
AzureStatsDataHolder statsData = new AzureStatsDataHolder();
statsData.statsRequest = statsRequest;
statsData.taskManager = taskManager;
getVMDescription(statsData);
}
use of com.vmware.photon.controller.model.adapters.util.TaskManager in project photon-model by vmware.
the class VSphereAdapterInstanceService method handlePatch.
@Override
public void handlePatch(Operation op) {
if (!op.hasBody()) {
op.fail(new IllegalArgumentException("body is required"));
return;
}
op.setStatusCode(Operation.STATUS_CODE_CREATED);
op.complete();
ComputeInstanceRequest request = op.getBody(ComputeInstanceRequest.class);
TaskManager mgr = new TaskManager(this, request.taskReference, request.resourceLink());
if (request.isMockRequest) {
handleMockRequest(mgr);
return;
}
ProvisionContext.populateContextThen(this, createInitialContext(request, op), ctx -> {
switch(request.requestType) {
case CREATE:
handleCreateInstance(ctx);
break;
case DELETE:
handleDeleteInstance(ctx);
break;
default:
Throwable error = new IllegalStateException("Unsupported requestType " + request.requestType);
ctx.fail(error);
}
});
}
Aggregations