Hi, Deni

Of course, you can modify codes as you want, including bridge.py.

And, about the exception you got, the response from OVS may be delayed due to network delay.
Please try to extend the timeout, e.g. 2, 3, and so on.

Thanks,
Fujimoto

On 2017年05月03日 23:49, Deni Toruan wrote:
Hi Fujimoto san,

Thank you for the information.
To add the port, I didn't use "run_command()" in bridge.py. To be honest, I didn,t know yet how to use it :). However, to add the port, I was trying to add function (add_port) in bridge.py. The function is very similar to the del_port function. It was working, the port was added in remote OVS. Btw, I was wondering whether it is OK to do add-port, add bridge, del-bridge through this way? (by adding function in library bridge.py).

My second question, when I ran the app, I got this message. Would you mind to let me know whats is the problem?

-------------------------------------------------
Registered VCS backend: git
Registered VCS backend: hg
Registered VCS backend: svn
Registered VCS backend: bzr
loading app ryu/app/test_simple_switch.py
loading app ryu.controller.ofp_handler
instantiating app ryu/app/test_simple_switch.py of SimpleSwitch
instantiating app ryu.controller.ofp_handler of OFPHandler
packet in 8796760143511 00:23:20:99:9b:bc ff:ff:ff:ff:ff:ff 65534
SimpleSwitch: Exception occurred during handler processing. Backtrace from offending handler [switch_features_handler] servicing event [EventOFPSwitchFeatures] follows.
Traceback (most recent call last):
File "/home/jedi/Downloads/ryu/ryu/base/app_manager.py", line 290, in _event_loop
    handler(ev)
File "/home/jedi/Downloads/ryu/ryu/app/test_simple_switch.py", line 44, in switch_features_handler
    self.add_port('eth1', datapath)
File "/home/jedi/Downloads/ryu/ryu/app/test_simple_switch.py", line 59, in add_port
    ovs_bridge.init()
  File "/home/jedi/Downloads/ryu/ryu/lib/ovs/bridge.py", line 109, in init
    self.br_name = self._get_bridge_name()
File "/home/jedi/Downloads/ryu/ryu/lib/ovs/bridge.py", line 117, in _get_bridge_name
    self.run_command([command])
File "/home/jedi/Downloads/ryu/ryu/lib/ovs/bridge.py", line 105, in run_command
    self.vsctl.run_command(commands, self.timeout, self.exception)
File "/home/jedi/Downloads/ryu/ryu/lib/ovs/vsctl.py", line 1207, in run_command
    self._run_command(commands)
File "/home/jedi/Downloads/ryu/ryu/lib/ovs/vsctl.py", line 1200, in _run_command
    self._do_main(commands)
File "/home/jedi/Downloads/ryu/ryu/lib/ovs/vsctl.py", line 1097, in _do_main
    self._init_schema_helper()
File "/home/jedi/Downloads/ryu/ryu/lib/ovs/vsctl.py", line 984, in _init_schema_helper
    vswitch_idl.OVSREC_DB_NAME)
File "/home/jedi/Downloads/ryu/ryu/lib/ovs/vsctl.py", line 967, in _rpc_get_schema_json
    stream.Stream.open(self.remote))
File "/home/jedi/.local/lib/python2.7/site-packages/ovs/stream.py", line 222, in open_block
    poller.block()
File "/home/jedi/.local/lib/python2.7/site-packages/ovs/poller.py", line 214, in block
    events = self.poll.poll(self.timeout)
File "/home/jedi/.local/lib/python2.7/site-packages/ovs/poller.py", line 123, in poll
    timeout)
File "/home/jedi/.local/lib/python2.7/site-packages/eventlet/green/select.py", line 80, in select
    return hub.switch()
File "/home/jedi/.local/lib/python2.7/site-packages/eventlet/hubs/hub.py", line 295, in switch
    return self.greenlet.switch()
Timeout: 1 second
packet in 8796760143511 08:00:27:90:4c:26 08:00:27:c3:76:97 2
packet in 8796760143511 08:00:27:c3:76:97 08:00:27:90:4c:26 65534
packet in 8796760143511 08:00:27:90:4c:26 08:00:27:c3:76:97 2
packet in 8796764093239 00:23:20:c0:9e:76 ff:ff:ff:ff:ff:ff 65534


-----------------------------------

Thank you.

regards,

deni toruan










On Fri, Apr 28, 2017 at 12:56 AM, Fujimoto Satoshi <satoshi.fujimo...@gmail.com <mailto:satoshi.fujimo...@gmail.com>> wrote:

    Hi, Deni

    If APIs in bridge.py are not enough to satisfy your demand, you
    can use "run_command()" in bridge.py.
    "run_command()" calls functions in vsctl.py.
    I think you will be able to add/delete bridges by using this
    function. :)
    https://github.com/osrg/ryu/blob/master/ryu/lib/ovs/bridge.py#L104
    <https://github.com/osrg/ryu/blob/master/ryu/lib/ovs/bridge.py#L104>

    Thanks,
    Fujimoto


    On 2017年04月28日 00:51, Deni Toruan wrote:
    Hi Fujimoto san,

    Thank you very much for the code. I have ran it and it was
    working. Thanks, you have saved my days.
    Btw, I have another questions related to this issue. I do hope
    you will not mind :)

    a. When I am trying to add port and add/delete bridge, I did not
    find any function related to those commands in library bridge.py.
    Is it mean I can't add port using library bridge.py?

    b. I saw in library vsctl.py, there is some commands related to
    add port and add/delete bridge. Is it mean we must use this
    library to add the port?

    Thank you for your help.

    regards,

    deni

    On Wed, Apr 26, 2017 at 1:46 AM, Fujimoto Satoshi
    <satoshi.fujimo...@gmail.com
    <mailto:satoshi.fujimo...@gmail.com>> wrote:

        Hi, Deni

        In your application, I think there is no one which calls
        "ovs_bridge()".
        It is better to implement your code in Event Handlers.
        For example, Features Reply Handler will be called when your
        application gets the Features Reply message
        (≒ when the connection to the OVS is established).
        For details, you can read the Ryu Book and Ryu API Reference:
        https://osrg.github.io/ryu-book/en/html/switching_hub.html#event-handler
        
<https://osrg.github.io/ryu-book/en/html/switching_hub.html#event-handler>
        http://ryu.readthedocs.io/en/latest/ryu_app_api.html#event-classes
        <http://ryu.readthedocs.io/en/latest/ryu_app_api.html#event-classes>

        And you have to specify the port with string, like this:
        ovs_bridge.del_port('eth1')


        Now I made a simple code by modifying simple_switch.py and
        attached it to this mail.
        Please check and try it! :)

        Thanks,
        Fujimoto


        On 2017年04月25日 20:04, Deni Toruan wrote:
        Dear Fujimoto san, thank you very much for your information.

        I have tried to put the code to the file: simple_switch.py
        (as in attachment), and try to run it in Ryu controller
        machine.
        The code is running, how ever, when I checked in the OVS
        machine (VM IP: 10.0.0.5), there is no changes. The port
        eth1 is still there.
        Is there anything wrong in putting the code to file
        simple_switch.py?
        thank you.

        regards,

        deni toruan


        On Tue, Apr 25, 2017 at 1:40 AM, Fujimoto Satoshi
        <satoshi.fujimo...@gmail.com
        <mailto:satoshi.fujimo...@gmail.com>> wrote:

            Hi, Deni

            You can make a connection by instantiating OVSBridge:
            ovs_bridge = OVSBridge(None, datapath.id
            <http://datapath.id>, 'tcp:127.0.0.1:6632
            <http://127.0.0.1:6632>', timeout=1)

            And by the following code, for example, you can delete a
            port:
            ovs_bridge = OVSBridge(None, datapath.id
            <http://datapath.id>, 'tcp:127.0.0.1:6632
            <http://127.0.0.1:6632>', timeout=1)
            ovs_bridge.init()
                    ports = ovs_bridge.get_port_name_list()
            ovs_bridge.del_port(ports[0])

            OVSBridge provides some other APIs.
            For details, please check this code:
            https://github.com/osrg/ryu/blob/master/ryu/lib/ovs/bridge.py
            <https://github.com/osrg/ryu/blob/master/ryu/lib/ovs/bridge.py>


            Thanks,
            Fujimoto


            On 2017年04月24日 16:18, Deni Toruan wrote:
            Hi Satoshi san, thank you for your kind reply.


            On Mon, Apr 24, 2017 at 5:07 AM, Fujimoto Satoshi
            <satoshi.fujimo...@gmail.com
            <mailto:satoshi.fujimo...@gmail.com>> wrote:

                Hi, Deni

                The problem may be caused by that you use
                "ovsdb_event" and "ovs_vsctl" at the same time.
                If you don't need to monitor the status of OVS, you
                should not use "ovsdb_event".


            Is it mean I should not use initiation :
            "ovsdb_event.EventNewOVSDBConnection)"? So how I will
            make (realize) a connection between controller and
            OVSDB Server?


                Also, you can use "OVSBridge" to control your OVS.
                "OVSBridge" calls "ovs_vsctl.VSCtl()" in
                __init__(), and wraps some operations including
                adding a port.


            Thank you for your suggestion.Would you mind to give me
            some clue for using the "OVSBridge" and for calling the
            "ovs_vsctl.VSCtl()"?

                Thanks,
                Fujimoto



            Thank you.

            Regards, Deni


                On 2017年04月23日 19:23, Deni Toruan wrote:

                Dear all,

                Currently, I am trying to make a connection
                between Ryu Controller and OVS, and trying to
                modify OVS from controller (add bridge, add port,
                delete port, etc) dynamically.

                Currently, the OVS and Ryu controller can be
                connected. They are running in different VM.
                However, when I try to run my simple app, it
                didn't work. In the code, I am trying to delete
                one port that I have already set up from OVS
                terminal. I always got this in controller:

                ----------------------------
                d5f55957-26e1-4e24-8b9c-bb15210aa220
                New OVSDB connection from system id
                d5f55957-26e1-4e24-8b9c-bb15210aa220
                New connection from 10.0.0.11:47985
                <http://10.0.0.11:47985>
                instantiating app None of RemoteOvsdb
                BRICK RemoteOvsdb-d5f55957-26e1-4e24-8b9c-bb15210aa220
                EVENT OVSDB->SimpleSwitch EventNewOVSDBConnection

                
EventNewOVSDBConnection<system_id=d5f55957-26e1-4e24-8b9c-bb15210aa220>

                d5f55957-26e1-4e24-8b9c-bb15210aa220
                New OVSDB connection from system id
                d5f55957-26e1-4e24-8b9c-bb15210aa220
                instantiating app None of RemoteOvsdb
                BRICK RemoteOvsdb-d5f55957-26e1-4e24-8b9c-bb15210aa220
                EVENT OVSDB->SimpleSwitch EventNewOVSDBConnection

                
EventNewOVSDBConnection<system_id=d5f55957-26e1-4e24-8b9c-bb15210aa220>

                d5f55957-26e1-4e24-8b9c-bb15210aa220
                New OVSDB connection from system id
                d5f55957-26e1-4e24-8b9c-bb15210aa220
                New connection from 10.0.0.11:47986
                <http://10.0.0.11:47986>
                ---------------------------------

                For your information, I customize the code and I
                put it in attachment. Please give some hints for
                doing this, especially with the code. Thank you.

                Best regards,

                Deni Lumbantoruan


                
------------------------------------------------------------------------------
                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
                Ryu-devel@lists.sourceforge.net
                <mailto:Ryu-devel@lists.sourceforge.net>
                https://lists.sourceforge.net/lists/listinfo/ryu-devel
                <https://lists.sourceforge.net/lists/listinfo/ryu-devel>

-- Deni Toruan
            Dosen IT Del
            Sitoluama

            
------------------------------------------------------------------------------
            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
            Ryu-devel@lists.sourceforge.net
            <mailto:Ryu-devel@lists.sourceforge.net>
            https://lists.sourceforge.net/lists/listinfo/ryu-devel
            <https://lists.sourceforge.net/lists/listinfo/ryu-devel>

-- Deni Toruan
        Dosen IT Del
        Sitoluama

        
------------------------------------------------------------------------------
        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
        Ryu-devel@lists.sourceforge.net
        <mailto:Ryu-devel@lists.sourceforge.net>
        https://lists.sourceforge.net/lists/listinfo/ryu-devel
        <https://lists.sourceforge.net/lists/listinfo/ryu-devel>

-- Deni Toruan
    Dosen IT Del
    Sitoluama

    
------------------------------------------------------------------------------
    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
    Ryu-devel@lists.sourceforge.net
    <mailto:Ryu-devel@lists.sourceforge.net>
    https://lists.sourceforge.net/lists/listinfo/ryu-devel
    <https://lists.sourceforge.net/lists/listinfo/ryu-devel>

--
Deni Toruan
Dosen IT Del
Sitoluama

------------------------------------------------------------------------------
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
Ryu-devel@lists.sourceforge.net
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
Ryu-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to