use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.SecurityRuleAttrBuilder in project netvirt by opendaylight.
the class NeutronSecurityRuleListener method toAceBuilder.
private AceBuilder toAceBuilder(SecurityRule securityRule) {
AceIpBuilder aceIpBuilder = new AceIpBuilder();
SecurityRuleAttrBuilder securityRuleAttrBuilder = new SecurityRuleAttrBuilder();
DestinationPortRangeBuilder destinationPortRangeBuilder = new DestinationPortRangeBuilder();
boolean isDirectionIngress = false;
if (securityRule.getDirection() != null) {
securityRuleAttrBuilder.setDirection(DIRECTION_MAP.get(securityRule.getDirection()));
isDirectionIngress = securityRule.getDirection().equals(DirectionIngress.class);
}
if (securityRule.getPortRangeMax() != null) {
destinationPortRangeBuilder.setUpperPort(new PortNumber(securityRule.getPortRangeMax()));
}
if (securityRule.getPortRangeMin() != null) {
destinationPortRangeBuilder.setLowerPort(new PortNumber(securityRule.getPortRangeMin()));
// set destination port range if lower port is specified as it is mandatory parameter in acl model
aceIpBuilder.setDestinationPortRange(destinationPortRangeBuilder.build());
}
aceIpBuilder = handleRemoteIpPrefix(securityRule, aceIpBuilder, isDirectionIngress);
if (securityRule.getRemoteGroupId() != null) {
securityRuleAttrBuilder.setRemoteGroupId(securityRule.getRemoteGroupId());
}
if (securityRule.getProtocol() != null) {
SecurityRuleAttributes.Protocol protocol = securityRule.getProtocol();
if (protocol.getUint8() != null) {
// uint8
aceIpBuilder.setProtocol(protocol.getUint8());
} else {
// symbolic protocol name
aceIpBuilder.setProtocol(PROTOCOL_MAP.get(protocol.getIdentityref()));
}
}
MatchesBuilder matchesBuilder = new MatchesBuilder();
matchesBuilder.setAceType(aceIpBuilder.build());
// set acl action as permit for the security rule
ActionsBuilder actionsBuilder = new ActionsBuilder();
actionsBuilder.setPacketHandling(new PermitBuilder().setPermit(true).build());
AceBuilder aceBuilder = new AceBuilder();
aceBuilder.setKey(new AceKey(securityRule.getUuid().getValue()));
aceBuilder.setRuleName(securityRule.getUuid().getValue());
aceBuilder.setMatches(matchesBuilder.build());
aceBuilder.setActions(actionsBuilder.build());
aceBuilder.addAugmentation(SecurityRuleAttr.class, securityRuleAttrBuilder.build());
return aceBuilder;
}
Aggregations