Add check for onos service failing to start

Retry onos-install by default if it fails

Change-Id: I8989c21bb05c60f5e314a3613e01c1a39c669c5e
(cherry picked from commit 370733fb51f02bf64d9d16aabd44ab09c22dc9b4)
diff --git a/TestON/drivers/common/cli/onosdriver.py b/TestON/drivers/common/cli/onosdriver.py
index f9bbcff..7be9084 100755
--- a/TestON/drivers/common/cli/onosdriver.py
+++ b/TestON/drivers/common/cli/onosdriver.py
@@ -1123,6 +1123,7 @@
                                       "onos\sstart/running,\sprocess",
                                       "ONOS\sis\salready\sinstalled",
                                       "does not exist",
+                                      "Failed to start",
                                       self.prompt,
                                       pexpect.TIMEOUT ], timeout=180 )
             if i == 0:
@@ -1149,11 +1150,16 @@
                 self.handle.expect( self.prompt )
                 return main.FALSE
             elif i == 4:
+                # Service failed to start
+                main.log.error( "ONOS service failed to start" )
+                self.handle.expect( self.prompt )
+                return main.FALSE
+            elif i == 5:
                 # prompt
                 main.log.info( "ONOS was installed on {} {}.".format(  node,
                                "but not started" if 'n' in options else "and started" ) )
                 return main.TRUE
-            elif i == 5:
+            elif i == 6:
                 # timeout
                 main.log.info(
                     "Installation of ONOS on " +
diff --git a/TestON/tests/dependencies/Cluster.py b/TestON/tests/dependencies/Cluster.py
index 9ed9256..d255745 100644
--- a/TestON/tests/dependencies/Cluster.py
+++ b/TestON/tests/dependencies/Cluster.py
@@ -438,7 +438,7 @@
                 result = result and t.result
         return result
 
-    def installOnos( self, installMax=True, installParallel=True ):
+    def installOnos( self, installMax=True, installParallel=True, retries=5 ):
         """
         Description:
             Installing onos.
@@ -455,16 +455,21 @@
             options = "-f"
             if installMax and i >= self.numCtrls:
                 options = "-nf"
+            args = [ ctrl.Bench.onosInstall, main.FALSE ]
+            kwargs={ "node" : ctrl.ipAddress,
+                     "options" : options }
             if installParallel:
-                t = main.Thread( target=ctrl.Bench.onosInstall,
+                t = main.Thread( target=utilities.retry,
                                  name="onos-install-" + ctrl.name,
-                                 kwargs={ "node" : ctrl.ipAddress,
-                                          "options" : options } )
+                                 args=args,
+                                 kwargs={ 'kwargs': kwargs,
+                                          'attempts': retries } )
+
                 threads.append( t )
                 t.start()
             else:
                 result = result and \
-                            main.ONOSbench.onosInstall( node=ctrl.ipAddress, options=options )
+                            utilities.retry( args=args, kwargs=kwargs, attempts=retries )
             i += 1
         if installParallel:
             for t in threads: