Search in sources :

Example 6 with Deployment

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

the class DeploymentTest method readCredentials.

@Test
public void readCredentials() throws IOException {
    String pythonFilename = "readCredentials.py";
    Deployment deployment = new Deployment(deployScript, testApp, fileAccess, context);
    deployment.readCredentials(appName, service, ServiceTypes.MYSQL, "my_db");
    File targetFile = new File(targetDir, outputPath + pythonFilename);
    File deployFile = new File(targetDir, outputPath + "deploy_" + appName + ".sh");
    String contentDeploy = FileUtils.readFileToString(deployFile);
    String expectedDeployContent = String.format(SHEBANG + "\n" + SOURCE_UTIL_ALL + "\n" + SUBCOMMAND_EXIT + "\n" + "check python\n" + "python %s %s %s %s %s\n", pythonFilename, appName, service, ServiceTypes.MYSQL.getName(), "my_db");
    assertTrue(targetFile.exists());
    assertEquals(expectedDeployContent, contentDeploy);
}
Also used : Deployment(org.opentosca.toscana.plugins.cloudfoundry.application.deployment.Deployment) File(java.io.File) BaseUnitTest(org.opentosca.toscana.core.BaseUnitTest) Test(org.junit.Test)

Example 7 with Deployment

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

Deployment (org.opentosca.toscana.plugins.cloudfoundry.application.deployment.Deployment)7 File (java.io.File)4 Test (org.junit.Test)4 BaseUnitTest (org.opentosca.toscana.core.BaseUnitTest)4 Application (org.opentosca.toscana.plugins.cloudfoundry.application.Application)3 Map (java.util.Map)1 BashScript (org.opentosca.toscana.plugins.scripts.BashScript)1