示例#1
0
def getPeriodicStats(dp):
    """show periodic stats on screen

    :param dp: the datapath from which the stats shall be shown for network debugging and Malicious attacks """
    waiters = {}
    while True:
        get_flow_stats(dp, waiters)
        get_port_stats(dp, waiters)
        time.sleep(1)
示例#2
0
def getPeriodicStats(dp):
    """show periodic stats on screen

    :param dp: the datapath from which the stats shall be shown
    """
    waiters = {}
    while True:
        get_flow_stats(dp, waiters)
        get_port_stats(dp, waiters)
        time.sleep(1)
示例#3
0
    def get_flow_stats(self, req, dpid, **_kwargs):
        if req.body == '':
            flow = {}
        else:
            try:
                flow = ast.literal_eval(req.body)
            except SyntaxError:
                LOG.debug('invalid syntax %s', req.body)
                return Response(status=400)

        dp = self.dpset.get(int(dpid))
        if dp is None:
            return Response(status=404)

        if dp.ofproto.OFP_VERSION == ofproto_v1_0.OFP_VERSION:
            flows = ofctl_v1_0.get_flow_stats(dp, self.waiters, flow)
        elif dp.ofproto.OFP_VERSION == ofproto_v1_2.OFP_VERSION:
            flows = ofctl_v1_2.get_flow_stats(dp, self.waiters, flow)
        elif dp.ofproto.OFP_VERSION == ofproto_v1_3.OFP_VERSION:
            flows = ofctl_v1_3.get_flow_stats(dp, self.waiters, flow)
        else:
            LOG.debug('Unsupported OF protocol')
            return Response(status=501)

        body = json.dumps(flows)
        return (Response(content_type='application/json', body=body))
示例#4
0
    def get_flow_stats(self, req, dpid, **_kwargs):
        if req.body == '':
            flow = {}
        else:
            try:
                flow = ast.literal_eval(req.body)
            except SyntaxError:
                LOG.debug('invalid syntax %s', req.body)
                return Response(status=400)

        dp = self.dpset.get(int(dpid))
        if dp is None:
            return Response(status=404)

        CMD_LIST.append(flow)
        if dp.ofproto.OFP_VERSION == ofproto_v1_0.OFP_VERSION:
            flows = ofctl_v1_0.get_flow_stats(dp, self.waiters, flow)
        elif dp.ofproto.OFP_VERSION == ofproto_v1_2.OFP_VERSION:
            flows = ofctl_v1_2.get_flow_stats(dp, self.waiters, flow)
        elif dp.ofproto.OFP_VERSION == ofproto_v1_3.OFP_VERSION:
            flows = ofctl_v1_3.get_flow_stats(dp, self.waiters, flow)
        else:
            LOG.debug('Unsupported OF protocol')
            return Response(status=501)

        body = json.dumps(flows)
        return Response(content_type='application/json', body=body)
示例#5
0
	def get_flows(self):
		flows = {}
		for dpid, dp in self.dpset.get_all():
			if dp.ofproto.OFP_VERSION == ofproto_v1_0.OFP_VERSION:
				flows.update(ofctl_v1_0.get_flow_stats(dp, self.waiters, {}))
			elif dp.ofproto.OFP_VERSION == ofproto_v1_2.OFP_VERSION:
				flows.update(ofctl_v1_2.get_flow_stats(dp, self.waiters, {}))
			elif dp.ofproto.OFP_VERSION == ofproto_v1_3.OFP_VERSION:
				flows.update(ofctl_v1_3.get_flow_stats(dp, self.waiters, {}))
		return flows
示例#6
0
	def get_flows(self):
		flows = {}
		for dpid, dp in self.dpset.get_all():
			if dp.ofproto.OFP_VERSION == ofproto_v1_0.OFP_VERSION:
				flows.update(ofctl_v1_0.get_flow_stats(dp, self.waiters, {}))
			elif dp.ofproto.OFP_VERSION == ofproto_v1_2.OFP_VERSION:
				flows.update(ofctl_v1_2.get_flow_stats(dp, self.waiters, {}))
			elif dp.ofproto.OFP_VERSION == ofproto_v1_3.OFP_VERSION:
				flows.update(ofctl_v1_3.get_flow_stats(dp, self.waiters, {}))
		return flows
示例#7
0
    def cmd_get_flows(self):
        result = ""
        for dp in self.fwd.get_all_datapaths():
            flows = ofctl_v1_3.get_flow_stats(dp, self.waiters, {})

            result = result + "{:0>16}:\n".format(dp.id)
            result = result + "=" * 17 + "\n"

            for flow in flows:
                result = result + json.dumps(flow) + "\n"

        return result
示例#8
0
    def cmd_get_flows(self):
        result = ""
        for dp in self.fwd.get_all_datapaths():
            flows = ofctl_v1_3.get_flow_stats(dp, self.waiters, {})

            result = result + "{:0>16}:\n".format(dp.id)
            result = result + "=" * 17 + "\n"

            for flow in flows:
                result = result + json.dumps(flow) + "\n"

        return result
示例#9
0
    def initialize_switch(self):
        flow_stat = ofctl.get_flow_stats(self.dp, self.waiters)
        for s in flow_stat[str(self.dp.id)]:
            self.logger.debug("deleting flow [cookie: %d]" % s['cookie'])
            cmd = self.dp.ofproto.OFPFC_DELETE
            ofctl.mod_flow_entry(self.dp, {'table_id':self.dp.ofproto.OFPTT_ALL}, cmd)

        group_stat = ofctl.get_group_desc(self.dp, self.waiters)
        for s in group_stat[str(self.dp.id)]:
            self.logger.debug("deleting group[id: %d] %s" % (s['group_id'], s))
            cmd = self.dp.ofproto.OFPGC_DELETE
            ofctl.mod_group_entry(self.dp, {'type':s['type'], 'group_id':s['group_id']}, cmd)

        ofctl.mod_meter_entry(self.dp, {'meter_id':self.dp.ofproto.OFPM_ALL}, self.dp.ofproto.OFPMC_DELETE)
示例#10
0
    def _get_flow_entry(self, req, dpid, **kwargs):
        dp_id = dpid_lib.str_to_dpid(dpid)

        if dp_id in  self.ofuro_spp._OFSW_LIST.keys():
            ofsw = self.ofuro_spp._OFSW_LIST[dp_id]
        else:
            logging.info('<*** ERROR ***>  OFSW Not Found')                                         
            return wsgi.Response(status=400)

        datapath = ofsw.dpset

        flow_entry = ofctl_v1_3.get_flow_stats(datapath, self.waiters, {})
        content_body = json.dumps(flow_entry, indent=4)
        return wsgi.Response(status=200, body=content_body, headers=self.headers)
    def get_flow_stats(self, req, dpid, **_kwargs):
        dp = self.dpset.get(int(dpid))
        if dp is None:
            return Response(status=404)

        if dp.ofproto.OFP_VERSION == ofproto_v1_0.OFP_VERSION:
            flows = ofctl_v1_0.get_flow_stats(dp, self.waiters)
        elif dp.ofproto.OFP_VERSION == ofproto_v1_3.OFP_VERSION:
            flows = ofctl_v1_3.get_flow_stats(dp, self.waiters)
        else:
            LOG.debug('Unsupported OF protocol')
            return Response(status=501)

        body = json.dumps(flows)
        return (Response(content_type='application/json', body=body))
示例#12
0
 def getFlows(self, dpid):
     flow = {}
     dp = self.dpset.get(int(dpid))
     if dp is None:
         return None
     if dp.ofproto.OFP_VERSION == ofproto_v1_0.OFP_VERSION:
         flows = ofctl_v1_0.get_flow_stats(dp, self.waiters, flow)
     elif dp.ofproto.OFP_VERSION == ofproto_v1_2.OFP_VERSION:
         flows = ofctl_v1_2.get_flow_stats(dp, self.waiters, flow)
     elif dp.ofproto.OFP_VERSION == ofproto_v1_3.OFP_VERSION:
         flows = ofctl_v1_3.get_flow_stats(dp, self.waiters, flow)
     else:
         LOG.debug('Unsupported OF protocol')
         return None
     return flows
示例#13
0
 def getFlows(self, dpid):
     flow = {}
     dp = self.dpset.get(int(dpid))
     if dp is None:
         return None
     if dp.ofproto.OFP_VERSION == ofproto_v1_0.OFP_VERSION:
         flows = ofctl_v1_0.get_flow_stats(dp, self.waiters, flow)
     elif dp.ofproto.OFP_VERSION == ofproto_v1_2.OFP_VERSION:
         flows = ofctl_v1_2.get_flow_stats(dp, self.waiters, flow)
     elif dp.ofproto.OFP_VERSION == ofproto_v1_3.OFP_VERSION:
         flows = ofctl_v1_3.get_flow_stats(dp, self.waiters, flow)
     else:
         LOG.debug('Unsupported OF protocol')
         return None
     return flows
示例#14
0
    def get_flow_stats(self, req, dpid, **_kwargs):
        dp = self.dpset.get(int(dpid))
        if dp is None:
            return Response(status=404)

        if dp.ofproto.OFP_VERSION == ofproto_v1_0.OFP_VERSION:
            flows = ofctl_v1_0.get_flow_stats(dp, self.waiters)
        if dp.ofproto.OFP_VERSION == ofproto_v1_3.OFP_VERSION:
            flows = ofctl_v1_3.get_flow_stats(dp, self.waiters)
        else:
            LOG.debug('Unsupported OF protocol')
            return Response(status=501)

        body = json.dumps(flows)
        return (Response(content_type='application/json', body=body))
示例#15
0
    def initialize_switch(self):
        flow_stat = ofctl.get_flow_stats(self.dp, self.waiters)
        for s in flow_stat[str(self.dp.id)]:
            self.logger.debug("deleting flow [cookie: %d]" % s['cookie'])
            cmd = self.dp.ofproto.OFPFC_DELETE
            ofctl.mod_flow_entry(self.dp,
                                 {'table_id': self.dp.ofproto.OFPTT_ALL}, cmd)

        group_stat = ofctl.get_group_desc(self.dp, self.waiters)
        for s in group_stat[str(self.dp.id)]:
            self.logger.debug("deleting group[id: %d] %s" % (s['group_id'], s))
            cmd = self.dp.ofproto.OFPGC_DELETE
            ofctl.mod_group_entry(self.dp, {
                'type': s['type'],
                'group_id': s['group_id']
            }, cmd)

        ofctl.mod_meter_entry(self.dp, {'meter_id': self.dp.ofproto.OFPM_ALL},
                              self.dp.ofproto.OFPMC_DELETE)
示例#16
0
    def get_flow_stats(self, req, dpid, **_kwargs):
        dp = self.dpset.get(int(dpid, 0))
        if dp is None:
            return Response(status=404)

        if dp.ofproto.OFP_VERSION == ofproto_v1_0.OFP_VERSION:
            flows = ofctl_v1_0.get_flow_stats(dp, self.waiters)
        elif dp.ofproto.OFP_VERSION == ofproto_v1_2.OFP_VERSION:
            flows = ofctl_v1_2.get_flow_stats(dp, self.waiters)
        elif dp.ofproto.OFP_VERSION == ofproto_v1_3.OFP_VERSION:
            # -------------------------- Fujitsu code start -----------------------------
            # For optical enhancing
            #            flows = ofctl_v1_3.get_flow_stats(dp, self.waiters)
            flows = ofctl_v1_3.get_flow_stats(dp, self.waiters, match)


# -------------------------- Fujitsu code end -------------------------------
        else:
            LOG.debug('Unsupported OF protocol')
            return Response(status=501)

        body = json.dumps(flows)
        return (Response(content_type='application/json', body=body))
示例#17
0
def send_table_stats_request(datapath, waiters):
    return ofctl_v1_3.get_flow_stats(datapath, waiters)
示例#18
0
def send_table_stats_request(datapath, waiters):
    return ofctl_v1_3.get_flow_stats(datapath, waiters)
示例#19
0
文件: omniui.py 项目: uozbek/OpenADM
    def flow_stats_reply_handler_API(self, dpid):
        flow = {}
        dp = self.dpset.get(int(dpid))
        if dp is None:
            return None
        if dp.ofproto.OFP_VERSION == ofproto_v1_0.OFP_VERSION:
            flows = ofctl_v1_0.get_flow_stats(dp, self.waiters, flow)
        elif dp.ofproto.OFP_VERSION == ofproto_v1_2.OFP_VERSION:
            flows = ofctl_v1_2.get_flow_stats(dp, self.waiters, flow)
        elif dp.ofproto.OFP_VERSION == ofproto_v1_3.OFP_VERSION:
            flows = ofctl_v1_3.get_flow_stats(dp, self.waiters, flow)
        else:
            LOG.debug('Unsupported OF protocol')
            return None

        print '----------------------flowAPI----------------------'

        flowstatsReplyAPI = {}
        flowstatsReplyAPI["controller"] = controllerName

        for key in flows:
            temp = "%016x" % int(key)
            temp = map(str, temp)
            for i in range(2, 23, 3):
                temp.insert(i, ':')
            flowstatsReplyAPI["dpid"] = ''.join(temp)

            flowstatsReplyAPI["flows"] = []
            i = 0
            for inflow in flows[key]:
                if 'priority' in inflow:
                    flowstatsReplyAPI["flows"].append({})
                    flowstatsReplyAPI["flows"][i]["ingressPort"] = str(
                        inflow['match']
                        ['in_port']) if 'in_port' in inflow['match'] else "0"
                    flowstatsReplyAPI["flows"][i]["dstMac"] = inflow['match'][
                        'dl_dst'] if 'dl_dst' in inflow[
                            'match'] else "00:00:00:00:00:00"
                    flowstatsReplyAPI["flows"][i]["srcMac"] = inflow['match'][
                        'dl_src'] if 'dl_src' in inflow[
                            'match'] else "00:00:00:00:00:00"
                    flowstatsReplyAPI["flows"][i]["dstIP"] = inflow['match'][
                        'nw_dst'] if 'nw_dst' in inflow['match'] else "0.0.0.0"
                    flowstatsReplyAPI["flows"][i][
                        "dstIPMask"] = "0"  # not support in ryu
                    flowstatsReplyAPI["flows"][i]["srcIP"] = inflow['match'][
                        'nw_src'] if 'nw_src' in inflow['match'] else "0.0.0.0"
                    flowstatsReplyAPI["flows"][i][
                        "srcIPMask"] = "0"  # not support in ryu
                    flowstatsReplyAPI["flows"][i]["netProtocol"] = hex(
                        inflow['match']['nw_proto']
                    ) if 'nw_proto' in inflow['match'] else "0x00"
                    flowstatsReplyAPI["flows"][i]["dstPort"] = str(
                        inflow['match']
                        ['tp_dst']) if 'tp_dst' in inflow['match'] else "0"
                    flowstatsReplyAPI["flows"][i]["srcPort"] = str(
                        inflow['match']
                        ['tp_src']) if 'tp_src' in inflow['match'] else "0"
                    flowstatsReplyAPI["flows"][i]["vlan"] = str(
                        inflow['match']
                        ['dl_vlan']) if 'dl_vlan' in inflow['match'] else "0"
                    flowstatsReplyAPI["flows"][i]["vlanP"] = str(
                        inflow['match']['dl_vlan_pcp']
                    ) if 'dl_vlan_pcp' in inflow['match'] else "0"
                    flowstatsReplyAPI["flows"][i]["tosBits"] = str(
                        inflow['match']
                        ['nw_tos']) if 'nw_tos' in inflow['match'] else "0"
                    flowstatsReplyAPI["flows"][i]["counterByte"] = str(
                        inflow['byte_count'])
                    flowstatsReplyAPI["flows"][i]["counterPacket"] = str(
                        inflow['packet_count'])
                    flowstatsReplyAPI["flows"][i]["idleTimeout"] = str(
                        inflow['idle_timeout'])
                    flowstatsReplyAPI["flows"][i]["hardTimeout"] = str(
                        inflow['hard_timeout'])
                    flowstatsReplyAPI["flows"][i]["priority"] = str(
                        inflow['priority'])
                    flowstatsReplyAPI["flows"][i]["duration"] = str(
                        inflow['duration_sec'])
                    flowstatsReplyAPI["flows"][i]["dlType"] = hex(
                        inflow['match']['dl_type']
                    ) if 'dl_type' in inflow['match'] else "0x0000"

                    flowstatsReplyAPI["flows"][i]["actions"] = []
                    for action in inflow['actions']:
                        if len(action.split(':')) == 1:
                            act = {"value": "0", "type": action}
                        else:
                            act = {
                                "value": action.split(':')[1],
                                "type": action.split(':')[0]
                            }
                        flowstatsReplyAPI["flows"][i]["actions"].append(act)

                    i += 1

        print json.dumps(flowstatsReplyAPI)
        tmpIP = coreURL + "/publish/flow"
        self.post_json_to_core(tmpIP, json.dumps(flowstatsReplyAPI))
        return flows
示例#20
0
    def flow_stats_reply_handler_API(self, dpid):
        flow = {}
        dp = self.dpset.get(int(dpid))
        if dp is None:
            return None
        if dp.ofproto.OFP_VERSION == ofproto_v1_0.OFP_VERSION:
            flows = ofctl_v1_0.get_flow_stats(dp, self.waiters, flow)
        elif dp.ofproto.OFP_VERSION == ofproto_v1_2.OFP_VERSION:
            flows = ofctl_v1_2.get_flow_stats(dp, self.waiters, flow)
        elif dp.ofproto.OFP_VERSION == ofproto_v1_3.OFP_VERSION:
            flows = ofctl_v1_3.get_flow_stats(dp, self.waiters, flow)
        else:
            LOG.debug('Unsupported OF protocol')
            return None

        print '----------------------flowAPI----------------------'

        flowstatsReplyAPI = {}
        flowstatsReplyAPI["controller"] = controllerName

        for key in flows:
            temp = "%016x" %int(key)
            temp = map(str, temp)
            for i in range(2, 23, 3):
                temp.insert(i, ':')
            flowstatsReplyAPI["dpid"] = ''.join(temp)

            flowstatsReplyAPI["flows"] = []
            i = 0
            for inflow in flows[key]:
                if 'priority' in inflow:
                    flowstatsReplyAPI["flows"].append({})
                    flowstatsReplyAPI["flows"][i]["ingressPort"] = str(inflow['match']['in_port']) if 'in_port' in inflow['match'] else "0"
                    flowstatsReplyAPI["flows"][i]["dstMac"] = inflow['match']['dl_dst'] if 'dl_dst' in inflow['match'] else "00:00:00:00:00:00"
                    flowstatsReplyAPI["flows"][i]["srcMac"] = inflow['match']['dl_src'] if 'dl_src' in inflow['match'] else "00:00:00:00:00:00"
                    flowstatsReplyAPI["flows"][i]["dstIP"] = inflow['match']['nw_dst'] if 'nw_dst' in inflow['match'] else "0.0.0.0"
                    flowstatsReplyAPI["flows"][i]["dstIPMask"] = "0" # not support in ryu
                    flowstatsReplyAPI["flows"][i]["srcIP"] = inflow['match']['nw_src'] if 'nw_src' in inflow['match'] else "0.0.0.0"
                    flowstatsReplyAPI["flows"][i]["srcIPMask"] = "0" # not support in ryu
                    flowstatsReplyAPI["flows"][i]["netProtocol"] = hex(inflow['match']['nw_proto']) if 'nw_proto' in inflow['match'] else "0x00"
                    flowstatsReplyAPI["flows"][i]["dstPort"] = str(inflow['match']['tp_dst']) if 'tp_dst' in inflow['match'] else "0"
                    flowstatsReplyAPI["flows"][i]["srcPort"] = str(inflow['match']['tp_src']) if 'tp_src' in inflow['match'] else "0"
                    flowstatsReplyAPI["flows"][i]["vlan"] = str(inflow['match']['dl_vlan']) if 'dl_vlan' in inflow['match'] else "0"
                    flowstatsReplyAPI["flows"][i]["vlanP"] = str(inflow['match']['dl_vlan_pcp']) if 'dl_vlan_pcp' in inflow['match'] else "0"
                    flowstatsReplyAPI["flows"][i]["tosBits"] = str(inflow['match']['nw_tos']) if 'nw_tos' in inflow['match'] else "0"
                    flowstatsReplyAPI["flows"][i]["counterByte"] = str(inflow['byte_count'])
                    flowstatsReplyAPI["flows"][i]["counterPacket"] = str(inflow['packet_count'])
                    flowstatsReplyAPI["flows"][i]["idleTimeout"] = str(inflow['idle_timeout'])
                    flowstatsReplyAPI["flows"][i]["hardTimeout"] = str(inflow['hard_timeout'])
                    flowstatsReplyAPI["flows"][i]["priority"] = str(inflow['priority'])
                    flowstatsReplyAPI["flows"][i]["duration"] = str(inflow['duration_sec'])
                    flowstatsReplyAPI["flows"][i]["dlType"] = hex(inflow['match']['dl_type']) if 'dl_type' in inflow['match'] else "0x0000"

                    flowstatsReplyAPI["flows"][i]["actions"] = []
                    for action in inflow['actions']:
                        if len(action.split(':')) == 1:
                            act = {
                                "value": "0",
                                "type": action
                            }
                        else:
                            act = {
                                "value": action.split(':')[1],
                                "type": action.split(':')[0]
                            }
                        flowstatsReplyAPI["flows"][i]["actions"].append(act)

                    i += 1

        print json.dumps(flowstatsReplyAPI)
        tmpIP = coreURL + "/publish/flow"
        self.post_json_to_core(tmpIP, json.dumps(flowstatsReplyAPI))
        return flows
示例#21
0
    def flow_stats_reply_handler_API(self, dpid):
        flow = {}
        dp = self.dpset.get(int(dpid))
        if dp is None:
            return None
        if dp.ofproto.OFP_VERSION == ofproto_v1_0.OFP_VERSION:
            flows = ofctl_v1_0.get_flow_stats(dp, self.waiters, flow)
        elif dp.ofproto.OFP_VERSION == ofproto_v1_2.OFP_VERSION:
            flows = ofctl_v1_2.get_flow_stats(dp, self.waiters, flow)
        elif dp.ofproto.OFP_VERSION == ofproto_v1_3.OFP_VERSION:
            flows = ofctl_v1_3.get_flow_stats(dp, self.waiters, flow)
        else:
            LOG.debug("Unsupported OF protocol")
            return None

        print "----------------------flowAPI----------------------"

        flowstatsReplyAPI = {}
        flowstatsReplyAPI["controller"] = controllerName

        for key in flows:
            temp = "%016x" % int(key)
            temp = map(str, temp)
            for i in range(2, 23, 3):
                temp.insert(i, ":")
            flowstatsReplyAPI["dpid"] = "".join(temp)

            flowstatsReplyAPI["flows"] = []
            i = 0
            for inflow in flows[key]:
                if "priority" in inflow:
                    flowstatsReplyAPI["flows"].append({})
                    flowstatsReplyAPI["flows"][i]["ingressPort"] = (
                        str(inflow["match"]["in_port"]) if "in_port" in inflow["match"] else "0"
                    )
                    flowstatsReplyAPI["flows"][i]["dstMac"] = (
                        inflow["match"]["dl_dst"] if "dl_dst" in inflow["match"] else "00:00:00:00:00:00"
                    )
                    flowstatsReplyAPI["flows"][i]["srcMac"] = (
                        inflow["match"]["dl_src"] if "dl_src" in inflow["match"] else "00:00:00:00:00:00"
                    )
                    flowstatsReplyAPI["flows"][i]["dstIP"] = (
                        inflow["match"]["nw_dst"] if "nw_dst" in inflow["match"] else "0.0.0.0"
                    )
                    flowstatsReplyAPI["flows"][i]["dstIPMask"] = "0"  # not support in ryu
                    flowstatsReplyAPI["flows"][i]["srcIP"] = (
                        inflow["match"]["nw_src"] if "nw_src" in inflow["match"] else "0.0.0.0"
                    )
                    flowstatsReplyAPI["flows"][i]["srcIPMask"] = "0"  # not support in ryu
                    flowstatsReplyAPI["flows"][i]["netProtocol"] = (
                        hex(inflow["match"]["nw_proto"]) if "nw_proto" in inflow["match"] else "0x00"
                    )
                    flowstatsReplyAPI["flows"][i]["dstPort"] = (
                        str(inflow["match"]["tp_dst"]) if "tp_dst" in inflow["match"] else "0"
                    )
                    flowstatsReplyAPI["flows"][i]["srcPort"] = (
                        str(inflow["match"]["tp_src"]) if "tp_src" in inflow["match"] else "0"
                    )
                    flowstatsReplyAPI["flows"][i]["vlan"] = (
                        str(inflow["match"]["dl_vlan"]) if "dl_vlan" in inflow["match"] else "0"
                    )
                    flowstatsReplyAPI["flows"][i]["vlanP"] = (
                        str(inflow["match"]["dl_vlan_pcp"]) if "dl_vlan_pcp" in inflow["match"] else "0"
                    )
                    flowstatsReplyAPI["flows"][i]["wildcards"] = (
                        str(inflow["match"]["wildcards"]) if "wildcards" in inflow["match"] else "0"
                    )
                    flowstatsReplyAPI["flows"][i]["tosBits"] = (
                        str(inflow["match"]["nw_tos"]) if "nw_tos" in inflow["match"] else "0"
                    )
                    flowstatsReplyAPI["flows"][i]["counterByte"] = str(inflow["byte_count"])
                    flowstatsReplyAPI["flows"][i]["counterPacket"] = str(inflow["packet_count"])
                    flowstatsReplyAPI["flows"][i]["idleTimeout"] = str(inflow["idle_timeout"])
                    flowstatsReplyAPI["flows"][i]["hardTimeout"] = str(inflow["hard_timeout"])
                    flowstatsReplyAPI["flows"][i]["priority"] = str(inflow["priority"])
                    flowstatsReplyAPI["flows"][i]["duration"] = str(inflow["duration_sec"])
                    flowstatsReplyAPI["flows"][i]["dlType"] = (
                        hex(inflow["match"]["dl_type"]) if "dl_type" in inflow["match"] else "0x0000"
                    )

                    flowstatsReplyAPI["flows"][i]["actions"] = []
                    for action in inflow["actions"]:
                        if len(action.split(":")) == 1:
                            act = {"value": "0", "type": action}
                        else:
                            act = {"value": action.split(":")[1], "type": action.split(":")[0]}
                        flowstatsReplyAPI["flows"][i]["actions"].append(act)

                    i += 1

        print json.dumps(flowstatsReplyAPI)
        tmpIP = "http://" + coreIP + ":" + corePort + "/publish/flow"
        self.post_json_to_core(tmpIP, json.dumps(flowstatsReplyAPI))
        return flows