/** * Process default deployment properties * * @param deploymentTopology the deployment setup to generate configuration for */ public void processProviderDeploymentProperties(DeploymentTopology deploymentTopology) { if (deploymentTopology.getOrchestratorId() == null) { // No orchestrator assigned for the topology do nothing return; } Map<String, PropertyDefinition> propertyDefinitionMap = orchestratorDeploymentService.getDeploymentPropertyDefinitions( deploymentTopology.getOrchestratorId()); if (propertyDefinitionMap != null) { // Reset deployment properties as it might have changed between cloud Map<String, String> propertyValueMap = deploymentTopology.getProviderDeploymentProperties(); if (propertyValueMap == null) { propertyValueMap = Maps.newHashMap(); } else { Iterator<Map.Entry<String, String>> propertyValueMapIterator = propertyValueMap.entrySet().iterator(); while (propertyValueMapIterator.hasNext()) { Map.Entry<String, String> entry = propertyValueMapIterator.next(); if (!propertyDefinitionMap.containsKey(entry.getKey())) { // Remove the mapping if topology do not contain the node with that name and of type // compute // Or the mapping do not exist anymore in the match result propertyValueMapIterator.remove(); } } } for (Map.Entry<String, PropertyDefinition> propertyDefinitionEntry : propertyDefinitionMap.entrySet()) { String existingValue = propertyValueMap.get(propertyDefinitionEntry.getKey()); if (existingValue != null) { try { constraintPropertyService.checkSimplePropertyConstraint( propertyDefinitionEntry.getKey(), existingValue, propertyDefinitionEntry.getValue()); } catch (ConstraintViolationException | ConstraintValueDoNotMatchPropertyTypeException e) { propertyValueMap.put( propertyDefinitionEntry.getKey(), propertyDefinitionEntry.getValue().getDefault()); } } else if (propertyDefinitionEntry.getValue().getDefault() != null) { propertyValueMap.put( propertyDefinitionEntry.getKey(), propertyDefinitionEntry.getValue().getDefault()); } } deploymentTopology.setProviderDeploymentProperties(propertyValueMap); } }