Merge remote-tracking branch 'upstream/master'
authorstevenvanrossem <steven.vanrossem@intec.ugent.be>
Tue, 9 Aug 2016 21:39:36 +0000 (23:39 +0200)
committerstevenvanrossem <steven.vanrossem@intec.ugent.be>
Tue, 9 Aug 2016 21:39:36 +0000 (23:39 +0200)
src/emuvim/api/rest/compute.py
src/emuvim/api/rest/network.py
src/emuvim/api/rest/rest_api_endpoint.py
src/emuvim/dcemulator/monitoring.py
src/emuvim/dcemulator/net.py

index 9f0516b..1082a4d 100755 (executable)
@@ -106,10 +106,10 @@ class ComputeList(Resource):
 
     global dcs
 
-    def get(self, dc_label):
+    def get(self, dc_label=None):
         logging.debug("API CALL: compute list")
         try:
-            if dc_label == 'None':
+            if dc_label is None:
                 # return list with all compute nodes in all DCs
                 all_containers = []
                 for dc in dcs.itervalues():
index e3945b0..83fbde7 100755 (executable)
@@ -53,6 +53,7 @@ class NetworkAction(Resource):
     :param match: OpenFlow match format of the flow entry
     :param bidirectional: boolean value if the link needs to be implemented from src to dst and back
     :param cookie: cookie value, identifier of the flow entry to be installed.
+    :param priority: integer indicating the priority of the flow entry
     :return: message string indicating if the chain action is succesful or not
     """
 
index 536ed7a..51b58cb 100755 (executable)
@@ -62,7 +62,9 @@ class RestApiEndpoint(object):
         self.api = Api(self.app)
 
         # setup endpoints
-        self.api.add_resource(ComputeList, "/restapi/compute/<dc_label>")
+        self.api.add_resource(ComputeList,
+                              "/restapi/compute",
+                              "/restapi/compute/<dc_label>")
         self.api.add_resource(ComputeStart, "/restapi/compute/<dc_label>/<compute_name>/start")
         self.api.add_resource(ComputeStop, "/restapi/compute/<dc_label>/<compute_name>/stop")
         self.api.add_resource(ComputeStatus, "/restapi/compute/<dc_label>/<compute_name>")
index 80b139c..2c07ab5 100755 (executable)
@@ -348,6 +348,7 @@ class DCNetworkMonitor():
                 data = {}\r
 \r
                 data['cookie'] = flow_dict['cookie']\r
+                data['cookie_mask'] = flow_dict['cookie']\r
 \r
                 if 'tx' in flow_dict['metric_key']:\r
                     data['match'] = {'in_port':flow_dict['mon_port']}\r
@@ -358,8 +359,8 @@ class DCNetworkMonitor():
                 # query Ryu\r
                 ret = self.net.ryu_REST('stats/flow', dpid=flow_dict['switch_dpid'], data=data)\r
                 flow_stat_dict = ast.literal_eval(ret)\r
-\r
                 logging.debug('received flow stat:{0} '.format(flow_stat_dict))\r
+\r
                 self.set_flow_metric(flow_dict, flow_stat_dict)\r
 \r
             self.monitor_flow_lock.release()\r
index bca20b2..4503e1c 100755 (executable)
@@ -32,8 +32,7 @@ import time
 from subprocess import Popen
 import os
 import re
-import urllib2
-from functools import partial
+import requests
 
 from mininet.net import Containernet
 from mininet.node import Controller, DefaultController, OVSSwitch, OVSKernelSwitch, Docker, RemoteController
@@ -540,11 +539,14 @@ class DCNetwork(Containernet):
                 url = self.ryu_REST_api + '/' + str(prefix)
             if data:
                 #LOG.info('POST: {0}'.format(str(data)))
-                req = urllib2.Request(url, str(data))
+                #req = urllib2.Request(url, str(data))
+                req = requests.post(url, data=str(data))
             else:
-                req = urllib2.Request(url)
+                #req = urllib2.Request(url)
+                req = requests.get(url)
 
-            ret = urllib2.urlopen(req).read()
+            #ret = urllib2.urlopen(req).read()
+            ret = req.text
             return ret
         except:
             LOG.info('error url: {0}'.format(str(url)))