use of org.opentosca.toscana.model.node.WebApplication 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.WebApplication 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");
}
}
Aggregations