private boolean isRemoveOperation(RequestBrokerState state) { if (RequestBrokerState.REMOVE_RESOURCE_OPERATION.equals(state.operation)) { return true; } if (isContainerType(state) || isCompositeComponentType(state)) { return ContainerOperationType.DELETE.id.equals(state.operation) || ApplicationOperationType.DELETE.id.equals(state.operation); } if (isComputeType(state)) { return ComputeOperationType.DELETE.id.equals(state.operation); } if (isContainerNetworkType(state)) { return NetworkOperationType.DELETE.id.equals(state.operation); } if (isContainerVolumeType(state)) { return VolumeOperationType.DELETE.id.equals(state.operation); } if (isClosureType(state)) { return ClosureOperationType.DELETE.id.equals(state.operation); } return false; }
@Override protected void validateStateOnStart(RequestBrokerState state) throws IllegalArgumentException { if (state.operation == null) { state.operation = RequestBrokerState.PROVISION_RESOURCE_OPERATION; } if (isProvisionOperation(state) || isClusteringOperation(state)) { if (!isPKSClusterType(state)) { assertNotEmpty(state.resourceDescriptionLink, "resourceDescriptionLink"); } } else { assertNotEmpty(state.resourceLinks, "resourceLinks"); } if (!(isContainerType(state) || isContainerHostType(state) || isContainerNetworkType(state) || isContainerVolumeType(state) || isComputeType(state) || isCompositeComponentType(state) || isClosureType(state) || isPKSClusterType(state))) { throw new LocalizableValidationException( String.format("Only [ %s ] resource types are supported.", ResourceType.getAllTypesAsString()), "request.supported.resource-types", ResourceType.getAllTypesAsString()); } if (state.resourceCount <= 0) { state.resourceCount = 1; } }
private void createCompositionTask(RequestBrokerState state) { if (isCompositeComponentType(state)) { CompositionTaskState compositionTask = new CompositionTaskState(); compositionTask.documentSelfLink = getSelfId(); compositionTask.serviceTaskCallback = ServiceTaskCallback.create( getSelfLink(), TaskStage.STARTED, SubStage.ALLOCATED, TaskStage.STARTED, SubStage.ERROR); compositionTask.customProperties = state.customProperties; compositionTask.resourceDescriptionLink = state.resourceDescriptionLink; compositionTask.tenantLinks = state.tenantLinks; compositionTask.requestTrackerLink = state.requestTrackerLink; compositionTask.groupResourcePlacementLink = state.groupResourcePlacementLink; sendRequest(Operation.createPost(this, CompositionTaskFactoryService.SELF_LINK) .setBodyNoCloning(compositionTask) .setContextId(getSelfId()) .setCompletion((o, e) -> { if (e != null) { failTask("Failure creating composition task", e); return; } proceedTo(SubStage.ALLOCATING); })); } else { failTask(null, new LocalizableValidationException("Not supported resourceType: " + state.resourceType, "request.resource-type.not.supported", state.resourceType)); } }
case RESOURCE_COUNTED: if (isProvisionOperation(state)) { if (isCompositeComponentType(state)) { createCompositionTask(state); } else { completeWithError(); if (isCompositeComponentType(state)) { ResourceDescriptionUtil.deleteClonedCompositeDescription(getHost(), state.resourceDescriptionLink);
createContainerOperationTasks(state); } else if (isCompositeComponentType(state)) { createCompositeComponentOperationTask(state); } else if (isContainerHostType(state)) {