Search in sources :

Example 1 with Application

use of org.opentosca.toscana.plugins.cloudfoundry.application.Application 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 Application

use of org.opentosca.toscana.plugins.cloudfoundry.application.Application in project TOSCAna by StuPro-TOSCAna.

the class FileCreator method replaceStrings.

/**
 *     replaces strings in files with suitable strings.
 *     If a path is not suitable to the path in the warden container
 *     A replace command will be added to the deployscript which replaces the Strings locally.
 *
 *     @param deployScript script the commands will be written in
 */
private void replaceStrings(BashScript deployScript) throws IOException {
    for (Application application : applications) {
        Deployment deployment = new Deployment(deployScript, application, fileAccess, context);
        if (!application.getExecuteCommands().isEmpty()) {
            Map<String, String> executeCommands = application.getExecuteCommands();
            for (Map.Entry<String, String> command : executeCommands.entrySet()) {
                // TODO: add lists which strings should be replaced. In 12 Factor it is probably not necessary.
                String findStr = "/var/www/html/";
                String replaceStr = "/home/vcap/app/htdocs/";
                deployment.replaceStrings(command.getKey(), findStr, replaceStr);
                logger.info("Add command to replace all occurence of {} with {}", findStr, replaceStr);
            }
        }
    }
}
Also used : Deployment(org.opentosca.toscana.plugins.cloudfoundry.application.deployment.Deployment) Application(org.opentosca.toscana.plugins.cloudfoundry.application.Application) Map(java.util.Map)

Example 3 with Application

use of org.opentosca.toscana.plugins.cloudfoundry.application.Application in project TOSCAna by StuPro-TOSCAna.

the class FileCreator method handleServices.

/**
 *     looks for a suitable service of the provider which matches to the needed service
 *     adds the creation command to the deployscript
 *
 *     @param deployScript script the commands will be written in
 */
private void handleServices(BashScript deployScript) throws IOException {
    for (Application application : applications) {
        Deployment deployment = new Deployment(deployScript, application, fileAccess, context);
        // only one time all service offerings should be printed
        this.alreadyHandledServices = deployment.treatServices(alreadyHandledServices);
    }
}
Also used : Deployment(org.opentosca.toscana.plugins.cloudfoundry.application.deployment.Deployment) Application(org.opentosca.toscana.plugins.cloudfoundry.application.Application)

Example 4 with Application

use of org.opentosca.toscana.plugins.cloudfoundry.application.Application in project TOSCAna by StuPro-TOSCAna.

the class FileCreator method createFiles.

/**
 *     creates all files which are necessary for deployment
 *     Each application has to be filled with information
 */
public void createFiles() throws IOException, JSONException {
    logger.info("Create manifest.yml");
    createManifest();
    logger.info("Create deploy script");
    createDeployScript();
    for (Application application : applications) {
        createBuildpackAdditionsFile(application);
        insertFiles(application);
        createEnvironmentConfigFile(application, application.getEnvironmentVariables());
    }
    logger.info("Create readme text file");
    createReadme();
}
Also used : Application(org.opentosca.toscana.plugins.cloudfoundry.application.Application)

Example 5 with Application

use of org.opentosca.toscana.plugins.cloudfoundry.application.Application in project TOSCAna by StuPro-TOSCAna.

the class FileCreator method createManifest.

/**
 *     creates the manifest
 *     multiple applications are in the same manifest
 */
private void createManifest() throws IOException {
    createManifestHead();
    for (Application application : applications) {
        addNameToManifest(application);
        addPathToApplication(application);
        createAttributes(application);
        createEnvironmentVariables(application);
        createService(application);
    }
}
Also used : Application(org.opentosca.toscana.plugins.cloudfoundry.application.Application)

Aggregations

Application (org.opentosca.toscana.plugins.cloudfoundry.application.Application)19 File (java.io.File)9 ArrayList (java.util.ArrayList)7 FileCreator (org.opentosca.toscana.plugins.cloudfoundry.filecreator.FileCreator)7 Test (org.junit.Test)5 BaseUnitTest (org.opentosca.toscana.core.BaseUnitTest)5 EffectiveModel (org.opentosca.toscana.model.EffectiveModel)5 EffectiveModelFactory (org.opentosca.toscana.model.EffectiveModelFactory)5 WebApplication (org.opentosca.toscana.model.node.WebApplication)5 Before (org.junit.Before)4 PluginFileAccess (org.opentosca.toscana.core.plugin.PluginFileAccess)4 RootNode (org.opentosca.toscana.model.node.RootNode)3 Deployment (org.opentosca.toscana.plugins.cloudfoundry.application.deployment.Deployment)3 KubernetesNodeContainer (org.opentosca.toscana.plugins.kubernetes.util.KubernetesNodeContainer)2 BashScript (org.opentosca.toscana.plugins.scripts.BashScript)2 InputStream (java.io.InputStream)1 Map (java.util.Map)1 PropertyInstance (org.opentosca.toscana.core.transformation.properties.PropertyInstance)1 Artifact (org.opentosca.toscana.model.artifact.Artifact)1 Compute (org.opentosca.toscana.model.node.Compute)1