Search in sources :

Example 1 with KubernetesNodeContainer

use of org.opentosca.toscana.plugins.kubernetes.util.KubernetesNodeContainer in project TOSCAna by StuPro-TOSCAna.

the class CloudFoundryLifecycle method fillApplications.

/**
 *     Fills the Applications with the sorted Node structure
 */
public void fillApplications() {
    filledApplications = new ArrayList<>();
    for (Application app : applications) {
        for (int i = 0; i < app.getStack().getNodes().size(); i++) {
            nodeApplicationMap.put(app.getStack().getNodes().get(i).getNode(), app);
        }
    }
    for (Application application : applications) {
        NodeVisitor visitor = new NodeVisitor(application, nodeApplicationMap, graph, logger);
        for (KubernetesNodeContainer s : application.getStack().getNodes()) {
            s.getNode().accept(visitor);
        }
        Application filledApplication = visitor.getFilledApp();
        filledApplications.add(filledApplication);
    }
}
Also used : KubernetesNodeContainer(org.opentosca.toscana.plugins.kubernetes.util.KubernetesNodeContainer) Application(org.opentosca.toscana.plugins.cloudfoundry.application.Application) NodeVisitor(org.opentosca.toscana.plugins.cloudfoundry.visitor.NodeVisitor)

Example 2 with KubernetesNodeContainer

use of org.opentosca.toscana.plugins.kubernetes.util.KubernetesNodeContainer 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);
}
Also used : RootNode(org.opentosca.toscana.model.node.RootNode) KubernetesNodeContainer(org.opentosca.toscana.plugins.kubernetes.util.KubernetesNodeContainer) NodeStack(org.opentosca.toscana.plugins.kubernetes.util.NodeStack) EffectiveModelFactory(org.opentosca.toscana.model.EffectiveModelFactory) LinkedList(java.util.LinkedList)

Example 3 with KubernetesNodeContainer

use of org.opentosca.toscana.plugins.kubernetes.util.KubernetesNodeContainer in project TOSCAna by StuPro-TOSCAna.

the class PrepareHandler method findComputeNodes.

private ComputeNodeFindingVisitor findComputeNodes() {
    logger.debug("Collecting Compute Nodes in topology");
    ComputeNodeFindingVisitor computeFinder = new ComputeNodeFindingVisitor();
    lifecycle.model.getNodes().forEach(e -> {
        e.accept(computeFinder);
        KubernetesNodeContainer container = new KubernetesNodeContainer(e);
        lifecycle.nodes.put(e.getEntityName(), container);
    });
    computeFinder.getComputeNodes().forEach(e -> lifecycle.computeNodes.add(lifecycle.nodes.get(e.getEntityName())));
    return computeFinder;
}
Also used : KubernetesNodeContainer(org.opentosca.toscana.plugins.kubernetes.util.KubernetesNodeContainer) ComputeNodeFindingVisitor(org.opentosca.toscana.plugins.kubernetes.visitor.util.ComputeNodeFindingVisitor)

Example 4 with KubernetesNodeContainer

use of org.opentosca.toscana.plugins.kubernetes.util.KubernetesNodeContainer in project TOSCAna by StuPro-TOSCAna.

the class CloudFoundryLifecycle method prepare.

@Override
public void prepare() {
    logger.info("Begin preparation for transformation to Cloud Foundry");
    PrepareVisitor prepareVisitor = new PrepareVisitor(logger);
    for (RootNode node : context.getModel().getNodes()) {
        node.accept(prepareVisitor);
    }
    logger.debug("Collecting Compute Nodes in topology");
    ComputeNodeFindingVisitor computeFinder = new ComputeNodeFindingVisitor();
    model.getNodes().forEach(e -> {
        e.accept(computeFinder);
        KubernetesNodeContainer container = new KubernetesNodeContainer(e);
        nodes.put(e.getEntityName(), container);
    });
    computeFinder.getComputeNodes().forEach(e -> computeNodes.add(nodes.get(e.getEntityName())));
    logger.debug("Finding top Level Nodes");
    graph = model.getTopology();
    Set<RootNode> topLevelNodes = determineTopLevelNodes(context.getModel(), computeFinder.getComputeNodes().stream().map(Compute.class::cast).collect(Collectors.toList()), e -> nodes.get(e.getEntityName()).activateParentComputeNode());
    logger.debug("Building complete Topology stacks");
    this.stacks.addAll(buildTopologyStacks(model, topLevelNodes, nodes));
    // TODO: check how many different applications there are and fill list with them
    // probably there must be a combination of application and set of nodes
    applications = new ArrayList<>();
    int i = 1;
    for (NodeStack stack : stacks) {
        Application myApp = new Application(i, context);
        i++;
        myApp.setProvider(provider);
        myApp.setConnection(connection);
        myApp.setName(stack.getStackName());
        myApp.addStack(stack);
        applications.add(myApp);
    }
}
Also used : RootNode(org.opentosca.toscana.model.node.RootNode) Compute(org.opentosca.toscana.model.node.Compute) KubernetesNodeContainer(org.opentosca.toscana.plugins.kubernetes.util.KubernetesNodeContainer) NodeStack(org.opentosca.toscana.plugins.kubernetes.util.NodeStack) ComputeNodeFindingVisitor(org.opentosca.toscana.plugins.kubernetes.visitor.util.ComputeNodeFindingVisitor) PrepareVisitor(org.opentosca.toscana.plugins.cloudfoundry.visitor.PrepareVisitor) Application(org.opentosca.toscana.plugins.cloudfoundry.application.Application)

Aggregations

KubernetesNodeContainer (org.opentosca.toscana.plugins.kubernetes.util.KubernetesNodeContainer)4 RootNode (org.opentosca.toscana.model.node.RootNode)2 Application (org.opentosca.toscana.plugins.cloudfoundry.application.Application)2 NodeStack (org.opentosca.toscana.plugins.kubernetes.util.NodeStack)2 ComputeNodeFindingVisitor (org.opentosca.toscana.plugins.kubernetes.visitor.util.ComputeNodeFindingVisitor)2 LinkedList (java.util.LinkedList)1 EffectiveModelFactory (org.opentosca.toscana.model.EffectiveModelFactory)1 Compute (org.opentosca.toscana.model.node.Compute)1 NodeVisitor (org.opentosca.toscana.plugins.cloudfoundry.visitor.NodeVisitor)1 PrepareVisitor (org.opentosca.toscana.plugins.cloudfoundry.visitor.PrepareVisitor)1