use of org.alien4cloud.tosca.model.types.NodeType in project alien4cloud by alien4cloud.
the class TopologyServiceCore method getIndexedNodeTypesFromTopology.
/**
* Get the indexed node types used in a topology.
*
* @param topology The topology for which to get indexed node types.
* @param abstractOnly If true, only abstract types will be retrieved.
* @param useTemplateNameAsKey If true the name of the node template will be used as key for the type in the returned map, if not the type will be used as
* key.
* @param failOnTypeNotFound
* @return A map of indexed node types.
*/
public Map<String, NodeType> getIndexedNodeTypesFromTopology(Topology topology, boolean abstractOnly, boolean useTemplateNameAsKey, boolean failOnTypeNotFound) {
Map<String, NodeType> nodeTypeMap = getIndexedNodeTypesFromDependencies(topology.getNodeTemplates(), topology.getDependencies(), abstractOnly, useTemplateNameAsKey, failOnTypeNotFound);
if (!useTemplateNameAsKey && topology.getSubstitutionMapping() != null && topology.getSubstitutionMapping().getSubstitutionType() != null) {
NodeType nodeType = getFromContextIfDefined(NodeType.class, topology.getSubstitutionMapping().getSubstitutionType(), topology.getDependencies(), failOnTypeNotFound);
nodeTypeMap.put(topology.getSubstitutionMapping().getSubstitutionType(), nodeType);
}
return nodeTypeMap;
}
use of org.alien4cloud.tosca.model.types.NodeType in project alien4cloud by alien4cloud.
the class TopologyServiceCore method getIndexedNodeTypesFromDependencies.
private Map<String, NodeType> getIndexedNodeTypesFromDependencies(Map<String, NodeTemplate> nodeTemplates, Set<CSARDependency> dependencies, boolean abstractOnly, boolean useTemplateNameAsKey, boolean failOnTypeNotFound) {
Map<String, NodeType> nodeTypes = Maps.newHashMap();
if (nodeTemplates == null) {
return nodeTypes;
}
for (Map.Entry<String, NodeTemplate> template : nodeTemplates.entrySet()) {
if (!nodeTypes.containsKey(template.getValue().getType())) {
NodeType nodeType = getFromContextIfDefined(NodeType.class, template.getValue().getType(), dependencies, failOnTypeNotFound);
if (!abstractOnly || nodeType.isAbstract()) {
String key = useTemplateNameAsKey ? template.getKey() : template.getValue().getType();
nodeTypes.put(key, nodeType);
}
}
}
return nodeTypes;
}
use of org.alien4cloud.tosca.model.types.NodeType in project alien4cloud by alien4cloud.
the class DeprecatedNodeTypesValidationService method validate.
public List<DeprecatedNodeTask> validate(Topology topology) {
List<DeprecatedNodeTask> taskList = Lists.newArrayList();
topology.getNodeTemplates().forEach((nodeTemplateName, nodeTemplate) -> {
NodeType type = ToscaContext.get(NodeType.class, nodeTemplate.getType());
if (isDeprecated(type)) {
taskList.add(new DeprecatedNodeTask(nodeTemplateName, type));
}
});
return taskList;
}
use of org.alien4cloud.tosca.model.types.NodeType in project alien4cloud by alien4cloud.
the class NodeFilterValidationService method validateFiltersForNode.
private void validateFiltersForNode(NodeType sourceNodeType, Map<String, RelationshipTemplate> relationshipsMap, Topology topology, Map<String, NodeType> nodeTypes, Map<String, CapabilityType> capabilityTypes, NodeFiltersTask task, boolean skipInputs) {
Map<String, RequirementDefinition> requirementDefinitionMap = getRequirementsAsMap(sourceNodeType);
for (Map.Entry<String, RelationshipTemplate> relationshipEntry : relationshipsMap.entrySet()) {
RequirementDefinition requirementDefinition = requirementDefinitionMap.get(relationshipEntry.getValue().getRequirementName());
NodeFilter nodeFilter = requirementDefinition.getNodeFilter();
if (nodeFilter != null) {
NodeTemplate targetNode = topology.getNodeTemplates().get(relationshipEntry.getValue().getTarget());
NodeType targetType = nodeTypes.get(relationshipEntry.getValue().getTarget());
NodeFilterToSatisfy nodeFilterToSatisfy = new NodeFilterToSatisfy();
nodeFilterToSatisfy.setRelationshipName(relationshipEntry.getKey());
nodeFilterToSatisfy.setTargetName(targetNode.getName());
nodeFilterToSatisfy.setMissingCapabilities(Lists.<String>newArrayList());
nodeFilterToSatisfy.setViolations(Lists.<Violations>newArrayList());
validateNodeFilter(nodeFilter, targetNode, targetType, capabilityTypes, nodeFilterToSatisfy, skipInputs);
if (!nodeFilterToSatisfy.getViolations().isEmpty() || !nodeFilterToSatisfy.getMissingCapabilities().isEmpty()) {
task.getNodeFiltersToSatisfy().add(nodeFilterToSatisfy);
}
}
}
}
use of org.alien4cloud.tosca.model.types.NodeType in project alien4cloud by alien4cloud.
the class TopologyPropertiesValidationService method validateProperties.
/**
* Validate properties.
*
* @param topology
* @param skipInputProperties whether to skip input properties validation or not. This is in case inputs are not yet processed
* @return
*/
private List<PropertiesTask> validateProperties(Topology topology, boolean skipInputProperties) {
List<PropertiesTask> toReturnTaskList = Lists.newArrayList();
Map<String, NodeTemplate> nodeTemplates = topology.getNodeTemplates();
// create task by nodetemplate
for (Map.Entry<String, NodeTemplate> nodeTempEntry : nodeTemplates.entrySet()) {
NodeTemplate nodeTemplate = nodeTempEntry.getValue();
NodeType relatedIndexedNodeType = ToscaContext.get(NodeType.class, nodeTemplate.getType());
// do pass if abstract node
if (relatedIndexedNodeType.isAbstract()) {
continue;
}
validateNodeTemplate(toReturnTaskList, relatedIndexedNodeType, nodeTemplate, nodeTempEntry.getKey(), skipInputProperties);
}
return toReturnTaskList.isEmpty() ? null : toReturnTaskList;
}
Aggregations