use of org.eclipse.winery.model.tosca.TDeploymentArtifact in project winery by eclipse.
the class DASpecificationTest method getNodesWithSuitableConcreteDAAndTheDirectlyConnectedNode.
@Test
public void getNodesWithSuitableConcreteDAAndTheDirectlyConnectedNode() throws Exception {
setRevisionTo("5f63267261584a513dd8a9b7960687cc3dda910a");
ServiceTemplateId id = new ServiceTemplateId("http://winery.opentosca.org/test/servicetemplates/ponyuniverse/daspecifier", "DASpecificationTest", false);
TTopologyTemplate topologyTemplate = this.repository.getElement(id).getTopologyTemplate();
assertNotNull(topologyTemplate);
TNodeTemplate nodeTemplateWithAbstractDA = topologyTemplate.getNodeTemplate("shetland_pony");
assertNotNull(nodeTemplateWithAbstractDA);
assertNotNull(nodeTemplateWithAbstractDA.getDeploymentArtifacts());
TDeploymentArtifact deploymentArtifact = nodeTemplateWithAbstractDA.getDeploymentArtifacts().get(0);
TNodeTemplate nodeTemplateConcreteDA1 = topologyTemplate.getNodeTemplate("dressageequipment");
TRelationshipTemplate relationshipTemplate1 = topologyTemplate.getRelationshipTemplate("con_42");
TNodeTemplate nodeTemplateConcreteDA2 = topologyTemplate.getNodeTemplate("westernequipment");
TRelationshipTemplate relationshipTemplate2 = topologyTemplate.getRelationshipTemplate("con_54");
Set<Pair<TRelationshipTemplate, TNodeTemplate>> concreteDAsAndConnectedNodes = new HashSet<>();
concreteDAsAndConnectedNodes.add(Pair.of(relationshipTemplate1, nodeTemplateConcreteDA1));
concreteDAsAndConnectedNodes.add(Pair.of(relationshipTemplate2, nodeTemplateConcreteDA2));
Set<Pair<TRelationshipTemplate, TNodeTemplate>> actualNodeWithConcreteDA = DASpecification.getNodesWithSuitableConcreteDAAndTheDirectlyConnectedNode(nodeTemplateWithAbstractDA, deploymentArtifact, topologyTemplate);
assertEquals(concreteDAsAndConnectedNodes, actualNodeWithConcreteDA);
}
use of org.eclipse.winery.model.tosca.TDeploymentArtifact in project winery by eclipse.
the class DASpecificationTest method getArtifactTypeOfDA.
@Test
public void getArtifactTypeOfDA() throws Exception {
setRevisionTo("af529e513388dc9358a8f700757d8dc59aba3a55");
ServiceTemplateId id = new ServiceTemplateId("http://winery.opentosca.org/test/servicetemplates/ponyuniverse/daspecifier", "DASpecificationTest", false);
TTopologyTemplate topologyTemplate = this.repository.getElement(id).getTopologyTemplate();
assertNotNull(topologyTemplate);
TNodeTemplate nodeTemplateWithAbstractDA = topologyTemplate.getNodeTemplate("shetland_pony");
assertNotNull(nodeTemplateWithAbstractDA);
assertNotNull(nodeTemplateWithAbstractDA.getDeploymentArtifacts());
TDeploymentArtifact deploymentArtifact = nodeTemplateWithAbstractDA.getDeploymentArtifacts().get(0);
QName artifactTypeQName = deploymentArtifact.getArtifactType();
ArtifactTypeId artifactTypeId = new ArtifactTypeId(artifactTypeQName);
TArtifactType artifactType = this.repository.getElement(artifactTypeId);
assertEquals(artifactType.getTargetNamespace(), DASpecification.getArtifactTypeOfDA(nodeTemplateWithAbstractDA.getDeploymentArtifacts().get(0)).getTargetNamespace());
assertEquals(artifactType.getName(), DASpecification.getArtifactTypeOfDA(nodeTemplateWithAbstractDA.getDeploymentArtifacts().get(0)).getName());
}
use of org.eclipse.winery.model.tosca.TDeploymentArtifact in project winery by eclipse.
the class DASpecificationTest method getNodesWithSuitableConcreteDAs.
@Test
public void getNodesWithSuitableConcreteDAs() throws Exception {
setRevisionTo("5f63267261584a513dd8a9b7960687cc3dda910a");
ServiceTemplateId id = new ServiceTemplateId("http://winery.opentosca.org/test/servicetemplates/ponyuniverse/daspecifier", "DASpecificationTest", false);
TTopologyTemplate topologyTemplate = this.repository.getElement(id).getTopologyTemplate();
assertNotNull(topologyTemplate);
TNodeTemplate nodeTemplate = topologyTemplate.getNodeTemplate("ponycompetition");
TNodeTemplate nodeTemplateWithAbstractDA = topologyTemplate.getNodeTemplate("shetland_pony");
assertNotNull(nodeTemplateWithAbstractDA);
assertNotNull(nodeTemplateWithAbstractDA.getDeploymentArtifacts());
TDeploymentArtifact deploymentArtifact = nodeTemplateWithAbstractDA.getDeploymentArtifacts().get(0);
TNodeTemplate expectedNodeTemplate = topologyTemplate.getNodeTemplate("dressageequipment");
TNodeTemplate actualNodeWithConcreteDA = DASpecification.getNodesWithSuitableConcreteDAs(nodeTemplate, deploymentArtifact, topologyTemplate);
assertEquals(expectedNodeTemplate, actualNodeWithConcreteDA);
}
use of org.eclipse.winery.model.tosca.TDeploymentArtifact in project winery by eclipse.
the class TopologyFragmentRefinement method applyDeploymentArtifactMapping.
private boolean applyDeploymentArtifactMapping(RefinementCandidate refinement, TNodeTemplate detectorNode, TNodeTemplate matchingNode, TTopologyTemplate topology, Map<String, String> idMapping) {
List<OTDeploymentArtifactMapping> deploymentArtifactMappings = ((OTTopologyFragmentRefinementModel) refinement.getRefinementModel()).getDeploymentArtifactMappings();
return matchingNode.getDeploymentArtifacts() == null || matchingNode.getDeploymentArtifacts().isEmpty() || (deploymentArtifactMappings != null && matchingNode.getDeploymentArtifacts().stream().filter(deploymentArtifact -> deploymentArtifact.getArtifactType() != null).allMatch(deploymentArtifact -> deploymentArtifactMappings.stream().filter(mapping -> mapping.getDetectorElement().getId().equals(detectorNode.getId())).anyMatch(mapping -> {
if (ModelUtilities.isOfType(mapping.getArtifactType(), deploymentArtifact.getArtifactType(), this.artifactTypes)) {
if (idMapping != null) {
TNodeTemplate addedNode = topology.getNodeTemplate(idMapping.get(mapping.getRefinementElement().getId()));
if (addedNode != null) {
List<TDeploymentArtifact> existingDAs = addedNode.getDeploymentArtifacts();
if (existingDAs == null) {
existingDAs = new ArrayList<>();
addedNode.setDeploymentArtifacts(existingDAs);
} else if (existingDAs.stream().anyMatch(da -> da.getName().equals(deploymentArtifact.getName()))) {
deploymentArtifact.setName(deploymentArtifact.getName() + UUID.randomUUID());
}
existingDAs.add(deploymentArtifact);
} else {
LOGGER.error("Error while adding Deployment Artifacts! Node was not added to the topology!");
}
}
return true;
}
return false;
})));
}
use of org.eclipse.winery.model.tosca.TDeploymentArtifact in project container by OpenTOSCA.
the class BPELPrePhasePlugin method canHandleCreate.
@Override
public boolean canHandleCreate(BPELPlanContext context, final TNodeTemplate nodeTemplate) {
LOG.debug("Checking if DAs of node template {} can be deployed", nodeTemplate.getId());
// Find infrastructures of this node and check if we can deploy all of its DA's
if (nodeTemplate.getDeploymentArtifacts() == null) {
// No DAs = we can work with that
return true;
}
for (final TDeploymentArtifact da : nodeTemplate.getDeploymentArtifacts()) {
if (getDeployableInfrastructureNode(nodeTemplate, da, context.getCsar()) == null) {
LOG.debug("DAs of node template {} can't be deployed", nodeTemplate.getId());
return false;
}
}
LOG.debug("DAs of node template {} can be deployed", nodeTemplate.getId());
return true;
}
Aggregations