Rewrote assignSwController function in mininetclidriver
diff --git a/TestON/drivers/common/cli/emulator/mininetclidriver.py b/TestON/drivers/common/cli/emulator/mininetclidriver.py
index d3ca4dd..5f2ba89 100644
--- a/TestON/drivers/common/cli/emulator/mininetclidriver.py
+++ b/TestON/drivers/common/cli/emulator/mininetclidriver.py
@@ -39,6 +39,7 @@
 import pexpect
 import re
 import sys
+import types
 sys.path.append( "../" )
 from math import pow
 from drivers.common.cli.emulatordriver import Emulator
@@ -1106,53 +1107,135 @@
             main.cleanup()
             main.exit()
 
-    def assignSwController( self, **kwargs ):
+    def assignSwController( self, sw, ip, port="6633", ptcp="" ):
         """
-           count is only needed if there is more than 1 controller"""
-        args = utilities.parse_args( [ "COUNT" ], **kwargs )
-        count = args[ "COUNT" ] if args != {} else 1
+        Description:
+            Assign switches to the controllers ( for ovs use only )
+        Required:
+            sw - Name of the switch. This can be a list or a string.
+            ip - Ip addresses of controllers. This can be a list or a string.
+        Optional:
+            port - ONOS use port 6633, if no list of ports is passed, then
+                   the all the controller will use 6633 as their port number
+            ptcp - ptcp number, This can be a string or a list that has
+                   the same length as switch. This is optional and not required
+                   when using ovs switches.
+        NOTE: If switches and ptcp are given in a list type they should have the
+              same length and should be in the same order, Eg. sw=[ 's1' ... n ]
+              ptcp=[ '6637' ... n ], s1 has ptcp number 6637 and so on.
 
-        argstring = "SW"
-        for j in range( count ):
-            argstring = argstring + ",IP" + \
-                str( j + 1 ) + ",PORT" + str( j + 1 )
-        args = utilities.parse_args( argstring.split( "," ), **kwargs )
+        Return:
+            Returns main.TRUE if mininet correctly assigned switches to
+            controllers, otherwise it will return main.FALSE or an appropriate
+            exception(s)
+        """
+        assignResult = main.TRUE
+        # Initial ovs command
+        command = "sh ovs-vsctl set-controller "
+        onosIp = ""
 
-        sw = args[ "SW" ] if args[ "SW" ] is not None else ""
-        ptcpA = int( args[ "PORT1" ] ) + \
-            int( sw ) if args[ "PORT1" ] is not None else ""
-        ptcpB = "ptcp:" + str( ptcpA ) if ptcpA != "" else ""
+        if isinstance( ip, types.StringType ):
+            onosIp = "tcp:" + ip + ":"
+            if isinstance( port, types.StringType ):
+                onosIp += port
+            elif isinstance( port, types.ListType ):
+                main.log.error( self.name + ": Only one controller " +
+                                "assigned and a list of ports has" +
+                                " been passed" )
+                return main.FALSE
+            else:
+                main.log.error( self.name + ": Invalid controller port " +
+                                "number. Please specify correct " +
+                                "controller port" )
+                return main.FALSE
 
-        command = "sh ovs-vsctl set-controller s" + \
-            str( sw ) + " " + ptcpB + " "
-        for j in range( count ):
-            i = j + 1
-            args = utilities.parse_args(
-                [ "IP" + str( i ), "PORT" + str( i ) ], **kwargs )
-            ip = args[
-                "IP" +
-                str( i ) ] if args[
-                "IP" +
-                str( i ) ] is not None else ""
-            port = args[
-                "PORT" +
-                str( i ) ] if args[
-                "PORT" +
-                str( i ) ] is not None else ""
-            tcp = "tcp:" + str( ip ) + ":" + str( port ) + \
-                " " if ip != "" else ""
-            command = command + tcp
-        try:
-            self.execute( cmd=command, prompt="mininet>", timeout=5 )
-        except pexpect.EOF:
-            main.log.error( self.name + ": EOF exception found" )
-            main.log.error( self.name + ":     " + self.handle.before )
-            main.cleanup()
-            main.exit()
-        except Exception:
-            main.log.exception( self.name + ": Uncaught exception!" )
-            main.cleanup()
-            main.exit()
+        elif isinstance( ip, types.ListType ):
+            if isinstance( port, types.StringType ):
+                for ipAddress in ip:
+                    onosIp = "tcp:" + ipAddress + ":" + port + " "
+            elif isinstance( port, types.ListType ):
+                if ( len( ip ) != len( port ) ):
+                    main.log.error( self.name + ": Port list = " +
+                                    str( len( port ) ) +
+                                    "should be the same as controller" +
+                                    " ip list = " + str( len( ip ) ) )
+                    return main.FALSE
+                onosIp = ""
+                for ipAddress, portNum in zip( ip, port ):
+                    onosIp += "tcp:" + ipAddress + ":" + portNum + " "
+            else:
+                main.log.error( self.name + ": Invalid controller port " +
+                                "number. Please specify correct " +
+                                "controller port" )
+                return main.FALSE
+
+        if isinstance( sw, types.StringType ):
+            command += sw + " "
+            if ptcp:
+                if isinstance( ptcp, types.StringType ):
+                    command += "ptcp:" + ptcp + " "
+                elif isinstance( ptcp, types.ListType ):
+                    main.log.error( self.name + ": Only one switch is " +
+                                    "being set and multiple PTCP is " +
+                                    "being passed " )
+                else:
+                    main.log.error( self.name + ": Invalid PTCP" )
+                    ptcp = ""
+            command += onosIp
+            try:
+                self.execute( cmd=command, prompt="mininet>", timeout=5 )
+                return main.TRUE
+            except pexpect.EOF:
+                main.log.error( self.name + ": EOF exception found" )
+                main.log.error( self.name + ":     " + self.handle.before )
+                main.cleanup()
+                main.exit()
+            except Exception:
+                main.log.exception( self.name + ": Uncaught exception!" )
+                main.cleanup()
+                main.exit()
+
+        elif isinstance( sw, types.ListType ):
+            commandList = []
+            tempCmdList = []
+            if ptcp:
+                if isinstance( ptcp, types.ListType ):
+                    if len( ptcp ) != len( sw ):
+                        main.log.error( self.name + ": PTCP length = " +
+                                        str( len( ptcp ) ) +
+                                        " is not the same as switch length = " +
+                                        str( len( sw ) ) )
+                        return main.FALSE
+                    for switch, ptcpNum in zip( sw, ptcp ):
+                        tempCmd = "sh ovs-vsctl set-controller "
+                        tempCmd += switch + " ptcp:" + ptcpNum + " "
+                        tempCmdList.append( tempCmd )
+                else:
+                    main.log.error( self.name + ": Invalid PTCP" )
+                    return main.FALSE
+            else:
+                for switch in sw:
+                    tempCmd = "sh ovs-vsctl set-controller "
+                    tempCmd += switch + " "
+                    tempCmdList.append( tempCmd )
+
+            for cmd in tempCmdList:
+                cmd += onosIp
+                commandList.append( cmd )
+
+            try:
+                for cmd in commandList:
+                    self.execute( cmd=cmd, prompt="mininet>", timeout=5 )
+                return main.TRUE
+            except pexpect.EOF:
+                main.log.error( self.name + ": EOF exception found" )
+                main.log.error( self.name + ":     " + self.handle.before )
+                main.cleanup()
+                main.exit()
+            except Exception:
+                main.log.exception( self.name + ": Uncaught exception!" )
+                main.cleanup()
+                main.exit()
 
     def deleteSwController( self, sw ):
         """
@@ -2000,6 +2083,72 @@
 
         return hostList
 
+    def getHosts( self ):
+        """
+           Returns a list of all hosts
+           Don't ask questions just use it"""
+        self.handle.sendline( "" )
+        self.handle.expect( "mininet>" )
+
+        self.handle.sendline( "py [ host.name for host in net.hosts ]" )
+        self.handle.expect( "mininet>" )
+
+        handlePy = self.handle.before
+        handlePy = handlePy.split( "]\r\n", 1 )[ 1 ]
+        handlePy = handlePy.rstrip()
+
+        self.handle.sendline( "" )
+        self.handle.expect( "mininet>" )
+
+        hostStr = handlePy.replace( "]", "" )
+        hostStr = hostStr.replace( "'", "" )
+        hostStr = hostStr.replace( "[", "" )
+        hostStr = hostStr.replace( " ", "" )
+        hostList = hostStr.split( "," )
+
+        return hostList
+
+    def getSwitch( self ):
+        """
+            Returns a list of all switches
+            Again, don't ask question just use it...
+        """
+        # get host list...
+        hostList = self.getHosts()
+        # Make host set
+        hostSet = set( hostList )
+
+        # Getting all the nodes in mininet
+        self.handle.sendline( "" )
+        self.handle.expect( "mininet>" )
+
+        self.handle.sendline( "py [ node.name for node in net.values() ]" )
+        self.handle.expect( "mininet>" )
+
+        handlePy = self.handle.before
+        handlePy = handlePy.split( "]\r\n", 1 )[ 1 ]
+        handlePy = handlePy.rstrip()
+
+        self.handle.sendline( "" )
+        self.handle.expect( "mininet>" )
+
+        nodesStr = handlePy.replace( "]", "" )
+        nodesStr = nodesStr.replace( "'", "" )
+        nodesStr = nodesStr.replace( "[", "" )
+        nodesStr = nodesStr.replace( " ", "" )
+        nodesList = nodesStr.split( "," )
+
+        nodesSet = set( nodesList )
+        # discarding default controller(s) node
+        nodesSet.discard( 'c0' )
+        nodesSet.discard( 'c1' )
+        nodesSet.discard( 'c2' )
+
+        switchSet = nodesSet - hostSet
+        switchList = list( switchSet )
+
+        return switchList
+
     def update( self ):
         """
            updates the port address and status information for
diff --git a/TestON/tests/FuncIntent/FuncIntent.py b/TestON/tests/FuncIntent/FuncIntent.py
index d74f9a9..3a716ee 100644
--- a/TestON/tests/FuncIntent/FuncIntent.py
+++ b/TestON/tests/FuncIntent/FuncIntent.py
@@ -223,11 +223,19 @@
         main.case( "Assign switches to controllers" )
         main.step( "Assigning switches to controllers" )
         assignResult = main.TRUE
+        switchList = []
+
+        # Creates a list switch name, use getSwitch() function later...
         for i in range( 1, ( main.numSwitch + 1 ) ):
-            main.Mininet1.assignSwController( sw=str( i ),
-                                              count=1,
-                                              ip1=main.ONOSip[ 0 ],
-                                              port1=main.ONOSport[ 0 ] )
+            switchList.append( 's' + str( i ) )
+
+        assignResult = main.Mininet1.assignSwController( sw=switchList,
+                                                         ip=main.ONOSip,
+                                                         port=main.ONOSport )
+        if not assignResult:
+            main.cleanup()
+            main.exit()
+
         for i in range( 1, ( main.numSwitch + 1 ) ):
             response = main.Mininet1.getSwController( "s" + str( i ) )
             print( "Response is " + str( response ) )
diff --git a/TestON/tests/FuncTopo/Dependency/FuncTopoFunction.py b/TestON/tests/FuncTopo/Dependency/FuncTopoFunction.py
index ad30942..a953640 100644
--- a/TestON/tests/FuncTopo/Dependency/FuncTopoFunction.py
+++ b/TestON/tests/FuncTopo/Dependency/FuncTopoFunction.py
@@ -45,16 +45,19 @@
     # Starts topology
     startResult = startNewTopology( main, topoFile, args, mnCmd )
 
+    # Gets list of switches in mininet
+    assignSwitch( main )
+
+    # This function activates fwd app then does pingall as well as store
+    # hosts data in a variable main.hostsData
+    getHostsResult = getHostsData( main )
+
     # Create topology object using sts
     topoObjectResult = createTopoObject( main )
 
     # Compare Topology
     compareTopoResult = compareTopo( main )
 
-    # This function activates fwd app then does pingall as well as store
-    # hosts data in a variable main.hostsData
-    getHostsResult = getHostsData( main )
-
     testTopoResult = startResult and topoObjectResult and \
                      compareTopoResult and getHostsResult
 
@@ -224,6 +227,14 @@
 
     return compareTopoResult
 
+def assignSwitch( main ):
+    """
+        Returns switch list using getSwitch in Mininet driver
+    """
+    switchList =  main.Mininet1.getSwitch()
+    print switchList
+    return switchList
+
 def getHostsData( main ):
     """
         Use fwd app and pingall to discover all the hosts
diff --git a/TestON/tests/FuncTopo/FuncTopo.py b/TestON/tests/FuncTopo/FuncTopo.py
index 829c582..35d9049 100644
--- a/TestON/tests/FuncTopo/FuncTopo.py
+++ b/TestON/tests/FuncTopo/FuncTopo.py
@@ -48,6 +48,7 @@
         main.numLinks = int( main.params[ 'MININET' ][ 'links' ] )
         main.numCtrls = main.params[ 'CTRL' ][ 'num' ]
         main.hostsData = {}
+        main.topoName = " "
         PULLCODE = False
         if main.params[ 'GIT' ][ 'pull' ] == 'True':
             PULLCODE = True
@@ -150,7 +151,7 @@
                                  onpass="Successfully installed ONOS package",
                                  onfail="Failed to install ONOS package" )
 
-        time.sleep( 20 )
+        time.sleep( 10 )
         main.step( "Starting ONOS service" )
         stopResult = main.TRUE
         startResult = main.TRUE
@@ -174,17 +175,6 @@
                                  onpass="ONOS service is ready",
                                  onfail="ONOS service did not start properly" )
 
-        main.step( "Start ONOS cli" )
-        cliResult = main.TRUE
-        for i in range( main.numCtrls ):
-            cliResult = cliResult and \
-                        main.CLIs[ i ].startOnosCli( main.ONOSip[ i ] )
-        stepResult = cliResult
-        utilities.assert_equals( expect=main.TRUE,
-                                 actual=stepResult,
-                                 onpass="Successfully start ONOS cli",
-                                 onfail="Failed to start ONOS cli" )
-
     def CASE9( self, main ):
         '''
             Report errors/warnings/exceptions