use of org.opentosca.toscana.model.relation.ConnectsTo in project TOSCAna by StuPro-TOSCAna.
the class ServiceGraphTest method requirementTest.
@Test
public void requirementTest() {
currentFile = REQUIREMENT;
Optional<Entity> fulfiller = getGraph().getEntity(Lists.newArrayList("topology_template", "node_templates", "test-node", "requirements", "test-requirement1", "node"));
assertTrue(fulfiller.isPresent());
Optional<Entity> fulfiller2 = getGraph().getEntity(Lists.newArrayList("topology_template", "node_templates", "test-node", "requirements", "test-requirement2", "node"));
assertTrue(fulfiller2.isPresent());
MappingEntity capabilityEntity = (MappingEntity) getGraph().getEntity(new EntityId(Lists.newArrayList("topology_template", "node_templates", "test-node", "requirements", "test-requirement2", "capability"))).get();
DatabaseEndpointCapability capability = TypeWrapper.wrapTypedElement(capabilityEntity);
assertNotNull(capability);
MappingEntity relationshipEntity = (MappingEntity) getGraph().getEntity(new EntityId(Lists.newArrayList("topology_template", "node_templates", "test-node", "requirements", "test-requirement2", "relationship"))).get();
ConnectsTo relationship = TypeWrapper.wrapTypedElement(relationshipEntity);
assertNotNull(relationship);
assertEquals(Lists.newArrayList("1", "2"), getList("topology_template", "node_templates", "test-node", "requirements", "test-requirement2", "occurrences"));
}
use of org.opentosca.toscana.model.relation.ConnectsTo in project TOSCAna by StuPro-TOSCAna.
the class DockerfileBuildingVisitor method handleDefault.
/**
* This method implements the default node transformation behaviour. This means, the
* exectuion of scripts implements the functionality thats expected from the node.
*/
private void handleDefault(RootNode node, String[] ignoredLifecycles) {
try {
Map<NodeStack, String> address = new HashMap<>();
// Add the ports exposed by the node to the ports list
node.getCapabilities().forEach(e -> {
try {
if (e instanceof EndpointCapability) {
if (((EndpointCapability) e).getPort().isPresent()) {
ports.add(((EndpointCapability) e).getPort().get().port);
}
}
} catch (Exception ex) {
logger.warn("Failed reading Port from node {}", node.getEntityName(), ex);
}
});
// name. We therefore have to set this to 127.0.0.1 ('localhost' causes issues too)
for (Requirement e : node.getRequirements()) {
if (e.getRelationship().isPresent() && e.getRelationship().get() instanceof ConnectsTo) {
for (Object o : e.getFulfillers()) {
if (o instanceof RootNode) {
NodeStack targetStack = this.connectionGraph.vertexSet().stream().filter(ek -> ek.hasNode((RootNode) o)).findFirst().orElse(null);
if (targetStack != null && targetStack.getComputeNode() == this.stack.getComputeNode()) {
address.put(this.stack, this.stack.getComputeNode().getPrivateAddress().orElse(null));
this.stack.getComputeNode().setPrivateAddress(IPV4_LOCAL_ADDRESS);
}
}
}
}
}
// Add the scripts from the lifecycle to the Dockerfile
addLifecycleOperationsToDockerfile(node.getEntityName(), node.getStandardLifecycle(), ignoredLifecycles);
// Reset to original address
address.forEach((k, v) -> {
k.getComputeNode().setPrivateAddress(v);
});
} catch (IOException e) {
throw new UnsupportedOperationException("Transformation failed while copying artifacts", e);
}
}
Aggregations