use of com.sequenceiq.cloudbreak.api.model.EndpointRule in project cloudbreak by hortonworks.
the class NetworkUtils method getPorts.
public static List<Port> getPorts(Optional<Stack> stack) {
List<Port> result = new ArrayList<>();
if (stack.isPresent()) {
Stack stackInstance = stack.get();
List<EndpointRule> aclRules = createACLRules(stackInstance);
for (InstanceGroup instanceGroup : stackInstance.getInstanceGroups()) {
for (SecurityRule rule : instanceGroup.getSecurityGroup().getSecurityRules()) {
for (String portNumber : rule.getPorts()) {
Port port = getPortByPortNumberAndProtocol(portNumber, rule.getProtocol());
if (port != null) {
result.add(new Port(port.getExposedService(), portNumber, portNumber, rule.getProtocol(), aclRules));
}
}
}
}
} else {
result.addAll(PORTS);
}
return result;
}
use of com.sequenceiq.cloudbreak.api.model.EndpointRule in project cloudbreak by hortonworks.
the class NetworkUtils method createACLRules.
private static List<EndpointRule> createACLRules(Stack stack) {
List<EndpointRule> rules = new LinkedList<>();
for (InstanceGroup instanceGroup : stack.getInstanceGroups()) {
for (SecurityRule rule : instanceGroup.getSecurityGroup().getSecurityRules()) {
rules.add(new EndpointRule(Action.PERMIT.getText(), rule.getCidr()));
}
}
EndpointRule internalRule = new EndpointRule(Action.PERMIT.toString(), stack.getNetwork().getSubnetCIDR());
rules.add(internalRule);
rules.add(EndpointRule.DENY_RULE);
return rules;
}
Aggregations