Merge "Adding option to disable BDs for L3 only case"
authorTomas Cechvala <tcechval@cisco.com>
Fri, 5 May 2017 11:43:03 +0000 (11:43 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Fri, 5 May 2017 11:43:03 +0000 (11:43 +0000)
renderers/vpp/src/main/java/org/opendaylight/controller/config/yang/config/vpp_provider/impl/GbpVppProviderInstance.java
renderers/vpp/src/main/java/org/opendaylight/groupbasedpolicy/renderer/vpp/config/ConfigUtil.java
renderers/vpp/src/main/java/org/opendaylight/groupbasedpolicy/renderer/vpp/policy/BridgeDomainManagerImpl.java
renderers/vpp/src/main/java/org/opendaylight/groupbasedpolicy/renderer/vpp/policy/ForwardingManager.java
renderers/vpp/src/main/java/org/opendaylight/groupbasedpolicy/renderer/vpp/policy/VppRendererPolicyManager.java
renderers/vpp/src/main/resources/startup.cfg

index 32e428a8fa825077631441cc6fc3e63bd9f79565..29cb5fcdfb303b2883b7412fedb18ba2135be1d7 100644 (file)
@@ -16,6 +16,7 @@ import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
 import org.opendaylight.groupbasedpolicy.renderer.vpp.adapter.VppRpcServiceImpl;
+import org.opendaylight.groupbasedpolicy.renderer.vpp.config.ConfigUtil;
 import org.opendaylight.groupbasedpolicy.renderer.vpp.config.ConfigurationService;
 import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService;
 import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
@@ -29,7 +30,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.vpp_adapte
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.vpp_adapter.rev161201.DeleteInterfaceFromNodeInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.vpp_adapter.rev161201.DeleteVirtualBridgeDomainFromNodesInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.vpp_adapter.rev161201.VppAdapterService;
+import org.opendaylight.yangtools.yang.common.RpcError;
 import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -42,6 +45,9 @@ public class GbpVppProviderInstance implements ClusterSingletonService, VppAdapt
 
     private static final ServiceGroupIdentifier IDENTIFIER =
             ServiceGroupIdentifier.create(GroupbasedpolicyInstance.GBP_SERVICE_GROUP_IDENTIFIER);
+    private static final RpcResult<Void> L2_DISABLED_RESULT =
+        RpcResultBuilder.<Void>status(false).withWarning(RpcError.ErrorType.APPLICATION, "L2 disabled",
+            "Bridge domains are disabled because L3Flat mode is enabled. Check VPP startup config.").build();
     private final DataBroker dataBroker;
     private final BindingAwareBroker bindingAwareBroker;
     private final ClusterSingletonServiceProvider clusterSingletonService;
@@ -62,7 +68,7 @@ public class GbpVppProviderInstance implements ClusterSingletonService, VppAdapt
         this.clusterSingletonService = Preconditions.checkNotNull(clusterSingletonService);
         this.publicInterfaces = publicInterfaces;
         this.rpcProviderRegistry = Preconditions.checkNotNull(rpcProviderRegistry);
-        configurationService = new ConfigurationService();
+        this.configurationService = new ConfigurationService();
     }
 
     public void initialize() {
@@ -128,17 +134,26 @@ public class GbpVppProviderInstance implements ClusterSingletonService, VppAdapt
 
     @Override
     public Future<RpcResult<Void>> addInterfaceToBridgeDomain(AddInterfaceToBridgeDomainInput input) {
+        if (!ConfigUtil.getInstance().isL3FlatEnabled()) {
         return vppRpcService.addInterfaceToBridgeDomain(input);
+        }
+        return Futures.immediateFuture(L2_DISABLED_RESULT);
     }
 
     @Override
     public Future<RpcResult<Void>> delInterfaceFromBridgeDomain(DelInterfaceFromBridgeDomainInput input) {
-        return vppRpcService.delInterfaceFromBridgeDomain(input);
+        if (!ConfigUtil.getInstance().isL3FlatEnabled()) {
+            return vppRpcService.delInterfaceFromBridgeDomain(input);
+        }
+        return Futures.immediateFuture(L2_DISABLED_RESULT);
     }
 
     @Override
     public Future<RpcResult<Void>> cloneVirtualBridgeDomainOnNodes(CloneVirtualBridgeDomainOnNodesInput input) {
-        return vppRpcService.cloneVirtualBridgeDomainOnNodes(input);
+        if (!ConfigUtil.getInstance().isL3FlatEnabled()) {
+            return vppRpcService.cloneVirtualBridgeDomainOnNodes(input);
+        }
+        return Futures.immediateFuture(L2_DISABLED_RESULT);
     }
 
     @Override
index 76532393d55631adb25777b5d52a3aa3beea0c1b..1c3f6fabe457dba45a05030bce0bcbae7b4ed059 100644 (file)
@@ -17,103 +17,78 @@ import org.slf4j.LoggerFactory;
  * Created by Shakib Ahmed on 4/13/17.
  */
 public class ConfigUtil {
+
     private static final Logger LOG = LoggerFactory.getLogger(ConfigUtil.class);
 
-    private static boolean DEFAULT_LISP_OVERLAY_ENABLED = false;
-    private static boolean DEFAULT_LISP_MAPREGISTER_ENABLED = true;
-    private static boolean DEFAULT_L3_FLAT_ENABLED = false;
+    private static final boolean DEFAULT_LISP_OVERLAY_ENABLED = false;
+    private static final boolean DEFAULT_LISP_MAPREGISTER_ENABLED = true;
+    private static final boolean DEFAULT_L3_FLAT_ENABLED = false;
+    private static final String DEFAULT_TRUE_STRING_VALUE = "true";
+    private static final String CONFIGURATION_VARIABLE_MESSAGE =
+        "Configuration variable {} is being unset. Setting the variable to {}";
 
     private IpAddress odlTenantIp;
     private boolean lispOverlayEnabled = DEFAULT_LISP_OVERLAY_ENABLED;
     private boolean lispMapRegisterEnbled = DEFAULT_LISP_MAPREGISTER_ENABLED;
     private boolean l3FlatEnabled = DEFAULT_L3_FLAT_ENABLED;
 
+    static final String ODL_TENANT_IP = "odl.ip.tenant";
+    static final String LISP_OVERLAY_ENABLED = "gbp.lisp.enabled";
+    static final String LISP_MAPREGISTER_ENABLED = "vpp.lisp.mapregister.enabled";
+    static final String L3_FLAT_ENABLED = "vpp.l3.flat.enabled";
 
-    public static String ODL_TENANT_IP = "odl.ip.tenant";
-    public static String LISP_OVERLAY_ENABLED = "gbp.lisp.enabled";
-    public static String LISP_MAPREGISTER_ENABLED = "vpp.lisp.mapregister.enabled";
-    public static String L3_FLAT_ENABLED = "vpp.l3.flat.enabled";
-
-    private static ConfigUtil INSTANCE = new ConfigUtil();
+    private static final ConfigUtil INSTANCE = new ConfigUtil();
 
     private ConfigUtil() {
-        configureDefaults();
+        configureOdlTenantIp(null);
+        configureLispOverlayEnabled(null);
+        configureMapRegister(null);
+        configL3FlatEnabled(null);
     }
 
     public static ConfigUtil getInstance() {
         return INSTANCE;
     }
 
-    private void configureDefaults() {
-        configureOdlTenantIp(null);
-        configureLispOverlayEnabled(null);
-        configureMapRegister(null);
-    }
-
-    public void configureLispOverlayEnabled(String configStr) {
+    void configureLispOverlayEnabled(String configStr) {
         if (configStr == null) {
             configStr = System.getProperty(LISP_OVERLAY_ENABLED);
 
             if (configStr == null) {
                 lispOverlayEnabled = DEFAULT_LISP_OVERLAY_ENABLED;
-                LOG.debug("Configuration variable {} is being unset. Setting the variable to {}",
-                        LISP_OVERLAY_ENABLED, DEFAULT_LISP_OVERLAY_ENABLED);
+                LOG.debug(CONFIGURATION_VARIABLE_MESSAGE, LISP_OVERLAY_ENABLED, DEFAULT_LISP_OVERLAY_ENABLED);
                 return;
             }
         }
-
-        configStr = configStr.trim();
-
-        if (configStr.equalsIgnoreCase("true")) {
-            lispOverlayEnabled = true;
-        } else {
-            lispOverlayEnabled = false;
-        }
+        lispOverlayEnabled = configStr.trim().equalsIgnoreCase(DEFAULT_TRUE_STRING_VALUE);
     }
 
-    public void configureOdlTenantIp(String configStr) {
+    void configureOdlTenantIp(String configStr) {
         if (configStr == null) {
             odlTenantIp = null;
             LOG.debug("Configuration variable {} is being unset. Setting the variable to null",
                     ODL_TENANT_IP);
             return;
         }
-
-        configStr = configStr.trim();
-        odlTenantIp = new IpAddress(configStr.toCharArray());
+        odlTenantIp = new IpAddress(configStr.trim().toCharArray());
     }
 
-    public void configureMapRegister(String configStr) {
+    void configureMapRegister(String configStr) {
         if (configStr == null) {
             lispMapRegisterEnbled = DEFAULT_LISP_MAPREGISTER_ENABLED;
-            LOG.debug("Configuration variable {} is being unset. Setting the variable to {}",
-                    LISP_MAPREGISTER_ENABLED, DEFAULT_LISP_MAPREGISTER_ENABLED);
+            LOG.debug(CONFIGURATION_VARIABLE_MESSAGE, LISP_MAPREGISTER_ENABLED, DEFAULT_LISP_MAPREGISTER_ENABLED);
             return;
         }
-
-        configStr = configStr.trim();
-
-        if (configStr.equalsIgnoreCase("true")) {
-            lispMapRegisterEnbled = true;
-        } else {
-            lispOverlayEnabled = false;
-        }
+        lispMapRegisterEnbled = configStr.trim().equalsIgnoreCase(DEFAULT_TRUE_STRING_VALUE);
     }
 
-    public void configL3FlatEnabled(String configStr) {
+    void configL3FlatEnabled(String configStr) {
         if (configStr == null) {
             l3FlatEnabled = DEFAULT_L3_FLAT_ENABLED;
-            LOG.debug("Configuration variable {} is being unset. Setting the variable to {}",
-                    L3_FLAT_ENABLED, DEFAULT_L3_FLAT_ENABLED);
-        }
-
-        configStr = configStr.trim();
-
-        if (configStr.equalsIgnoreCase("true")) {
-            l3FlatEnabled = true;
-        } else {
-            l3FlatEnabled = false;
+            LOG.debug(CONFIGURATION_VARIABLE_MESSAGE, L3_FLAT_ENABLED, DEFAULT_L3_FLAT_ENABLED);
+            return;
         }
+        l3FlatEnabled = configStr.trim().equalsIgnoreCase(DEFAULT_TRUE_STRING_VALUE);
     }
 
     public IpAddress getOdlTenantIp() {
index 43f3e1aaf187b68e0ca7db7991ceca14a9c07961..f7c587b5c6889c8fce96e8fbef850db95f81ce87 100644 (file)
@@ -27,6 +27,7 @@ import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
 import org.opendaylight.groupbasedpolicy.renderer.vpp.api.BridgeDomainManager;
+import org.opendaylight.groupbasedpolicy.renderer.vpp.config.ConfigUtil;
 import org.opendaylight.groupbasedpolicy.renderer.vpp.util.VppIidFactory;
 import org.opendaylight.groupbasedpolicy.util.DataStoreHelper;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.vpp_renderer.rev160425.Config;
@@ -104,8 +105,12 @@ public class BridgeDomainManagerImpl implements BridgeDomainManager {
             Preconditions.checkArgument(!future.isDone());
             this.modificationForFutureSet = Preconditions.checkNotNull(modificationForFutureSet);
             this.iid = Preconditions.checkNotNull(iid);
-            registeredListener = dataProvider.registerDataTreeChangeListener(iid, this);
-            LOG.debug("Registered listener for path {}", iid.getRootIdentifier());
+            if(!ConfigUtil.getInstance().isL3FlatEnabled()) {
+                registeredListener = dataProvider.registerDataTreeChangeListener(iid, this);
+                LOG.debug("Registered listener for path {}", iid.getRootIdentifier());
+            } else {
+                throw new IllegalStateException("L3 flat is enabled, BD manager should not even be registering now!");
+            }
         }
 
         @Override
index 91396d85f6a1c92cec5c99a4152bd48a18905a34..f65248ca8655e17228427ecd04fd6e3b0302c243 100644 (file)
@@ -25,6 +25,7 @@ import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.groupbasedpolicy.renderer.vpp.api.BridgeDomainManager;
 import org.opendaylight.groupbasedpolicy.renderer.vpp.commands.RoutingCommand;
+import org.opendaylight.groupbasedpolicy.renderer.vpp.config.ConfigUtil;
 import org.opendaylight.groupbasedpolicy.renderer.vpp.iface.AclManager;
 import org.opendaylight.groupbasedpolicy.renderer.vpp.iface.InterfaceManager;
 import org.opendaylight.groupbasedpolicy.renderer.vpp.nat.NatManager;
@@ -209,16 +210,20 @@ public final class ForwardingManager {
                 LOG.info("Renderer endpoint does not have l2FloodDomain as network containment {}", rEp);
                 return;
             }
-            String l2FloodDomain = optL2FloodDomain.get();
-            try {
-                ifaceManager.addBridgeDomainToInterface(l2FloodDomain, rEp, AccessListUtil.resolveAclsOnInterface(
+
+            if (!ConfigUtil.getInstance().isL3FlatEnabled()) {
+                String l2FloodDomain = optL2FloodDomain.get();
+                try {
+                    ifaceManager.addBridgeDomainToInterface(l2FloodDomain, rEp, AccessListUtil.resolveAclsOnInterface(
                         rEpKey, policyCtx), isBviForEndpoint(rEp)).get();
-                aclManager.updateAclsForPeers(policyCtx, rEpKey);
-                LOG.debug("Interface added to bridge-domain {} for endpoint {}", l2FloodDomain, rEp);
-            } catch (InterruptedException | ExecutionException e) {
-                // TODO add it to the status for renderer manager
-                LOG.warn("Interface was not added to bridge-domain {} for endpoint {}", l2FloodDomain, rEp, e);
+                    LOG.debug("Interface added to bridge-domain {} for endpoint {}", l2FloodDomain, rEp);
+
+                } catch (InterruptedException | ExecutionException e) {
+                    // TODO add it to the status for renderer manager
+                    LOG.warn("Interface was not added to bridge-domain {} for endpoint {}", l2FloodDomain, rEp, e);
+                }
             }
+            aclManager.updateAclsForPeers(policyCtx, rEpKey);
         } else {
             LOG.debug("Forwarding is not created - Location of renderer endpoint contains "
                     + "external-node therefore VPP renderer assumes that interface for endpoint is "
index 3b7ae60461820784397e571691a738c6f102d796..348c96b13320958035a61f49a8426806bee62d34 100644 (file)
@@ -22,6 +22,7 @@ import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.groupbasedpolicy.renderer.util.AddressEndpointUtils;
+import org.opendaylight.groupbasedpolicy.renderer.vpp.config.ConfigUtil;
 import org.opendaylight.groupbasedpolicy.renderer.vpp.event.NodeOperEvent;
 import org.opendaylight.groupbasedpolicy.renderer.vpp.event.RendererPolicyConfEvent;
 import org.opendaylight.groupbasedpolicy.renderer.vpp.iface.AclManager;
@@ -164,10 +165,12 @@ public class VppRendererPolicyManager {
         LOG.debug("Removed renderer endpoints {}", removedRendEps);
         removedRendEps.forEach(rEpKey -> fwManager.removeForwardingForEndpoint(rEpKey, policyCtxBefore));
 
-        LOG.debug("Removing bridge domains on nodes {}", removedVppNodesByL2Fd);
-        fwManager.removeBridgeDomainOnNodes(removedVppNodesByL2Fd);
-        LOG.debug("Creating bridge domains on nodes {}", createdVppNodesByL2Fd);
-        fwManager.createBridgeDomainOnNodes(createdVppNodesByL2Fd);
+        if (!ConfigUtil.getInstance().isL3FlatEnabled()) {
+            LOG.debug("Removing bridge domains on nodes {}", removedVppNodesByL2Fd);
+            fwManager.removeBridgeDomainOnNodes(removedVppNodesByL2Fd);
+            LOG.debug("Creating bridge domains on nodes {}", createdVppNodesByL2Fd);
+            fwManager.createBridgeDomainOnNodes(createdVppNodesByL2Fd);
+        }
 
         fwManager.syncNatEntries(policyCtxAfter);
 
@@ -265,9 +268,10 @@ public class VppRendererPolicyManager {
         LOG.trace("VPP renderer policy version {} created", rPolicy.getVersion());
         PolicyContext policyCtx = new PolicyContext(rPolicy);
         ImmutableSet<RendererEndpointKey> rEpKeys = policyCtx.getPolicyTable().rowKeySet();
-
-        SetMultimap<String, NodeId> vppNodesByL2Fd = resolveVppNodesByL2Fd(rEpKeys, policyCtx);
-        fwManager.createBridgeDomainOnNodes(vppNodesByL2Fd);
+        if (!ConfigUtil.getInstance().isL3FlatEnabled()) {
+            SetMultimap<String, NodeId> vppNodesByL2Fd = resolveVppNodesByL2Fd(rEpKeys, policyCtx);
+            fwManager.createBridgeDomainOnNodes(vppNodesByL2Fd);
+        }
         fwManager.syncNatEntries(policyCtx);
         fwManager.syncRouting(policyCtx);
         rEpKeys.forEach(rEpKey -> fwManager.createForwardingForEndpoint(rEpKey, policyCtx));
@@ -279,11 +283,12 @@ public class VppRendererPolicyManager {
         ImmutableSet<RendererEndpointKey> rEpKeys = policyCtx.getPolicyTable().rowKeySet();
 
         rEpKeys.forEach(rEpKey -> fwManager.removeForwardingForEndpoint(rEpKey, policyCtx));
-
-        SetMultimap<String, NodeId> vppNodesByL2Fd = resolveVppNodesByL2Fd(rEpKeys, policyCtx);
+        if (!ConfigUtil.getInstance().isL3FlatEnabled()) {
+            SetMultimap<String, NodeId> vppNodesByL2Fd = resolveVppNodesByL2Fd(rEpKeys, policyCtx);
+            fwManager.removeBridgeDomainOnNodes(vppNodesByL2Fd);
+        }
         fwManager.deleteNatEntries(policyCtx);
         fwManager.deleteRouting(policyCtx);
-        fwManager.removeBridgeDomainOnNodes(vppNodesByL2Fd);
     }
 
     private static SetMultimap<String, NodeId> resolveVppNodesByL2Fd(Set<RendererEndpointKey> rEpKeys,
index 5ebd8d87430e6e0716fc873d2a6c9fcb71fd1bd2..04c908bad27405970908774d755036de9dc04774 100644 (file)
 
 # This property should be  set to the Ip address the ODL can be reached from tenant network.
 # Valid config: Ip Address (IPv4/ IPv6)
-odl.ip.tenant = 10.0.0.1
+#odl.ip.tenant = 10.0.0.1
 
 # This property should be true if L3 overlay is desired. If `true`, GBP will
 # push LISP configurations in VPP.
 # Valid config: true/false
 # Required config: odl.ip.tenant to be set.
 # Default value: false
-gbp.lisp.enabled = true
+#gbp.lisp.enabled = true
 
 # This property determines whether VPP makes the map request directly to the map server.
 # If true, VPP will register the mappings in the Map server and no LISP feature will
@@ -25,7 +25,7 @@ gbp.lisp.enabled = true
 # Valid config: true/false
 # Required config: gbp.lisp.enabled is set to be true.
 # Default value: true
-vpp.lisp.mapregister.enabled = true
+#vpp.lisp.mapregister.enabled = true
 
 # This property determines whether a flat l3 overlay will created.
 # If true, there will not be any vxlan involved for L2. There will
@@ -34,4 +34,4 @@ vpp.lisp.mapregister.enabled = true
 # Valid config: true/false
 # Required config: gbp.lisp.enabled is set to be true.
 # Default value: true
-vpp.l3.flat.enabled = true
\ No newline at end of file
+#vpp.l3.flat.enabled = true