ONOS-1521 : Supports Leaf-Spine topology (tested with 4 x 4 )
- Supports ECMPNotSupportedInTransitRouter option
- Adds Leaf-Spine config file
- Removes the temporary NetworkConfigHanlder class
- Removes the grouphandler dependency
- Removes the grouphandler app
Change-Id: I8c70e81bfb4062e251b25c0fa23ef2c92419a75c
diff --git a/src/main/java/org/onosproject/segmentrouting/RoutingRulePopulator.java b/src/main/java/org/onosproject/segmentrouting/RoutingRulePopulator.java
index 0a466de..c4db26c 100644
--- a/src/main/java/org/onosproject/segmentrouting/RoutingRulePopulator.java
+++ b/src/main/java/org/onosproject/segmentrouting/RoutingRulePopulator.java
@@ -48,10 +48,9 @@
 
     private static final Logger log = LoggerFactory.getLogger(RoutingRulePopulator.class);
 
-    private final SegmentRoutingManager srManager;
-    private final NetworkConfigHandler config;
     private AtomicLong rulePopulationCounter;
-
+    private SegmentRoutingManager srManager;
+    private DeviceConfiguration config;
     /**
      * Creates a RoutingRulePopulator object.
      *
@@ -59,7 +58,7 @@
      */
     public RoutingRulePopulator(SegmentRoutingManager srManager) {
         this.srManager = srManager;
-        this.config = checkNotNull(srManager.networkConfigHandler);
+        this.config = checkNotNull(srManager.deviceConfiguration);
         this.rulePopulationCounter = new AtomicLong(0);
     }
 
@@ -94,7 +93,7 @@
         sbuilder.matchEthType(Ethernet.TYPE_IPV4);
 
         tbuilder.setEthDst(hostMac)
-                .setEthSrc(config.getRouterMacAddress(deviceId))
+                .setEthSrc(config.getDeviceMac(deviceId))
                 .setOutput(outPort);
 
         TrafficTreatment treatment = tbuilder.build();
@@ -156,7 +155,7 @@
             ns = new NeighborSet(nextHops);
         } else {
             tbuilder.copyTtlOut();
-            ns = new NeighborSet(nextHops, config.getMplsId(destSw));
+            ns = new NeighborSet(nextHops, config.getSegmentId(destSw));
         }
 
         DefaultGroupKey groupKey = (DefaultGroupKey) srManager.getGroupKey(ns);
@@ -201,7 +200,7 @@
         Collection<TrafficTreatment> treatments = new ArrayList<>();
 
         // TODO Handle the case of Bos == false
-        sbuilder.matchMplsLabel(MplsLabel.mplsLabel(config.getMplsId(destSwId)));
+        sbuilder.matchMplsLabel(MplsLabel.mplsLabel(config.getSegmentId(destSwId)));
         sbuilder.matchEthType(Ethernet.MPLS_UNICAST);
 
         //If the next hop is the destination router, do PHP
@@ -262,15 +261,15 @@
             tbuilder.decMplsTtl();
         }
 
-        if (config.isEcmpNotSupportedInTransit(deviceId)
-                && config.isTransitRouter(deviceId)) {
+        if (!isECMPSupportedInTransitRouter() && !config.isEdgeDevice(deviceId)) {
             Link link = selectOneLink(deviceId, nextHops);
+            DeviceId nextHop = (DeviceId) nextHops.toArray()[0];
             if (link == null) {
                 log.warn("No link from {} to {}", deviceId, nextHops);
                 return null;
             }
-            tbuilder.setEthSrc(config.getRouterMacAddress(deviceId))
-                    .setEthDst(config.getRouterMacAddress(link.dst().deviceId()))
+            tbuilder.setEthSrc(config.getDeviceMac(deviceId))
+                    .setEthDst(config.getDeviceMac(nextHop))
                     .setOutput(link.src().port());
         } else {
             NeighborSet ns = new NeighborSet(nextHops);
@@ -292,6 +291,12 @@
         return tbuilder.build();
     }
 
+    private boolean isECMPSupportedInTransitRouter() {
+
+        // TODO: remove this function when objectives subsystem is supported.
+        return false;
+    }
+
     /**
      * Populates VLAN flows rules.
      * All packets are forwarded to TMAC table.
@@ -327,7 +332,7 @@
         // flow rule for IP packets
         TrafficSelector selectorIp = DefaultTrafficSelector.builder()
                 .matchEthType(Ethernet.TYPE_IPV4)
-                .matchEthDst(config.getRouterMacAddress(deviceId))
+                .matchEthDst(config.getDeviceMac(deviceId))
                 .build();
         TrafficTreatment treatmentIp = DefaultTrafficTreatment.builder()
                 .transition(FlowRule.Type.IP)
@@ -341,7 +346,7 @@
         // flow rule for MPLS packets
         TrafficSelector selectorMpls = DefaultTrafficSelector.builder()
                 .matchEthType(Ethernet.MPLS_UNICAST)
-                .matchEthDst(config.getRouterMacAddress(deviceId))
+                .matchEthDst(config.getDeviceMac(deviceId))
                 .build();
         TrafficTreatment treatmentMpls = DefaultTrafficTreatment.builder()
                 .transition(FlowRule.Type.MPLS)