* Revert to using l2agent. 51/5351/1
authorSuchi Raman <suchi.raman@plexxi.com>
Sat, 15 Feb 2014 15:24:33 +0000 (10:24 -0500)
committerSuchi Raman <suchi.raman@plexxi.com>
Sat, 15 Feb 2014 15:24:33 +0000 (10:24 -0500)
* Miscellaneous fixes to scripts.

Signed-off-by: Suchi Raman <suchi.raman@plexxi.com>
flatl2/src/main/java/org/opendaylight/affinity/flatl2/FlatL2AffinityImpl.java
scripts/affinity.py
scripts/affinity_control.py
scripts/analytics.py
scripts/demo.py
scripts/subnet.py

index ed3310ea26e2886cec1b8f885e6c29f29c6eb11f..4b12704c75ad08aacff7898e772eb6b718ddaf90 100644 (file)
@@ -372,7 +372,7 @@ public class FlatL2AffinityImpl implements IfNewHostNotify {
                 // Lookup output port on this node for this destination. 
 
                 // Using L2agent
-                Output output = getOutputPort(node, wp);
+                Output output = getOutputPortL2Agent(node, wp);
                 if (output != null) {
                     fwdactions.add(output);
                 }
@@ -395,12 +395,12 @@ public class FlatL2AffinityImpl implements IfNewHostNotify {
                 // Add a new rule with original destination + tap destinations. 
                 for (InetAddress tapip: taplist) {
                     log.info("tap information = {}", tapip);
-                    Output output1 = getOutputPort(node, tapip);
+                    Output output1 = getOutputPortL2Agent(node, tapip);
                     if (output1 != null) {
                         fwdactions = merge(fwdactions, output1);
                     }
                 }
-                Output output2 = getOutputPort(node, dst);
+                Output output2 = getOutputPortL2Agent(node, dst);
                 if (output2 != null) {
                     fwdactions = merge(fwdactions, output2);
                 }
index e4c9cd654fd6198b19a8d1170f738cbd70082ab7..4bae8f1cc1acb8830a9c9e70b114c547745e540a 100644 (file)
@@ -132,19 +132,20 @@ def tap_example():
     rest_method(put_url, "PUT")
 
     print "create link A -> B"
-    put_url = 'http://localhost:8080/affinity/nb/v2/affinity/default/create/link/a_to_b/from/a/to/b'
+    put_url = 'http://localhost:8080/affinity/nb/v2/affinity/default/create/link/a_to_b/from/b/to/a'
     rest_method(put_url, "PUT")
 
     print "add ip addresses to A"
     put_url = 'http://localhost:8080/affinity/nb/v2/affinity/default/group/a/add/ip/10.0.0.1'
     rest_method(put_url, "PUT")
-    put_url = 'http://localhost:8080/affinity/nb/v2/affinity/default/group/a/add/ip/10.0.0.2'
-    rest_method(put_url, "PUT")
+#    put_url = 'http://localhost:8080/affinity/nb/v2/affinity/default/group/a/add/ip/10.0.0.2'
+#    rest_method(put_url, "PUT")
 
     print "add ip addresses to B"    
     put_url = 'http://localhost:8080/affinity/nb/v2/affinity/default/group/b/add/ip/10.0.0.3'
     rest_method(put_url, "PUT")
 
+
 def repeat_add_link(): 
     print "create link inflows"
     put_url = 'http://localhost:8080/affinity/nb/v2/affinity/default/create/link/inflows/from/clients/to/webservers'
@@ -201,13 +202,20 @@ def add_waypoint():
     set_waypoint_address('inflows', '10.0.0.2')
 
 # Add tap servers. 
-def test_tap(): 
+def test_tap_1(): 
     tap_example()
     set_tap('a_to_b', '10.0.0.4')
     add_static_host_tap('a_to_b', '10.0.0.20')
     get_affinity_link('a_to_b')
     enable_affinity() # Tap to '10.0.0.4'.
 
+# Add tap servers. 
+def test_tap_2(): 
+    tap_example()
+    set_tap('a_to_b', '10.0.0.2')
+    get_affinity_link('a_to_b')
+    enable_affinity() # Tap to '10.0.0.2'.
+
 def add_isolate(): 
     set_path_isolate()    
     get_affinity_link('inflows')
@@ -230,7 +238,7 @@ def main():
     print "get_all_affinity_links..."
     get_all_affinity_links()
 
-    test_tap()
+    test_tap_2()
     list_all_hosts()
     return
 
index bc8b670305c435dd2511888fab31b22e33ca895f..3cbde45c6790146a94ffb302acd26a91eb2ef831 100644 (file)
@@ -60,6 +60,15 @@ class AffinityControl:
             return
         print "Isolate successfully set for link %s" % (link_name)
 
+    # Remove isolate to the link.
+    def remove_isolate(self, link_name):
+        resp, content = self.http.request(self.url_prefix + "link/%s/unsetisolate" % (link_name), "PUT")
+        if (resp.status != 201):
+            print "Isolate could not be removed for link %s" % (link_name)
+            return
+        print "Isolate successfully removed for link %s" % (link_name)
+
+
     # Add waypoint
     def add_waypoint(self, link_name, ip):
         resp, content = self.http.request(self.url_prefix + "link/%s/setwaypoint/%s" % (link_name, ip), "PUT")
index 1c6297c17caaeeb2db6f1f11dfcd932cb614213d..3b1003819894d7ee2cfd43ddfb1c8b6e57b6f732 100644 (file)
@@ -198,7 +198,10 @@ def add_protocol_flows():
         name = "flow" + str(i)
         flow.set_priority(2)
         flow.set_protocol(1)
-        flow_success = add_flow(flow, name)
+        try: 
+            flow_success = add_flow(flow, name)
+        except Exception as e: 
+            continue;
         if (flow_success != 201):
             success = False
     return success
@@ -212,7 +215,10 @@ def get_flows():
     for item in data['flowStatistics']:
         n = item['node']
         for item in item['flowStatistic']:
-            f = Flow(n, item['flow'])
+            try: 
+                f = Flow(n, item['flow'])
+            except Exception, e: 
+                continue
             flows.append(f)
     return flows
 
index 514990621bf7aa8c4a40361f3d524bef457d42ee..3e748cca43e2219dd0fa2f3fe3d82b74993193bf 100644 (file)
@@ -152,6 +152,7 @@ def main():
 
     # Default subnet is required for the host tracker to work.
     subnet_control = SubnetControl()
+    subnet_control.list()
     subnet_control.add_subnet("defaultSubnet", "10.0.0.254/8")
 
     raw_input("[Press enter when mininet is ready] ")
index c561717d73daa7fadedf48cb1081e93d74db0e90..b4c6cb9bff5f193e663ad58d88a8840827057abc 100644 (file)
@@ -50,3 +50,10 @@ class SubnetControl:
             print "Subnet", subnet, "added"
         else:
             print "Subnet", subnet, "could not be added"
+
+    def list(self):
+        resp, content = self.http.request(self.url_prefix + "subnets", "GET")
+        if (resp.status != 200):
+            print "Error could not get subnets"
+        data = json.loads(content)
+        print data