Search in sources :

Example 1 with EnvironmentHandler

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.");
}
Also used : RootNode(org.opentosca.toscana.model.node.RootNode) TransformationFailureException(org.opentosca.toscana.plugins.util.TransformationFailureException) EnvironmentHandler(org.opentosca.toscana.plugins.cloudformation.handler.EnvironmentHandler) TransformModelNodeVisitor(org.opentosca.toscana.plugins.cloudformation.visitor.TransformModelNodeVisitor) IOException(java.io.IOException) TransformationFailureException(org.opentosca.toscana.plugins.util.TransformationFailureException) UnsupportedTypeException(org.opentosca.toscana.model.visitor.UnsupportedTypeException) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 RootNode (org.opentosca.toscana.model.node.RootNode)1 UnsupportedTypeException (org.opentosca.toscana.model.visitor.UnsupportedTypeException)1 EnvironmentHandler (org.opentosca.toscana.plugins.cloudformation.handler.EnvironmentHandler)1 TransformModelNodeVisitor (org.opentosca.toscana.plugins.cloudformation.visitor.TransformModelNodeVisitor)1 TransformationFailureException (org.opentosca.toscana.plugins.util.TransformationFailureException)1