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;
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;
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;
this.clusterSingletonService = Preconditions.checkNotNull(clusterSingletonService);
this.publicInterfaces = publicInterfaces;
this.rpcProviderRegistry = Preconditions.checkNotNull(rpcProviderRegistry);
- configurationService = new ConfigurationService();
+ this.configurationService = new ConfigurationService();
}
public void initialize() {
@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
* 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() {
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;
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
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;
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 "
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;
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);
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));
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,
# 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
# 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
# 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