[CORD-578] MPLS ECMP configurable
Changes:
- Adds MPLS-ECMP option to SR configuration;
- Updates the json examples;
- Implements unit tests to verify the expected behaviors;
Change-Id: I6a7f5d34161be7c85ecb76c9a09288d960aad3cb
diff --git a/src/main/java/org/onosproject/segmentrouting/AppConfigHandler.java b/src/main/java/org/onosproject/segmentrouting/AppConfigHandler.java
index 841ad2f..c24c3ca 100644
--- a/src/main/java/org/onosproject/segmentrouting/AppConfigHandler.java
+++ b/src/main/java/org/onosproject/segmentrouting/AppConfigHandler.java
@@ -58,7 +58,7 @@
* @param event network config added event
*/
protected void processAppConfigAdded(NetworkConfigEvent event) {
- log.info("Processing vRouter CONFIG_ADDED");
+ log.info("Processing AppConfig CONFIG_ADDED");
SegmentRoutingAppConfig config = (SegmentRoutingAppConfig) event.config().get();
deviceService.getAvailableDevices().forEach(device -> {
populateVRouter(device.id(), getMacAddresses(config));
@@ -71,7 +71,7 @@
* @param event network config updated event
*/
protected void processAppConfigUpdated(NetworkConfigEvent event) {
- log.info("Processing vRouter CONFIG_UPDATED");
+ log.info("Processing AppConfig CONFIG_UPDATED");
SegmentRoutingAppConfig config = (SegmentRoutingAppConfig) event.config().get();
SegmentRoutingAppConfig prevConfig = (SegmentRoutingAppConfig) event.prevConfig().get();
deviceService.getAvailableDevices().forEach(device -> {
@@ -96,7 +96,7 @@
* @param event network config removed event
*/
protected void processAppConfigRemoved(NetworkConfigEvent event) {
- log.info("Processing vRouter CONFIG_REMOVED");
+ log.info("Processing AppConfig CONFIG_REMOVED");
SegmentRoutingAppConfig prevConfig = (SegmentRoutingAppConfig) event.prevConfig().get();
deviceService.getAvailableDevices().forEach(device -> {
revokeVRouter(device.id(), getMacAddresses(prevConfig));
diff --git a/src/main/java/org/onosproject/segmentrouting/SegmentRoutingManager.java b/src/main/java/org/onosproject/segmentrouting/SegmentRoutingManager.java
index bd89102..81fb220 100644
--- a/src/main/java/org/onosproject/segmentrouting/SegmentRoutingManager.java
+++ b/src/main/java/org/onosproject/segmentrouting/SegmentRoutingManager.java
@@ -468,6 +468,17 @@
}
/**
+ * Returns the MPLS-ECMP configuration.
+ *
+ * @return MPLS-ECMP value
+ */
+ public boolean getMplsEcmp() {
+ SegmentRoutingAppConfig segmentRoutingAppConfig = cfgService
+ .getConfig(this.appId, SegmentRoutingAppConfig.class);
+ return segmentRoutingAppConfig != null && segmentRoutingAppConfig.mplsEcmp();
+ }
+
+ /**
* Returns the tunnel object with the tunnel ID.
*
* @param tunnelId Tunnel ID
diff --git a/src/main/java/org/onosproject/segmentrouting/config/SegmentRoutingAppConfig.java b/src/main/java/org/onosproject/segmentrouting/config/SegmentRoutingAppConfig.java
index 0eb2c8e..3fe7e4b 100644
--- a/src/main/java/org/onosproject/segmentrouting/config/SegmentRoutingAppConfig.java
+++ b/src/main/java/org/onosproject/segmentrouting/config/SegmentRoutingAppConfig.java
@@ -40,17 +40,39 @@
private static final String SUPPRESS_HOST_BY_PORT = "suppressHostByPort";
// TODO We might want to move SUPPRESS_HOST_BY_PROVIDER to Component Config
private static final String SUPPRESS_HOST_BY_PROVIDER = "suppressHostByProvider";
+ private static final String MPLS_ECMP = "MPLS-ECMP";
@Override
public boolean isValid() {
return hasOnlyFields(VROUTER_MACS, VROUTER_ID, SUPPRESS_SUBNET,
- SUPPRESS_HOST_BY_PORT, SUPPRESS_HOST_BY_PROVIDER) &&
+ SUPPRESS_HOST_BY_PORT, SUPPRESS_HOST_BY_PROVIDER, MPLS_ECMP) &&
vRouterMacs() != null && vRouterId() != null &&
suppressSubnet() != null && suppressHostByPort() != null &&
suppressHostByProvider() != null;
}
/**
+ * Gets MPLS-ECMP configuration from the config.
+ *
+ * @return the configuration of MPLS-ECMP. If it is not
+ * specified, the default behavior is false.
+ */
+ public boolean mplsEcmp() {
+ return get(MPLS_ECMP, false);
+ }
+
+ /**
+ * Sets MPLS-ECMP to the config.
+ *
+ * @param mplsEcmp the MPLS-ECMP configuration
+ * @return this {@link SegmentRoutingAppConfig}
+ */
+ public SegmentRoutingAppConfig setMplsEcmp(boolean mplsEcmp) {
+ object.put(MPLS_ECMP, mplsEcmp);
+ return this;
+ }
+
+ /**
* Gets vRouters from the config.
*
* @return Set of vRouter MAC addresses, empty is not specified,
@@ -276,6 +298,7 @@
.add("suppressSubnet", suppressSubnet())
.add("suppressHostByPort", suppressHostByPort())
.add("suppressHostByProvider", suppressHostByProvider())
+ .add("mplsEcmp", mplsEcmp())
.toString();
}
}