use of org.opentosca.toscana.model.operation.Operation in project TOSCAna by StuPro-TOSCAna.
the class OperationHandler method handleCreate.
/**
* Handles a create operation.
*
* @param node which the operation belongs to
* @param computeHostName alphanumerical name of the Compute host of node
*/
public void handleCreate(RootNode node, String computeHostName) {
if (node.getStandardLifecycle().getCreate().isPresent()) {
Operation create = node.getStandardLifecycle().getCreate().get();
handleOperation(create, computeHostName, CONFIG_CREATE);
}
}
use of org.opentosca.toscana.model.operation.Operation in project TOSCAna by StuPro-TOSCAna.
the class OperationHandler method handleStart.
/**
* Handles a start operation.
*
* @param node which the operation belongs to
* @param computeHostName alphanumerical name of the Compute host of node
*/
public void handleStart(RootNode node, String computeHostName) {
if (node.getStandardLifecycle().getStart().isPresent()) {
Operation start = node.getStandardLifecycle().getStart().get();
handleOperation(start, computeHostName, CONFIG_START);
// Add environment variables
Set<OperationVariable> inputs = start.getInputs();
if (!inputs.isEmpty()) {
for (OperationVariable input : inputs) {
String value = input.getValue().orElseThrow(() -> new IllegalArgumentException("Input value of " + input.getKey() + " expected to not be " + "null"));
cfnModule.putEnvironmentMap(computeHostName, input.getKey(), value);
}
}
}
}
use of org.opentosca.toscana.model.operation.Operation in project TOSCAna by StuPro-TOSCAna.
the class NodeVisitor method getScripts.
private void getScripts(RootNode node, Application application) {
StandardLifecycle lifecycle = node.getStandardLifecycle();
Optional<Operation> configureOptional = lifecycle.getConfigure();
// get configure script
if (configureOptional.isPresent()) {
Optional<Artifact> configureArtifact = configureOptional.get().getArtifact();
configureArtifact.ifPresent(artifact -> application.addExecuteFile(artifact.getFilePath(), node));
}
// get create script
Optional<Operation> createOptional = lifecycle.getCreate();
if (createOptional.isPresent()) {
Optional<Artifact> createArtifact = createOptional.get().getArtifact();
createArtifact.ifPresent(artifact -> application.addExecuteFile(artifact.getFilePath(), node));
}
}
use of org.opentosca.toscana.model.operation.Operation in project TOSCAna by StuPro-TOSCAna.
the class NodeVisitor method handleStandardLifecycle.
private void handleStandardLifecycle(RootNode node, boolean isTopNode, Application application) {
// get node artifacts
node.getArtifacts().stream().forEach(artifact -> {
String filePath = artifact.getFilePath();
application.setPathToApplication(filePath);
application.addFilePath(filePath);
});
// get StandardLifecycle inputs
for (OperationVariable lifecycleInput : node.getStandardLifecycle().getInputs()) {
addEnvironmentVariable(lifecycleInput);
}
// get operation inputs
for (Operation operation : node.getStandardLifecycle().getOperations()) {
// artifact path
if (operation.getArtifact().isPresent()) {
String path = operation.getArtifact().get().getFilePath();
setPathToApplication(path, isTopNode);
}
// add dependencies paths
for (String dependency : operation.getDependencies()) {
application.addFilePath(dependency);
setPathToApplication(dependency, isTopNode);
}
// add inputs to environment list
for (OperationVariable input : operation.getInputs()) {
addEnvironmentVariable(input);
}
// TODO: investigate what to do with outputs?
}
}
use of org.opentosca.toscana.model.operation.Operation in project TOSCAna by StuPro-TOSCAna.
the class LinkResolver method resolveImplementationArtifacts.
private static void resolveImplementationArtifacts(ServiceGraph graph) {
logger.debug(LogFormat.indent(1, "artifacts"));
Map<String, RootNode> nodes = new TypeWrapper().wrapNodes(graph);
for (RootNode node : nodes.values()) {
for (Interface thisInterface : node.getInterfaces()) {
for (Operation operation : thisInterface.getOperations()) {
Optional<Artifact> optionalArtifact = operation.getArtifact();
if (optionalArtifact.isPresent()) {
Artifact operationArtifact = optionalArtifact.get();
for (Artifact nodeArtifact : node.getArtifacts()) {
if (operationArtifact.getFilePath().equals(nodeArtifact.getEntityName())) {
graph.replaceEntity(operationArtifact.getBackingEntity(), nodeArtifact.getBackingEntity());
logger.debug(LogFormat.pointAt(2, operationArtifact.getBackingEntity().getId(), nodeArtifact.getBackingEntity().getId()));
// at this point it's obvious: we need a better solution for navigating the service graph...
}
}
}
}
}
}
}
Aggregations