# we cannot use port 8080 because ryu-ofrest api is already using that one\r
CADVISOR_PORT = 8081\r
\r
+COOKIE_MASK = 0xffffffff\r
+\r
class DCNetworkMonitor():\r
def __init__(self, net):\r
self.net = net\r
data = {}\r
\r
data['cookie'] = flow_dict['cookie']\r
- data['cookie_mask'] = flow_dict['cookie']\r
+ data['cookie_mask'] = COOKIE_MASK\r
\r
if 'tx' in flow_dict['metric_key']:\r
data['match'] = {'in_port':flow_dict['mon_port']}\r
\r
# query Ryu\r
ret = self.net.ryu_REST('stats/port', dpid=dpid)\r
- port_stat_dict = ast.literal_eval(ret)\r
+ if isinstance(ret, dict):\r
+ port_stat_dict = ret\r
+ elif isinstance(ret, basestring):\r
+ port_stat_dict = ast.literal_eval(ret.rstrip())\r
+ else:\r
+ port_stat_dict = None\r
\r
metric_list = [metric_dict for metric_dict in self.network_metrics\r
if int(metric_dict['switch_dpid'])==int(dpid)]\r