use of org.opentosca.toscana.model.node.Compute in project TOSCAna by StuPro-TOSCAna.
the class LinkResolverTest method resolveRequirementLink.
@Test
public void resolveRequirementLink() {
EffectiveModel model = new EffectiveModelFactory().create(REQUIREMENT, logMock());
WebServer node = (WebServer) model.getNodeMap().get("test-node1");
HostRequirement requirement = node.getHost();
assertNotNull(requirement);
Set<Compute> fulfillers = requirement.getFulfillers();
assertEquals(1, fulfillers.size());
Compute fulfiller = fulfillers.iterator().next();
assertEquals("test-node2", fulfiller.getEntityName());
}
use of org.opentosca.toscana.model.node.Compute in project TOSCAna by StuPro-TOSCAna.
the class ScalableCapabilityTest method scalableTest.
@Test
public void scalableTest() {
EffectiveModel model = new EffectiveModelFactory().create(TestTemplates.Capabilities.SCALABLE, logMock());
Compute compute = (Compute) model.getNodes().iterator().next();
ScalableCapability scalable = compute.getScalable();
assertEquals(5, (int) scalable.getMinInstances());
assertEquals(7, (int) scalable.getDefaultInstances().get());
assertEquals(Integer.MAX_VALUE, (int) scalable.getMaxInstances());
}
use of org.opentosca.toscana.model.node.Compute in project TOSCAna by StuPro-TOSCAna.
the class Pod method getPods.
/**
* @param stacks The List of NodeStacks to group in Pods
* @return a List Containing the given NodeStacks grouped in Pods
*/
public static List<Pod> getPods(Collection<NodeStack> stacks) {
// Group Node Stacks
Map<Compute, List<NodeStack>> stackMap = new HashMap<>();
for (NodeStack stack : stacks) {
Compute computeNode = stack.getComputeNode();
stackMap.computeIfAbsent(computeNode, k -> new ArrayList<>());
stackMap.get(computeNode).add(stack);
}
// Convert NodeStacks to Pods
List<Pod> pods = new ArrayList<>();
stackMap.forEach((k, v) -> pods.add(new Pod(v, k)));
return pods;
}
use of org.opentosca.toscana.model.node.Compute in project TOSCAna by StuPro-TOSCAna.
the class CloudFormationVisitorExtension method getHostsOfConnectedTo.
protected Set<Compute> getHostsOfConnectedTo(RootNode node) {
Set<Compute> connected = new HashSet<>();
Set<RootRelationship> incomingEdges = topology.incomingEdgesOf(node);
for (RootRelationship incomingEdge : incomingEdges) {
RootNode source = topology.getEdgeSource(incomingEdge);
if (source instanceof WebApplication) {
WebApplication webApplication = (WebApplication) source;
Compute compute = getCompute(webApplication);
connected.add(compute);
}
}
return connected;
}
use of org.opentosca.toscana.model.node.Compute in project TOSCAna by StuPro-TOSCAna.
the class PrepareModelNodeVisitor method visit.
@Override
public void visit(MysqlDatabase node) {
// if certain values aren't given, fill them
if (node.getPassword().isPresent()) {
// password needs to be at least 8 characters long
String password = node.getPassword().get();
if (password.length() < minPWLength) {
logger.warn("Database password too short, creating new random password");
node.setPassword(randomString(minPWLength));
}
} else {
logger.warn("No database password given, creating new random password");
node.setPassword(randomString(minPWLength));
}
if (!node.getUser().isPresent()) {
logger.warn("User not set, setting to default");
node.setUser(DEFAULT_DB_USER);
}
if (!node.getPort().isPresent()) {
logger.warn("Database port not set, setting to default");
node.setPort(DEFAULT_DB_PORT);
}
// check if Mysql is the only node hosted on his compute node
Compute compute = getCompute(node);
if (topology.incomingEdgesOf(compute).stream().filter(relation -> relation instanceof HostedOn).collect(Collectors.toSet()).size() == 1) {
// means our dbms is the only one hosted on this compute
// means we can set the private address as reference the database endpoint
Fn databaseEndpointFn = Fn.fnGetAtt(toAlphanumerical(node.getEntityName()), AWS_ENDPOINT_REFERENCE);
String databaseEndpoint = databaseEndpointFn.toString(true);
cfnModule.putFn(databaseEndpoint, databaseEndpointFn);
compute.setPrivateAddress(databaseEndpoint);
compute.setPublicAddress(databaseEndpoint);
logger.debug("Set private address and public address of '{}' to reference MysqlDatabase '{}'", compute.getEntityName(), node.getEntityName());
// also the underlying compute should not get mapped to an ec2
cfnModule.removeComputeToEc2(compute);
logger.debug("Removing Compute '{}' to be transformed", compute.getEntityName());
}
}
Aggregations