Search in sources :

Example 1 with CFNPackage

use of com.scaleset.cfbuilder.ec2.metadata.CFNPackage in project TOSCAna by StuPro-TOSCAna.

the class TransformModelNodeVisitor method visit.

@Override
public void visit(Apache node) {
    try {
        Compute compute = getCompute(node);
        String computeName = toAlphanumerical(compute.getEntityName());
        // instead of lifecycle create we add the package apache2 to the configset
        cfnModule.getCFNInit(computeName).getOrAddConfig(CONFIG_SETS, CONFIG_CREATE).putPackage(// TODO apt only if linux
        new CFNPackage("apt").addPackage("apache2"));
        // handle configure
        operationHandler.handleConfigure(node, computeName);
        // handle start
        operationHandler.handleStart(node, computeName);
        // Source environment variables in /etc/apache/envvars from /etc/environment and restart apache2 directly
        // afterwards
        cfnModule.getCFNInit(computeName).getOrAddConfig(CONFIG_SETS, CONFIG_CONFIGURE).putCommand(new CFNCommand("Add Apache environment variables", APACHE_ENV_IMPORT));
        // we add restart apache2 command to the configscript if start or configure existed
        if (node.getStandardLifecycle().getConfigure().isPresent() || node.getStandardLifecycle().getStart().isPresent()) {
            cfnModule.getCFNInit(computeName).getOrAddConfig(CONFIG_SETS, CONFIG_START).putCommand(new CFNCommand("restart apache2", APACHE_RESTART_COMMAND));
        }
    } catch (Exception e) {
        logger.error("Error while creating Apache");
        throw new TransformationFailureException("Failed at Apache node " + node.getEntityName(), e);
    }
}
Also used : CFNPackage(com.scaleset.cfbuilder.ec2.metadata.CFNPackage) TransformationFailureException(org.opentosca.toscana.plugins.util.TransformationFailureException) Compute(org.opentosca.toscana.model.node.Compute) CFNCommand(com.scaleset.cfbuilder.ec2.metadata.CFNCommand) TransformationFailureException(org.opentosca.toscana.plugins.util.TransformationFailureException) SdkClientException(com.amazonaws.SdkClientException)

Aggregations

SdkClientException (com.amazonaws.SdkClientException)1 CFNCommand (com.scaleset.cfbuilder.ec2.metadata.CFNCommand)1 CFNPackage (com.scaleset.cfbuilder.ec2.metadata.CFNPackage)1 Compute (org.opentosca.toscana.model.node.Compute)1 TransformationFailureException (org.opentosca.toscana.plugins.util.TransformationFailureException)1