Bug 8900 - fixing ACL updates 12/60812/5
authorTomas Cechvala <tcechval@cisco.com>
Thu, 27 Jul 2017 13:32:09 +0000 (15:32 +0200)
committerTomas Cechvala <tcechval@cisco.com>
Wed, 2 Aug 2017 07:29:42 +0000 (07:29 +0000)
some entries were not getting written to ACL
because of bad interface name resolving

Change-Id: I70132c5d204ff4c408cb4bcc771b27fe702dbbcc
Signed-off-by: Tomas Cechvala <tcechval@cisco.com>
groupbasedpolicy/src/main/java/org/opendaylight/groupbasedpolicy/renderer/RendererConfigurationBuilder.java
renderers/vpp/src/main/java/org/opendaylight/groupbasedpolicy/renderer/vpp/iface/VppPathMapper.java
renderers/vpp/src/main/java/org/opendaylight/groupbasedpolicy/renderer/vpp/policy/acl/AclManager.java

index 7d2f0fab7cefea0f052f87dfe8d91b3831830230..72e846abefb981cf3a31e730487776155a8381c2 100644 (file)
@@ -315,7 +315,11 @@ public class RendererConfigurationBuilder {
             Map<InstanceIdentifier<?>, RendererName> rendererByNode) {
         Optional<InstanceIdentifier<?>> potentialAbsNodeLoc = EndpointLocationUtils.resolveAbsoluteNodeLocation(epLoc);
         if (potentialAbsNodeLoc.isPresent()) {
-            return Optional.of(rendererByNode.get(potentialAbsNodeLoc.get()));
+            if (rendererByNode.get(potentialAbsNodeLoc.get()) != null) {
+                return Optional.of(rendererByNode.get(potentialAbsNodeLoc.get()));
+            } else {
+                return Optional.absent();
+            }
         }
         Optional<List<InstanceIdentifier<?>>> potentianRelativeLocation =
                 EndpointLocationUtils.resolveRelativeExternalNodeMountPointLocation(epLoc);
index a802c1bdceb9a0c0f84fb9bf6fc1ee667a29ec1f..941ed50c1be04e69b6d218364af5253952344abd 100644 (file)
@@ -27,7 +27,6 @@ public class VppPathMapper {
             INTERFACE_PATH_BEFORE_KEY.length() + INTERFACE_PATH_AFTER_KEY.length() + 1;
     private static final String BD_PATH_BEFORE_KEY = "/v3po:vpp/v3po:bridge-domains/v3po:bridge-domain[v3po:name='";
     private static final String BD_PATH_AFTER_KEY = "']";
-    private static final int BD_PATH_MIN_LENGTH = BD_PATH_BEFORE_KEY.length() + BD_PATH_AFTER_KEY.length() + 1;
 
     private VppPathMapper() {}
 
index 49737dffd7b841097b5c72fea586175ca8539559..b12dbe5b216508bfc0b04e4fc8579f91a5ea2ed4 100644 (file)
@@ -216,15 +216,18 @@ public class AclManager {
                         getInterfacesForEndpoint(policyCtx, KeyFactory.addressEndpointKey(endpointKey));
                 interfacesForEndpoint.keySet().forEach(nodeId -> {
                     ImmutableSet<InterfaceKey> intfcsOnNode = interfacesForEndpoint.get(nodeId);
-                    intfcsOnNode.forEach(intf -> {
-                        if (aceTable.get(nodeId, intf) != null) {
+                    intfcsOnNode.forEach(intfKey -> {
+                        Optional<String> intfName =
+                                VppPathMapper.interfacePathToInterfaceName(intfKey.getName());
+                        Preconditions.checkArgument(intfName.isPresent(), "Failed to resolve interface name from " + intfKey);
+                        if (aceTable.get(nodeId, intfKey) != null) {
                             List<Ace> aces = Stream
-                                .concat(aceTable.get(nodeId, intf).stream(),
+                                .concat(aceTable.get(nodeId, intfKey).stream(),
                                         aceBuilders.stream().map(aceBuilder -> aceBuilder.build()))
                                 .collect(Collectors.toList());
-                            aceTable.put(nodeId, new AclKey(intf.getName() + aceDirection, VppAcl.class), aces);
+                            aceTable.put(nodeId, new AclKey(intfName.get() + aceDirection, VppAcl.class), aces);
                         } else {
-                            aceTable.put(nodeId, new AclKey(intf.getName() + aceDirection, VppAcl.class),
+                            aceTable.put(nodeId, new AclKey(intfName.get() + aceDirection, VppAcl.class),
                                     aceBuilders.stream()
                                         .map(aceBuilder -> aceBuilder.build())
                                         .collect(Collectors.toList()));
@@ -243,7 +246,6 @@ public class AclManager {
 
                 @Override
                 public Void call() throws Exception {
-                    LOG.debug("Updating node {}", nodeId);
                     InstanceIdentifier<Node> vppIid = VppIidFactory.getNetconfNodeIid(nodeId);
                     Optional<DataBroker> dataBroker =
                         mountDataProvider.resolveDataBrokerForMountPoint(vppIid);
@@ -264,7 +266,7 @@ public class AclManager {
                         if (entries.isEmpty()) {
                             return;
                         }
-                        LOG.info("Updating ACL: Action={}, Node={}, ACL={}", write, nodeId.getValue(),
+                        LOG.debug("Updating ACL: Action={}, Node={}, ACL={}", write, nodeId.getValue(),
                                 aclKey.getAclName());
                         boolean result = (write) ? GbpNetconfTransaction.netconfSyncedWrite(vppIid, entries,
                                 GbpNetconfTransaction.RETRY_COUNT) : GbpNetconfTransaction.netconfSyncedDelete(