Minor tweaks for SegmentRouting-CHO

Change-Id: I19c3764377aed420d1aeb2cff8f34a03907b691b
(cherry picked from commit 17f344b9355ff9875d36f45df97ea639b68491fa)
diff --git a/TestON/tests/CHOTestMonkey/CHOTestMonkey.params.trellis.flex b/TestON/tests/CHOTestMonkey/CHOTestMonkey.params.trellis.flex
index 61fd307..ac5be42 100644
--- a/TestON/tests/CHOTestMonkey/CHOTestMonkey.params.trellis.flex
+++ b/TestON/tests/CHOTestMonkey/CHOTestMonkey.params.trellis.flex
@@ -22,7 +22,7 @@
 
     <TEST>
         <IPv6>off</IPv6>
-        <restartCluster>False</restartCluster>
+        <restartCluster>True</restartCluster>
         <dataPlaneConnectivity>True</dataPlaneConnectivity>
         <numCtrl>3</numCtrl>
         <pauseTest>on</pauseTest>
@@ -241,7 +241,7 @@
             <device-down>2</device-down>
             <onos-down>1</onos-down>
         </eventWeight>
-        <skipSwitches>s201,s228</skipSwitches>
+        <skipSwitches>s201,s228,s203,s225,s204</skipSwitches>
         <skipLinks></skipLinks>
     </CASE70>
 
diff --git a/TestON/tests/CHOTestMonkey/CHOTestMonkey.py b/TestON/tests/CHOTestMonkey/CHOTestMonkey.py
index b61b69d..8989672 100644
--- a/TestON/tests/CHOTestMonkey/CHOTestMonkey.py
+++ b/TestON/tests/CHOTestMonkey/CHOTestMonkey.py
@@ -856,7 +856,7 @@
         allControllers = range( 1, int( main.params[ 'TEST' ][ 'numCtrl' ] ) + 1 )
         while True:
             upControllers = [ i for i in allControllers if main.controllers[ i - 1 ].isUp() ]
-            downOnosNum = len( allControllers ) - len( upControllers )
+            downControllers = [ i for i in allControllers if i not in upControllers ]
             hostIntentNum = len( [ intent for intent in main.intents if intent.type == 'INTENT_HOST' ] )
             pointIntentNum = len( [ intent for intent in main.intents if intent.type == 'INTENT_POINT' ] )
             downDeviceNum = len( [ device for device in main.devices if device.isDown() or device.isRemoved() ] )
@@ -867,12 +867,12 @@
                 events += [ event ] * int( weight )
             events += [ 'del-host-intent' ] * int( pow( hostIntentNum, 1.5 ) / 100 )
             events += [ 'del-point-intent' ] * int( pow( pointIntentNum, 1.5 ) / 100 )
-            events += [ 'device-up' ] * int( pow( 4, downDeviceNum ) - 1 )
+            events += [ 'device-up' ] * int( pow( 3, downDeviceNum ) - 1 )
             if 'link-down' in main.params[ 'CASE70' ][ 'eventWeight' ].keys():
-                events += [ 'link-up' ] * int( pow( 4, downLinkNum ) - 1 )
+                events += [ 'link-up' ] * int( pow( 3, downLinkNum ) - 1 )
             if 'port-down' in main.params[ 'CASE70' ][ 'eventWeight' ].keys():
-                events += [ 'port-up' ] * int( pow( 4, downPortNum ) - 1 )
-            events += [ 'onos-up' ] * int( pow( 4, downOnosNum ) - 1 )
+                events += [ 'port-up' ] * int( pow( 3, downPortNum ) - 1 )
+            events += [ 'onos-up' ] * int( pow( 3, len( downControllers ) - 1 ) )
             main.log.debug( events )
             event = random.sample( events, 1 )[ 0 ]
             if event == 'add-host-intent':
@@ -907,10 +907,11 @@
                 main.eventGenerator.triggerEvent( EventType().NETWORK_PORT_DOWN, EventScheduleMethod().RUN_BLOCK, 'random', 'random' )
             elif event == 'port-up':
                 main.eventGenerator.triggerEvent( EventType().NETWORK_PORT_UP, EventScheduleMethod().RUN_BLOCK, 'random', 'random' )
-            elif event == 'onos-down' and downOnosNum == 0:
-                main.eventGenerator.triggerEvent( EventType().ONOS_ONOS_DOWN, EventScheduleMethod().RUN_BLOCK, 1 )
-            elif event == 'onos-up':
-                main.eventGenerator.triggerEvent( EventType().ONOS_ONOS_UP, EventScheduleMethod().RUN_BLOCK, 1 )
+            elif event == 'onos-down' and len( downControllers ) == 0:
+                onosIndex = random.sample( upControllers, 1 )[ 0 ]
+                main.eventGenerator.triggerEvent( EventType().ONOS_ONOS_DOWN, EventScheduleMethod().RUN_BLOCK, onosIndex )
+            elif event == 'onos-up' and len( downControllers ) > 0:
+                main.eventGenerator.triggerEvent( EventType().ONOS_ONOS_UP, EventScheduleMethod().RUN_BLOCK, downControllers[ 0 ] )
                 main.eventGenerator.triggerEvent( EventType().ONOS_BALANCE_MASTERS, EventScheduleMethod().RUN_BLOCK )
             elif event == 'toggle-flowobj':
                 main.eventGenerator.triggerEvent( EventType().ONOS_SET_FLOWOBJ, EventScheduleMethod().RUN_BLOCK, 'false' if main.flowObj else 'true' )
diff --git a/TestON/tests/CHOTestMonkey/dependencies/events/NetworkEvent.py b/TestON/tests/CHOTestMonkey/dependencies/events/NetworkEvent.py
index 90f74a9..778b5b1 100644
--- a/TestON/tests/CHOTestMonkey/dependencies/events/NetworkEvent.py
+++ b/TestON/tests/CHOTestMonkey/dependencies/events/NetworkEvent.py
@@ -24,6 +24,7 @@
 """
 from tests.CHOTestMonkey.dependencies.events.Event import EventType, EventStates, Event
 from tests.CHOTestMonkey.dependencies.elements.NetworkElement import NetworkElement, Device, Host, Link
+import time
 
 
 class LinkEvent( Event ):
@@ -299,6 +300,7 @@
                 continue
             # FIXME: remove this temporary hack for CORD-3240
             if neighbor.name == 's225':
+                time.sleep( 5 )
                 main.NetworkBench.switches[ 's225' ].setPortSpeed( index=link.portB )
             # Bring down again any link that was brought down before the device was down
             if int( link.portB ) in link.deviceB.downPorts: