use of org.opentosca.toscana.plugins.cloudformation.handler.EnvironmentHandler in project TOSCAna by StuPro-TOSCAna.
the class CloudFormationLifecycle method transform.
@Override
public void transform() {
logger.info("Begin transformation to CloudFormation.");
Set<RootNode> nodes = model.getNodes();
// Visit Compute nodes first, then all others
try {
TransformModelNodeVisitor cfnNodeVisitor = new TransformModelNodeVisitor(context, cfnModule);
logger.info("Transform nodes");
visitComputeNodesFirst(nodes, cfnNodeVisitor);
logger.info("Handling environment variables.");
EnvironmentHandler environmentHandler = new EnvironmentHandler(cfnModule, logger);
environmentHandler.handleEnvironment();
logger.info("Creating CloudFormation template.");
fileAccess.access(OUTPUT_DIR + CloudFormationFileCreator.TEMPLATE_YAML).appendln(cfnModule.toString()).close();
CloudFormationFileCreator fileCreator = new CloudFormationFileCreator(context, cfnModule);
logger.info("Creating CloudFormation scripts.");
fileCreator.copyUtilScripts();
fileCreator.copyUtilDependencies();
fileCreator.writeScripts();
fileCreator.copyFiles();
fileCreator.writeReadme(context);
} catch (IOException ie) {
logger.error("File access error");
throw new TransformationFailureException("Could not write template with fileAccess", ie);
} catch (TransformationFailureException tfe) {
logger.error("Transformation to CloudFormation unsuccessful. Please check the StackTrace for more Info.");
throw tfe;
} catch (Exception e) {
logger.error("Transformation to CloudFormation unsuccessful. Unexpected exception should not appear here.");
throw new TransformationFailureException("Unexpected exception", e);
}
logger.info("Transformation to CloudFormation successful.");
}
Aggregations