Hi raghu, Sorry, I could not see your code expectedly, because there are some invalid indentations.
On 2017年01月28日 00:21, raghu rathode wrote: > Dear Iwase, > > Thank you for the above information. I attached the file to my email and can > you point out where I am doing wrong? I am doing wrong? > > 1. I am facing an error: > 2. I would like to call the function "Configurerules" after a certain time > period? How can I implement? > > L2learningswitch: Exception occurred during handler processing. Backtrace > from offending handler [switch_features_handler] servicing event > [EventOFPSwitchFeatures] follows. > > Traceback (most recent call last): > > File "/usr/local/lib/python2.7/dist-packages/ryu/base/app_manager.py", line > 290, in _event_loop > > handler(ev) > > File "/usr/local/lib/python2.7/dist-packages/ryu/app/Simple_l2Ryu.py", line > 42, in switch_features_handler > > self.configurerules(ev, lruleset=self.CONF.ruleset) > > File "/usr/local/lib/python2.7/dist-packages/ryu/app/Simple_l2Ryu.py", line > 127,in configurerules > > match = parser.OFPMatch(eth_type=eth_type, eth_src=eth_src1, > eth_dst=eth_dst1, ipv4_src=ipv4_src1, ipv4_dst=ipv4_dst1, in_port=in_port1, > vlan_vid=(0x1000)) > > NameError: global name 'eth_src1' is not defined. The above message shows just the value named 'eth_src1' cannot be accessed at line 127. I recommend you to fix the indentation up and try some inspection tools (e.g. pylint or PyCharm IDE, Eclipse IDE, ...). It might be very helpful for your happy coding. Thanks, Iwase > > On 27 January 2017 at 03:21, Iwase Yusuke <[email protected] > <mailto:[email protected]>> wrote: > > FYI, for the syntax of JSON is similar to the input of ofctl_rest. > > http://ryu.readthedocs.io/en/latest/app/ofctl_rest.html#modify-all-matching-flow-entries > > <http://ryu.readthedocs.io/en/latest/app/ofctl_rest.html#modify-all-matching-flow-entries> > > > On 2017年01月27日 11:20, Iwase Yusuke wrote: > > 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 <http://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> > <http://10.1.0.1/16>, nw_dst=10.2.0.1/16 <http://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> <http://10.1.0.1/16>, > nw_dst=10.2.0.1/16 <http://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> <http://10.3.0.1/16>, > nw_dst=10.4.0.1/16 <http://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] > <mailto:[email protected]> > >> https://lists.sourceforge.net/lists/listinfo/ryu-devel > <https://lists.sourceforge.net/lists/listinfo/ryu-devel> > >> > > > > > -- > 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
