Search in sources :

Example 1 with SecurityRule

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;
}
Also used : SecurityRule(com.sequenceiq.cloudbreak.domain.SecurityRule)

Example 2 with 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;
}
Also used : Port(com.sequenceiq.cloudbreak.api.model.Port) EndpointRule(com.sequenceiq.cloudbreak.api.model.EndpointRule) ArrayList(java.util.ArrayList) SecurityRule(com.sequenceiq.cloudbreak.domain.SecurityRule) Stack(com.sequenceiq.cloudbreak.domain.Stack) InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup)

Example 3 with SecurityRule

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"));
}
Also used : SecurityRule(com.sequenceiq.cloudbreak.domain.SecurityRule) Test(org.junit.Test)

Example 4 with SecurityRule

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"));
}
Also used : SecurityRule(com.sequenceiq.cloudbreak.domain.SecurityRule) Test(org.junit.Test)

Example 5 with SecurityRule

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"));
}
Also used : SecurityRule(com.sequenceiq.cloudbreak.domain.SecurityRule) Test(org.junit.Test)

Aggregations

SecurityRule (com.sequenceiq.cloudbreak.domain.SecurityRule)12 Test (org.junit.Test)6 EndpointRule (com.sequenceiq.cloudbreak.api.model.EndpointRule)2 InstanceGroup (com.sequenceiq.cloudbreak.domain.InstanceGroup)2 SecurityGroup (com.sequenceiq.cloudbreak.domain.SecurityGroup)2 Port (com.sequenceiq.cloudbreak.api.model.Port)1 SecurityRuleRequest (com.sequenceiq.cloudbreak.api.model.SecurityRuleRequest)1 SecurityGroupV2Request (com.sequenceiq.cloudbreak.api.model.v2.SecurityGroupV2Request)1 Stack (com.sequenceiq.cloudbreak.domain.Stack)1 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 TypeDescriptor (org.springframework.core.convert.TypeDescriptor)1