Merge "Fixed DataStore related issue and cleaned up pom"
authorVivek Srivastava <vivek.v.srivastava@ericsson.com>
Tue, 12 May 2015 08:30:15 +0000 (08:30 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Tue, 12 May 2015 08:30:15 +0000 (08:30 +0000)
18 files changed:
bgpmanager/bgpmanager-impl/src/main/java/org/opendaylight/bgpmanager/BgpConfigurationManager.java
bgpmanager/bgpmanager-impl/src/main/java/org/opendaylight/bgpmanager/BgpManager.java
bgpmanager/bgpmanager-impl/src/main/java/org/opendaylight/bgpmanager/FibDSWriter.java
bgpmanager/bgpmanager-impl/src/main/java/org/opendaylight/bgpmanager/thrift/client/implementation/BgpRouter.java
bgpmanager/bgpmanager-impl/src/main/java/org/opendaylight/bgpmanager/thrift/server/implementation/BgpThriftService.java
bgpmanager/bgpmanager-impl/src/main/java/org/opendaylight/bgpmanager/thrift/server/implementation/BgpUpdateHandler.java
bgpmanager/bgpmanager-impl/src/test/java/org/opendaylight/vpnservice/bgpmanager/test/AbstractMockFibManager.java
bgpmanager/bgpmanager-impl/src/test/java/org/opendaylight/vpnservice/bgpmanager/test/BgpManagerTest.java
bgpmanager/bgpmanager-impl/src/test/java/org/opendaylight/vpnservice/bgpmanager/test/MockFibManager.java
fibmanager/fibmanager-impl/pom.xml
fibmanager/fibmanager-impl/src/main/config/default-config.xml
fibmanager/fibmanager-impl/src/main/java/org/opendaylight/vpnservice/fibmanager/FibManager.java
fibmanager/fibmanager-impl/src/main/java/org/opendaylight/vpnservice/fibmanager/FibManagerProvider.java
fibmanager/fibmanager-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/fibmanager/impl/rev150325/FibmanagerImplModule.java
fibmanager/fibmanager-impl/src/main/yang/fibmanager-impl.yang
nexthopmgr/nexthopmgr-impl/src/main/java/org/opendaylight/vpnservice/nexthopmgr/NexthopManager.java
vpnmanager/vpnmanager-impl/src/main/java/org/opendaylight/vpnservice/VpnInterfaceManager.java
vpnmanager/vpnmanager-impl/src/main/java/org/opendaylight/vpnservice/VpnManager.java

index 21e4cb0139216f283118526d923b6a74a49d9bcc..ebd49642ceaf58c54f6657bfeb57fb1108b27a35 100644 (file)
@@ -82,7 +82,7 @@ public class BgpConfigurationManager {
         protected void remove(InstanceIdentifier<BgpRouter> identifier,
                               BgpRouter del) {
 
-            LOG.info("Bgp Router deleted in DS - " + "key: " + identifier + ", value=" + del);
+            LOG.debug("Bgp Router deleted in DS - key: {} value={} ", identifier, del);
 
             removeBgpRouter(del);
 
@@ -110,7 +110,7 @@ public class BgpConfigurationManager {
         protected void update(InstanceIdentifier<BgpRouter> identifier,
                               BgpRouter original, BgpRouter update) {
 
-            LOG.info("Bgp Router Updated in DS - " + "key: " + identifier + ", original=" + original + ", update=" + update);
+            LOG.debug("Bgp Router Updated in DS - key: {}, original={}, update={} ", identifier, original, update);
 
             updateBgpRouter(original, update);
         }
@@ -132,9 +132,7 @@ public class BgpConfigurationManager {
         @Override
         protected void add(InstanceIdentifier<BgpRouter> identifier,
                            BgpRouter value) {
-            LOG.info("Bgp Router added in DS - " + "key: " + identifier + ", value=" + value);
-            LOG.info("Bgp Router localASNumber:" + value.getLocalAsNumber());
-            LOG.info("Bgp Router localASIdentifier:" + value.getLocalAsIdentifier());
+            LOG.debug("Bgp Router added in DS - key: {}, value={} ",identifier, value);
 
             addBgpRouter(value);
         }
@@ -181,7 +179,7 @@ public class BgpConfigurationManager {
             if(gateway != null) {
                 if ((gateway.getPeerAddressType() != null) && (gateway.getPeerAddressType() instanceof org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.bgp.rev130715.bgp.neighbors.bgp.neighbor.peer.address.type.IpAddress)) {
                     IpAddress neighborIPAddr = ((org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.bgp.rev130715.bgp.neighbors.bgp.neighbor.peer.address.type.IpAddress) gateway.getPeerAddressType()).getIpAddress();
-                    LOG.info("Bgp Neighbor IP Address " + neighborIPAddr.getIpv4Address().getValue());
+                    LOG.debug("Bgp Neighbor IP Address {} ", neighborIPAddr.getIpv4Address().getValue());
 
                     configureBgpServer(BgpOp.DEL_NGHBR);
 
@@ -197,7 +195,7 @@ public class BgpConfigurationManager {
         protected void remove(InstanceIdentifier<BgpNeighbors> identifier,
                               BgpNeighbors del) {
 
-            LOG.info("Bgp Neighbors deleted in DS - " + "key: " + identifier + ", value=" + del);
+            LOG.debug("Bgp Neighbors deleted in DS - key: {}, value={} ", identifier, del);
             removeBgpNeighbors(del);
         }
 
@@ -221,7 +219,7 @@ public class BgpConfigurationManager {
                     configureBgpServer(BgpOp.DEL_NGHBR);
                 }
                 if(gateway.getAsNumber() != null) {
-                    LOG.info("Bgp Neighbor AS number " + gateway.getAsNumber());
+                    LOG.debug("Bgp Neighbor AS number {} ", gateway.getAsNumber());
                     if(bgpConfiguration.getNeighbourAsNum() != gateway.getAsNumber()) {
                         bgpConfiguration.setNeighbourAsNum(gateway.getAsNumber());
                         bgpConfiguration.setConfigUpdated();
@@ -229,7 +227,7 @@ public class BgpConfigurationManager {
                 }
                 if((gateway.getPeerAddressType() != null) && (gateway.getPeerAddressType() instanceof org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.bgp.rev130715.bgp.neighbors.bgp.neighbor.peer.address.type.IpAddress)) {
                     IpAddress neighborIPAddr = ((org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.bgp.rev130715.bgp.neighbors.bgp.neighbor.peer.address.type.IpAddress)gateway.getPeerAddressType()).getIpAddress();
-                    LOG.info("Bgp Neighbor IP Address " + neighborIPAddr.getIpv4Address().getValue());
+                    LOG.debug("Bgp Neighbor IP Address {}", neighborIPAddr.getIpv4Address().getValue());
                     if(bgpConfiguration.getNeighbourIp() != neighborIPAddr.getIpv4Address().getValue()) {
                         bgpConfiguration.setNeighbourIp(neighborIPAddr.getIpv4Address().getValue());
                         bgpConfiguration.setConfigUpdated();
@@ -247,7 +245,7 @@ public class BgpConfigurationManager {
         protected void update(InstanceIdentifier<BgpNeighbors> identifier,
                               BgpNeighbors original, BgpNeighbors update) {
 
-            LOG.info("Bgp Neighbors Updated in DS - " + "key: " + identifier + ", original=" + original + ", update=" + update);
+            LOG.debug("Bgp Neighbors Updated in DS - key: {}, original={}, update={} ", identifier,  original, update);
 
             updateBgpNeighbors(original, update);
 
@@ -261,12 +259,12 @@ public class BgpConfigurationManager {
 
             if(gateway != null) {
                 if(gateway.getAsNumber() != null) {
-                    LOG.info("Bgp Neighbor AS number " + gateway.getAsNumber());
+                    LOG.debug("Bgp Neighbor AS number {} ", gateway.getAsNumber());
                     bgpConfiguration.setNeighbourAsNum(gateway.getAsNumber());
                 }
                 if((gateway.getPeerAddressType() != null) && (gateway.getPeerAddressType() instanceof org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.bgp.rev130715.bgp.neighbors.bgp.neighbor.peer.address.type.IpAddress)) {
                     IpAddress neighborIPAddr = ((org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.bgp.rev130715.bgp.neighbors.bgp.neighbor.peer.address.type.IpAddress)gateway.getPeerAddressType()).getIpAddress();
-                    LOG.info("Bgp Neighbor IP Address " + neighborIPAddr.getIpv4Address().getValue());
+                    LOG.debug("Bgp Neighbor IP Address {} ", neighborIPAddr.getIpv4Address().getValue());
                     bgpConfiguration.setNeighbourIp(neighborIPAddr.getIpv4Address().getValue());
 
                 }
@@ -280,8 +278,7 @@ public class BgpConfigurationManager {
         @Override
         protected void add(InstanceIdentifier<BgpNeighbors> identifier,
                            BgpNeighbors value) {
-            LOG.info("key: " + identifier + ", value=" + value);
-            LOG.info("Bgp Neighbor added in DS - " + "key: " + identifier + ", value=" + value);
+            LOG.debug("Bgp Neighbor added in DS - key: {}, value={} ", identifier, value);
 
             addBgpNeighbors(value);
         }
@@ -322,7 +319,7 @@ public class BgpConfigurationManager {
                         bgpManager.deleteNeighbor(bgpConfiguration.getNeighbourIp());
                         break;
                     default:
-                        LOG.info("Invalid configuration option");
+                        LOG.error("Invalid configuration option {}", bgpOp);
                 }
 
                 retry = false;
index 35d492471d2e48227a0cafc39bcff876c19c077a..d8e387eaf58e52478b4e2d215045a37b2bf8bcf3 100644 (file)
@@ -96,14 +96,14 @@ public class BgpManager implements BindingAwareProvider, AutoCloseable, IBgpMana
 
     public void startBgpService() throws TException {
         if(bgpThriftClient == null) {
-            LOGGER.info("Start Bgp Service - bgpThriftClient is null. Unable to start BGP service.");
+            LOGGER.error("Start Bgp Service - bgpThriftClient is null. Unable to start BGP service.");
             return;
         }
 
         // Now try start bgp - if bgp is already Active, it will tell us, nothing to do then
         try {
             bgpThriftClient.startBgp((int)bgpConfiguration.getAsNum(), bgpConfiguration.getRouterId());
-            LOGGER.info("Started BGP with AS number " + (int)bgpConfiguration.getAsNum() + " and router id " + bgpConfiguration.getRouterId());
+            LOGGER.debug("Started BGP with AS number " + (int)bgpConfiguration.getAsNum() + " and router id " + bgpConfiguration.getRouterId());
         } catch (BgpRouterException be) {
             if(be.getErrorCode() == BgpRouterException.BGP_ERR_ACTIVE) {
                 LOGGER.info("bgp server already active");
@@ -121,12 +121,12 @@ public class BgpManager implements BindingAwareProvider, AutoCloseable, IBgpMana
 
         }  catch (TException t) {
             LOGGER.error("Could not set up thrift connection with bgp server");
-            //LOGGER.trace("Transport error while starting bgp server ", t);
+            LOGGER.debug("Transport error while starting bgp server ", t);
             reInitConn();
             throw t;
         } catch (Exception e) {
             LOGGER.error("Error while starting bgp server");
-            //LOGGER.trace("Bgp Service not started due to exception", e);
+            LOGGER.debug("Bgp Service not started due to exception", e);
             return;
         }
 
@@ -174,15 +174,15 @@ public class BgpManager implements BindingAwareProvider, AutoCloseable, IBgpMana
 
     protected void addNeighbor(String ipAddress, long asNum) throws TException {
         if(bgpThriftClient == null) {
-            LOGGER.info("Add BGP Neighbor - bgpThriftClient is null. Unable to add BGP Neighbor.");
+            LOGGER.error("Add BGP Neighbor - bgpThriftClient is null. Unable to add BGP Neighbor.");
             return;
         }
 
         try {
             bgpThriftClient.addNeighbor(ipAddress, (int) asNum);
         } catch (BgpRouterException b) {
-            LOGGER.error("Failed to add BGP neighbor " + ipAddress + "due to BgpRouter Exception number " + b.getErrorCode());
-            LOGGER.error("BgpRouterException trace ", b);
+            LOGGER.error("Failed to add BGP neighbor " + ipAddress + " due to BgpRouter Exception number " + b.getErrorCode());
+            LOGGER.debug("BgpRouterException trace ", b);
         } catch (TException t) {
             LOGGER.error(String.format("Failed adding neighbor %s due to Transport error", ipAddress));
             reInitConn();
@@ -195,7 +195,7 @@ public class BgpManager implements BindingAwareProvider, AutoCloseable, IBgpMana
 
     protected void deleteNeighbor(String ipAddress) throws TException {
         if(bgpThriftClient == null) {
-            LOGGER.info("Delete BGP Neighbor - bgpThriftClient is null. Unable to delete BGP Neighbor.");
+            LOGGER.error("Delete BGP Neighbor - bgpThriftClient is null. Unable to delete BGP Neighbor.");
             return;
         }
 
@@ -203,7 +203,7 @@ public class BgpManager implements BindingAwareProvider, AutoCloseable, IBgpMana
             bgpThriftClient.delNeighbor(ipAddress);
         } catch (BgpRouterException b) {
             LOGGER.error("Failed to delete BGP neighbor " + ipAddress + "due to BgpRouter Exception number " + b.getErrorCode());
-            LOGGER.error("BgpRouterException trace ", b);
+            LOGGER.debug("BgpRouterException trace ", b);
         }catch (TException t) {
             LOGGER.error(String.format("Failed deleting neighbor %s due to Transport error", ipAddress));
             reInitConn();
@@ -217,14 +217,14 @@ public class BgpManager implements BindingAwareProvider, AutoCloseable, IBgpMana
     @Override
     public void addVrf(String rd, Collection<String> importRts, Collection<String> exportRts) throws Exception {
         if(bgpThriftClient == null) {
-            LOGGER.info("Add BGP vrf - bgpThriftClient is null. Unable to add BGP vrf.");
+            LOGGER.error("Add BGP vrf - bgpThriftClient is null. Unable to add BGP vrf.");
             return;
         }
         try {
             bgpThriftClient.addVrf(rd, new ArrayList<>(importRts), new ArrayList<>(exportRts));
         } catch (BgpRouterException b) {
             LOGGER.error("Failed to add BGP vrf " + rd + "due to BgpRouter Exception number " + b.getErrorCode());
-            LOGGER.error("BgpRouterException trace ", b);
+            LOGGER.debug("BgpRouterException trace ", b);
             throw b;
         } catch (TException t) {
             LOGGER.error(String.format("Failed adding vrf %s due to Transport error", rd));
@@ -246,7 +246,7 @@ public class BgpManager implements BindingAwareProvider, AutoCloseable, IBgpMana
             bgpThriftClient.delVrf(rd);
         } catch (BgpRouterException b) {
             LOGGER.error("Failed to delete BGP vrf " + rd + "due to BgpRouter Exception number " + b.getErrorCode());
-            LOGGER.error("BgpRouterException trace ", b);
+            LOGGER.debug("BgpRouterException trace ", b);
             throw b;
         } catch (TException t) {
             LOGGER.error(String.format("Failed deleting vrf %s due to Transport error", rd));
@@ -270,7 +270,7 @@ public class BgpManager implements BindingAwareProvider, AutoCloseable, IBgpMana
             bgpThriftClient.addPrefix(rd, prefix, nextHop, vpnLabel);
         } catch (BgpRouterException b) {
             LOGGER.error("Failed to add BGP prefix " + prefix + "due to BgpRouter Exception number " + b.getErrorCode());
-            LOGGER.error("BgpRouterException trace ", b);
+            LOGGER.debug("BgpRouterException trace ", b);
             throw b;
         } catch (TException t) {
             LOGGER.error(String.format("Failed adding prefix entry <vrf:prefix:nexthop:vpnlabel> %s:%s:%s:%d due to Transport error",
@@ -296,7 +296,7 @@ public class BgpManager implements BindingAwareProvider, AutoCloseable, IBgpMana
             bgpThriftClient.delPrefix(rd, prefix);
         } catch (BgpRouterException b) {
             LOGGER.error("Failed to delete BGP prefix " + prefix + "due to BgpRouter Exception number " + b.getErrorCode());
-            LOGGER.error("BgpRouterException trace ", b);
+            LOGGER.debug("BgpRouterException trace ", b);
             throw b;
         } catch (TException t) {
             LOGGER.error(String.format("Failed deleting prefix entry <vrf:prefix> %s:%s due to Transport error",
@@ -321,10 +321,10 @@ public class BgpManager implements BindingAwareProvider, AutoCloseable, IBgpMana
         }
         try {
             bgpThriftClient.connect(host, port);
-            LOGGER.info("Connected to BGP server " + host + " on port " + port);
+            LOGGER.debug("Connected to BGP server {} on port {} ", host, port);
         } catch (BgpRouterException b) {
             LOGGER.error("Failed to connect to BGP server " + host + " on port " + port + " due to BgpRouter Exception number " + b.getErrorCode());
-            //_logger.error("BgpRouterException trace ", b);
+            LOGGER.debug("BgpRouterException trace ", b);
             throw b;
         } catch (TException t) {
             LOGGER.error("Failed to initialize BGP Connection due to Transport error ");
@@ -349,10 +349,10 @@ public class BgpManager implements BindingAwareProvider, AutoCloseable, IBgpMana
 
         try {
             bgpThriftClient.reInit();
-            LOGGER.info("Reinitialized connection to BGP Server " + bgpHost);
+            LOGGER.debug("Reinitialized connection to BGP Server {}", bgpHost);
         } catch (BgpRouterException b) {
-            LOGGER.error("Failed to reinitialize connection to BGP server " + bgpHost + " on port " + bgpPort + " due to BgpRouter Exception number " + b.getErrorCode());
-            LOGGER.error("BgpRouterException trace ", b);
+            LOGGER.error("Failed to reinitialize connection to BGP server {} on port {} due to BgpRouter Exception number {}", bgpHost, bgpPort, b.getErrorCode());
+            LOGGER.debug("BgpRouterException trace ", b);
         } catch (TException t) {
             LOGGER.error("Failed to reinitialize BGP Connection due to Transport error.");
         }
index 28d196a093992fe7f1281eff8da85c8119f5885b..496f3cfa847b356c4cd9090373a8eac090177ca1 100644 (file)
@@ -44,7 +44,7 @@ public class FibDSWriter {
 
         VrfEntry vrfEntry = new VrfEntryBuilder().setDestPrefix(prefix).
             setNextHopAddress(nexthop).setLabel((long)label).build();
-        logger.debug("Created vrfEntry for " + prefix + " nexthop " + nexthop + " label " + label);
+        logger.debug("Created vrfEntry for {} nexthop {} label {}", prefix, nexthop, label);
 
         List<VrfEntry> vrfEntryList = new ArrayList<VrfEntry>();
         vrfEntryList.add(vrfEntry);
@@ -62,7 +62,7 @@ public class FibDSWriter {
 
     public synchronized void removeFibEntryFromDS(String rd, String prefix) {
 
-        logger.debug("Removing fib entry with destination prefix " + prefix + " from vrf table for rd " + rd);
+        logger.debug("Removing fib entry with destination prefix {} from vrf table for rd {}", prefix, rd);
 
         InstanceIdentifierBuilder<VrfEntry> idBuilder =
             InstanceIdentifier.builder(FibEntries.class).child(VrfTables.class, new VrfTablesKey(rd)).child(VrfEntry.class, new VrfEntryKey(prefix));
index e5af15acd93e733c946c5d4d08b633a9334102f6..93c92f87ad2e5ba911747da2815469ee3d2f8516 100644 (file)
@@ -70,7 +70,7 @@ public class BgpRouter {
         this.bgpPort = bgpPort;
         bop = new BgpOp();
         try {
-            LOGGER.info("Connecting to BGP Server " + bgpHost + " on port " + bgpPort);
+            LOGGER.debug("Connecting to BGP Server " + bgpHost + " on port " + bgpPort);
             reInit();
         } catch (Exception e) {
             LOGGER.error("Failed connecting to BGP server ");
@@ -142,7 +142,7 @@ public class BgpRouter {
         bop.type = START_BGP;
         bop.asNum = asNum;
         bop.rtrId = rtrId;
-        LOGGER.info("Starting BGP Server with as number " + asNum + " and router ID " + rtrId);
+        LOGGER.debug("Starting BGP Server with as number {} and router ID {} ", asNum, rtrId);
         dispatch(bop);
     }
 
@@ -151,7 +151,7 @@ public class BgpRouter {
         bop.type = ADD_NBR;
         bop.nbrIp = nbrIp;
         bop.nbrAsNum = nbrAsNum;
-        LOGGER.info("Adding BGP Neighbor " + nbrIp + " with as number " + nbrAsNum);
+        LOGGER.debug("Adding BGP Neighbor {} with as number {} ", nbrIp, nbrAsNum);
         dispatch(bop);
     }
 
@@ -159,7 +159,7 @@ public class BgpRouter {
         throws TException, BgpRouterException {
         bop.type = DEL_NBR;
         bop.nbrIp = nbrIp;
-        LOGGER.info("Deleting BGP Neighbor " + nbrIp);
+        LOGGER.debug("Deleting BGP Neighbor {} ", nbrIp);
         dispatch(bop);
     }
 
@@ -169,7 +169,7 @@ public class BgpRouter {
         bop.rd = rd;
         bop.irts = irts;
         bop.erts = erts;
-        LOGGER.info("Adding BGP VRF rd: " + rd);
+        LOGGER.debug("Adding BGP VRF rd: {} ", rd);
         dispatch(bop);
     }
 
@@ -177,7 +177,7 @@ public class BgpRouter {
         throws TException, BgpRouterException {
         bop.type = DEL_VRF;
         bop.rd = rd;
-        LOGGER.info("Deleting BGP VRF rd: " + rd);
+        LOGGER.debug("Deleting BGP VRF rd: {} " + rd);
         dispatch(bop);
     }
 
@@ -188,7 +188,7 @@ public class BgpRouter {
         bop.pfx = prefix;
         bop.nh = nexthop;
         bop.lbl = label;
-        LOGGER.info("Adding BGP route - rd:" + rd + " prefix:" + prefix + " nexthop:" + nexthop + " label:" + label);
+        LOGGER.debug("Adding BGP route - rd:{} prefix:{} nexthop:{} label:{} ", rd ,prefix, nexthop, label);
         dispatch(bop);
     }
 
@@ -197,7 +197,7 @@ public class BgpRouter {
         bop.type = DEL_PFX;
         bop.rd = rd;
         bop.pfx = prefix;
-        LOGGER.info("Deleting BGP route - rd:" + rd + " prefix:" + prefix);
+        LOGGER.debug("Deleting BGP route - rd:{} prefix:{} ", rd, prefix);
         dispatch(bop);
     }
 
@@ -267,7 +267,7 @@ public class BgpRouter {
         BgpSyncHandle bsh = BgpSyncHandle.getInstance();
 
         try {
-            LOGGER.info("Starting BGP Route sync.. ");
+            LOGGER.debug("Starting BGP Route sync.. ");
             initRibSync(bsh);
             while (bsh.getState() != bsh.DONE) {
                 Routes r = doRibSync(bsh);
@@ -288,7 +288,7 @@ public class BgpRouter {
                 }
             }
             endRibSync(bsh);
-            LOGGER.info("Completed BGP Route sync.");
+            LOGGER.debug("Completed BGP Route sync.");
         }  catch (Exception e) {
             throw e;
         }
index dfe4af646d97f2907c2f8b39c1cd6bd5d81ea699..921c9cf96217643c340dd9b0f6826e5c4d2632fd 100644 (file)
@@ -31,12 +31,12 @@ public class BgpThriftService {
 
 
        public void start() {
-               LOGGER.info("BGP Thrift Server starting.");
+               LOGGER.debug("BGP Thrift Server starting...");
                startBgpThriftServer();
        }
        
        public void stop() {
-               LOGGER.info("BGP Thrift Server stopping.");
+               LOGGER.debug("BGP Thrift Server stopping...");
                stopBgpThriftServer();
        }
 
@@ -68,13 +68,12 @@ public class BgpThriftService {
 
        public void stopBgpThriftServer() {
                try {
-            LOGGER.debug("Server stopping");
-
             if (serverTransport != null) {
                 serverTransport.close();
             }
             
             server.stop();
+                       LOGGER.info("BGP Thrift Server stopped");
         } catch (Exception e) {
             LOGGER.error("Error while stopping the server - {} {}", getClass().getName(), e.getMessage());
         }
@@ -86,7 +85,7 @@ public class BgpThriftService {
 
                try {
                                serverTransport = new TServerSocket(port);
-                   LOGGER.info("Server Socket on Port {} ", port);
+                               LOGGER.info("BGP Thrift Server started on port {} ", port);
                        } catch (TTransportException e) {
                                LOGGER.error("Transport Exception while starting bgp thrift server", e);
                                return;
index 9f3c40a89a65a2d5ae33f791bf1cab1abd3767bf..bf7b33bbd49bdc2039ccca25fd4b5c8acf646c55 100644 (file)
@@ -20,21 +20,20 @@ class BgpUpdateHandler implements BgpUpdater.Iface {
     public void onUpdatePushRoute(String rd, String prefix, int plen,
                                 String nexthop, int label) {
 
-       LOGGER.info("Route add ** " + rd + " ** " + prefix + "/" + plen
-               + " ** " + nexthop + " ** " + label);
+       LOGGER.debug("Route add ** {} ** {}/{} ** {} ** {} ", rd, prefix, plen, nexthop, label);
         //Write to FIB in Data Store
         fibDSWriter.addFibEntryToDS(rd, prefix + "/" + plen, nexthop, label);
 
    }
 
    public void onUpdateWithdrawRoute(String rd, String prefix, int plen) {
-       LOGGER.info("Route del ** " + rd + " ** " + prefix + "/" + plen);
+       LOGGER.debug("Route del ** {} ** {}/{} ", rd, prefix, plen);
        fibDSWriter.removeFibEntryFromDS(rd, prefix + "/" + plen);
 
    }
 
    public void onStartConfigResyncNotification() {
-       LOGGER.info("BGP (re)started");
+       LOGGER.debug("BGP (re)started");
        bgpManager.reInitConn();
    }
 
index 1c7ee261b0fee0d0bb364f3914ae03b9d0ace62f..bcf127d1f004760c74a94047a1d7c3a988bbd4f4 100644 (file)
@@ -1,4 +1,4 @@
-package org.opendaylight.vpnservice.test;
+package org.opendaylight.vpnservice.bgpmanager.test;
 
 import java.math.BigInteger;
 import java.util.ArrayList;
index 1afb94660583e40fdee255472e8296806b18c74d..d9f46bcd7c3155e329b018a8b6188cbb73c83a3a 100644 (file)
@@ -26,12 +26,26 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
       <artifactId>fibmanager-api</artifactId>
       <version>${vpnservices.version}</version>
     </dependency>
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>mdsalutil-api</artifactId>
+      <version>${vpnservices.version}</version>
+    </dependency>
     <dependency>
       <groupId>org.opendaylight.vpnservice</groupId>
       <artifactId>vpnmanager-impl</artifactId>
       <version>${vpnservices.version}</version>
     </dependency>
-
+    <dependency>
+      <groupId>org.opendaylight.vpnservice</groupId>
+      <artifactId>vpnmanager-api</artifactId>
+      <version>${vpnservices.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.vpnservice</groupId>
+      <artifactId>nexthopmgr-api</artifactId>
+      <version>${vpnservices.version}</version>
+    </dependency>
   </dependencies>
 
 </project>
index a624ae7d58099f87aec186d398a00425a69ae983..0548df61c0267f4f1fcc356f5ab8a66472cd4fe8 100644 (file)
@@ -10,6 +10,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
 <snapshot>
   <required-capabilities>
       <capability>urn:opendaylight:params:xml:ns:yang:fibmanager:impl?module=fibmanager-impl&amp;revision=2015-03-25</capability>
+      <capability>urn:opendaylight:params:xml:ns:yang:mdsalutil:api?module=odl-mdsalutil&amp;revision=2015-04-10</capability>
       <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&amp;revision=2013-10-28</capability>
   </required-capabilities>
   <configuration>
@@ -23,6 +24,10 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
             <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-broker-osgi-registry</type>
             <name>binding-osgi-broker</name>
           </broker>
+          <mdsalutil>
+            <type xmlns:mdsalutil="urn:opendaylight:params:xml:ns:yang:mdsalutil:api">mdsalutil:odl-mdsalutil</type>
+            <name>mdsalutil-service</name>
+          </mdsalutil>
         </module>
       </modules>
     </data>
index 42476b0871794b509b6802818d3e796c9e00e24c..a134addb65e802e3d17aa9811b9c3c753e5130d9 100644 (file)
@@ -7,12 +7,33 @@
  */
 package org.opendaylight.vpnservice.fibmanager;
 
+import com.google.common.base.Preconditions;
 import com.google.common.util.concurrent.Futures;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import com.google.common.util.concurrent.FutureCallback;
 import org.opendaylight.vpnservice.AbstractDataChangeListener;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
+import org.opendaylight.vpnservice.mdsalutil.ActionInfo;
+import org.opendaylight.vpnservice.mdsalutil.ActionType;
+import org.opendaylight.vpnservice.mdsalutil.FlowEntity;
+import org.opendaylight.vpnservice.mdsalutil.InstructionInfo;
+import org.opendaylight.vpnservice.mdsalutil.InstructionType;
+import org.opendaylight.vpnservice.mdsalutil.MDSALUtil;
+import org.opendaylight.vpnservice.mdsalutil.MatchFieldType;
+import org.opendaylight.vpnservice.mdsalutil.MatchInfo;
+import org.opendaylight.vpnservice.mdsalutil.MetaDataUtil;
+import org.opendaylight.vpnservice.mdsalutil.NwConstants;
+import org.opendaylight.vpnservice.mdsalutil.interfaces.IMdsalApiManager;
+import org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.VpnInstances;
+import org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.instances.VpnInstance;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.l3vpn.rev130911.VpnInstance1;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.fibmanager.rev150330.fibentries.VrfTables;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.fibmanager.rev150330.fibentries.VrfTablesKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.fibmanager.rev150330.vrfentries.VrfEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.l3nexthop.rev150409.GetEgressPointerInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.l3nexthop.rev150409.GetEgressPointerOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.l3nexthop.rev150409.L3nexthopService;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
@@ -21,14 +42,35 @@ import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.fibmanager.rev150330.FibEntries;
+import org.opendaylight.yangtools.yang.binding.RpcService;
+import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import com.google.common.base.Optional;
 
-public class FibManager extends AbstractDataChangeListener<FibEntries> implements AutoCloseable{
+import java.math.BigInteger;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+
+public class FibManager extends AbstractDataChangeListener<VrfEntry> implements AutoCloseable{
   private static final Logger LOG = LoggerFactory.getLogger(FibManager.class);
+  private static final String FLOWID_PREFIX = "L3.";
   private ListenerRegistration<DataChangeListener> listenerRegistration;
   private final DataBroker broker;
+  private final L3nexthopService l3nexthopService;
+  private IMdsalApiManager mdsalManager;
+
+  private static final short L3_FIB_TABLE = 20;
+  private static final short L3_LFIB_TABLE = 21;
+  private static final BigInteger COOKIE_VM_LFIB_TABLE = new BigInteger("8000002", 16);
+  private static final BigInteger COOKIE_VM_FIB_TABLE =  new BigInteger("8000003", 16);
+  private static final int DEFAULT_FIB_FLOW_PRIORITY = 10;
+
 
   private static final FutureCallback<Void> DEFAULT_CALLBACK =
       new FutureCallback<Void>() {
@@ -41,9 +83,10 @@ public class FibManager extends AbstractDataChangeListener<FibEntries> implement
         };
       };
 
-  public FibManager(final DataBroker db) {
-    super(FibEntries.class);
+  public FibManager(final DataBroker db, final RpcService nextHopService) {
+    super(VrfEntry.class);
     broker = db;
+    l3nexthopService = (L3nexthopService)nextHopService;
     registerListener(db);
   }
 
@@ -60,6 +103,11 @@ public class FibManager extends AbstractDataChangeListener<FibEntries> implement
     LOG.info("Fib Manager Closed");
   }
 
+
+  public void setMdsalManager(IMdsalApiManager mdsalManager) {
+    this.mdsalManager = mdsalManager;
+  }
+
   private void registerListener(final DataBroker db) {
     try {
       listenerRegistration = db.registerDataChangeListener(LogicalDatastoreType.CONFIGURATION,
@@ -71,9 +119,10 @@ public class FibManager extends AbstractDataChangeListener<FibEntries> implement
   }
 
   @Override
-  protected void add(final InstanceIdentifier<FibEntries> identifier,
-                     final FibEntries fibEntries) {
-    LOG.trace("key: " + identifier + ", value=" + fibEntries );
+  protected void add(final InstanceIdentifier<VrfEntry> identifier,
+                     final VrfEntry vrfEntry) {
+    LOG.trace("key: " + identifier + ", value=" + vrfEntry );
+    createFibEntries(identifier, vrfEntry);
   }
 
   private <T extends DataObject> Optional<T> read(LogicalDatastoreType datastoreType,
@@ -91,17 +140,17 @@ public class FibManager extends AbstractDataChangeListener<FibEntries> implement
     return result;
   }
 
-  private InstanceIdentifier<FibEntries> getWildCardPath() {
-    return InstanceIdentifier.create(FibEntries.class);
+  private InstanceIdentifier<VrfEntry> getWildCardPath() {
+    return InstanceIdentifier.create(FibEntries.class).child(VrfTables.class).child(VrfEntry.class);
   }
 
   @Override
-  protected void remove(InstanceIdentifier<FibEntries> identifier, FibEntries del) {
+  protected void remove(InstanceIdentifier<VrfEntry> identifier, VrfEntry del) {
     LOG.trace("key: " + identifier + ", value=" + del );
   }
 
   @Override
-  protected void update(InstanceIdentifier<FibEntries> identifier, FibEntries original, FibEntries update) {
+  protected void update(InstanceIdentifier<VrfEntry> identifier, VrfEntry original, VrfEntry update) {
     LOG.trace("key: " + identifier + ", original=" + original + ", update=" + update );
   }
 
@@ -111,4 +160,217 @@ public class FibManager extends AbstractDataChangeListener<FibEntries> implement
     tx.put(datastoreType, path, data, true);
     Futures.addCallback(tx.submit(), callback);
   }
+
+  private void createFibEntries(final InstanceIdentifier<VrfEntry> identifier,
+                                final VrfEntry vrfEntry) {
+    final VrfTablesKey vrfTableKey = identifier.firstKeyOf(VrfTables.class, VrfTablesKey.class);
+    Preconditions.checkNotNull(vrfTableKey, "VrfTablesKey cannot be null or empty!");
+    Preconditions.checkNotNull(vrfEntry, "VrfEntry cannot be null or empty!");
+
+    Long vpnId = getVpnId(vrfTableKey.getRouteDistinguisher());
+    Preconditions.checkNotNull(vpnId, "Vpn Instance not available!");
+    List<Long> dpns = getDpnsByVpn(vpnId);
+    for (Long dpId : dpns) {
+      addRouteInternal(dpId, vpnId, vrfTableKey, vrfEntry);
+    }
+  }
+
+  /*
+   *
+   */
+  private void addRouteInternal(final long dpId, final long vpnId, final VrfTablesKey vrfTableKey,
+                        final VrfEntry vrfEntry) {
+    String rd = vrfTableKey.getRouteDistinguisher();
+    LOG.info("adding route " + vrfEntry.getDestPrefix() + " " + rd);
+
+    String values[] = vrfEntry.getDestPrefix().split("/");
+    LOG.info(String.format("Adding route to DPN. ip %s masklen %s", values[0], values[1]));
+    String ipAddress = values[0];
+    int prefix = Integer.parseInt(values[1]);
+    InetAddress destAddress = null;
+    try {
+      destAddress = InetAddress.getByName(ipAddress);
+    } catch (UnknownHostException e) {
+      LOG.error(String.format("UnknowHostException in addRoute."
+                                 + "Failed to add Route for ipPrefix %s", vrfEntry.getDestPrefix()));
+      return;
+    }
+
+    GetEgressPointerOutput adjacency = resolveAdjacency(dpId, vpnId, vrfTableKey, vrfEntry);
+    long groupId = -1;
+    boolean isLocalRoute = false;
+    if(adjacency != null) {
+      groupId = adjacency.getEgressPointer();
+      isLocalRoute = adjacency.isLocalDestination();
+    }
+    if(groupId == -1) {
+      LOG.error(String.format("Could not get nexthop group id for nexthop: %s in vpn %s",
+                                   vrfEntry.getNextHopAddress(), rd));
+      LOG.warn(String.format("Failed to add Route: %s in vpn: %s",
+                             vrfEntry.getDestPrefix(), rd));
+      return;
+    }
+
+    makeConnectedRoute(dpId, destAddress, prefix, vpnId, rd, groupId, NwConstants.ADD_FLOW);
+
+    if (isLocalRoute) {
+      makeLFibTableEntry(dpId, vrfEntry.getLabel(), groupId, vrfEntry.getNextHopAddress(), NwConstants.ADD_FLOW);
+    }
+
+    LOG.info(
+        "Successfully added fib entry for " + destAddress.getHostAddress() + " vpnId " + vpnId);
+  }
+
+  public void deleteRoute(InetAddress destPrefix, int prefixLength, int vpnId, String rd) {
+    LOG.info("deleting route "+destPrefix.getHostAddress()+ " "+vpnId);
+
+    List<Long> dpnIds = getDpnsByVpn(vpnId);
+
+    for (long dpnId : dpnIds) {
+      makeConnectedRoute(dpnId, destPrefix, prefixLength, vpnId, rd, 0/*groupId*/, NwConstants.DEL_FLOW);
+    }
+    LOG.info("Successfully delete fib entry for "+destPrefix.getHostAddress()+ " vpnId "+vpnId);
+  }
+
+  public void deleteRoute(InetAddress destPrefix, int prefixLength, int vpnId, String rd, long dpId) {
+    LOG.info("deleting route "+destPrefix.getHostAddress()+ " "+vpnId);
+
+    makeConnectedRoute(dpId, destPrefix, prefixLength, vpnId, rd, 0/*groupId*/, NwConstants.DEL_FLOW);
+
+    LOG.info("Successfully delete fib entry for "+destPrefix.getHostAddress()+ " vpnId "+vpnId);
+  }
+
+  private long getIpAddress(byte[] rawIpAddress) {
+    return (((rawIpAddress[0] & 0xFF) << (3 * 8)) + ((rawIpAddress[1] & 0xFF) << (2 * 8))
+            + ((rawIpAddress[2] & 0xFF) << (1 * 8)) + (rawIpAddress[3] & 0xFF)) & 0xffffffffL;
+  }
+
+  private void makeConnectedRoute(long dpId, InetAddress destPrefix, int prefixLength, long vpnId,
+                          String rd, long groupId, int addOrRemove) {
+
+    List<MatchInfo> matches = new ArrayList<MatchInfo>();
+
+    matches.add(new MatchInfo(MatchFieldType.metadata, new BigInteger[] {
+        BigInteger.valueOf(vpnId), MetaDataUtil.METADATA_MASK_VRFID }));
+
+    matches.add(new MatchInfo(MatchFieldType.eth_type,
+                              new long[] { 0x0800L }));
+
+    if(prefixLength != 0) {
+      matches.add(new MatchInfo(MatchFieldType.ipv4_dst, new long[] {
+          getIpAddress(destPrefix.getAddress()), prefixLength }));
+    }
+
+    List<InstructionInfo> instructions = new ArrayList<InstructionInfo>();
+    List<ActionInfo> actionsInfos = new ArrayList<ActionInfo>();
+
+    if(addOrRemove == NwConstants.ADD_FLOW) {
+      actionsInfos.add(new ActionInfo(ActionType.group, new String[] { String.valueOf(groupId)}));
+      instructions.add(new InstructionInfo(InstructionType.write_actions, actionsInfos));
+    }
+
+    String flowRef = getFlowRef(dpId, L3_FIB_TABLE, rd, destPrefix);
+
+    FlowEntity flowEntity;
+
+    int priority = DEFAULT_FIB_FLOW_PRIORITY + prefixLength;
+    flowEntity = MDSALUtil.buildFlowEntity(dpId, L3_FIB_TABLE, flowRef,
+                                           priority, flowRef, 0, 0,
+                                           COOKIE_VM_FIB_TABLE, matches, instructions);
+
+    if (addOrRemove == NwConstants.ADD_FLOW) {
+      mdsalManager.installFlow(flowEntity);
+    } else {
+      mdsalManager.removeFlow(flowEntity);
+    }
+  }
+
+  private void makeLFibTableEntry(long dpId, long label, long groupId,
+                                  String nextHop, int addOrRemove) {
+    List<MatchInfo> matches = new ArrayList<MatchInfo>();
+    matches.add(new MatchInfo(MatchFieldType.eth_type,
+                              new long[] { 0x8847L }));
+    matches.add(new MatchInfo(MatchFieldType.mpls_label, new String[]{Long.toString(label)}));
+
+    List<InstructionInfo> instructions = new ArrayList<InstructionInfo>();
+    List<ActionInfo> actionsInfos = new ArrayList<ActionInfo>();
+    actionsInfos.add(new ActionInfo(ActionType.pop_mpls, new String[]{Long.toString(label)}));
+    actionsInfos.add(new ActionInfo(ActionType.group, new String[] { String.valueOf(groupId) }));
+    instructions.add(new InstructionInfo(InstructionType.write_actions, actionsInfos));
+
+    // Install the flow entry in L3_LFIB_TABLE
+    String flowRef = getFlowRef(dpId, L3_LFIB_TABLE, label, nextHop);
+
+    FlowEntity flowEntity;
+    flowEntity = MDSALUtil.buildFlowEntity(dpId, L3_LFIB_TABLE, flowRef,
+                                           DEFAULT_FIB_FLOW_PRIORITY, flowRef, 0, 0,
+                                           COOKIE_VM_LFIB_TABLE, matches, instructions);
+
+    if (addOrRemove == NwConstants.ADD_FLOW) {
+      mdsalManager.installFlow(flowEntity);
+    } else {
+      mdsalManager.removeFlow(flowEntity);
+    }
+    LOG.info("LFIB Entry for dpID {} : label : {} grpup {} modified successfully {}",dpId, label, groupId );
+  }
+
+  private String getFlowRef(long dpnId, short tableId, long label, String nextHop) {
+    return new StringBuilder(64).append(FLOWID_PREFIX).append(dpnId).append(NwConstants.FLOWID_SEPARATOR)
+        .append(tableId).append(NwConstants.FLOWID_SEPARATOR)
+        .append(label).append(NwConstants.FLOWID_SEPARATOR)
+        .append(nextHop).toString();
+  }
+
+  private String getFlowRef(long dpnId, short tableId, String rd, InetAddress destPrefix) {
+    return new StringBuilder(64).append(FLOWID_PREFIX).append(dpnId).append(NwConstants.FLOWID_SEPARATOR)
+        .append(tableId).append(NwConstants.FLOWID_SEPARATOR)
+        .append(rd).append(NwConstants.FLOWID_SEPARATOR)
+        .append(destPrefix.getHostAddress()).toString();
+  }
+
+  private GetEgressPointerOutput resolveAdjacency(final long dpId, final long vpnId, final VrfTablesKey vrfTableKey,
+                        final VrfEntry vrfEntry) {
+    GetEgressPointerOutput adjacency = null;
+    try {
+      Future<RpcResult<GetEgressPointerOutput>> result =
+          l3nexthopService.getEgressPointer(new GetEgressPointerInputBuilder().setDpnId(dpId)
+                                                .setIpPrefix(vrfEntry.getDestPrefix())
+                                                .setNexthopIp(vrfEntry.getNextHopAddress())
+                                                .setVpnId(vpnId)
+                                                .build());
+      RpcResult<GetEgressPointerOutput> rpcResult = result.get();
+      if (rpcResult.isSuccessful()) {
+        adjacency = rpcResult.getResult();
+      } else {
+        LOG.error("Next hop information not available");
+      }
+    } catch (NullPointerException | InterruptedException | ExecutionException e) {
+      LOG.trace("", e);
+    }
+    return adjacency;
+  }
+
+  private List<Long> getDpnsByVpn(long vpnId) {
+    // TODO: get list of dpns from vpnmanager, for all dpns List<Long>
+    return new ArrayList<>();
+  }
+
+  private Long getVpnId(String rd) {
+    Long vpnId = null;
+    InstanceIdentifier<VpnInstances> id = InstanceIdentifier.create(VpnInstances.class);
+    Optional<VpnInstances> vpnInstances = read(LogicalDatastoreType.OPERATIONAL, id);
+    if(vpnInstances.isPresent()) {
+      List<VpnInstance> vpns = vpnInstances.get().getVpnInstance();
+      for(VpnInstance vpn : vpns) {
+        if(vpn.getIpv4Family().getRouteDistinguisher().equals(rd)) {
+          VpnInstance1 vpnInstanceId = vpn.getAugmentation(VpnInstance1.class);
+          if (vpnInstanceId != null) {
+            vpnId = vpnInstanceId.getVpnId();
+            break;
+          }
+        }
+      }
+    }
+    return vpnId;
+  }
 }
index 2015dc0fda96845ede533e819aafbfa8c5f177df..cb2da5e2b8d4efe83391f4207e10ce8bf7adc95a 100644 (file)
@@ -10,6 +10,9 @@ package org.opendaylight.vpnservice.fibmanager;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
 import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
+import org.opendaylight.vpnservice.mdsalutil.interfaces.IMdsalApiManager;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.l3nexthop.rev150409.L3nexthopService;
+import org.opendaylight.yangtools.yang.binding.RpcService;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -18,13 +21,16 @@ public class FibManagerProvider implements BindingAwareProvider, AutoCloseable {
   private static final Logger LOG = LoggerFactory.getLogger(FibManagerProvider.class);
 
   private FibManager fibManager;
+  private IMdsalApiManager mdsalManager;
 
   @Override
   public void onSessionInitiated(ProviderContext session) {
     LOG.info("FibManagerProvider Session Initiated");
     try {
       final  DataBroker dataBroker = session.getSALService(DataBroker.class);
-      fibManager = new FibManager(dataBroker);
+      final RpcService nexthopService = session.getRpcService(L3nexthopService.class);
+      fibManager = new FibManager(dataBroker, nexthopService);
+      fibManager.setMdsalManager(mdsalManager);
     } catch (Exception e) {
       LOG.error("Error initializing services", e);
     }
@@ -36,4 +42,7 @@ public class FibManagerProvider implements BindingAwareProvider, AutoCloseable {
     fibManager.close();
   }
 
+  public void setMdsalManager(IMdsalApiManager mdsalManager) {
+    this.mdsalManager = mdsalManager;
+  }
 }
\ No newline at end of file
index f3d9acd90e41b1e72b6a971311ac051a3b54b341..363919235b57f0625306213019927f8235e63177 100644 (file)
@@ -26,6 +26,7 @@ public class FibmanagerImplModule extends org.opendaylight.yang.gen.v1.urn.opend
     public java.lang.AutoCloseable createInstance() {
         FibManagerProvider provider = new FibManagerProvider();
         getBrokerDependency().registerProvider(provider);
+        provider.setMdsalManager(getMdsalutilDependency());
         return provider;
     }
 
index a9321ae359d75048a28ca43bb90853164e3a0162..b4bee70b79c4f4c1e5b4ad258d3728f447b65f8f 100644 (file)
@@ -5,6 +5,7 @@ module fibmanager-impl {
 
     import config { prefix config; revision-date 2013-04-05; }
     import opendaylight-md-sal-binding { prefix md-sal-binding; revision-date 2013-10-28;}
+    import odl-mdsalutil { prefix odl-mdsal; revision-date 2015-04-10;}
 
     description
         "Service definition for fibmanager project";
@@ -30,6 +31,14 @@ module fibmanager-impl {
                     }
                 }
             }
+            container mdsalutil {
+                uses config:service-ref {
+                    refine type {
+                        mandatory true;
+                        config:required-identity odl-mdsal:odl-mdsalutil;
+                    }
+                }
+            }
         }
     }
 }
index 9864b61c646202ac120b0aa3d971ce763d7addb3..c9fee48716f391c0717b0f77db162d4be176c28f 100644 (file)
@@ -122,12 +122,12 @@ public class NexthopManager implements L3nexthopService, AutoCloseable {
 
         InstanceIdentifier<VpnInstance> id = idBuilder.build();
         InstanceIdentifier<VpnInstance1> idx = id.augmentation(VpnInstance1.class);
-        Optional<VpnInstance1> vpn = read(LogicalDatastoreType.CONFIGURATION, idx);
+        Optional<VpnInstance1> vpn = read(LogicalDatastoreType.OPERATIONAL, idx);
 
         if (vpn.isPresent()) {
             return vpn.get().getVpnId();
         } else {
-            return 0;
+            return -1;
         }
     }
 
index f8e04be665a623d6cdf28b56eefa7efb683a4f18..6d7d7d02ca784be62ef7e88de74e991d9b172133 100644 (file)
@@ -205,9 +205,11 @@ public class VpnInterfaceManager extends AbstractDataChangeListener<VpnInterface
     }
 
     private long getVpnId(String vpnName) {
+        //TODO: This should be a Util function
         InstanceIdentifier<VpnInstance1> id = InstanceIdentifier.builder(VpnInstances.class)
                 .child(VpnInstance.class, new VpnInstanceKey(vpnName)).augmentation(VpnInstance1.class).build();
-        Optional<VpnInstance1> vpnInstance = read(LogicalDatastoreType.CONFIGURATION, id);
+        Optional<VpnInstance1> vpnInstance = read(LogicalDatastoreType.OPERATIONAL, id);
+        //TODO: Default vpnid should be a constant.
         long vpnId = -1;
         if(vpnInstance.isPresent()) {
             vpnId = vpnInstance.get().getVpnId();
index 0e60710092a1bda755592345928e15e4fefc2aa5..ee0c56eaefaccb00bb449e3136dc43ef4f57f3e6 100644 (file)
@@ -122,13 +122,6 @@ public class VpnManager extends AbstractDataChangeListener<VpnInstance> implemen
         LOG.info("key: {}, value: {}" +identifier, value);
 
         long vpnId = getUniqueId(value.getVpnInstanceName());
-        InstanceIdentifier<VpnInstance1> augId = identifier.augmentation(VpnInstance1.class);
-        Optional<VpnInstance1> vpnAugmenation = read(LogicalDatastoreType.CONFIGURATION, augId);
-        if(vpnAugmenation.isPresent()) {
-            VpnInstance1 vpn = vpnAugmenation.get();
-            vpnId = vpn.getVpnId();
-            LOG.info("VPN ID is {}", vpnId);
-        }
 
         VpnInstance opValue = new VpnInstanceBuilder(value).
                  addAugmentation(VpnInstance1.class, new VpnInstance1Builder().setVpnId(vpnId).build()).build();