diff --git a/bin/mn b/bin/mn index 0e9cded..71c76ec 100755 --- a/bin/mn +++ b/bin/mn @@ -26,7 +26,7 @@ from mininet.log import lg, LEVELS, info, debug, error from mininet.net import Mininet, MininetWithControlNet, VERSION from mininet.node import ( Host, CPULimitedHost, Controller, OVSController, NOX, RemoteController, UserSwitch, OVSKernelSwitch, - OVSLegacyKernelSwitch ) + OVSLegacyKernelSwitch, IVSSwitch ) from mininet.link import Link, TCLink from mininet.topo import SingleSwitchTopo, LinearTopo, SingleSwitchReversedTopo from mininet.topolib import TreeTopo @@ -45,7 +45,8 @@ TOPOS = { 'minimal': lambda: SingleSwitchTopo( k=2 ), SWITCHDEF = 'ovsk' SWITCHES = { 'user': UserSwitch, 'ovsk': OVSKernelSwitch, - 'ovsl': OVSLegacyKernelSwitch } + 'ovsl': OVSLegacyKernelSwitch, + 'ivs': IVSSwitch } HOSTDEF = 'proc' HOSTS = { 'proc': Host, diff --git a/mininet/clean.py b/mininet/clean.py index c5ef1ab..5162bf3 100755 --- a/mininet/clean.py +++ b/mininet/clean.py @@ -11,6 +11,7 @@ nothing irreplaceable! """ from subprocess import Popen, PIPE +import time from mininet.log import info from mininet.term import cleanUpScreens @@ -27,10 +28,13 @@ def cleanup(): info("*** Removing excess controllers/ofprotocols/ofdatapaths/pings/noxes" "\n") zombies = 'controller ofprotocol ofdatapath ping nox_core lt-nox_core ' - zombies += 'ovs-openflowd ovs-controller udpbwtest mnexec' + zombies += 'ovs-openflowd ovs-controller udpbwtest mnexec ivs' # Note: real zombie processes can't actually be killed, since they # are already (un)dead. Then again, # you can't connect to them either, so they're mostly harmless. + # Send SIGTERM first to give processes a chance to shutdown cleanly. + sh( 'killall ' + zombies + ' 2> /dev/null' ) + time.sleep(1) sh( 'killall -9 ' + zombies + ' 2> /dev/null' ) # And kill off sudo mnexec @@ -49,7 +53,7 @@ def cleanup(): sh( 'dpctl deldp ' + dp ) info( "*** Removing OVS datapaths" ) - dps = sh("ovs-vsctl list-br").split( '\n' ) + dps = sh("ovs-vsctl --timeout=1 list-br").split( '\n' ) for dp in dps: if dp: sh( 'ovs-vsctl del-br ' + dp ) diff --git a/mininet/node.py b/mininet/node.py index 639bae2..c51254d 100644 --- a/mininet/node.py +++ b/mininet/node.py @@ -1026,6 +1026,64 @@ class OVSSwitch( Switch ): OVSKernelSwitch = OVSSwitch +class IVSSwitch(Switch): + """IVS virtual switch""" + + def __init__( self, name, **kwargs ): + Switch.__init__( self, name, **kwargs ) + + @classmethod + def setup( cls ): + "Make sure IVS is installed" + pathCheck( 'ivs-ctl', 'ivs', + moduleName="Indigo Virtual Switch (projectfloodlight.org)" ) + out, err, exitcode = errRun( 'ivs-ctl show' ) + if exitcode: + error( out + err + + 'ivs-ctl exited with code %d\n' % exitcode + + '*** The openvswitch kernel module might ' + 'not be loaded. Try modprobe openvswitch.\n' ) + exit( 1 ) + + def start( self, controllers ): + "Start up a new IVS switch" + args = ['ivs'] + args.extend( ['--name', self.name] ) + args.extend( ['--dpid', self.dpid] ) + args.extend( ['--verbose'] ) + for intf in self.intfs.values(): + if not intf.IP(): + args.extend( ['-i', intf.name] ) + for c in controllers: + args.extend( ['-c', '%s:%d' % (c.IP(), c.port)] ) + if self.listenPort: + args.extend( ['--listen', '127.0.0.1:%i' % self.listenPort] ) + + logfile = '/tmp/ivs.%s.log' % self.name + + self.cmd( ' '.join(args) + ' >' + logfile + ' 2>&1 &2 + printf '\nUsage: %s [-abcdfhikmnprtvwx03]\n\n' $(basename $0) >&2 printf 'This install script attempts to install useful packages\n' >&2 printf 'for Mininet. It should (hopefully) work on Ubuntu 11.10+\n' >&2 @@ -653,21 +673,22 @@ function usage { printf -- ' -b: install controller (B)enchmark (oflops)\n' >&2 printf -- ' -c: (C)lean up after kernel install\n' >&2 printf -- ' -d: (D)elete some sensitive files from a VM image\n' >&2 - printf -- ' -f: install open(F)low\n' >&2 + printf -- ' -e: install Mininet d(E)veloper dependencies\n' >&2 + printf -- ' -f: install Open(F)low\n' >&2 printf -- ' -h: print this (H)elp message\n' >&2 + printf -- ' -i: install (I)ndigo Virtual Switch\n' >&2 printf -- ' -k: install new (K)ernel\n' >&2 printf -- ' -m: install Open vSwitch kernel (M)odule from source dir\n' >&2 - printf -- ' -n: install mini(N)et dependencies + core files\n' >&2 - printf -- ' -e: install mininet d(E)veloper dependencies\n' >&2 + printf -- ' -n: install Mini(N)et dependencies + core files\n' >&2 printf -- ' -p: install (P)OX OpenFlow Controller\n' >&2 printf -- ' -r: remove existing Open vSwitch packages\n' >&2 + printf -- ' -s : place dependency (S)ource/build trees in \n' >&2 printf -- ' -t: complete o(T)her Mininet VM setup tasks\n' >&2 - printf -- ' -v: install open (V)switch\n' >&2 - printf -- ' -w: install OpenFlow (w)ireshark dissector\n' >&2 + printf -- ' -v: install Open (V)switch\n' >&2 + printf -- ' -w: install OpenFlow (W)ireshark dissector\n' >&2 printf -- ' -x: install NO(X) Classic OpenFlow controller\n' >&2 printf -- ' -0: (default) -0[fx] installs OpenFlow 1.0 versions\n' >&2 printf -- ' -3: -3[fx] installs OpenFlow 1.3 versions\n' >&2 - printf -- ' -i < directory >: sets the (I)nstallation directory for Mininet dependencies\n' >&2 exit 2 } @@ -677,25 +698,29 @@ if [ $# -eq 0 ] then all else - while getopts 'abcdefhkmnprtvwx03i:' OPTION + while getopts 'abcdefhikmnprs:tvwx03' OPTION do case $OPTION in a) all;; b) cbench;; c) kernel_clean;; d) vm_clean;; + e) mn_dev;; f) case $OF_VERSION in 1.0) of;; 1.3) of13;; *) echo "Invalid OpenFlow version $OF_VERSION";; esac;; h) usage;; + i) ivs;; k) kernel;; m) modprobe;; n) mn_deps;; - e) mn_dev;; p) pox;; r) remove_ovs;; + s) mkdir -p $OPTARG; # ensure the directory is created + BUILD_DIR="$( cd -P "$OPTARG" && pwd )"; # get the full path + echo "Dependency installation directory: $BUILD_DIR";; t) vm_other;; v) ovs;; w) wireshark;; @@ -706,9 +731,6 @@ else esac;; 0) OF_VERSION=1.0;; 3) OF_VERSION=1.3;; - i) mkdir -p $OPTARG; # ensure the directory is created - BUILD_DIR="$( cd -P "$OPTARG" && pwd )"; # get the full path of the directory - echo "Dependency installation directory: $BUILD_DIR";; ?) usage;; esac done