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);
}
}
Aggregations