Search in sources :

Example 1 with UnsupportedTypeException

use of org.opentosca.toscana.model.visitor.UnsupportedTypeException in project TOSCAna by StuPro-TOSCAna.

the class CheckModelRelationshipVisitor method visit.

@Override
public void visit(ConnectsTo relation) {
    RootNode source = topology.getEdgeSource(relation);
    RootNode target = topology.getEdgeTarget(relation);
    if (!(source instanceof WebApplication && target instanceof Database)) {
        throw new UnsupportedTypeException("ConnectsTo relationship from source: " + source + " to target: " + target + " not supported.");
    }
}
Also used : RootNode(org.opentosca.toscana.model.node.RootNode) Database(org.opentosca.toscana.model.node.Database) UnsupportedTypeException(org.opentosca.toscana.model.visitor.UnsupportedTypeException) WebApplication(org.opentosca.toscana.model.node.WebApplication)

Example 2 with UnsupportedTypeException

use of org.opentosca.toscana.model.visitor.UnsupportedTypeException in project TOSCAna by StuPro-TOSCAna.

the class CloudFormationLifecycle method checkModel.

@Override
public boolean checkModel() {
    logger.info("Check model for compatibility to CloudFormation");
    Set<RootNode> nodes = model.getNodes();
    Set<RootRelationship> relationships = model.getTopology().edgeSet();
    try {
        CheckModelNodeVisitor checkModelNodeVisitor = new CheckModelNodeVisitor(context);
        logger.info("Check nodes");
        visitAllNodes(nodes, checkModelNodeVisitor);
        CheckModelRelationshipVisitor checkModelRelationshipVisitor = new CheckModelRelationshipVisitor(context);
        logger.info("Check relationships");
        visitAllRelationships(relationships, checkModelRelationshipVisitor);
    } catch (UnsupportedTypeException ute) {
        logger.error(ute.getMessage());
        return false;
    }
    return true;
}
Also used : RootNode(org.opentosca.toscana.model.node.RootNode) UnsupportedTypeException(org.opentosca.toscana.model.visitor.UnsupportedTypeException) CheckModelNodeVisitor(org.opentosca.toscana.plugins.cloudformation.visitor.CheckModelNodeVisitor) CheckModelRelationshipVisitor(org.opentosca.toscana.plugins.cloudformation.visitor.CheckModelRelationshipVisitor) RootRelationship(org.opentosca.toscana.model.relation.RootRelationship)

Example 3 with UnsupportedTypeException

use of org.opentosca.toscana.model.visitor.UnsupportedTypeException in project TOSCAna by StuPro-TOSCAna.

the class CheckModelNodeVisitor method visit.

@Override
public void visit(Compute node) {
    List<OsCapability.Type> supportedTypes = Lists.newArrayList(OsCapability.Type.LINUX);
    // might grow but for now only linux
    List<OsCapability.Distribution> supportedDistributions = Lists.newArrayList(OsCapability.Distribution.UBUNTU);
    // might grow, but for now only ubuntu, maybe already work with others but not yet tested
    OsCapability osCapability = node.getOs();
    // check type
    if (osCapability.getType().isPresent()) {
        OsCapability.Type type = osCapability.getType().get();
        if (!supportedTypes.contains(type)) {
            throw new UnsupportedTypeException("OS Type " + type + " not supported.");
        }
    }
    // check distribution
    if (osCapability.getDistribution().isPresent()) {
        OsCapability.Distribution distribution = osCapability.getDistribution().get();
        if (!supportedDistributions.contains(distribution)) {
            throw new UnsupportedTypeException("OS distribution " + distribution + " not supported.");
        }
    }
}
Also used : OsCapability(org.opentosca.toscana.model.capability.OsCapability) UnsupportedTypeException(org.opentosca.toscana.model.visitor.UnsupportedTypeException)

Aggregations

UnsupportedTypeException (org.opentosca.toscana.model.visitor.UnsupportedTypeException)3 RootNode (org.opentosca.toscana.model.node.RootNode)2 OsCapability (org.opentosca.toscana.model.capability.OsCapability)1 Database (org.opentosca.toscana.model.node.Database)1 WebApplication (org.opentosca.toscana.model.node.WebApplication)1 RootRelationship (org.opentosca.toscana.model.relation.RootRelationship)1 CheckModelNodeVisitor (org.opentosca.toscana.plugins.cloudformation.visitor.CheckModelNodeVisitor)1 CheckModelRelationshipVisitor (org.opentosca.toscana.plugins.cloudformation.visitor.CheckModelRelationshipVisitor)1