use of org.opentosca.toscana.plugins.util.TransformationFailureException in project TOSCAna by StuPro-TOSCAna.
the class BuildpackDetector method detectBuildpackAdditions.
/**
* checks the application suffix e.g. .php and add defined buildpacks
* currently only php is supported
*/
public void detectBuildpackAdditions() {
if (applicationSuffix != null) {
logger.info("Application suffix is: " + applicationSuffix);
if (applicationSuffix.equalsIgnoreCase("php")) {
try {
logger.debug("Add PHP buildpacks");
addBuildpackAdditonsPHP();
} catch (JSONException | IOException e) {
throw new TransformationFailureException("Fail to add buildpacks", e);
}
// TODO: expand with more languages
}
}
}
use of org.opentosca.toscana.plugins.util.TransformationFailureException in project TOSCAna by StuPro-TOSCAna.
the class NodeVisitor method visit.
/**
* a MysqlDatabase is a service in CloudFoundry
* Therefore the service will be added to the application where the source of the connects to relationship is
*/
@Override
public void visit(MysqlDatabase node) {
/*
create service
ignore password and port
*/
logger.debug("Visit Mysql Database");
Set<RootNode> sourceNodes = getSourcesOfConnectsTo(node);
Set<Application> belongingApplication = getSourceApplications(sourceNodes);
if (CollectionUtils.isEmpty(belongingApplication)) {
logger.error("No source node of connects to relationship of MysqlDatabase {} was found", node.getEntityName());
throw new TransformationFailureException("Could not find source of database");
}
handleStandardLifecycle(node, false, myApp);
logger.debug("Add MYSQL service to application");
belongingApplication.forEach(app -> app.addService(node.getEntityName(), ServiceTypes.MYSQL));
// current application is a dummy application
myApp.applicationIsNotReal(belongingApplication);
// check artifacts and add paths to application
for (Artifact artifact : node.getArtifacts()) {
String path = artifact.getFilePath();
myApp.addFilePath(path);
logger.debug("Add artifact path {} to application", path);
if (path.endsWith("sql")) {
myApp.addConfigMysql(node.getEntityName(), path);
logger.info("Found a SQL script in artifact paths. Will execute it with python script in deployment phase");
}
}
}
use of org.opentosca.toscana.plugins.util.TransformationFailureException in project TOSCAna by StuPro-TOSCAna.
the class CloudFormationPluginTest method testLamp.
@Test(expected = TransformationFailureException.class)
public void testLamp() {
try {
Set<RootNode> nodes = lamp.getNodes();
// visit compute nodes first
for (VisitableNode node : nodes) {
if (node instanceof Compute) {
node.accept(cfnNodeVisitor);
}
}
for (VisitableNode node : nodes) {
if (!(node instanceof Compute)) {
node.accept(cfnNodeVisitor);
}
}
System.err.println(cfnModule.toString());
} catch (TransformationFailureException tfe) {
// provided so this test can pass
if (!(tfe.getCause() instanceof SdkClientException)) {
throw tfe;
}
logger.debug("Passed without internet connection / credentials provided");
}
}
use of org.opentosca.toscana.plugins.util.TransformationFailureException in project TOSCAna by StuPro-TOSCAna.
the class DockerfileBuildingVisitor method visit.
@Override
public void visit(MysqlDatabase node) {
builder.env(ENV_KEY_MYSQL_DATABASE, node.getDatabaseName());
if (node.getUser().isPresent() && !node.getUser().get().equals("root")) {
builder.env(ENV_KEY_MYSQL_USER, node.getUser().get());
builder.env(ENV_KEY_MYSQL_PASSWORD, node.getPassword().orElse(""));
if (!node.getPassword().isPresent()) {
builder.env(ENV_KEY_MYSQL_ALLOW_EMPTY_PASSWORD, "true");
}
}
handleDefault(node, new String[] {});
List<Optional<Operation>> lifecycles = new ArrayList<>();
lifecycles.add(node.getStandardLifecycle().getConfigure());
lifecycles.add(node.getStandardLifecycle().getCreate());
if (lifecycles.stream().anyMatch(Optional::isPresent)) {
builder.workdir("/docker-entrypoint-initdb.d");
lifecycles.forEach(e -> {
if (e.isPresent()) {
Operation operation = e.get();
Optional<Artifact> artifact = operation.getArtifact();
if (artifact.isPresent()) {
String path = artifact.get().getFilePath();
if (path.endsWith(".sql")) {
String filename = determineFilename(path);
try {
builder.copyFromCsar(path, "", filename);
} catch (IOException ex) {
logger.error("Copying dependencies of node {} has failed!", node.getEntityName(), ex);
throw new TransformationFailureException("Copying dependencies failed", ex);
}
}
}
}
});
builder.workdir(TOSCANA_ROOT_WORKDIR_PATH);
}
}
use of org.opentosca.toscana.plugins.util.TransformationFailureException in project TOSCAna by StuPro-TOSCAna.
the class ImageMappingVisitor method visit.
@Override
public void visit(DockerApplication node) {
this.requiresBuilding = false;
this.baseImage = node.getStandardLifecycle().getCreate().orElseThrow(() -> new TransformationFailureException(NO_CREATE_ERROR_MESSAGE)).getArtifact().orElseThrow(() -> new TransformationFailureException(String.format(NO_IMAGE_PATH_ERROR_MESSAGE, node.getEntityName()))).getFilePath();
if (this.baseImage == null) {
throw new TransformationFailureException(String.format(NO_IMAGE_PATH_ERROR_MESSAGE, node.getEntityName()));
}
// TODO implement check if the docker application has children.
}
Aggregations