Search in sources :

Example 6 with NicSecurityGroupsTaskState

use of com.vmware.photon.controller.model.tasks.NicSecurityGroupsTaskService.NicSecurityGroupsTaskState in project photon-model by vmware.

the class NicSecurityGroupsTaskService method handleStart.

@Override
public void handleStart(Operation start) {
    if (!start.hasBody()) {
        start.fail(new IllegalArgumentException("body is required"));
        return;
    }
    NicSecurityGroupsTaskState state = start.getBody(NicSecurityGroupsTaskState.class);
    try {
        Utils.validateState(getStateDescription(), state);
    } catch (Exception e) {
        start.fail(e);
        return;
    }
    validateSecurityGroupsEndpoint(state).whenComplete((ignore, e) -> {
        if (e != null) {
            start.fail(e);
            return;
        }
        state.taskInfo = new TaskState();
        state.taskInfo.stage = TaskState.TaskStage.CREATED;
        state.taskSubStage = SubStage.CREATED;
        start.complete();
        // start the task
        sendSelfPatch(TaskState.TaskStage.CREATED, null);
    });
}
Also used : NicSecurityGroupsTaskState(com.vmware.photon.controller.model.tasks.NicSecurityGroupsTaskService.NicSecurityGroupsTaskState) NicSecurityGroupsTaskState(com.vmware.photon.controller.model.tasks.NicSecurityGroupsTaskService.NicSecurityGroupsTaskState) TaskState(com.vmware.xenon.common.TaskState)

Aggregations

NicSecurityGroupsTaskState (com.vmware.photon.controller.model.tasks.NicSecurityGroupsTaskService.NicSecurityGroupsTaskState)6 TaskState (com.vmware.xenon.common.TaskState)3 UriPaths (com.vmware.photon.controller.model.UriPaths)1 NicSecurityGroupsRequest (com.vmware.photon.controller.model.adapterapi.NicSecurityGroupsRequest)1 OperationRequestType (com.vmware.photon.controller.model.adapterapi.NicSecurityGroupsRequest.OperationRequestType)1 QueryUtils (com.vmware.photon.controller.model.query.QueryUtils)1 SecurityGroupState (com.vmware.photon.controller.model.resources.SecurityGroupService.SecurityGroupState)1 AssertUtil (com.vmware.photon.controller.model.util.AssertUtil)1 PhotonModelUriUtils.createInventoryUri (com.vmware.photon.controller.model.util.PhotonModelUriUtils.createInventoryUri)1 DeferredResult (com.vmware.xenon.common.DeferredResult)1 Operation (com.vmware.xenon.common.Operation)1 ServiceDocument (com.vmware.xenon.common.ServiceDocument)1 EXPAND (com.vmware.xenon.common.ServiceDocumentDescription.PropertyIndexingOption.EXPAND)1 FIXED_ITEM_NAME (com.vmware.xenon.common.ServiceDocumentDescription.PropertyIndexingOption.FIXED_ITEM_NAME)1 PropertyUsageOption (com.vmware.xenon.common.ServiceDocumentDescription.PropertyUsageOption)1 LINK (com.vmware.xenon.common.ServiceDocumentDescription.PropertyUsageOption.LINK)1 OPTIONAL (com.vmware.xenon.common.ServiceDocumentDescription.PropertyUsageOption.OPTIONAL)1 REQUIRED (com.vmware.xenon.common.ServiceDocumentDescription.PropertyUsageOption.REQUIRED)1 UriUtils (com.vmware.xenon.common.UriUtils)1 Utils (com.vmware.xenon.common.Utils)1