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"));
}
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;
}
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);
}
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;
}
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;
}
Aggregations