Hi,

Currently, Ryu does not provides such feature, you need to implement it.

But just an idea,
JSON representation is might be convenient for such purpose, I guess.
"ryu.lib.ofctl_v1_3" can accept JSON like dictionary as input,
so you can describe flows as JSON.

The following example installs flows at switch connection from JSON file.

e.g.)
$ cat sample_flows.json 
[
  {
    "dpid": 1,
    "match": {
      "in_port": 1
    },
    "actions": [
      {
        "type": "OUTPUT",
        "port": 2
      }
    ]
  },
  {
    "dpid": 1,
    "match": {
      "in_port": 2
    },
    "actions": [
      {
        "type": "OUTPUT",
        "port": 1
      }
    ]
  }
]


$ git diff
diff --git a/ryu/app/simple_switch_13.py b/ryu/app/simple_switch_13.py
index 3e7c598..dba09e5 100644
--- a/ryu/app/simple_switch_13.py
+++ b/ryu/app/simple_switch_13.py
@@ -13,6 +13,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+import json
+
 from ryu.base import app_manager
 from ryu.controller import ofp_event
 from ryu.controller.handler import CONFIG_DISPATCHER, MAIN_DISPATCHER
@@ -21,6 +23,7 @@ from ryu.ofproto import ofproto_v1_3
 from ryu.lib.packet import packet
 from ryu.lib.packet import ethernet
 from ryu.lib.packet import ether_types
+from ryu.lib import ofctl_v1_3
 
 
 class SimpleSwitch13(app_manager.RyuApp):
@@ -48,6 +51,10 @@ class SimpleSwitch13(app_manager.RyuApp):
                                           ofproto.OFPCML_NO_BUFFER)]
         self.add_flow(datapath, 0, match, actions)
 
+        for flow in json.load(open('sample_flows.json')):
+            if datapath.id == flow.get('dpid', 0):
+                ofctl_v1_3.mod_flow_entry(datapath, flow, ofproto.OFPFC_ADD)
+
     def add_flow(self, datapath, priority, match, actions, buffer_id=None):
         ofproto = datapath.ofproto
         parser = datapath.ofproto_parser


Thanks,
Iwase


On 2017年01月24日 20:58, raghu rathode wrote:
> Dear Sir/Madam,
> 
> I would like to know, how to pass text file as an argument to Ryu 
> application. Which contains a set of rules to install on OpenFlow switches.
> 
> For Example:
> 
> Switch 00-00-00-00-00-01: 
> dl_type=0x0800, nw_src=10.1.0.1/16 <http://10.1.0.1/16>, nw_dst=10.2.0.1/16 
> <http://10.2.0.1/16>, in_port=4, actions=mod_dl_src:00:00:12:00:01:03, 
> mod_dl_dst:00:00:00:00:00:02, output:3
> dl_type=0x0800, dl_src=00:00:00:00:00:02, dl_dst=00:00:12:00:01:03, 
> in_port=3, nw_src=10.1.0.1/16 <http://10.1.0.1/16>, nw_dst=10.2.0.1/16 
> <http://10.2.0.1/16>, actions=mod_dl_src:00:00:12:00:01:02, 
> mod_dl_dst:00:00:12:00:04:01, output:2
> dl_type=0x0800, dl_src=00:00:12:00:02:01, dl_dst=00:00:12:00:01:01, 
> in_port=1, nw_src=10.3.0.1/16 <http://10.3.0.1/16>, nw_dst=10.4.0.1/16 
> <http://10.4.0.1/16>, actions=mod_dl_src:00:00:12:
> 
> 
> -- 
> Thanks and Regards
> Hari Raghavendar Rao Bandari
> App 10,
> Karolinenweg 20,
> 37075 Goettingen,
> Germany.
> 
> 
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> 
> 
> 
> _______________________________________________
> Ryu-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/ryu-devel
> 

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to