Search in sources :

Example 6 with BashScript

use of org.opentosca.toscana.plugins.scripts.BashScript in project TOSCAna by StuPro-TOSCAna.

the class FileCreator method createDeployScript.

/**
 *     creates a deploy shell script
 */
private void createDeployScript() throws IOException {
    if (applications.size() > 1) {
        deploy_name += "s";
    }
    BashScript deployScript = new BashScript(fileAccess, FILEPRAEFIX_DEPLOY + deploy_name);
    deployScript.append("echo \"$(tput bold)--------TOSCAna Cloud Foundry deployment--------$(tput sgr0)\"");
    deployScript.append("echo \"This script will deploy your application to the Cloud Foundry instance\"");
    deployScript.append("echo \"We use the CloudFoundry CLI and show you the output as well\"");
    deployScript.append("echo \"Is there no CF CLI installed we have to stop, we will check it\"");
    deployScript.append("echo \"We will deploy the application to the connected provider\"");
    deployScript.append("echo \"If you use a Cloud Foundry service with your application, " + "you are able to change the service or plan in this deploy script manually\"");
    deployScript.append("echo \"We tried to choose a suitable service with a free plan\"");
    deployScript.append("echo \"You could check all possible services in the file$(tput bold) " + SERVICE_FILE_PATH + " $(tput sgr0)\"");
    deployScript.append("echo \"$(tput bold)--------TOSCAna Cloud Foundry deployment$(tput sgr0)--------\n\"");
    deployScript.append(EnvironmentCheck.checkEnvironment("cf"));
    // handle services
    logger.debug("Handle services");
    handleServices(deployScript);
    // replace
    logger.debug("Replace strings");
    replaceStrings(deployScript);
    // push applications
    for (Application application : applications) {
        deployScript.append(CLI_PUSH + application.getName() + CLI_PATH_TO_MANIFEST + MANIFEST_NAME + CLI_NO_START);
    }
    // read credentials, replace, executeScript, configureMysql
    for (Application application : applications) {
        Deployment deployment = new Deployment(deployScript, application, fileAccess, context);
        // read credentials
        readCredentials(deployment, application);
        // configureSql
        configureSql(deployment, application);
        // start application
        deployScript.append(CLI_START + application.getName());
        // execute
        executeFiles(deployment, application);
    }
    deployScript.append("echo \"\n\n$(tput bold)The deployment of your application is finished. You see the urls of your apps here:$(tput sgr0)\n\"");
    deployScript.append("cf routes");
}
Also used : BashScript(org.opentosca.toscana.plugins.scripts.BashScript) Deployment(org.opentosca.toscana.plugins.cloudfoundry.application.deployment.Deployment) Application(org.opentosca.toscana.plugins.cloudfoundry.application.Application)

Aggregations

BashScript (org.opentosca.toscana.plugins.scripts.BashScript)6 Application (org.opentosca.toscana.plugins.cloudfoundry.application.Application)2 Parameter (com.scaleset.cfbuilder.core.Parameter)1 File (java.io.File)1 List (java.util.List)1 Map (java.util.Map)1 Before (org.junit.Before)1 PluginFileAccess (org.opentosca.toscana.core.plugin.PluginFileAccess)1 EffectiveModel (org.opentosca.toscana.model.EffectiveModel)1 EffectiveModelFactory (org.opentosca.toscana.model.EffectiveModelFactory)1 FileUpload (org.opentosca.toscana.plugins.cloudformation.util.FileUpload)1 Deployment (org.opentosca.toscana.plugins.cloudfoundry.application.deployment.Deployment)1