Stability fixes for SR Tests and small fixes for running ONOS in docker

- move checkOptions to component driver
- use karafTimeout for SR tests
- Fix some docker options
- Make sure mn docker can resolve own hostname
- Fix config file ip format for DHCP relay app

Change-Id: I85e8c52384e0fb478462fa9bbaf0b31a599b632b
(cherry picked from commit 521ecde3f8d28288303ea11129faa0cfd86b9bcd)
diff --git a/TestON/tests/USECASE/SegmentRouting/SRBridging/dependencies/SRBridgingTest.py b/TestON/tests/USECASE/SegmentRouting/SRBridging/dependencies/SRBridgingTest.py
index 984ba6b..a617716 100644
--- a/TestON/tests/USECASE/SegmentRouting/SRBridging/dependencies/SRBridgingTest.py
+++ b/TestON/tests/USECASE/SegmentRouting/SRBridging/dependencies/SRBridgingTest.py
@@ -41,60 +41,64 @@
         main.switchType = "ovs"
 
     def runTest( self, main, test_idx, topology, onosNodes, description, vlan = [] ):
-        skipPackage = False
-        init = False
-        if not hasattr( main, 'apps' ):
-            init = True
-            run.initTest( main )
-        # Skip onos packaging if the clusrer size stays the same
-        if not init and onosNodes == main.Cluster.numCtrls:
-            skipPackage = True
+        try:
+            skipPackage = False
+            init = False
+            if not hasattr( main, 'apps' ):
+                init = True
+                run.initTest( main )
+            # Skip onos packaging if the clusrer size stays the same
+            if not init and onosNodes == main.Cluster.numCtrls:
+                skipPackage = True
 
-        main.case( '%s, with %s, %s switches and %d ONOS instance%s' %
-                   ( description, self.topo[ topology ][ 3 ], main.switchType, onosNodes, 's' if onosNodes > 1 else '' ) )
+            main.case( '%s, with %s, %s switches and %d ONOS instance%s' %
+                       ( description, self.topo[ topology ][ 3 ], main.switchType, onosNodes, 's' if onosNodes > 1 else '' ) )
 
-        main.cfgName = 'CASE%01d%01d' % ( test_idx / 10, ( ( test_idx - 1 ) % 10 ) % 4 + 1 )
-        main.Cluster.setRunningNode( onosNodes )
-        run.installOnos( main, skipPackage=skipPackage, cliSleep=5 )
-        if main.useBmv2:
-            switchPrefix = main.params[ 'DEPENDENCY' ].get( 'switchPrefix', "bmv2" )
-            # Translate configuration file from OVS-OFDPA to BMv2 driver
-            translator.bmv2ToOfdpa( main ) # Try to cleanup if switching between switch types
-            translator.ofdpaToBmv2( main, switchPrefix=switchPrefix )
-        else:
-            translator.bmv2ToOfdpa( main )
-        suf = main.params.get( 'jsonFileSuffix', None)
-        if suf:
-            run.loadJson( main, suffix=suf )
-        else:
-            run.loadJson( main )
-        run.loadChart( main )
-        if hasattr( main, 'Mininet1' ):
-            run.mnDockerSetup( main )  # optionally create and setup docker image
-
-            # Run the test with Mininet
-            mininet_args = ' --spine=%d --leaf=%d' % ( self.topo[ topology ][ 0 ], self.topo[ topology ][ 1 ] )
-            if self.topo[ topology ][ 2 ]:
-                mininet_args += ' --dual-homed'
-            if len( vlan ) > 0 :
-                mininet_args += ' --vlan=%s' % ( ','.join( ['%d' % vlanId for vlanId in vlan ] ) )
+            main.cfgName = 'CASE%01d%01d' % ( test_idx / 10, ( ( test_idx - 1 ) % 10 ) % 4 + 1 )
+            main.Cluster.setRunningNode( onosNodes )
+            run.installOnos( main, skipPackage=skipPackage, cliSleep=5 )
             if main.useBmv2:
-                mininet_args += ' --switch %s' % main.switchType
-                main.log.info( "Using %s switch" % main.switchType )
+                switchPrefix = main.params[ 'DEPENDENCY' ].get( 'switchPrefix', "bmv2" )
+                # Translate configuration file from OVS-OFDPA to BMv2 driver
+                translator.bmv2ToOfdpa( main )  # Try to cleanup if switching between switch types
+                translator.ofdpaToBmv2( main, switchPrefix=switchPrefix )
+            else:
+                translator.bmv2ToOfdpa( main )
+            suf = main.params.get( 'jsonFileSuffix', None)
+            if suf:
+                run.loadJson( main, suffix=suf )
+            else:
+                run.loadJson( main )
+            run.loadChart( main )
+            if hasattr( main, 'Mininet1' ):
+                run.mnDockerSetup( main )  # optionally create and setup docker image
 
-            run.startMininet( main, 'trellis_fabric.py', args=mininet_args )
+                # Run the test with Mininet
+                mininet_args = ' --spine=%d --leaf=%d' % ( self.topo[ topology ][ 0 ], self.topo[ topology ][ 1 ] )
+                if self.topo[ topology ][ 2 ]:
+                    mininet_args += ' --dual-homed'
+                if len( vlan ) > 0 :
+                    mininet_args += ' --vlan=%s' % ( ','.join( ['%d' % vlanId for vlanId in vlan ] ) )
+                if main.useBmv2:
+                    mininet_args += ' --switch %s' % main.switchType
+                    main.log.info( "Using %s switch" % main.switchType )
 
-        else:
-            # Run the test with physical devices
-            run.connectToPhysicalNetwork( main )
+                run.startMininet( main, 'trellis_fabric.py', args=mininet_args )
 
-        run.checkFlows( main, minFlowCount=self.topo[ topology ][ 5 if main.useBmv2 else 4 ] * self.topo[ topology ][ 1 ], sleep=5 )
-        if main.useBmv2:
-            leaf_dpid = [ "device:bmv2:leaf%d" % ( ls + 1 ) for ls in range( self.topo[ topology ][ 1 ]) ]
-        else:
-            leaf_dpid = [ "of:%016d" % ( ls + 1 ) for ls in range( self.topo[ topology ][ 1 ] ) ]
-        for dpid in leaf_dpid:
-            run.checkFlowsByDpid( main, dpid, self.topo[ topology ][ 5 if main.useBmv2 else 4 ], sleep=5 )
-        run.pingAll( main )
+            else:
+                # Run the test with physical devices
+                run.connectToPhysicalNetwork( main )
+
+            run.checkFlows( main, minFlowCount=self.topo[ topology ][ 5 if main.useBmv2 else 4 ] * self.topo[ topology ][ 1 ], sleep=5 )
+            if main.useBmv2:
+                leaf_dpid = [ "device:bmv2:leaf%d" % ( ls + 1 ) for ls in range( self.topo[ topology ][ 1 ]) ]
+            else:
+                leaf_dpid = [ "of:%016d" % ( ls + 1 ) for ls in range( self.topo[ topology ][ 1 ] ) ]
+            for dpid in leaf_dpid:
+                run.checkFlowsByDpid( main, dpid, self.topo[ topology ][ 5 if main.useBmv2 else 4 ], sleep=5 )
+            run.pingAll( main )
+        except Exception as e:
+            main.log.exception( "Error in runTest" )
+            main.skipCase( result="FAIL", msg=e )
 
         run.cleanup( main )