Better error messages when switch setup() fails.

This commit is contained in:
Bob Lantz
2010-08-18 10:58:24 -07:00
parent a77e7a029e
commit f9654e5654
2 changed files with 17 additions and 11 deletions
+9 -7
View File
@@ -47,19 +47,21 @@ def moduleDeps( subtract=None, add=None ):
info( '*** Loading ' + mod + '\n' ) info( '*** Loading ' + mod + '\n' )
modprobeOutput = modprobe( mod ) modprobeOutput = modprobe( mod )
if modprobeOutput: if modprobeOutput:
error( 'Error inserting ' + mod + '- is it installed?\n' + error( 'Error inserting ' + mod +
'Error was: "%s"\n' % modprobeOutput ) ' - is it installed and available via modprobe?\n' +
'Error was: "%s"\n' % modprobeOutput )
if mod not in lsmod(): if mod not in lsmod():
error( 'Failed to insert ' + mod + '\n' ) error( 'Failed to insert ' + mod + ' - quitting.\n' )
exit( 1 ) exit( 1 )
else: else:
debug( '*** ' + mod + ' already loaded\n' ) debug( '*** ' + mod + ' already loaded\n' )
def pathCheck( *args ): def pathCheck( *args, **kwargs ):
"Make sure each program in *args can be found in $PATH." "Make sure each program in *args can be found in $PATH."
moduleName = kwargs.get( 'moduleName', 'it' )
for arg in args: for arg in args:
if not quietRun( 'which ' + arg ): if not quietRun( 'which ' + arg ):
error( 'Cannot find required executable %s -' error( 'Cannot find required executable %s.\n' % arg +
' is it installed somewhere in your $PATH?\n(%s)\n' % 'Please make sure that %s is installed ' % moduleName +
( arg, environ[ 'PATH' ] ) ) 'and available in your $PATH:\n(%s)\n' % environ[ 'PATH' ] )
exit( 1 ) exit( 1 )
+8 -4
View File
@@ -465,7 +465,8 @@ 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' ) pathCheck( 'ofdatapath', 'ofprotocol',
moduleName='the OpenFlow reference user switch (openflow.org)' )
@staticmethod @staticmethod
def setup(): def setup():
@@ -521,8 +522,10 @@ class KernelSwitch( Switch ):
@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."
pathCheck( 'ofprotocol',
moduleName='the OpenFlow reference kernel switch'
' (openflow.org) (NOTE: not available in OpenFlow 1.0!)' )
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."
@@ -575,8 +578,9 @@ class OVSKernelSwitch( Switch ):
@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( subtract = OF_KMOD, add = OVS_KMOD ) pathCheck( 'ovs-dpctl', 'ovs-openflowd',
pathCheck( 'ovs-dpctl', 'ovs-openflowd' ) moduleName='Open vSwitch (openvswitch.org)')
moduleDeps( subtract=OF_KMOD, add=OVS_KMOD )
def start( self, controllers ): def start( self, controllers ):
"Start up kernel datapath." "Start up kernel datapath."