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.");
}
}
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;
}
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.");
}
}
}
Aggregations