Re: [Ryu-devel] Running a ryu app like a python file

2017-01-10 Thread Iwase Yusuke
Hi,

How about the following?

$ git diff
diff --git a/ryu/app/simple_switch_13.py b/ryu/app/simple_switch_13.py
index 3e7c598..34881e1 100644
--- a/ryu/app/simple_switch_13.py
+++ b/ryu/app/simple_switch_13.py
@@ -117,3 +117,8 @@ class SimpleSwitch13(app_manager.RyuApp):
 out = parser.OFPPacketOut(datapath=datapath, buffer_id=msg.buffer_id,
   in_port=in_port, actions=actions, data=data)
 datapath.send_msg(out)
+
+
+if __name__ == "__main__":
+from ryu.cmd.manager import main
+main(["ryu.app.simple_switch_13"])  # specify the path or module name of 
your application(s)


Thanks,
Iwase


On 2017年01月11日 12:02, Juan Francisco Guano wrote:
> Hey everybody
> 
> I wanna know if it is possible Running a ryu app like a python file, how I 
> coding this.
> For example normally run a ryu app like below:
> ryu-manager ryu-app.py
> 
> I wanna run the same app like below:
> python ryu-app.py
> 
> What lines I must add to python file to do this?
> 
> Any suggestiosn?
> 
> Regards.
> 
> 
> --
> Developer Access Program for Intel Xeon Phi Processors
> Access to Intel Xeon Phi processor-based developer platforms.
> With one year of Intel Parallel Studio XE.
> Training and support from Colfax.
> Order your platform today. http://sdm.link/xeonphi
> 
> 
> 
> ___
> Ryu-devel mailing list
> Ryu-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/ryu-devel
> 

--
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
___
Ryu-devel mailing list
Ryu-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ryu-devel


[Ryu-devel] Running a ryu app like a python file

2017-01-10 Thread Juan Francisco Guano
Hey everybody

I wanna know if it is possible Running a ryu app like a python file, how I
coding this.
For example normally run a ryu app like below:
ryu-manager ryu-app.py

I wanna run the same app like below:
python ryu-app.py

What lines I must add to python file to do this?

Any suggestiosn?

Regards.
--
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi___
Ryu-devel mailing list
Ryu-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ryu-devel


Re: [Ryu-devel] Regarding Missing links between switches----switches.

2017-01-10 Thread Iwase Yusuke
Hi,

On 2017年01月10日 05:41, raghu rathode wrote:
> Hi,
> 
> I am currently working on OpenFlow HP 5900. I have topology of 6 switches and 
> 6 hosts. Therefore, I build topology using GEANT Testbed Services. When using 
> RYU as OpenFlow Controller i am facing issue with the links in between 
> switch——switch i.e SW5—SW6 link is missing remaining other switches are 
> connected. How can I resolve below issue. when I run OpenDayLight controller 
> I get all switch links. But, I currently working on RYU controller. Kindly, 
> your help is very required.

Because I don't have HP switch, I tried with Mininet + OVS, and I could get
all links as expected.

e.g.)
$ sudo python topo_looped.py
...

$ ryu-manager --observe-links ryu/app/gui_topology/gui_topology.py
...


Which version of Ryu are you using?
Could you try it with the latest Ryu?

Thanks,
Iwase

> 
> Thanks
> Hari Raghavendar Rao
> 
> 
> 
> --
> Developer Access Program for Intel Xeon Phi Processors
> Access to Intel Xeon Phi processor-based developer platforms.
> With one year of Intel Parallel Studio XE.
> Training and support from Colfax.
> Order your platform today. http://sdm.link/xeonphi
> 
> 
> 
> ___
> Ryu-devel mailing list
> Ryu-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/ryu-devel
> 
from mininet.cli import CLI
from mininet.net import Mininet
from mininet.node import RemoteController
from mininet.log import setLogLevel


if '__main__' == __name__:
setLogLevel('info')

net = Mininet(controller=RemoteController)

c0 = net.addController('c0')

s1 = net.addSwitch('s1')
s2 = net.addSwitch('s2')
s3 = net.addSwitch('s3')
s4 = net.addSwitch('s4')
s5 = net.addSwitch('s5')
s6 = net.addSwitch('s6')

h1 = net.addHost('h1')
h2 = net.addHost('h2')
h3 = net.addHost('h3')
h4 = net.addHost('h4')
h5 = net.addHost('h5')
h6 = net.addHost('h6')

net.addLink(s1, h1)
net.addLink(s2, h2)
net.addLink(s3, h3)
net.addLink(s4, h4)
net.addLink(s5, h5)
net.addLink(s6, h6)

net.addLink(s1, s2)
net.addLink(s2, s3)
net.addLink(s3, s4)
net.addLink(s4, s5)
net.addLink(s5, s1)
net.addLink(s5, s6)

net.start()
CLI(net)
net.stop()
--
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi___
Ryu-devel mailing list
Ryu-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ryu-devel


Re: [Ryu-devel] How to modify "switch_enter" event on the OVS and read it correctly using RYU

2017-01-10 Thread Iwase Yusuke
Hi,


On 2017年01月08日 03:25, Garegin Grigoryan wrote:
> Good afternoon and Happy New Year!
> 
> I'm using RYU controller. When the OVS switch connects to the controller, the 
> controller gets a "switch enter" event message.
> 
> I'm handling it with this function
> 
> |@set_ev_cls(dpset.EventDP, dpset.DPSET_EV_DISPATCHER) def 
> _event_switch_enter_handler(self, ev): dp = ev.dp dpid = dp.id  
> ... |
> 
> Using this event I can get the switch ID (first two lines of the function). 
> But what if I want a switch to send some other parameters? How can I modify 
> the OVS switch event message and how can I read it on the controller?

"some other parameters" mean parameters (modules, classes, static definitions 
or else)
to send messages to switches, right?

You have already got "dp", which is an instance of Datapath, then you can send 
messages
like:
ofp = dp.ofproto
ofp_parser = dp.ofproto_parser
...
req = ofp_parser.OFPFlowMod(dp, ...)
...
dp.send_msg(req)

For more details, please refer to the Ryu Documentation.
  http://ryu.readthedocs.io/en/latest/ofproto_v1_3_ref.html
Note: "datapath" instance on this document is corresponding to "dp" instance in 
your code.

Thanks,
Iwase

> 
> Thanks a lot.
> 
> 
> 
> -- 
> Sincerely,
> Garegin Grigoryan
> 
> 
> --
> 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
> 

--
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
___
Ryu-devel mailing list
Ryu-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ryu-devel


Re: [Ryu-devel] dhcp server with ryu controller

2017-01-10 Thread Luis Zárate
Something like this dhcp rest responder.

The api is:

Set dhcp in a switch PUT /dhcp/add/{dpid}  params
'ipaddress': '192.168.1.1'
'netmask': '255.255.255.0'
'address': '0a:e4:1c:d1:3e:44'
'dns': '8.8.8.8'
'startip':'192.168.1.100'
'endip': '192.168.1.200'
Set static ip in a host PUT /dhcp/host/{dpid} params
'address': '00:00:00:d3:fc:57'
'ipaddress':  '192.168.1.2'
'hostname': 'huehuehue'
'dns': '8.8.8.8' * optional

This file is not complete (needs delete functions) but you will get so util.

2016-12-15 22:34 GMT-06:00 Munther Numan :

> Greeting ,
>
> Dear all,
>
>
>
> I just would like to ask you if I need to add dhcp server in my
> experiment, is any example code for it or there is already  code for dhcp
> server with Ryu controller?
>
> Best Regards
>
> Munther Numan
> Master Student
> Faculty of Engineering
> University Putra Malaysia
>
>
>
>
> 
> --
> 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
>
>


-- 
"La utopía sirve para caminar" Fernando Birri
# Copyright (C) 2013 Nippon Telegraph and Telephone Corporation.
# Copyright (C) 2013 YAMAMOTO Takashi 
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# a simple ICMP Echo Responder


import json

from ryu.app.wsgi import ControllerBase, WSGIApplication, route
from ryu.base import app_manager
from ryu.controller import ofp_event
from ryu.controller.handler import CONFIG_DISPATCHER, MAIN_DISPATCHER
from ryu.controller.handler import set_ev_cls
from ryu.lib import addrconv, dpid as dpid_lib
from ryu.lib.packet import dhcp
from ryu.lib.packet import ethernet
from ryu.lib.packet import ipv4
from ryu.lib.packet import packet
from ryu.lib.packet import udp
from ryu.ofproto import ofproto_v1_3
from webob import Response


class DHCPResponder(app_manager.RyuApp):
"""
use example
self.switches = {
'81474781969487': {
'ipaddress': '192.168.1.1',
'netmask': '255.255.255.0',
'address': '0a:e4:1c:d1:3e:44',
'dns': '8.8.8.8',
'hosts': {
'00:00:00:d3:fc:57': {
'hostname': 'huehuehue',
'dns': '8.8.8.8',
'ipaddress':  '192.168.1.2',
}
},
'available_address': [
'192.168.1.10',
'192.168.1.20'
]

}}
"""

OFP_VERSIONS = [ofproto_v1_3.OFP_VERSION]
_CONTEXTS = {'wsgi': WSGIApplication}

def __init__(self, *args, **kwargs):
super(DHCPResponder, self).__init__(*args, **kwargs)
self.acks = {}
self.switches = {}
wsgi = kwargs['wsgi']
wsgi.register(DHCPController,
  {'dhcp_server': self})

def get_server_info(self, datapath):
if datapath in self.switches:
ipaddress = addrconv.ipv4.text_to_bin(
self.switches[datapath]['ipaddress'])
netmask = addrconv.ipv4.text_to_bin(
self.switches[datapath]['netmask'])
address = str(self.switches[datapath]['address'])
return ipaddress, netmask, address, str(self.switches[datapath]['ipaddress'])
return None, None, None, None

def get_host_info(self, datapath, hostaddress):
ipaddress = hostname = dns = None
if datapath in self.switches:
if hostaddress in self.acks:
info = self.acks[hostaddress]
return str(info['ipaddress']), str(info['hostname']), info['dns']

if hostaddress in self.switches[datapath]['hosts']:
confhost = self.switches[datapath]['hosts'][hostaddress]
ipaddress = str(confhost['ipaddress'])
hostname = str(confhost['hostname'])
dns = addrconv.ipv4.text_to_bin(confhost['dns'])
if not ipaddress and self.switches[datapath]['available_address']:
ipaddress = str(
self.switches[datapath]['available_address'].pop())
num = ipaddress.split('.')[-1]
hostname =