Search in sources :

Example 61 with NodeType

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;
}
Also used : NodeType(org.alien4cloud.tosca.model.types.NodeType)

Example 62 with NodeType

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;
}
Also used : NodeTemplate(org.alien4cloud.tosca.model.templates.NodeTemplate) NodeType(org.alien4cloud.tosca.model.types.NodeType) Map(java.util.Map)

Example 63 with NodeType

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;
}
Also used : NodeType(org.alien4cloud.tosca.model.types.NodeType) DeprecatedNodeTask(alien4cloud.topology.task.DeprecatedNodeTask)

Example 64 with NodeType

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);
            }
        }
    }
}
Also used : RelationshipTemplate(org.alien4cloud.tosca.model.templates.RelationshipTemplate) NodeTemplate(org.alien4cloud.tosca.model.templates.NodeTemplate) NodeType(org.alien4cloud.tosca.model.types.NodeType) RequirementDefinition(org.alien4cloud.tosca.model.definitions.RequirementDefinition) Map(java.util.Map) NodeFilterToSatisfy(alien4cloud.topology.task.NodeFilterToSatisfy) NodeFilter(org.alien4cloud.tosca.model.definitions.NodeFilter)

Example 65 with NodeType

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;
}
Also used : NodeTemplate(org.alien4cloud.tosca.model.templates.NodeTemplate) PropertiesTask(alien4cloud.topology.task.PropertiesTask) NodeType(org.alien4cloud.tosca.model.types.NodeType) Map(java.util.Map)

Aggregations

NodeType (org.alien4cloud.tosca.model.types.NodeType)156 NodeTemplate (org.alien4cloud.tosca.model.templates.NodeTemplate)50 Test (org.junit.Test)44 ArchiveRoot (alien4cloud.tosca.model.ArchiveRoot)26 Set (java.util.Set)26 RelationshipType (org.alien4cloud.tosca.model.types.RelationshipType)23 CapabilityType (org.alien4cloud.tosca.model.types.CapabilityType)22 Map (java.util.Map)19 Csar (org.alien4cloud.tosca.model.Csar)19 CapabilityDefinition (org.alien4cloud.tosca.model.definitions.CapabilityDefinition)16 HashMap (java.util.HashMap)15 PropertyDefinition (org.alien4cloud.tosca.model.definitions.PropertyDefinition)15 LocationResourceTemplate (alien4cloud.model.orchestrators.locations.LocationResourceTemplate)14 RequirementDefinition (org.alien4cloud.tosca.model.definitions.RequirementDefinition)14 Topology (org.alien4cloud.tosca.model.templates.Topology)9 NotFoundException (alien4cloud.exception.NotFoundException)8 Capability (org.alien4cloud.tosca.model.templates.Capability)8 RelationshipTemplate (org.alien4cloud.tosca.model.templates.RelationshipTemplate)8 MatchingConfiguration (alien4cloud.model.deployment.matching.MatchingConfiguration)7 AbstractPropertyValue (org.alien4cloud.tosca.model.definitions.AbstractPropertyValue)7