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