Inhaltsverzeichnis

Ryu SDN-Controller auf MacOS X installieren

An diesem Artikel wird gearbeitet. Work in Progress to extend this article!

Voraussetzungen

Die Installation

Ich empfehle die Installation in folgenden Schritten.

virtualenv erstellen & aktivieren

Macbook:Python Benny$ virtualenv ryu-3.11
New python executable in ryu-3.11/bin/python
Installing setuptools, pip...done.
Macbook:Python Benny$ source ryu-3.11/bin/activate
(ryu-3.11)Macbook:Python Benny$ 

lxml zuerst installieren

Es ist wichtig das Kommando wie unten beschrieben einzugeben! lxml kompiliert sonst (zumindest bei mir) nicht!

(ryu-3.11)Macbook:Python Benny$ STATIC_DEPS=true pip install lxml
Downloading/unpacking lxml
  Downloading lxml-3.3.5.tar.gz (3.5MB): 3.5MB downloaded
  Running setup.py (path:/Users/Benny/Python/ryu-3.11/build/lxml/setup.py) egg_info for package lxml
  (... Jede Menge CLI-Kilometer ausgelassen ...)
Successfully installed lxml
Cleaning up...

Ryu installieren

(ryu-3.11)Macbook:Python Benny$ pip install ryu
Downloading/unpacking ryu
  Downloading ryu-3.12.tar.gz (1.1MB): 1.1MB downloaded
  Running setup.py (path:/Users/Benny/Python/ryu-3.11/build/ryu/setup.py) egg_info for package ryu
  (... Jede Menge CLI-Kilometer ausgelassen ...)
Successfully installed ryu eventlet msgpack-python netaddr oslo.config paramiko routes six webob greenlet argparse pycrypto ecdsa repoze.lru
Cleaning up...    

Hält man diese Reihenfolge nicht ein, dann schlägt a) die Installation von lxml fehl b) vergisst der Ryu Installer dann greenlet.

An dieser Stelle ist es sinnvoll sich die Beispiele von Ryu zu kopieren, siehe: Bei mir fehlen die Beispiele!

Ryu in Aktion!

(ryu-3.11)Macbook:ryu-3.11 Benny$ bin/ryu-manager --verbose ../ryu-git/ryu/app/simple_switch_13.py
loading app ../ryu-git/ryu/app/simple_switch_13.py
loading app ryu.controller.ofp_handler
instantiating app ryu.controller.ofp_handler of OFPHandler
instantiating app ../ryu-git/ryu/app/simple_switch_13.py of SimpleSwitch13
BRICK SimpleSwitch13
  CONSUMES EventOFPPacketIn
  CONSUMES EventOFPSwitchFeatures
BRICK ofp_event
  PROVIDES EventOFPPacketIn TO {'SimpleSwitch13': set(['main'])}
  PROVIDES EventOFPSwitchFeatures TO {'SimpleSwitch13': set(['config'])}
  CONSUMES EventOFPPortDescStatsReply
  CONSUMES EventOFPEchoRequest
  CONSUMES EventOFPSwitchFeatures
  CONSUMES EventOFPErrorMsg
  CONSUMES EventOFPHello

OmniSwitch in Ryu registrieren

Ich hab Urlaub! Danach werde ich diese Anleitung sicherlich noch erweitern .. :)

OmniSwitch 6900 Konfiguration

-> show configuration snapshot openflow 
! OPENFLOW:
openflow logical-switch OFSwitch vlan 2
openflow logical-switch OFSwitch controller 192.168.10.100:6633
openflow logical-switch OFSwitch interfaces port 1/1-20

Ausgaben von Ryu

(ryu)Macbook:ryu Benny$ ryu-manager --verbose ../ryu-git/ryu/app/simple_switch_13.py 
loading app ../ryu-git/ryu/app/simple_switch_13.py
loading app ryu.controller.ofp_handler
instantiating app ryu.controller.ofp_handler of OFPHandler
instantiating app ../ryu-git/ryu/app/simple_switch_13.py of SimpleSwitch13
BRICK SimpleSwitch13
  CONSUMES EventOFPSwitchFeatures
  CONSUMES EventOFPPacketIn
BRICK ofp_event
  PROVIDES EventOFPSwitchFeatures TO {'SimpleSwitch13': set(['config'])}
  PROVIDES EventOFPPacketIn TO {'SimpleSwitch13': set(['main'])}
  CONSUMES EventOFPSwitchFeatures
  CONSUMES EventOFPEchoRequest
  CONSUMES EventOFPHello
  CONSUMES EventOFPErrorMsg
  CONSUMES EventOFPPortDescStatsReply
connected socket:<eventlet.greenio.GreenSocket object at 0x103763250> address:('192.168.10.2', 36544)
hello ev <ryu.controller.ofp_event.EventOFPHello object at 0x103763610>
move onto config mode
EVENT ofp_event->SimpleSwitch13 EventOFPSwitchFeatures
switch features ev version: 0x4 msg_type 0x6 xid 0x84975d27 OFPSwitchFeatures(auxiliary_id=0,capabilities=79,datapath_id=537554651826897,n_buffers=256,n_tables=3)
move onto main mode

Typische Fehlermeldungen bei der Installation

lxml: xmlversion.h file not found

An diesem Fehler ist mein erster Installationsversuch mit pip install ryu auch gescheitert. Nach einiger Suche habe ich in den Untiefen von „stackoverflow“ den Tipp im Folgenden gefunden.

(ryu)Macbook:ryu Benny$ pip install ryu
Downloading/unpacking ryu
  Downloading ryu-3.11.tar.gz (1.3MB): 1.3MB downloaded
  Running setup.py (path:/Users/Benny/Python/ryu/build/ryu/setup.py) egg_info for package ryu
    
    Installed /Users/Benny/Python/ryu/build/ryu/pbr-0.10.0-py2.7.egg
    [pbr] Processing SOURCES.txt
    warning: LocalManifestMaker: standard file '-c' not found

In file included from src/lxml/lxml.etree.c:346:

/Users/Benny/Python/ryu/build/lxml/src/lxml/includes/etree_defs.h:9:10: fatal error: 'libxml/xmlversion.h' file not found

#include "libxml/xmlversion.h"

Lösung:

(ryu)Macbook:ryu Benny$ STATIC_DEPS=true pip install lxml

pkg_resources.DistributionNotFound: greenlet>=0.3

Nach der manuellen Korrektur mit lxml, scheint das pip install ryu Kommando greenlet irgendwie vergessen zu haben.

(ryu-3.11)Macbook:ryu-3.11 Benny$ bin/ryu-manager ../ryu-git/ryu/app/simple_switch_13.py
Traceback (most recent call last):
  File "bin/ryu-manager", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/Users/Benny/Python/ryu-3.11/lib/python2.7/site-packages/pkg_resources.py", line 2697, in <module>
    working_set.require(__requires__)
  File "/Users/Benny/Python/ryu-3.11/lib/python2.7/site-packages/pkg_resources.py", line 669, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/Users/Benny/Python/ryu-3.11/lib/python2.7/site-packages/pkg_resources.py", line 572, in resolve
    raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: greenlet>=0.3

Lösung:

(ryu-3.11)Macbook:ryu-3.11 Benny$ pip install greenlet

Bei mir fehlen alle Beispiele bzw. das /app Verzeichnis fehlt!

Die Beispiele werden von pip nicht mitinstalliert. Dies kann aber sehr leicht nachgeholt werden.

Lösung:

Macbook:Python Benny$ git clone https://github.com/osrg/ryu.git ryu-git
Cloning into 'ryu-git'...
remote: Counting objects: 14808, done.
remote: Compressing objects: 100% (134/134), done.
remote: Total 14808 (delta 80), reused 0 (delta 0)
Receiving objects: 100% (14808/14808), 18.27 MiB | 676.00 KiB/s, done.
Resolving deltas: 100% (10855/10855), done.
Checking connectivity... done.