Added additional sanity checks for when OF/OVS isn't installed.
This commit is contained in:
+8
-4
@@ -50,7 +50,7 @@ from time import sleep
|
|||||||
|
|
||||||
from mininet.log import info, error, debug
|
from mininet.log import info, error, debug
|
||||||
from mininet.util import quietRun, makeIntfPair, moveIntf, isShellBuiltin
|
from mininet.util import quietRun, makeIntfPair, moveIntf, isShellBuiltin
|
||||||
from mininet.moduledeps import moduleDeps, OVS_KMOD, OF_KMOD, TUN
|
from mininet.moduledeps import moduleDeps, pathCheck, OVS_KMOD, OF_KMOD, TUN
|
||||||
|
|
||||||
SWITCH_PORT_BASE = 1 # For OF > 0.9, switch ports start at 1 rather than zero
|
SWITCH_PORT_BASE = 1 # For OF > 0.9, switch ports start at 1 rather than zero
|
||||||
|
|
||||||
@@ -455,11 +455,12 @@ class UserSwitch( Switch ):
|
|||||||
"""Init.
|
"""Init.
|
||||||
name: name for the switch"""
|
name: name for the switch"""
|
||||||
Switch.__init__( self, name, **kwargs )
|
Switch.__init__( self, name, **kwargs )
|
||||||
|
pathCheck( 'ofdatapath', 'ofprotocol' )
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def setup():
|
def setup():
|
||||||
"Ensure any dependencies are loaded; if not, try to load them."
|
"Ensure any dependencies are loaded; if not, try to load them."
|
||||||
moduleDeps( add = TUN )
|
moduleDeps( add=TUN )
|
||||||
|
|
||||||
def start( self, controllers ):
|
def start( self, controllers ):
|
||||||
"""Start OpenFlow reference user datapath.
|
"""Start OpenFlow reference user datapath.
|
||||||
@@ -511,6 +512,7 @@ class KernelSwitch( Switch ):
|
|||||||
def setup():
|
def setup():
|
||||||
"Ensure any dependencies are loaded; if not, try to load them."
|
"Ensure any dependencies are loaded; if not, try to load them."
|
||||||
moduleDeps( subtract = OVS_KMOD, add = OF_KMOD )
|
moduleDeps( subtract = OVS_KMOD, add = OF_KMOD )
|
||||||
|
pathCheck( 'ofprotocol' )
|
||||||
|
|
||||||
def start( self, controllers ):
|
def start( self, controllers ):
|
||||||
"Start up reference kernel datapath."
|
"Start up reference kernel datapath."
|
||||||
@@ -523,7 +525,7 @@ class KernelSwitch( Switch ):
|
|||||||
if self.defaultMAC:
|
if self.defaultMAC:
|
||||||
self.cmd( 'ifconfig', self.intf, 'hw', 'ether', self.defaultMAC )
|
self.cmd( 'ifconfig', self.intf, 'hw', 'ether', self.defaultMAC )
|
||||||
ports = sorted( self.ports.values() )
|
ports = sorted( self.ports.values() )
|
||||||
if len( ports ) != ports[ -1 ] + 1:
|
if len( ports ) != ports[ -1 ] + 1 - self.portBase:
|
||||||
raise Exception( 'only contiguous, zero-indexed port ranges'
|
raise Exception( 'only contiguous, zero-indexed port ranges'
|
||||||
'supported: %s' % ports )
|
'supported: %s' % ports )
|
||||||
intfs = [ self.intfs[ port ] for port in ports ]
|
intfs = [ self.intfs[ port ] for port in ports ]
|
||||||
@@ -564,6 +566,7 @@ class OVSKernelSwitch( Switch ):
|
|||||||
def setup():
|
def setup():
|
||||||
"Ensure any dependencies are loaded; if not, try to load them."
|
"Ensure any dependencies are loaded; if not, try to load them."
|
||||||
moduleDeps( subtract = OF_KMOD, add = OVS_KMOD )
|
moduleDeps( subtract = OF_KMOD, add = OVS_KMOD )
|
||||||
|
pathCheck( 'ovs-dpctl', 'ovs-openflowd' )
|
||||||
|
|
||||||
def start( self, controllers ):
|
def start( self, controllers ):
|
||||||
"Start up kernel datapath."
|
"Start up kernel datapath."
|
||||||
@@ -580,7 +583,7 @@ class OVSKernelSwitch( Switch ):
|
|||||||
mac_str = ' --datapath-id=0000' + \
|
mac_str = ' --datapath-id=0000' + \
|
||||||
''.join( self.defaultMAC.split( ':' ) ) + ' '
|
''.join( self.defaultMAC.split( ':' ) ) + ' '
|
||||||
ports = sorted( self.ports.values() )
|
ports = sorted( self.ports.values() )
|
||||||
if len( ports ) != ports[ -1 ]:
|
if len( ports ) != ports[ -1 ] + 1 - self.portBase:
|
||||||
raise Exception( 'only contiguous, one-indexed port ranges '
|
raise Exception( 'only contiguous, one-indexed port ranges '
|
||||||
'supported: %s' % self.intfs )
|
'supported: %s' % self.intfs )
|
||||||
intfs = [ self.intfs[ port ] for port in ports ]
|
intfs = [ self.intfs[ port ] for port in ports ]
|
||||||
@@ -617,6 +620,7 @@ class Controller( Node ):
|
|||||||
def start( self ):
|
def start( self ):
|
||||||
"""Start <controller> <args> on controller.
|
"""Start <controller> <args> on controller.
|
||||||
Log to /tmp/cN.log"""
|
Log to /tmp/cN.log"""
|
||||||
|
pathCheck( self.controller )
|
||||||
cout = '/tmp/' + self.name + '.log'
|
cout = '/tmp/' + self.name + '.log'
|
||||||
if self.cdir is not None:
|
if self.cdir is not None:
|
||||||
self.cmd( 'cd ' + self.cdir )
|
self.cmd( 'cd ' + self.cdir )
|
||||||
|
|||||||
Reference in New Issue
Block a user