From c0a740eea72665c921a5f0f23dc0e822330d290c Mon Sep 17 00:00:00 2001 From: Aamir-raza-1 Date: Tue, 18 Aug 2020 21:03:17 +0500 Subject: [PATCH] Dump Openflow message into json --- ryu/controller/controller.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ryu/controller/controller.py b/ryu/controller/controller.py index d79f290ad..da288124f 100644 --- a/ryu/controller/controller.py +++ b/ryu/controller/controller.py @@ -31,6 +31,7 @@ from socket import timeout as SocketTimeout import ssl import sys +import requests from ryu import cfg from ryu.lib import hub @@ -50,6 +51,7 @@ from ryu.lib.dpid import dpid_to_str from ryu.lib import ip + LOG = logging.getLogger('ryu.controller.controller') DEFAULT_OFP_HOST = '0.0.0.0' @@ -447,6 +449,12 @@ def send_msg(self, msg, close_socket=False): if msg.xid is None: self.set_xid(msg) msg.serialize() + #Dump msg into json + msg_dict = msg.to_jsondict() + payload = json.dumps(msg_dict) + # Send as payload to http dummy url + #headers = {'content-type': 'application/json'} + #op_http = requests.post('http://localhost:5000/tasks', data=json.dumps(payload), headers=headers) # LOG.debug('send_msg %s', msg) return self.send(msg.buf, close_socket=close_socket)