Bug 8009 - public intf can be learned from HC 31/55731/3
authorTomas Cechvala <tcechval@cisco.com>
Thu, 20 Apr 2017 13:11:50 +0000 (15:11 +0200)
committerTomas Cechvala <tcechval@cisco.com>
Tue, 25 Apr 2017 08:35:05 +0000 (08:35 +0000)
Public interface can be specified not only in bundle configuration,
but directly from HC too by writing 'public-interface' to config DS
ietf-interfaces:interfaces/interface/description

Interface is marked as external if it is specified in blueprint
config of the bundle OR if it is learned from HC.

Change-Id: I330b25258cd4f32458734f80a90bbaf18a113ba3
Signed-off-by: Tomas Cechvala <tcechval@cisco.com>
renderers/vpp/src/main/java/org/opendaylight/groupbasedpolicy/renderer/vpp/manager/VppNodeManager.java

index 01dddbafe1bad00041c79f61c3db9ec0dd810437..6988567f3e64479c536919b6e5233f27aa2a3a8d 100644 (file)
@@ -88,6 +88,7 @@ public class VppNodeManager {
     private static final String INTERFACES_CAPABILITY = "(urn:ietf:params:xml:ns:yang:ietf-interfaces?revision=2014-05-08)ietf-interfaces";
     private static final NodeId CONTROLLER_CONFIG_NODE = new NodeId("controller-config");
     private static final String NO_PUBLIC_INT_SPECIFIED = "unspecified";
+    private static final String PUBLIC_INTERFACE = "public-interface";
     private final Map<NodeId, PhysicalInterfaceKey> extInterfaces = new HashMap<>();
     private final DataBroker dataBroker;
     private final List<String> requiredCapabilities;
@@ -252,6 +253,7 @@ public class VppNodeManager {
         final RendererNode rendererNode = remapNode(mountPointIid);
         final WriteTransaction wTx = dataBroker.newWriteOnlyTransaction();
         wTx.delete(LogicalDatastoreType.OPERATIONAL, VppIidFactory.getRendererNodeIid(rendererNode));
+        extInterfaces.remove(node.getNodeId());
         final CheckedFuture<Void, TransactionCommitFailedException> checkedFuture = wTx.submit();
         try {
             checkedFuture.checkedGet();
@@ -410,13 +412,18 @@ public class VppNodeManager {
                     phIface.setInterfaceName(iface.getName());
                     phIface.setType(iface.getType());
                     phIface.setAddress(resolveIpAddress(iface.getAugmentation(Interface1.class)));
-
-                    if (extInterfaces.get(nodeId) != null && extInterfaces.get(nodeId)
-                        .getInterfaceName()
-                        .equals(phIface.getInterfaceName())) {
+                    if (extInterfaces.get(nodeId) != null
+                            && extInterfaces.get(nodeId).getInterfaceName().equals(phIface.getInterfaceName())) {
+                        phIface.setExternal(true);
+                        extInterfaces.put(nodeId, new PhysicalInterfaceKey(iface.getName()));
+                        LOG.info("Interface {} is marked as public interface based on bundle configuration.",
+                                iface.getName());
+                    }
+                    if (PUBLIC_INTERFACE.equals(iface.getDescription())) {
                         phIface.setExternal(true);
-                        LOG.trace("Assigning external Interface, interface name: {}, extInterface name: {}",
-                            phIface.getInterfaceName(), extInterfaces.get(nodeId).getInterfaceName());
+                        extInterfaces.put(nodeId, new PhysicalInterfaceKey(iface.getName()));
+                        LOG.info("Interface {} is marked as public interface based on HC configuration.",
+                                iface.getName());
                     }
                     phIfaces.add(phIface.build());
                 });