private boolean isPostAllocationOperation(RequestBrokerState state) { return (isContainerType(state) || isContainerNetworkType(state) || isComputeType(state) || isContainerVolumeType(state) || isClosureType(state)) && (ContainerOperationType.CREATE.id.equals(state.operation) || NetworkOperationType.CREATE.id.equals(state.operation) || VolumeOperationType.CREATE.id.equals(state.operation) || ClosureOperationType.CREATE.id.equals(state.operation)); }
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; }
if (isContainerType(state)) { trackedTasks.addAll(SUPPORTED_ALLOCATION_TASKS_BY_RESOURCE_TYPE .get(ResourceType.CONTAINER_TYPE)); requestStatus.customProperties.put(RequestStatus.CUSTOM_PROP_NAME_REQUEST_TYPE, RequestType.PROVISIONING_ONLY.toString()); if (isContainerType(state)) { requestStatus.addTrackedTasks(ContainerAllocationTaskService.DISPLAY_NAME); } else if (isContainerNetworkType(state)) {
private void calculateActualRequestedResources(RequestBrokerState state, SubStage next) { if (isPKSClusterType(state)) { proceedTo(next, s -> { s.actualResourceCount = state.resourceCount; s.documentExpirationTimeMicros = getExpirationTimeFromNowInMicros( EXPIRATION_MICROS * 2); }); return; } if (isProvisionOperation(state)) { if (isContainerType(state)) { getContainerDescription(state, (cd) -> { proceedTo(next, s -> { s.actualResourceCount = getRequestContainerResourceCount(state, cd); updateRequestTrackerName(state, cd.name); }); }); } else { proceedTo(next, s -> s.actualResourceCount = state.resourceCount); } } else { proceedTo(next, s -> s.actualResourceCount = state.resourceCount); } }
@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 createAllocationTasks(RequestBrokerState state) { if (isContainerType(state)) { createContainerAllocationTask(state); } else if (isContainerNetworkType(state)) { if (!isPostAllocationOperation(state)) { createContainerNetworkAllocationTask(state); } else { createContainerNetworkProvisioningTask(state); } } else if (isContainerVolumeType(state)) { if (!isPostAllocationOperation(state)) { createContainerVolumeAllocationTask(state, null); } else { createContainerVolumeProvisioningTask(state); } } else if (isClosureType(state)) { if (!isPostAllocationOperation(state)) { createClosureAllocationTask(state); } else { createClosureProvisionTask(state); } } else if (isPKSClusterType(state)) { createPKSClusterProvisioningTask(state); } else { failTask(null, new LocalizableValidationException("Not supported resourceType: " + state.resourceType, "request.resource-type.not.supported", state.resourceType)); } }
private void createResourceOperation(RequestBrokerState state) { if (isContainerType(state)) { if (isRemoveOperation(state)) { createContainerRemovalTasks(state, false);