use of org.opentosca.toscana.plugins.scripts.BashScript in project TOSCAna by StuPro-TOSCAna.
the class CloudFormationFileCreator method writeStackCreationScript.
/**
* Creates the script for creating the CloudFormation stack from the template.
*/
private void writeStackCreationScript() throws IOException {
logger.debug("Creating create-stack script.");
BashScript createStackScript = new BashScript(cfnModule.getFileAccess(), FILENAME_CREATE_STACK);
// Build deploy command
StringBuilder deployCommand = new StringBuilder("");
deployCommand.append(CLI_COMMAND_CREATESTACK + CLI_PARAM_STACKNAME).append(cfnModule.getStackName()).append(" ").append(CLI_PARAM_TEMPLATEFILE).append("../").append(TEMPLATE_YAML);
// Add IAM capability if needed
List<FileUpload> fileUploadList = cfnModule.getFileUploadList();
if (!fileUploadList.isEmpty()) {
logger.debug("Adding IAM capability to create stack command.");
deployCommand.append(" " + CLI_PARAM_CAPABILITIES + " " + CAPABILITY_IAM);
}
// Add parameters if needed
Map<String, Parameter> parameters = cfnModule.getParameters();
if (!parameters.isEmpty()) {
logger.debug("Adding parameters to create stack command.");
deployCommand.append(" " + CLI_PARAM_PARAMOVERRIDES);
for (Map.Entry<String, Parameter> entry : parameters.entrySet()) {
String id = entry.getKey();
deployCommand.append(" ").append(id).append("=$").append(id).append("Var");
}
}
createStackScript.append(deployCommand.toString());
}
use of org.opentosca.toscana.plugins.scripts.BashScript in project TOSCAna by StuPro-TOSCAna.
the class DeploymentTest method setUp.
@Before
public void setUp() throws IOException {
EffectiveModel lamp = new EffectiveModelFactory().create(TestCsars.VALID_LAMP_NO_INPUT_TEMPLATE, logMock());
this.context = setUpMockTransformationContext(lamp);
appName = "testApp";
testApp = new Application("testApp", 1, context);
File sourceDir = new File(tmpdir, "sourceDir");
targetDir = new File(tmpdir, "targetDir");
sourceDir.mkdir();
targetDir.mkdir();
fileAccess = new PluginFileAccess(sourceDir, targetDir, log);
deployScript = new BashScript(fileAccess, "deploy_" + appName);
}
use of org.opentosca.toscana.plugins.scripts.BashScript in project TOSCAna by StuPro-TOSCAna.
the class CloudFormationFileCreator method writeDeployScript.
/**
* Creates a deploy script for deploying the cloudformation template.
*/
private void writeDeployScript() throws IOException {
logger.debug("Creating deploy script.");
BashScript deployScript = new BashScript(cfnModule.getFileAccess(), FILENAME_DEPLOY);
deployScript.append(EnvironmentCheck.checkEnvironment("aws"));
// Source file-upload script if needed
List fileUploadList = cfnModule.getFileUploadList();
if (!fileUploadList.isEmpty()) {
deployScript.append("source " + FILENAME_UPLOAD + ".sh");
}
deployScript.append("source " + FILENAME_CREATE_STACK + ".sh");
}
use of org.opentosca.toscana.plugins.scripts.BashScript in project TOSCAna by StuPro-TOSCAna.
the class CloudFormationFileCreator method writeCleanUpScript.
/**
* Creates a script to delete the S3Bucket and the deployed Stack.
* Note: May or may not be included in the final version. Currently used for quicker manual debugging.
*/
private void writeCleanUpScript() throws IOException {
logger.debug("Creating cleanup script.");
BashScript cleanupScript = new BashScript(cfnModule.getFileAccess(), FILENAME_CLEANUP);
// Delete Bucket
cleanupScript.append(CLI_COMMAND_DELETEBUCKET + cfnModule.getBucketName() + " " + CLI_PARAM_FORCE);
// Echo delete Stack
cleanupScript.append(COMMAND_ECHO + STRING_DELETESTACK + cfnModule.getStackName());
// Delete stack
cleanupScript.append(CLI_COMMAND_DELETESTACK + CLI_PARAM_STACKNAME + cfnModule.getStackName());
}
use of org.opentosca.toscana.plugins.scripts.BashScript in project TOSCAna by StuPro-TOSCAna.
the class CloudFormationFileCreator method writeFileUploadScript.
/**
* Creates the script for File Uploads if files need to be uploaded.
*/
private void writeFileUploadScript() throws IOException {
List<String> fileUploadList = getFilePaths(cfnModule.getFileUploadList());
logger.debug("Checking if files need to be uploaded.");
if (!fileUploadList.isEmpty()) {
logger.debug("Files to be uploaded found. Creating file upload script.");
BashScript fileUploadScript = new BashScript(cfnModule.getFileAccess(), FILENAME_UPLOAD);
fileUploadScript.append(createBucket());
logger.debug("Adding file upload commands.");
addFileUploadsToScript(fileUploadList, fileUploadScript);
} else {
logger.debug("No files to be uploaded found. Skipping creation of file upload script.");
}
}
Aggregations