public SecurityRuleAttrBuilder(SecurityRuleAttr base) { this._direction = base.getDirection(); this._remoteGroupId = base.getRemoteGroupId(); }
@Override public boolean equals(java.lang.Object obj) { if (this == obj) { return true; } if (!(obj instanceof DataObject)) { return false; } if (!org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.SecurityRuleAttr.class.equals(((DataObject)obj).getImplementedInterface())) { return false; } org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.SecurityRuleAttr other = (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.SecurityRuleAttr)obj; if (!Objects.equals(_direction, other.getDirection())) { return false; } if (!Objects.equals(_remoteGroupId, other.getRemoteGroupId())) { return false; } return true; }
private void updateRemoteAclCache(List<Ace> aceList, String aclName, AclServiceManager.Action action) { if (null == aceList) { return; } for (Ace ace : aceList) { SecurityRuleAttr aceAttributes = ace.getAugmentation(SecurityRuleAttr.class); if (aceAttributes != null && aceAttributes.getRemoteGroupId() != null) { if (action == AclServiceManager.Action.ADD) { AclDataUtil.addRemoteAclId(aceAttributes.getRemoteGroupId(), new Uuid(aclName)); } else { AclDataUtil.removeRemoteAclId(aceAttributes.getRemoteGroupId(), new Uuid(aclName)); } } } }
public static List<Ace> getAceWithRemoteAclId(DataBroker dataBroker, AclInterface port, Uuid remoteAcl) { List<Ace> remoteAclRuleList = new ArrayList<>(); List<Uuid> aclList = port.getSecurityGroups(); for (Uuid aclId : aclList) { Acl acl = getAcl(dataBroker, aclId.getValue()); List<Ace> aceList = acl.getAccessListEntries().getAce(); for (Ace ace : aceList) { Uuid tempRemoteAcl = getAccesssListAttributes(ace).getRemoteGroupId(); if (tempRemoteAcl != null && tempRemoteAcl.equals(remoteAcl)) { remoteAclRuleList.add(ace); } } } return remoteAclRuleList; }
@Override protected void programAceRule(BigInteger dpId, int lportTag, int addOrRemove, Ace ace, String portId, List<AllowedAddressPairs> syncAllowedAddresses) { SecurityRuleAttr aceAttr = AclServiceUtils.getAccesssListAttributes(ace); if (!aceAttr.getDirection().equals(DirectionIngress.class)) { return; } Matches matches = ace.getMatches(); AceType aceType = matches.getAceType(); Map<String,List<MatchInfoBase>> flowMap = null; if (aceType instanceof AceIp) { flowMap = AclServiceOFFlowBuilder.programIpFlow(matches); if (syncAllowedAddresses != null) { flowMap = AclServiceUtils.getFlowForAllowedAddresses(syncAllowedAddresses, flowMap, true); } else if (aceAttr.getRemoteGroupId() != null) { flowMap = AclServiceUtils.getFlowForRemoteAcl(aceAttr.getRemoteGroupId(), portId, flowMap, true); } } if (null == flowMap) { LOG.error("Failed to apply ACL {} lportTag {}", ace.getKey(), lportTag); return; } for ( String flowName : flowMap.keySet()) { flowName = syncSpecificAclFlow(dpId, lportTag, addOrRemove, ace, portId, flowMap, flowName); } }
@Override protected void programAceRule(BigInteger dpId, int lportTag, int addOrRemove, Ace ace, String portId, List<AllowedAddressPairs> syncAllowedAddresses) { SecurityRuleAttr aceAttr = AclServiceUtils.getAccesssListAttributes(ace); if (!aceAttr.getDirection().equals(DirectionEgress.class)) { return; } Matches matches = ace.getMatches(); AceType aceType = matches.getAceType(); Map<String,List<MatchInfoBase>> flowMap = null; if (aceType instanceof AceIp) { flowMap = AclServiceOFFlowBuilder.programIpFlow(matches); if (syncAllowedAddresses != null) { flowMap = AclServiceUtils.getFlowForAllowedAddresses(syncAllowedAddresses, flowMap, false); } else if (aceAttr.getRemoteGroupId() != null) { flowMap = AclServiceUtils.getFlowForRemoteAcl(aceAttr.getRemoteGroupId(), portId, flowMap, false); } } if (null == flowMap) { LOG.error("Failed to apply ACL {} lportTag {}", ace.getKey(), lportTag); return; } //The flow map contains list of flows if port range is selected. for ( String flowName : flowMap.keySet()) { flowName = syncSpecificAclFlow(dpId, lportTag, addOrRemove, ace, portId, flowMap, flowName); } }