From b7715d3a34e3dac8ae19ce54ca99ec31937658e4 Mon Sep 17 00:00:00 2001 From: stevenvanrossem Date: Fri, 26 Aug 2016 16:22:21 +0200 Subject: [PATCH] fix bugs in monitor commands --- src/emuvim/dcemulator/monitoring.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/emuvim/dcemulator/monitoring.py b/src/emuvim/dcemulator/monitoring.py index 875913f..b5f0204 100755 --- a/src/emuvim/dcemulator/monitoring.py +++ b/src/emuvim/dcemulator/monitoring.py @@ -48,6 +48,8 @@ PUSHGATEWAY_PORT = 9091 # we cannot use port 8080 because ryu-ofrest api is already using that one CADVISOR_PORT = 8081 +COOKIE_MASK = 0xffffffff + class DCNetworkMonitor(): def __init__(self, net): self.net = net @@ -344,7 +346,7 @@ class DCNetworkMonitor(): data = {} data['cookie'] = flow_dict['cookie'] - data['cookie_mask'] = flow_dict['cookie'] + data['cookie_mask'] = COOKIE_MASK if 'tx' in flow_dict['metric_key']: data['match'] = {'in_port':flow_dict['mon_port']} @@ -381,7 +383,12 @@ class DCNetworkMonitor(): # query Ryu ret = self.net.ryu_REST('stats/port', dpid=dpid) - port_stat_dict = ast.literal_eval(ret) + if isinstance(ret, dict): + port_stat_dict = ret + elif isinstance(ret, basestring): + port_stat_dict = ast.literal_eval(ret.rstrip()) + else: + port_stat_dict = None metric_list = [metric_dict for metric_dict in self.network_metrics if int(metric_dict['switch_dpid'])==int(dpid)] -- 2.25.1