Bug 8810 : BGP Manager / support for EVPN on OAM submodule missing 58/60058/4
authorPhilippe Guibert <philippe.guibert@6wind.com>
Thu, 6 Jul 2017 14:12:12 +0000 (15:12 +0100)
committerSam Hague <shague@redhat.com>
Wed, 19 Jul 2017 12:35:48 +0000 (12:35 +0000)
Despite EVPN is supported on VPNs, there is no statistics coming from
BGP. The changes include the following:
- evpn summary information ( list of neighbors speaking epvn)
- evpn total list of entries

Change-Id: I18b89b6ebe5815e1e3b827e96e0269852fd88a5f
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
vpnservice/bgpmanager/bgpmanager-impl/src/main/java/org/opendaylight/netvirt/bgpmanager/oam/BgpAlarms.java
vpnservice/bgpmanager/bgpmanager-impl/src/main/java/org/opendaylight/netvirt/bgpmanager/oam/BgpCounters.java

index 7db799de2ae982837af21f9bb1f7050a9bbbe227..764ecca821b2491608cb713344a597371f1e342c 100644 (file)
@@ -34,6 +34,7 @@ public class BgpAlarms extends TimerTask {
             LOG.debug("Fetching neighbor status' from BGP");
             BgpCounters.resetFile(BgpCounters.BGP_VPNV4_SUMMARY_FILE);
             BgpCounters.resetFile(BgpCounters.BGP_VPNV6_SUMMARY_FILE);
+            BgpCounters.resetFile(BgpCounters.BGP_EVPN_SUMMARY_FILE);
             neighborStatusMap.clear();
 
             if (bgpMgr != null && bgpMgr.getBgpCounters() != null) {
@@ -48,6 +49,12 @@ public class BgpAlarms extends TimerTask {
                         "show ip bgp vpnv6 all summary");
 
                 BgpCounters.parseIpBgpVpnv6AllSummary(neighborStatusMap);
+
+                bgpMgr.getBgpCounters().fetchCmdOutputs(BgpCounters.BGP_EVPN_SUMMARY_FILE,
+                        "show bgp l2vpn evpn all summary");
+
+                BgpCounters.parseBgpL2vpnEvpnAllSummary(neighborStatusMap);
+
                 processNeighborStatusMap(neighborStatusMap, nbrList, neighborsRaisedAlarmStatusMap);
             }
             LOG.debug("Finished getting the status of BGP neighbors");
index 6e86259a6eb8a46b60a19468166139686c68a742..073df84439369cec238a245298df90d52ddda6b7 100644 (file)
@@ -49,8 +49,10 @@ public class BgpCounters extends TimerTask {
     private String bgpSdncMip = "127.0.0.1";
     public static final String BGP_VPNV6_FILE = "cmd_ip_bgp_vpnv6_all.txt";
     public static final String BGP_VPNV4_FILE = "cmd_ip_bgp_vpnv4_all.txt";
+    public static final String BGP_EVPN_FILE = "cmd_bgp_l2vpn_evpn_all.txt";
     public static final String BGP_VPNV6_SUMMARY_FILE = "cmd_ip_bgp_vpnv6_all_summary.txt";
     public static final String BGP_VPNV4_SUMMARY_FILE = "cmd_ip_bgp_vpnv4_all_summary.txt";
+    public static final String BGP_EVPN_SUMMARY_FILE = "cmd_bgp_evpn_all_summary.txt";
 
     public BgpCounters(String mipAddress) {
         bgpSdncMip = mipAddress;
@@ -65,9 +67,12 @@ public class BgpCounters extends TimerTask {
             fetchCmdOutputs("cmd_bgp_ipv4_unicast_statistics.txt", "show bgp ipv4 unicast statistics");
             fetchCmdOutputs(BGP_VPNV4_FILE, "show ip bgp vpnv4 all");
             fetchCmdOutputs(BGP_VPNV6_FILE, "show ip bgp vpnv6 all");
+            fetchCmdOutputs(BGP_EVPN_FILE, "show bgp l2vpn evpn all");
             parseIpBgpSummary();
             parseIpBgpVpnv4All();
             parseIpBgpVpnv6All();
+            parseIpBgpVpnv6All();
+            parseBgpL2vpnEvpnAll();
             if (LOG.isDebugEnabled()) {
                 dumpCounters();
             }
@@ -366,6 +371,28 @@ public class BgpCounters extends TimerTask {
         }
     }
 
+    private void parseBgpL2vpnEvpnAll() {
+        File file = new File(BGP_EVPN_FILE);
+        List<String> inputStrs = new ArrayList<>();
+
+        try (Scanner scanner = new Scanner(file)) {
+            while (scanner.hasNextLine()) {
+                inputStrs.add(scanner.nextLine());
+            }
+        } catch (IOException e) {
+            LOG.error("Could not process the file {}", file.getAbsolutePath());
+            return;
+        }
+        for (int i = 0; i < inputStrs.size(); i++) {
+            String instr = inputStrs.get(i);
+            if (instr.contains("Route Distinguisher")) {
+                String[] result = instr.split(":");
+                String rd = result[1].trim() + "_" + result[2].trim();
+                i = processRouteCount(rd, i + 1, inputStrs);
+            }
+        }
+    }
+
     private int processRouteCount(String rd, int startIndex, List<String> inputStrs) {
         int num = startIndex;
         int routeCount = 0;
@@ -405,6 +432,7 @@ public class BgpCounters extends TimerTask {
         resetFile("cmd_bgp_ipv4_unicast_statistics.txt");
         resetFile(BGP_VPNV4_FILE);
         resetFile(BGP_VPNV6_FILE);
+        resetFile(BGP_EVPN_FILE);
     }
 
     static void resetFile(String fileName) {
@@ -463,4 +491,10 @@ public class BgpCounters extends TimerTask {
                                                    BGP_VPNV6_SUMMARY_FILE,
                                                    af_afi.AFI_IP);
     }
+
+    static Map<String, String> parseBgpL2vpnEvpnAllSummary(Map<String, String> countMap) {
+        return BgpCounters.parseIpBgpVpnAllSummary(countMap,
+                                                   BGP_EVPN_SUMMARY_FILE,
+                                                   af_afi.AFI_IP);
+    }
 }