use of org.opentosca.toscana.model.node.RootNode in project TOSCAna by StuPro-TOSCAna.
the class CloudFormationVisitorExtension method getHostsOfConnectedTo.
protected Set<Compute> getHostsOfConnectedTo(RootNode node) {
Set<Compute> connected = new HashSet<>();
Set<RootRelationship> incomingEdges = topology.incomingEdgesOf(node);
for (RootRelationship incomingEdge : incomingEdges) {
RootNode source = topology.getEdgeSource(incomingEdge);
if (source instanceof WebApplication) {
WebApplication webApplication = (WebApplication) source;
Compute compute = getCompute(webApplication);
connected.add(compute);
}
}
return connected;
}
use of org.opentosca.toscana.model.node.RootNode in project TOSCAna by StuPro-TOSCAna.
the class PrepareModelRelationshipVisitor method visit.
@Override
public void visit(ConnectsTo relation) {
RootNode source = topology.getEdgeSource(relation);
RootNode target = topology.getEdgeTarget(relation);
if (source instanceof WebApplication && target instanceof MysqlDatabase) {
MysqlDatabase mysqlDatabase = (MysqlDatabase) target;
WebApplication webApplication = (WebApplication) source;
// if they are hosted on the same compute --> we can set the compute private address to
Compute computeMysqlDatabase = getCompute(mysqlDatabase);
Compute computeWebApplication = getCompute(webApplication);
if (computeMysqlDatabase.equals(computeWebApplication)) {
// means we can set the private address as reference to the database endpoint
Fn databaseEndpointFn = Fn.fnGetAtt(toAlphanumerical(mysqlDatabase.getEntityName()), AWS_ENDPOINT_REFERENCE);
String databaseEndpoint = databaseEndpointFn.toString(true);
cfnModule.putFn(databaseEndpoint, databaseEndpointFn);
computeMysqlDatabase.setPrivateAddress(databaseEndpoint);
computeMysqlDatabase.setPublicAddress(databaseEndpoint);
logger.debug("Set private address and public address of '{}' to reference MysqlDatabase '{}'", computeMysqlDatabase.getEntityName(), mysqlDatabase.getEntityName());
} else {
logger.debug("Cannot safely set private/public address of '{}'", computeMysqlDatabase.getEntityName());
}
} else {
logger.debug("Drop relationship, because it is not supported");
}
}
use of org.opentosca.toscana.model.node.RootNode in project TOSCAna by StuPro-TOSCAna.
the class CloudFoundryLifecycle method prepare.
@Override
public void prepare() {
logger.info("Begin preparation for transformation to Cloud Foundry");
PrepareVisitor prepareVisitor = new PrepareVisitor(logger);
for (RootNode node : context.getModel().getNodes()) {
node.accept(prepareVisitor);
}
logger.debug("Collecting Compute Nodes in topology");
ComputeNodeFindingVisitor computeFinder = new ComputeNodeFindingVisitor();
model.getNodes().forEach(e -> {
e.accept(computeFinder);
KubernetesNodeContainer container = new KubernetesNodeContainer(e);
nodes.put(e.getEntityName(), container);
});
computeFinder.getComputeNodes().forEach(e -> computeNodes.add(nodes.get(e.getEntityName())));
logger.debug("Finding top Level Nodes");
graph = model.getTopology();
Set<RootNode> topLevelNodes = determineTopLevelNodes(context.getModel(), computeFinder.getComputeNodes().stream().map(Compute.class::cast).collect(Collectors.toList()), e -> nodes.get(e.getEntityName()).activateParentComputeNode());
logger.debug("Building complete Topology stacks");
this.stacks.addAll(buildTopologyStacks(model, topLevelNodes, nodes));
// TODO: check how many different applications there are and fill list with them
// probably there must be a combination of application and set of nodes
applications = new ArrayList<>();
int i = 1;
for (NodeStack stack : stacks) {
Application myApp = new Application(i, context);
i++;
myApp.setProvider(provider);
myApp.setConnection(connection);
myApp.setName(stack.getStackName());
myApp.addStack(stack);
applications.add(myApp);
}
}
use of org.opentosca.toscana.model.node.RootNode in project TOSCAna by StuPro-TOSCAna.
the class EffectiveModel method initEdges.
private void initEdges() {
logger.info("Populating edges");
for (RootNode node : topology.vertexSet()) {
for (Requirement<?, ?, ?> requirement : node.getRequirements()) {
Set<? extends RootNode> fulfillers = requirement.getFulfillers();
for (RootNode fulfiller : fulfillers) {
RootRelationship relationship = requirement.get(requirement.RELATIONSHIP);
logger.info(LogFormat.pointAt(1, 25, node.getEntityName(), relationship.getClass().getSimpleName(), fulfiller.getEntityName()));
topology.addEdge(node, fulfiller, relationship);
}
}
}
initialized = true;
}
use of org.opentosca.toscana.model.node.RootNode in project TOSCAna by StuPro-TOSCAna.
the class LinkResolver method resolveImplementationArtifacts.
private static void resolveImplementationArtifacts(ServiceGraph graph) {
logger.debug(LogFormat.indent(1, "artifacts"));
Map<String, RootNode> nodes = new TypeWrapper().wrapNodes(graph);
for (RootNode node : nodes.values()) {
for (Interface thisInterface : node.getInterfaces()) {
for (Operation operation : thisInterface.getOperations()) {
Optional<Artifact> optionalArtifact = operation.getArtifact();
if (optionalArtifact.isPresent()) {
Artifact operationArtifact = optionalArtifact.get();
for (Artifact nodeArtifact : node.getArtifacts()) {
if (operationArtifact.getFilePath().equals(nodeArtifact.getEntityName())) {
graph.replaceEntity(operationArtifact.getBackingEntity(), nodeArtifact.getBackingEntity());
logger.debug(LogFormat.pointAt(2, operationArtifact.getBackingEntity().getId(), nodeArtifact.getBackingEntity().getId()));
// at this point it's obvious: we need a better solution for navigating the service graph...
}
}
}
}
}
}
}
Aggregations