use of com.vmware.photon.controller.model.adapters.util.BaseAdapterContext.BaseAdapterStage in project photon-model by vmware.
the class AWSInstanceService method handlePatch.
@Override
public void handlePatch(Operation op) {
if (!op.hasBody()) {
op.fail(new IllegalArgumentException("body is required"));
return;
}
AWSInstanceContext ctx = new AWSInstanceContext(this, op.getBody(ComputeInstanceRequest.class));
try {
final BaseAdapterStage startingStage;
final AWSInstanceStage nextStage;
switch(ctx.computeRequest.requestType) {
case VALIDATE_CREDENTIALS:
ctx.operation = op;
startingStage = BaseAdapterStage.PARENTAUTH;
nextStage = AWSInstanceStage.CLIENT;
break;
default:
op.complete();
if (ctx.computeRequest.isMockRequest && ctx.computeRequest.requestType == InstanceRequestType.CREATE) {
ctx.taskManager.finishTask();
return;
}
startingStage = BaseAdapterStage.VMDESC;
nextStage = AWSInstanceStage.PROVISIONTASK;
break;
}
// Populate BaseAdapterContext and then continue with this state machine
ctx.populateBaseContext(startingStage).whenComplete(thenAllocation(ctx, nextStage));
} catch (Throwable t) {
finishExceptionally(ctx, t);
}
}
use of com.vmware.photon.controller.model.adapters.util.BaseAdapterContext.BaseAdapterStage in project photon-model by vmware.
the class AzureInstanceService method handlePatch.
@Override
public void handlePatch(Operation op) {
if (!op.hasBody()) {
op.fail(new IllegalArgumentException("body is required"));
return;
}
AzureInstanceContext ctx = new AzureInstanceContext(this, op.getBody(ComputeInstanceRequest.class));
final BaseAdapterStage startingStage;
switch(ctx.computeRequest.requestType) {
case VALIDATE_CREDENTIALS:
ctx.operation = op;
startingStage = BaseAdapterStage.PARENTAUTH;
break;
default:
op.complete();
if (ctx.computeRequest.isMockRequest && ctx.computeRequest.requestType == InstanceRequestType.CREATE) {
handleAllocation(ctx, AzureInstanceStage.FINISHED);
return;
}
startingStage = BaseAdapterStage.VMDESC;
break;
}
// Populate BaseAdapterContext and then continue with this state machine
ctx.populateBaseContext(startingStage).whenComplete(thenAllocation(ctx, AzureInstanceStage.CLIENT));
}
Aggregations