use of org.opentosca.toscana.plugins.cloudfoundry.application.deployment.Deployment 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);
}
}
}
}
use of org.opentosca.toscana.plugins.cloudfoundry.application.deployment.Deployment 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);
}
}
use of org.opentosca.toscana.plugins.cloudfoundry.application.deployment.Deployment in project TOSCAna by StuPro-TOSCAna.
the class DeploymentTest method replaceStrings.
@Test
public void replaceStrings() throws IOException {
String pythonFilename = "replace.py";
Deployment deployment = new Deployment(deployScript, testApp, fileAccess, context);
String pathToFile = "../../testApp/move.sh";
String findStr = "testAlt";
String replaceStr = "testNeu";
deployment.replaceStrings(pathToFile, findStr, replaceStr);
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\n", pythonFilename, pathToFile, findStr, replaceStr);
assertTrue(targetFile.exists());
assertEquals(expectedDeployContent, contentDeploy);
}
use of org.opentosca.toscana.plugins.cloudfoundry.application.deployment.Deployment in project TOSCAna by StuPro-TOSCAna.
the class DeploymentTest method configureSql.
@Test
public void configureSql() throws IOException {
String pythonFilename = "configureMysql.py";
String pathToSqlFile = "../../test/configMysql.sql";
Deployment deployment = new Deployment(deployScript, testApp, fileAccess, context);
deployment.configureSql(pathToSqlFile);
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\n", pythonFilename, pathToSqlFile);
assertTrue(targetFile.exists());
assertEquals(expectedDeployContent, contentDeploy);
}
use of org.opentosca.toscana.plugins.cloudfoundry.application.deployment.Deployment in project TOSCAna by StuPro-TOSCAna.
the class DeploymentTest method executeFile.
@Test
public void executeFile() throws IOException {
String pythonFilename = "executeCommand.py";
Deployment deployment = new Deployment(deployScript, testApp, fileAccess, context);
String pathToFile = "/home/vcap/app/testApp/command.sh";
deployment.executeFile(appName, pathToFile);
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\n", pythonFilename, appName, pathToFile);
assertTrue(targetFile.exists());
assertEquals(expectedDeployContent, contentDeploy);
}
Aggregations