Merge "Added YANG models for flow configuration, statistics and inventory."
authorEd Warnicke <eaw@cisco.com>
Tue, 20 Aug 2013 15:52:55 +0000 (15:52 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Tue, 20 Aug 2013 15:52:55 +0000 (15:52 +0000)
opendaylight/forwarding/staticrouting/src/main/java/org/opendaylight/controller/forwarding/staticrouting/internal/StaticRoutingImplementation.java
opendaylight/forwarding/staticrouting/src/test/java/org/opendaylight/controller/forwarding/staticrouting/StaticRouteTest.java
opendaylight/forwardingrulesmanager/api/src/main/java/org/opendaylight/controller/forwardingrulesmanager/IForwardingRulesManager.java
opendaylight/forwardingrulesmanager/implementation/src/main/java/org/opendaylight/controller/forwardingrulesmanager/internal/ForwardingRulesManager.java
opendaylight/hosttracker/implementation/src/main/java/org/opendaylight/controller/hosttracker/internal/HostTracker.java

index ec6da387691f617cefb810c5624e67ddab613770..eac854c10674f796fae64ec174aaef07aad4aed5 100644 (file)
@@ -97,6 +97,7 @@ public class StaticRoutingImplementation implements IfNewHostNotify,
         }
     }
 
+    @Override
     public ConcurrentMap<String, StaticRouteConfig> getStaticRouteConfigs() {
         return staticRouteConfigs;
     }
@@ -258,11 +259,13 @@ public class StaticRoutingImplementation implements IfNewHostNotify,
     }
 
     private void notifyHostUpdate(HostNodeConnector host, boolean added) {
-        if (host == null)
+        if (host == null) {
             return;
+        }
         for (StaticRoute s : staticRoutes.values()) {
-            if (s.getType() == StaticRoute.NextHopType.SWITCHPORT)
+            if (s.getType() == StaticRoute.NextHopType.SWITCHPORT) {
                 continue;
+            }
             if (s.getNextHopAddress().equals(host.getNetworkAddress())) {
                 if (added) {
                     s.setHost(host);
@@ -285,8 +288,9 @@ public class StaticRoutingImplementation implements IfNewHostNotify,
     }
 
     public boolean isIPv4AddressValid(String cidr) {
-        if (cidr == null)
+        if (cidr == null) {
             return false;
+        }
 
         String values[] = cidr.split("/");
         Pattern ipv4Pattern = Pattern
@@ -322,6 +326,7 @@ public class StaticRoutingImplementation implements IfNewHostNotify,
         return 0;
     }
 
+    @Override
     public StaticRoute getBestMatchStaticRoute(InetAddress ipAddress) {
         ByteBuffer bblongestPrefix = null;
         try {
@@ -349,10 +354,9 @@ public class StaticRoutingImplementation implements IfNewHostNotify,
         return longestPrefixRoute;
     }
 
+    @Override
     public Status addStaticRoute(StaticRouteConfig config) {
-        Status status;
-
-        status = config.isValid();
+        Status status = config.isValid();
         if (!status.isSuccess()) {
             return status;
         }
@@ -361,22 +365,29 @@ public class StaticRoutingImplementation implements IfNewHostNotify,
                                 "A valid Static Route configuration with this name " +
                                                 "already exists. Please use a different name");
         }
-        for (StaticRouteConfig s : staticRouteConfigs.values()) {
-            if (s.equals(config)) {
+
+        // Update database
+        StaticRoute sRoute = new StaticRoute(config);
+
+        for (Map.Entry<String, StaticRoute> entry : staticRoutes.entrySet()) {
+            if (entry.getValue().compareTo(sRoute) == 0) {
                 return new Status(StatusCode.CONFLICT,
-                                "This conflicts with an existing Static Route " +
-                                        "Configuration. Please check the configuration " +
-                                                "and try again");
+                        "This conflicts with an existing Static Route " +
+                                "Configuration. Please check the configuration " +
+                                        "and try again");
             }
         }
+        staticRoutes.put(config.getName(), sRoute);
 
+        // Update config databse
         staticRouteConfigs.put(config.getName(), config);
-        StaticRoute sRoute = new StaticRoute(config);
-        staticRoutes.put(config.getName(), sRoute);
+
+        // Notify
         checkAndUpdateListeners(sRoute, true);
         return status;
     }
 
+    @Override
     public Status removeStaticRoute(String name) {
         staticRouteConfigs.remove(name);
         StaticRoute sRoute = staticRoutes.remove(name);
@@ -424,8 +435,9 @@ public class StaticRoutingImplementation implements IfNewHostNotify,
         allocateCaches();
         retrieveCaches();
         this.executor = Executors.newFixedThreadPool(1);
-        if (staticRouteConfigs.isEmpty())
+        if (staticRouteConfigs.isEmpty()) {
             loadConfiguration();
+        }
 
         /*
          *  Slow probe to identify any gateway that might have silently appeared
index 4a497a058c0df7a1bdc5b16c5a0cac656010c8f3..25b2dacde10656cba2475775136265d85817fc18 100644 (file)
@@ -83,9 +83,9 @@ public class StaticRouteTest {
         Assert.assertFalse(staticRoute1.equals(staticRoute3));
         Assert.assertFalse(staticRoute1.equals(staticRoute4));
 
-        Assert.assertTrue(staticRoute1.compareTo(staticRoute2) == 0 ? true : false);
-        Assert.assertFalse(staticRoute1.compareTo(staticRoute3) == 0 ? true : false);
-        Assert.assertTrue(staticRoute1.compareTo(staticRoute4) == 0 ? true : false);
+        Assert.assertTrue(staticRoute1.compareTo(staticRoute2) == 0);
+        Assert.assertFalse(staticRoute1.compareTo(staticRoute3) == 0);
+        Assert.assertTrue(staticRoute1.compareTo(staticRoute4) == 0);
 
         }
 
index 4b8257488ef08c072785a5cef76f56c550ba882a..9f0005e7fb5b2aa3a7dea5cbfa62fdf11be94dab 100644 (file)
@@ -199,14 +199,29 @@ public interface IForwardingRulesManager {
 
     /**
      * Returns the list of Flow entries across network nodes which are part of
-     * the same flow group, policy
+     * the same flow group, policy. This list contains the flows as they were
+     * requested to be installed by the applications, before any merging with
+     * container flow is done.
      *
      * @param group
      *            the group name
-     * @return the list of flow entries belonging to the specified group
+     * @return the original list of flow entries belonging to the specified group
      */
     public List<FlowEntry> getFlowEntriesForGroup(String group);
 
+    /**
+     * Returns the list of Flow entries installed in network nodes which are part of
+     * the same flow group, policy. This list contains the effective flows installed
+     * on the nodes after the merging with any possible container flow was performed.
+     * If no container flow are specified, this method returns the same list returned
+     * by getFlowEntriesForGroup(String group).
+     *
+     * @param group
+     *            the group name
+     * @return the list of container flow merged flow entries belonging to the specified group
+     */
+    public List<FlowEntry> getInstalledFlowEntriesForGroup(String policyName);
+
     /**
      * Add a list of output port to the flow with the specified name on the
      * specified network node
index e7a8a8e22cf9b2c4826d33bcd2450253f7d59794..57f3e8eb3605195f516aec818ee6c4200fec9186 100644 (file)
@@ -1034,6 +1034,19 @@ public class ForwardingRulesManager implements IForwardingRulesManager, PortGrou
         return list;
     }
 
+    @Override
+    public List<FlowEntry> getInstalledFlowEntriesForGroup(String policyName) {
+        List<FlowEntry> list = new ArrayList<FlowEntry>();
+        if (policyName != null && !policyName.trim().isEmpty()) {
+            for (Map.Entry<FlowEntryInstall, FlowEntryInstall> entry : this.installedSwView.entrySet()) {
+                if (policyName.equals(entry.getKey().getGroupName())) {
+                    list.add(entry.getKey().getInstall().clone());
+                }
+            }
+        }
+        return list;
+    }
+
     @Override
     public void addOutputPort(Node node, String flowName, List<NodeConnector> portList) {
 
index fb9378cdd339b2fb76903199f5b9899c4db06191..367df5ebb05e87e7b93737f9a9db03bd43075e9f 100644 (file)
@@ -434,7 +434,15 @@ public class HostTracker implements IfIptoHost, IfHostListener, ISwitchManagerAw
     }
 
     private void replaceHost(InetAddress networkAddr, HostNodeConnector removedHost, HostNodeConnector newHost) {
+        // Ignore ARP messages from internal nodes
+        NodeConnector newHostNc = newHost.getnodeConnector();
+        boolean newHostIsInternal = topologyManager.isInternal(newHostNc);
+        if (newHostIsInternal) {
+            return;
+        }
+
         newHost.initArpSendCountDown();
+
         if (hostsDB.replace(networkAddr, removedHost, newHost)) {
             logger.debug("Host move occurred: Old Host IP:{}, New Host IP: {}", removedHost.getNetworkAddress()
                     .getHostAddress(), newHost.getNetworkAddress().getHostAddress());