use of org.opentosca.toscana.model.requirement.Requirement 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