use of com.sequenceiq.cloudbreak.domain.SecurityRule in project cloudbreak by hortonworks.
the class DefaultSecurityGroupCreator method createSecurityRule.
private SecurityRule createSecurityRule(String ports, SecurityGroup securityGroup) {
SecurityRule securityRule = new SecurityRule();
securityRule.setCidr("0.0.0.0/0");
securityRule.setModifiable(false);
securityRule.setPorts(ports);
securityRule.setProtocol(TCP_PROTOCOL);
securityRule.setSecurityGroup(securityGroup);
return securityRule;
}
use of com.sequenceiq.cloudbreak.domain.SecurityRule 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.domain.SecurityRule in project cloudbreak by hortonworks.
the class SecurityRuleRequestToSecurityRuleConverterTest method testConvert3.
@Test
public void testConvert3() {
SecurityRule result = underTest.convert(createRequest("1-65535"));
assertAllFieldsNotNull(result, Collections.singletonList("securityGroup"));
}
use of com.sequenceiq.cloudbreak.domain.SecurityRule in project cloudbreak by hortonworks.
the class SecurityRuleRequestToSecurityRuleConverterTest method testConvert4.
@Test
public void testConvert4() {
SecurityRule result = underTest.convert(createRequest("20-23,9400-9500"));
assertAllFieldsNotNull(result, Collections.singletonList("securityGroup"));
}
use of com.sequenceiq.cloudbreak.domain.SecurityRule in project cloudbreak by hortonworks.
the class SecurityRuleRequestToSecurityRuleConverterTest method testConvert2.
@Test
public void testConvert2() {
SecurityRule result = underTest.convert(createRequest("22,9443"));
assertAllFieldsNotNull(result, Collections.singletonList("securityGroup"));
}
Aggregations