Skip to content
Snippets Groups Projects
Commit f9654e56 authored by Bob Lantz's avatar Bob Lantz
Browse files

Better error messages when switch setup() fails.

parent a77e7a02
No related branches found
No related tags found
No related merge requests found
......@@ -47,19 +47,21 @@ def moduleDeps( subtract=None, add=None ):
info( '*** Loading ' + mod + '\n' )
modprobeOutput = modprobe( mod )
if modprobeOutput:
error( 'Error inserting ' + mod + '- is it installed?\n' +
'Error was: "%s"\n' % modprobeOutput )
error( 'Error inserting ' + mod +
' - is it installed and available via modprobe?\n' +
'Error was: "%s"\n' % modprobeOutput )
if mod not in lsmod():
error( 'Failed to insert ' + mod + '\n' )
error( 'Failed to insert ' + mod + ' - quitting.\n' )
exit( 1 )
else:
debug( '*** ' + mod + ' already loaded\n' )
def pathCheck( *args ):
def pathCheck( *args, **kwargs ):
"Make sure each program in *args can be found in $PATH."
moduleName = kwargs.get( 'moduleName', 'it' )
for arg in args:
if not quietRun( 'which ' + arg ):
error( 'Cannot find required executable %s -'
' is it installed somewhere in your $PATH?\n(%s)\n' %
( arg, environ[ 'PATH' ] ) )
error( 'Cannot find required executable %s.\n' % arg +
'Please make sure that %s is installed ' % moduleName +
'and available in your $PATH:\n(%s)\n' % environ[ 'PATH' ] )
exit( 1 )
......@@ -465,7 +465,8 @@ def __init__( self, name, **kwargs ):
"""Init.
name: name for the switch"""
Switch.__init__( self, name, **kwargs )
pathCheck( 'ofdatapath', 'ofprotocol' )
pathCheck( 'ofdatapath', 'ofprotocol',
moduleName='the OpenFlow reference user switch (openflow.org)' )
@staticmethod
def setup():
......@@ -521,8 +522,10 @@ def __init__( self, name, dp=None, **kwargs ):
@staticmethod
def setup():
"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 )
pathCheck( 'ofprotocol' )
def start( self, controllers ):
"Start up reference kernel datapath."
......@@ -575,8 +578,9 @@ def __init__( self, name, dp=None, **kwargs ):
@staticmethod
def setup():
"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 ):
"Start up kernel datapath."
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment