Search in sources :

Example 6 with WebApplication

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;
}
Also used : RootNode(org.opentosca.toscana.model.node.RootNode) Compute(org.opentosca.toscana.model.node.Compute) WebApplication(org.opentosca.toscana.model.node.WebApplication) HashSet(java.util.HashSet) RootRelationship(org.opentosca.toscana.model.relation.RootRelationship)

Example 7 with WebApplication

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");
    }
}
Also used : RootNode(org.opentosca.toscana.model.node.RootNode) MysqlDatabase(org.opentosca.toscana.model.node.MysqlDatabase) Compute(org.opentosca.toscana.model.node.Compute) Fn(com.scaleset.cfbuilder.core.Fn) WebApplication(org.opentosca.toscana.model.node.WebApplication)

Aggregations

WebApplication (org.opentosca.toscana.model.node.WebApplication)7 RootNode (org.opentosca.toscana.model.node.RootNode)5 Test (org.junit.Test)4 BaseUnitTest (org.opentosca.toscana.core.BaseUnitTest)4 EffectiveModel (org.opentosca.toscana.model.EffectiveModel)3 EffectiveModelFactory (org.opentosca.toscana.model.EffectiveModelFactory)3 EndpointCapability (org.opentosca.toscana.model.capability.EndpointCapability)2 Compute (org.opentosca.toscana.model.node.Compute)2 MysqlDatabase (org.opentosca.toscana.model.node.MysqlDatabase)2 RootRelationship (org.opentosca.toscana.model.relation.RootRelationship)2 Fn (com.scaleset.cfbuilder.core.Fn)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Entity (org.opentosca.toscana.core.parse.model.Entity)1 MappingEntity (org.opentosca.toscana.core.parse.model.MappingEntity)1 ScalarEntity (org.opentosca.toscana.core.parse.model.ScalarEntity)1 ServiceGraph (org.opentosca.toscana.core.parse.model.ServiceGraph)1 EntityId (org.opentosca.toscana.model.EntityId)1 Artifact (org.opentosca.toscana.model.artifact.Artifact)1