use of org.opentosca.toscana.model.capability.EndpointCapability in project TOSCAna by StuPro-TOSCAna.
the class WebServer method init.
private void init() {
setDefault(DATA_ENDPOINT, new EndpointCapability(getChildEntity(DATA_ENDPOINT)));
setDefault(ADMIN_ENDPOINT, new AdminEndpointCapability(getChildEntity(ADMIN_ENDPOINT)));
setDefault(CONTAINER_HOST, new ContainerCapability(getChildEntity(CONTAINER_HOST)));
}
use of org.opentosca.toscana.model.capability.EndpointCapability in project TOSCAna by StuPro-TOSCAna.
the class TransformModelNodeVisitor method visit.
@Override
public void visit(Nodejs node) {
try {
Compute computeHost = getCompute(node);
String computeHostName = toAlphanumerical(computeHost.getEntityName());
String nodeName = node.getEntityName();
// handle configure
operationHandler.handleConfigure(node, computeHostName);
// handle start
operationHandler.handleStart(node, computeHostName);
// add NodeJs create script
operationHandler.addCreate(FILEPATH_NODEJS_CREATE, computeHostName);
// Get ports
List<Integer> portList = new ArrayList<>();
node.getCapabilities().forEach(e -> {
try {
if (e instanceof EndpointCapability && ((EndpointCapability) e).getPort().isPresent()) {
int port = ((EndpointCapability) e).getPort().get().port;
logger.debug("Marking '{}' as port to be opened for '{}'.", port, nodeName);
portList.add(port);
}
} catch (Exception ex) {
logger.warn("Failed reading Port from node {}", nodeName, ex);
}
});
// Open ports
String SecurityGroupName = computeHostName + SECURITY_GROUP;
SecurityGroup securityGroup = (SecurityGroup) cfnModule.getResource(SecurityGroupName);
securityGroup.ingress(ingress -> ingress.cidrIp(IP_OPEN), PROTOCOL_TCP, portList.toArray());
} catch (Exception e) {
logger.error("Error while creating Nodejs");
throw new TransformationFailureException("Failed at Nodejs node " + node.getEntityName(), e);
}
}
use of org.opentosca.toscana.model.capability.EndpointCapability in project TOSCAna by StuPro-TOSCAna.
the class DockerfileBuildingVisitor method handleDefault.
/**
* This method implements the default node transformation behaviour. This means, the
* exectuion of scripts implements the functionality thats expected from the node.
*/
private void handleDefault(RootNode node, String[] ignoredLifecycles) {
try {
Map<NodeStack, String> address = new HashMap<>();
// Add the ports exposed by the node to the ports list
node.getCapabilities().forEach(e -> {
try {
if (e instanceof EndpointCapability) {
if (((EndpointCapability) e).getPort().isPresent()) {
ports.add(((EndpointCapability) e).getPort().get().port);
}
}
} catch (Exception ex) {
logger.warn("Failed reading Port from node {}", node.getEntityName(), ex);
}
});
// name. We therefore have to set this to 127.0.0.1 ('localhost' causes issues too)
for (Requirement e : node.getRequirements()) {
if (e.getRelationship().isPresent() && e.getRelationship().get() instanceof ConnectsTo) {
for (Object o : e.getFulfillers()) {
if (o instanceof RootNode) {
NodeStack targetStack = this.connectionGraph.vertexSet().stream().filter(ek -> ek.hasNode((RootNode) o)).findFirst().orElse(null);
if (targetStack != null && targetStack.getComputeNode() == this.stack.getComputeNode()) {
address.put(this.stack, this.stack.getComputeNode().getPrivateAddress().orElse(null));
this.stack.getComputeNode().setPrivateAddress(IPV4_LOCAL_ADDRESS);
}
}
}
}
}
// Add the scripts from the lifecycle to the Dockerfile
addLifecycleOperationsToDockerfile(node.getEntityName(), node.getStandardLifecycle(), ignoredLifecycles);
// Reset to original address
address.forEach((k, v) -> {
k.getComputeNode().setPrivateAddress(v);
});
} catch (IOException e) {
throw new UnsupportedOperationException("Transformation failed while copying artifacts", e);
}
}
use of org.opentosca.toscana.model.capability.EndpointCapability in project TOSCAna by StuPro-TOSCAna.
the class DataTypeTest method portTest.
@Test
public void portTest() {
EffectiveModel model = new EffectiveModelFactory().create(TestTemplates.Datatypes.PORT, logMock());
WebApplication app = (WebApplication) model.getNodes().iterator().next();
EndpointCapability endpoint = app.getAppEndpoint();
assertEquals(new Port(3000), endpoint.getPort().get());
Port expected = new Port(4000);
endpoint.setPort(expected);
assertEquals(expected, endpoint.getPort().get());
}
use of org.opentosca.toscana.model.capability.EndpointCapability in project TOSCAna by StuPro-TOSCAna.
the class WebApplication method init.
private void init() {
setDefault(APP_ENDPOINT, new EndpointCapability(getChildEntity(APP_ENDPOINT)));
setDefault(HOST, new WebServerRequirement(getChildEntity(HOST)));
}
Aggregations