use of alien4cloud.topology.task.PropertiesTask in project alien4cloud by alien4cloud.
the class DeploymentTopologyValidationService method validateProcessedDeploymentTopology.
/**
* Perform validation of a deployment topology where all inputs have been processed.
*
* @param topology The deployment topology to check.
* @return A DeploymentTopologyValidationResult with a list of errors and/or warnings er steps.
*/
public TopologyValidationResult validateProcessedDeploymentTopology(Topology topology, DeploymentMatchingConfiguration matchingConfiguration, OrchestratorDeploymentProperties orchestratorDeploymentProperties) {
TopologyValidationResult dto = new TopologyValidationResult();
if (topology.getNodeTemplates() == null || topology.getNodeTemplates().size() < 1) {
dto.setValid(false);
return dto;
}
// Node filters validation is performed twice, once at the editor times to check that the edition does not contains any values that breaks filters
// And one post matching (below) after all properties are filled-in (inputs and location provided).
dto.addTasks(nodeFilterValidationService.validateAllRequirementFilters(topology));
// Display warning if operations from the topology are overriden by service provided operations.
dto.addWarnings(topologyServiceInterfaceOverrideCheckerService.findWarnings(topology));
// validate workflows
dto.addTasks(workflowBuilderService.validateWorkflows(topology));
// validate abstract node types
dto.addTasks(topologyAbstractNodeValidationService.findReplacementForAbstracts(topology, matchingConfiguration.getMatchedLocationResources()));
// TODO Perform here validation of policies
// If a policy is not matched on the location this is a warning as we allow deployment but some features may be missing
// If a policy requires a configuration or cannot be applied du to any reason the policy implementation itself can trigger some errors (see Orchestrator
// plugins)
// validate required properties (properties of NodeTemplate, Relationship and Capability)
// check also location / ENVIRONMENT meta properties
List<PropertiesTask> validateProperties = topologyPropertiesValidationService.validateAllProperties(topology);
// validate orchestrator properties
PropertiesTask orchestratorValidation = orchestratorPropertiesValidationService.validate(orchestratorDeploymentProperties);
if (orchestratorValidation != null) {
dto.addTasks(Lists.newArrayList(orchestratorValidation));
}
if (TopologyValidationService.hasOnlyPropertiesWarnings(validateProperties)) {
dto.addWarnings(validateProperties);
} else {
dto.addTasks(validateProperties);
}
dto.setValid(TopologyValidationService.isValidTaskList(dto.getTaskList()));
return dto;
}
use of alien4cloud.topology.task.PropertiesTask in project alien4cloud by alien4cloud.
the class InputValidationModifier method process.
/**
* Validate all required input is provided with a non null value.
*
* @param topology The topology to process.
* @param context The object that stores warnings and errors (tasks) associated with the execution flow. Note that the flow will end-up if an error
*/
@Override
public void process(Topology topology, FlowExecutionContext context) {
Optional<DeploymentInputs> inputsOptional = context.getConfiguration(DeploymentInputs.class, InputValidationModifier.class.getSimpleName());
PreconfiguredInputsConfiguration preconfiguredInputsConfiguration = context.getConfiguration(PreconfiguredInputsConfiguration.class, InputValidationModifier.class.getSimpleName()).orElseThrow(() -> new IllegalStateException("PreconfiguredInputsConfiguration must be in the context"));
// Define a task regarding properties
PropertiesTask task = new PropertiesTask();
task.setCode(TaskCode.INPUT_PROPERTY);
task.setProperties(Maps.newHashMap());
task.getProperties().put(TaskLevel.REQUIRED, Lists.newArrayList());
Map<String, AbstractPropertyValue> inputValues = safe(inputsOptional.orElse(new DeploymentInputs()).getInputs());
Map<String, PropertyValue> predefinedInputValues = safe(preconfiguredInputsConfiguration.getInputs());
// override deployer inputValues with predefinedInputValues
inputValues = Maps.newHashMap(inputValues);
inputValues.putAll(predefinedInputValues);
for (Entry<String, PropertyDefinition> propDef : safe(topology.getInputs()).entrySet()) {
if (propDef.getValue().isRequired() && inputValues.get(propDef.getKey()) == null) {
task.getProperties().get(TaskLevel.REQUIRED).add(propDef.getKey());
}
}
if (CollectionUtils.isNotEmpty(task.getProperties().get(TaskLevel.REQUIRED))) {
context.log().error(task);
}
// Check input artifacts
deploymentInputArtifactValidationService.validate(topology, inputsOptional.orElse(new DeploymentInputs())).forEach(inputArtifactTask -> context.log().error(inputArtifactTask));
}
use of alien4cloud.topology.task.PropertiesTask in project alien4cloud by alien4cloud.
the class DeploymentSetupValidationStepDefinitions method theMissingOrchestratorPropertiesShouldBe.
@And("^the missing orchestrator properties should be$")
public void theMissingOrchestratorPropertiesShouldBe(List<String> expectedInvalidOrchestratorProperties) throws Throwable {
TopologyValidationResult topologyValidationResult = JsonUtil.read(Context.getInstance().getRestResponse(), DeploymentTopologyDTO.class, Context.getJsonMapper()).getData().getValidation();
for (String expectedInvalidProp : expectedInvalidOrchestratorProperties) {
boolean missingFound = topologyValidationResult.getTaskList().stream().anyMatch(task -> task.getCode().equals(TaskCode.ORCHESTRATOR_PROPERTY) && ((PropertiesTask) task).getProperties().get(TaskLevel.REQUIRED).contains(expectedInvalidProp));
Assert.assertTrue(expectedInvalidProp + " does not appear in invalid orchestrators properties task list for the deployment topology", missingFound);
}
}
Aggregations