Merge pull request #98 from opennetworkinglab/devl/HA_refactor_threads

Devl/ha refactor threads
diff --git a/TestON/drivers/common/cli/onosclidriver.py b/TestON/drivers/common/cli/onosclidriver.py
index 946faff..04d2eed 100644
--- a/TestON/drivers/common/cli/onosclidriver.py
+++ b/TestON/drivers/common/cli/onosclidriver.py
@@ -1187,11 +1187,9 @@
 
     def addMultipointToSinglepointIntent(
             self,
-            ingressDevice1,
-            ingressDevice2,
+            ingressDeviceList,
             egressDevice,
-            portIngress1="",
-            portIngress2="",
+            portIngressList=None,
             portEgress="",
             ethType="",
             ethSrc="",
@@ -1207,12 +1205,13 @@
             setEthDst="" ):
         """
         Note:
-            This function assumes that there would be 2 ingress devices and
-            one egress device. For more number of ingress devices, this
-            function needs to be modified
+            This function assumes the format of all ingress devices
+            is same. That is, all ingress devices include port nos 
+            with a "/" or all ingress devices could specify device 
+            ids and port nos seperately.
         Required:
-            * ingressDevice1: device id of ingress device1
-            * ingressDevice2: device id of ingress device2
+            * ingressDeviceList: List of device ids of ingress device 
+                ( Atleast 2 ingress devices required in the list )
             * egressDevice: device id of egress device
         Optional:
             * ethType: specify ethType
@@ -1270,6 +1269,7 @@
                     cmd += " --tcpSrc " + str( tcpSrc )
                 if tcpDst:
                     cmd += " --tcpDst " + str( tcpDst )
+            function needs to be modified
                 if setEthSrc:
                     cmd += " --setEthSrc " + str( setEthSrc )
                 if setEthDst:
@@ -1277,31 +1277,22 @@
 
             # Check whether the user appended the port
             # or provided it as an input
-            if "/" in ingressDevice1:
-                cmd += " " + str( ingressDevice1 )
+
+            if portIngressList is None:
+                for ingressDevice in ingressDeviceList:
+                    if "/" in ingressDevice:
+                        cmd += " " + str( ingressDevice )
+                    else:
+                        main.log.error( "You must specify " +
+                                    "the ingress port" )
+                        # TODO: perhaps more meaningful return
+                        return main.FALSE
             else:
-                if not portIngress1:
-                    main.log.error( "You must specify " +
-                                    "the ingress port1" )
-                    # TODO: perhaps more meaningful return
-                    return None
-
-                cmd += " " + \
-                    str( ingressDevice1 ) + "/" +\
-                    str( portIngress1 ) + " "
-
-            if "/" in ingressDevice2:
-                cmd += " " + str( ingressDevice2 )
-            else:
-                if not portIngress2:
-                    main.log.error( "You must specify " +
-                                    "the ingress port2" )
-                    # TODO: perhaps more meaningful return
-                    return None
-
-                cmd += " " + \
-                    str( ingressDevice2 ) + "/" +\
-                    str( portIngress2 ) + " "
+                if len( ingressDeviceList ) == len( portIngressList )
+                    for ingressDevice,portIngress in zip( ingressDeviceList,portIngressList ):
+                        cmd += " " + \
+                            str( ingressDevice ) + "/" +\
+                            str( portIngress ) + " "
 
             if "/" in egressDevice:
                 cmd += " " + str( egressDevice )
@@ -1314,6 +1305,7 @@
                 cmd += " " +\
                     str( egressDevice ) + "/" +\
                     str( portEgress )
+
             print "cmd= ", cmd
             handle = self.sendline( cmd )
             # If error, return error message
@@ -1324,15 +1316,14 @@
             else:
                 # TODO: print out all the options in this message?
                 main.log.info( "Multipoint-to-singlepoint intent installed" +
-                               " between " + str( ingressDevice1 ) + ", " +
-                               str( ingressDevice2 ) + " and " +
-                               str( egressDevice ) )
-                match = re.search('id=0x([\da-f]+),', handle)
-                if match:
-                    return match.group()[3:-1]
-                else:
-                    main.log.error( "Error, intent ID not found" )
-                    return None
+                               " failed " )
+                return None
+                #match = re.search('id=0x([\da-f]+),', handle)
+                #if match:
+                    #return match.group()[3:-1]
+                #else:
+                    #main.log.error( "Error, intent ID not found" )
+                    #return None
         except TypeError:
             main.log.exception( self.name + ": Object not as expected" )
             return None