Search in sources :

Example 36 with ResourceOperationRequest

use of com.vmware.photon.controller.model.adapters.registry.operations.ResourceOperationRequest in project photon-model by vmware.

the class AzureLifecycleOperationService method handlePatch.

@Override
public void handlePatch(Operation op) {
    if (!op.hasBody()) {
        op.fail(new IllegalArgumentException("body is required"));
        return;
    }
    ResourceOperationRequest request = op.getBody(ResourceOperationRequest.class);
    op.complete();
    AzureLifecycleOperationContext ctx = new AzureLifecycleOperationContext(this, request);
    logInfo("Handle operation %s for compute %s.", request.operation, request.resourceLink());
    if (request.isMockRequest) {
        updateComputeState(ctx);
        return;
    }
    ctx.populateBaseContext(BaseAdapterStage.VMDESC).whenComplete((ignoreCtx, e) -> {
        if (e != null) {
            logSevere("Error populating base context during Azure resource operation %s for resource %s failed with error %s", request.operation, request.resourceReference, Utils.toString(e));
            ctx.finishExceptionally(e);
            return;
        }
        ctx.vmName = ctx.child.name != null ? ctx.child.name : ctx.child.id;
        ctx.rgName = AzureUtils.getResourceGroupName(ctx);
        applyResourceOperation(ctx);
    });
}
Also used : ResourceOperationRequest(com.vmware.photon.controller.model.adapters.registry.operations.ResourceOperationRequest)

Aggregations

ResourceOperationRequest (com.vmware.photon.controller.model.adapters.registry.operations.ResourceOperationRequest)36 Operation (com.vmware.xenon.common.Operation)20 ResourceOperation (com.vmware.photon.controller.model.adapters.registry.operations.ResourceOperation)19 ComputeState (com.vmware.photon.controller.model.resources.ComputeService.ComputeState)16 ResourceOperationResponse (com.vmware.photon.controller.model.adapterapi.ResourceOperationResponse)8 TestContext (com.vmware.xenon.common.test.TestContext)8 TestRequestSender (com.vmware.xenon.common.test.TestRequestSender)7 DefaultAdapterContext (com.vmware.photon.controller.model.adapters.util.BaseAdapterContext.DefaultAdapterContext)5 StatelessService (com.vmware.xenon.common.StatelessService)5 ResourceOperationUtils.handleAdapterResourceOperationRegistration (com.vmware.photon.controller.model.adapters.registry.operations.ResourceOperationUtils.handleAdapterResourceOperationRegistration)4 ComputeService (com.vmware.photon.controller.model.resources.ComputeService)4 DiskService (com.vmware.photon.controller.model.resources.DiskService)4 SnapshotState (com.vmware.photon.controller.model.resources.SnapshotService.SnapshotState)4 ManagedObjectReference (com.vmware.vim25.ManagedObjectReference)4 FactoryService (com.vmware.xenon.common.FactoryService)4 Service (com.vmware.xenon.common.Service)4 ServiceDocument (com.vmware.xenon.common.ServiceDocument)4 HashMap (java.util.HashMap)4 Test (org.junit.Test)4 AmazonEC2AsyncClient (com.amazonaws.services.ec2.AmazonEC2AsyncClient)3