use of org.opentosca.toscana.model.node.RootNode 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.node.RootNode in project TOSCAna by StuPro-TOSCAna.
the class NodeVisitor method visit.
/**
* a MysqlDatabase is a service in CloudFoundry
* Therefore the service will be added to the application where the source of the connects to relationship is
*/
@Override
public void visit(MysqlDatabase node) {
/*
create service
ignore password and port
*/
logger.debug("Visit Mysql Database");
Set<RootNode> sourceNodes = getSourcesOfConnectsTo(node);
Set<Application> belongingApplication = getSourceApplications(sourceNodes);
if (CollectionUtils.isEmpty(belongingApplication)) {
logger.error("No source node of connects to relationship of MysqlDatabase {} was found", node.getEntityName());
throw new TransformationFailureException("Could not find source of database");
}
handleStandardLifecycle(node, false, myApp);
logger.debug("Add MYSQL service to application");
belongingApplication.forEach(app -> app.addService(node.getEntityName(), ServiceTypes.MYSQL));
// current application is a dummy application
myApp.applicationIsNotReal(belongingApplication);
// check artifacts and add paths to application
for (Artifact artifact : node.getArtifacts()) {
String path = artifact.getFilePath();
myApp.addFilePath(path);
logger.debug("Add artifact path {} to application", path);
if (path.endsWith("sql")) {
myApp.addConfigMysql(node.getEntityName(), path);
logger.info("Found a SQL script in artifact paths. Will execute it with python script in deployment phase");
}
}
}
use of org.opentosca.toscana.model.node.RootNode in project TOSCAna by StuPro-TOSCAna.
the class CloudFormationPluginTest method testLamp.
@Test(expected = TransformationFailureException.class)
public void testLamp() {
try {
Set<RootNode> nodes = lamp.getNodes();
// visit compute nodes first
for (VisitableNode node : nodes) {
if (node instanceof Compute) {
node.accept(cfnNodeVisitor);
}
}
for (VisitableNode node : nodes) {
if (!(node instanceof Compute)) {
node.accept(cfnNodeVisitor);
}
}
System.err.println(cfnModule.toString());
} catch (TransformationFailureException tfe) {
// provided so this test can pass
if (!(tfe.getCause() instanceof SdkClientException)) {
throw tfe;
}
logger.debug("Passed without internet connection / credentials provided");
}
}
use of org.opentosca.toscana.model.node.RootNode in project TOSCAna by StuPro-TOSCAna.
the class TestNodeStacks method getLampNodeStacks.
public static Set<NodeStack> getLampNodeStacks(Log log) {
Map<String, RootNode> map = new EffectiveModelFactory().create(TestCsars.VALID_LAMP_NO_INPUT_TEMPLATE, log).getNodeMap();
List<KubernetesNodeContainer> webAppNodes = new LinkedList<>();
KubernetesNodeContainer computeContainer = new KubernetesNodeContainer(map.get("server"));
computeContainer.hasParentComputeNode();
webAppNodes.add(new KubernetesNodeContainer(map.get("my_app")));
webAppNodes.add(new KubernetesNodeContainer(map.get("apache_web_server")));
webAppNodes.add(computeContainer);
NodeStack webAppNodeStack = new NodeStack(webAppNodes);
// Manualy set the docker image tag (used for testing the ResourceFileCreator)
webAppNodeStack.setDockerImageTag("my-app");
return Sets.newHashSet(webAppNodeStack);
}
use of org.opentosca.toscana.model.node.RootNode in project TOSCAna by StuPro-TOSCAna.
the class LinkResolver method resolveRepositories.
private static void resolveRepositories(ServiceGraph graph) {
logger.debug(LogFormat.indent(1, "repositories"));
Map<String, RootNode> nodes = new TypeWrapper().wrapNodes(graph);
for (RootNode node : nodes.values()) {
for (Artifact artifact : node.getArtifacts()) {
MappingEntity artifactEntity = artifact.getBackingEntity();
Optional<Entity> repository = artifactEntity.getChild(Artifact.REPOSITORY.name);
if (repository.isPresent()) {
String url = ((ScalarEntity) repository.get()).getValue();
EntityId targetId = ToscaStructure.REPOSITORIES.descend(url);
Optional<Entity> target = graph.getEntity(targetId);
target.ifPresent(baseEntity -> {
logger.debug(LogFormat.pointAt(2, repository.get().getId(), baseEntity.getId()));
graph.replaceEntity(repository.get(), baseEntity);
});
}
}
}
}
Aggregations