use of org.alien4cloud.tosca.model.definitions.RequirementDefinition in project alien4cloud by alien4cloud.
the class EsDaoCrudTest method prepareToscaElement.
private void prepareToscaElement() {
List<CapabilityDefinition> capa = Arrays.asList(new CapabilityDefinition("container", "container", 1), new CapabilityDefinition("container1", "container1", 1), new CapabilityDefinition("container2", "container2", 1), new CapabilityDefinition("container3", "container3", 1));
List<RequirementDefinition> req = Arrays.asList(new RequirementDefinition("Runtime", "Runtime"), new RequirementDefinition("server", "server"), new RequirementDefinition("blob", "blob"));
List<String> der = Arrays.asList("Parent1", "Parent2");
indexedNodeTypeTest = TestModelUtil.createIndexedNodeType("1", "positive", "1.0", "", capa, req, der, new ArrayList<String>(0), threeTags, new Date(), new Date());
}
use of org.alien4cloud.tosca.model.definitions.RequirementDefinition in project alien4cloud by alien4cloud.
the class EsDaoSearchTest method prepareToscaElement.
private void prepareToscaElement() {
List<CapabilityDefinition> capa = Arrays.asList(new CapabilityDefinition("container", "container", 1), new CapabilityDefinition("container1", "container1", 1), new CapabilityDefinition("container2", "container2", 1), new CapabilityDefinition("container3", "container3", 1), new CapabilityDefinition("war", "war", 1));
List<RequirementDefinition> req = Arrays.asList(new RequirementDefinition("Runtime", "Runtime"), new RequirementDefinition("server", "server"), new RequirementDefinition("blob", "blob"));
List<String> der = Arrays.asList("Parent1", "Parent2");
indexedNodeTypeTest = TestModelUtil.createIndexedNodeType("1", "positive", "1.0", "", capa, req, der, new ArrayList<String>(), threeTags, new Date(), new Date());
dataTest.add(indexedNodeTypeTest);
capa = Arrays.asList(new CapabilityDefinition("banana", "banana", 1), new CapabilityDefinition("banana1", "banana1", 1), new CapabilityDefinition("container", "container", 1), new CapabilityDefinition("banana3", "banana3", 1), new CapabilityDefinition("zar", "zar", 1));
req = Arrays.asList(new RequirementDefinition("Pant", "Pant"), new RequirementDefinition("DBZ", "DBZ"), new RequirementDefinition("Animes", "Animes"));
der = Arrays.asList("Songoku", "Kami");
indexedNodeTypeTest2 = TestModelUtil.createIndexedNodeType("2", "pokerFace", "1.0", "", capa, req, der, new ArrayList<String>(), threeTags, new Date(), new Date());
dataTest.add(indexedNodeTypeTest2);
capa = Arrays.asList(new CapabilityDefinition("potatoe", "potatoe", 1), new CapabilityDefinition("potatoe2", "potatoe2", 1), new CapabilityDefinition("potatoe3", "potatoe3", 1), new CapabilityDefinition("potatoe4", "potatoe4", 1), new CapabilityDefinition("zor", "zor", 1));
req = Arrays.asList(new RequirementDefinition("OnePiece", "OnePiece"), new RequirementDefinition("beelzebub", "beelzebub"), new RequirementDefinition("DBGT", "DBGT"));
der = Arrays.asList("Jerome", "Sandrini");
indexedNodeTypeTest3 = TestModelUtil.createIndexedNodeType("3", "nagative", "1.5", "", capa, req, der, new ArrayList<String>(), threeTags, new Date(), new Date());
dataTest.add(indexedNodeTypeTest3);
capa = Arrays.asList(new CapabilityDefinition("yams", "yams", 1), new CapabilityDefinition("yams1", "yams1", 1), new CapabilityDefinition("positiveYes", "positiveYes", 1), new CapabilityDefinition("yams3", "yams3", 1), new CapabilityDefinition("war world", "war world", 1));
req = Arrays.asList(new RequirementDefinition("Naruto", "Naruto"), new RequirementDefinition("FT", "FT"), new RequirementDefinition("Bleach", "Bleach"));
der = Arrays.asList("Luc", "Boutier");
indexedNodeTypeTest4 = TestModelUtil.createIndexedNodeType("4", "pokerFace", "2.0", "", capa, req, der, new ArrayList<String>(), threeTags, new Date(), new Date());
dataTest.add(indexedNodeTypeTest4);
}
use of org.alien4cloud.tosca.model.definitions.RequirementDefinition in project alien4cloud by alien4cloud.
the class ReplaceNodeProcessor method updateRelationshipsCapabilitiesRelationships.
private void updateRelationshipsCapabilitiesRelationships(Topology topology, NodeTemplate nodeTemplate) {
List<RelationshipEntry> targetRelationships = TopologyUtils.getTargetRelationships(nodeTemplate.getName(), topology.getNodeTemplates());
for (RelationshipEntry targetRelationshipEntry : targetRelationships) {
RelationshipTemplate targetRelationship = targetRelationshipEntry.getRelationship();
Capability capability = safe(nodeTemplate.getCapabilities()).get(targetRelationship.getTargetedCapabilityName());
if (capability == null || isCapabilityNotOfType(capability, targetRelationship.getRequirementType())) {
Entry<String, Capability> capabilityEntry = NodeTemplateUtils.getCapabilitEntryyByType(nodeTemplate, targetRelationship.getRequirementType());
targetRelationship.setTargetedCapabilityName(capabilityEntry.getKey());
// check that the relationship type is still valid with the new capability
RelationshipType relationshipType = ToscaContext.get(RelationshipType.class, targetRelationship.getType());
if (!isValidRelationship(relationshipType, capabilityEntry.getValue())) {
NodeType sourceNodeType = ToscaContext.get(NodeType.class, targetRelationshipEntry.getSource().getType());
RequirementDefinition requirementDefinition = NodeTypeUtils.getRequirementById(sourceNodeType, targetRelationshipEntry.getRelationship().getRequirementName());
NodeType targetNodeType = ToscaContext.get(NodeType.class, nodeTemplate.getType());
CapabilityDefinition capabilityDefinition = NodeTypeUtils.getCapabilityById(targetNodeType, capabilityEntry.getKey());
RelationshipType validRelationshipType = danglingRequirementService.fetchValidRelationshipType(requirementDefinition, capabilityDefinition);
targetRelationship.setType(validRelationshipType.getElementId());
targetRelationship.setType(validRelationshipType.getElementId());
targetRelationship.setArtifacts(newLinkedHashMap(safe(validRelationshipType.getArtifacts())));
targetRelationship.setAttributes(newLinkedHashMap(safe(validRelationshipType.getAttributes())));
Map<String, AbstractPropertyValue> properties = new LinkedHashMap();
TemplateBuilder.fillProperties(properties, validRelationshipType.getProperties(), null);
targetRelationship.setProperties(properties);
}
}
}
}
use of org.alien4cloud.tosca.model.definitions.RequirementDefinition in project alien4cloud by alien4cloud.
the class TopologySubstitutionService method buildSubstituteNodeType.
private NodeType buildSubstituteNodeType(Topology topology, Csar csar, NodeType nodeType) {
NodeType substituteNodeType = new NodeType();
substituteNodeType.setArchiveName(csar.getName());
substituteNodeType.setArchiveVersion(csar.getVersion());
substituteNodeType.setElementId(csar.getName());
substituteNodeType.setDerivedFrom(Lists.newArrayList(nodeType.getElementId()));
substituteNodeType.setSubstitutionTopologyId(topology.getId());
substituteNodeType.setWorkspace(topology.getWorkspace());
List<CapabilityDefinition> capabilities = Lists.newArrayList();
substituteNodeType.setCapabilities(capabilities);
List<RequirementDefinition> requirements = Lists.newArrayList();
substituteNodeType.setRequirements(requirements);
substituteNodeType.setAttributes(Maps.newHashMap());
return substituteNodeType;
}
use of org.alien4cloud.tosca.model.definitions.RequirementDefinition in project alien4cloud by alien4cloud.
the class ToscaWithDependenciesBuilder method buildNodeTypeWithDependencies.
private TypeWithDependenciesResult buildNodeTypeWithDependencies(NodeType nodeType) {
TypeWithDependenciesResult result = new TypeWithDependenciesResult();
result.setToscaType(nodeType);
for (CapabilityDefinition capabilityDefinition : nodeType.getCapabilities()) {
result.add(ToscaContext.getOrFail(CapabilityType.class, capabilityDefinition.getType()));
}
for (RequirementDefinition requirementDefinition : nodeType.getRequirements()) {
CapabilityType capabilityType = ToscaContext.get(CapabilityType.class, requirementDefinition.getType());
if (capabilityType != null) {
result.add(capabilityType);
} else {
// requirements are authorized to be a node type rather than a capability type TODO is it still possible in TOSCA ?
result.add(ToscaContext.get(NodeType.class, requirementDefinition.getType()));
}
}
result.setDependencies(ToscaContext.get().getDependencies());
// Fetch data types for the given type
DataTypesFetcher.getDataTypesDependencies(Collections.singleton(nodeType), ToscaContext::get).values().forEach(result::add);
return result;
}
Aggregations