Search in sources :

Example 6 with SecurityRule

use of com.sequenceiq.cloudbreak.domain.SecurityRule in project cloudbreak by hortonworks.

the class SecurityRuleRequestToSecurityRuleConverterTest method testConvert5.

@Test
public void testConvert5() {
    SecurityRule result = underTest.convert(createRequest("22,9400-9500"));
    assertAllFieldsNotNull(result, Collections.singletonList("securityGroup"));
}
Also used : SecurityRule(com.sequenceiq.cloudbreak.domain.SecurityRule) Test(org.junit.Test)

Example 7 with SecurityRule

use of com.sequenceiq.cloudbreak.domain.SecurityRule in project cloudbreak by hortonworks.

the class SecurityGroupToSecurityGroupV2RequestConverter method convert.

@Override
public SecurityGroupV2Request convert(SecurityGroup source) {
    SecurityGroupV2Request securityGroupV2Request = new SecurityGroupV2Request();
    securityGroupV2Request.setSecurityGroupId(source.getSecurityGroupId());
    securityGroupV2Request.setSecurityRules(new ArrayList<>());
    for (SecurityRule securityRule : source.getSecurityRules()) {
        securityGroupV2Request.getSecurityRules().add(getConversionService().convert(securityRule, SecurityRuleRequest.class));
    }
    return securityGroupV2Request;
}
Also used : SecurityGroupV2Request(com.sequenceiq.cloudbreak.api.model.v2.SecurityGroupV2Request) SecurityRuleRequest(com.sequenceiq.cloudbreak.api.model.SecurityRuleRequest) SecurityRule(com.sequenceiq.cloudbreak.domain.SecurityRule)

Example 8 with SecurityRule

use of com.sequenceiq.cloudbreak.domain.SecurityRule in project cloudbreak by hortonworks.

the class DefaultSecurityGroupCreator method addSecurityGroup.

private void addSecurityGroup(IdentityUser user, String platform, String name, Iterable<Port> securityGroupPorts, String securityGroupDesc) {
    SecurityGroup onlySshAndSsl = createSecurityGroup(user, platform, name, securityGroupDesc);
    SecurityRule sshAndSslRule = createSecurityRule(concatenatePorts(securityGroupPorts), onlySshAndSsl);
    onlySshAndSsl.setSecurityRules(new HashSet<>(Collections.singletonList(sshAndSslRule)));
    securityGroupService.create(user, onlySshAndSsl);
}
Also used : SecurityRule(com.sequenceiq.cloudbreak.domain.SecurityRule) SecurityGroup(com.sequenceiq.cloudbreak.domain.SecurityGroup)

Example 9 with SecurityRule

use of com.sequenceiq.cloudbreak.domain.SecurityRule 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;
}
Also used : EndpointRule(com.sequenceiq.cloudbreak.api.model.EndpointRule) SecurityRule(com.sequenceiq.cloudbreak.domain.SecurityRule) LinkedList(java.util.LinkedList) InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup)

Example 10 with SecurityRule

use of com.sequenceiq.cloudbreak.domain.SecurityRule in project cloudbreak by hortonworks.

the class SecurityRuleRequestToSecurityRuleConverter method convert.

@Override
public SecurityRule convert(SecurityRuleRequest json) {
    SecurityRule entity = new SecurityRule();
    entity.setCidr(json.getSubnet());
    String ports = json.getPorts();
    validatePorts(ports);
    entity.setPorts(ports);
    entity.setProtocol(json.getProtocol());
    entity.setModifiable(json.isModifiable() == null ? false : json.isModifiable());
    return entity;
}
Also used : SecurityRule(com.sequenceiq.cloudbreak.domain.SecurityRule)

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