add cell file & change test case name

Change-Id: Ifa3c2aa69cdb6fafe509ac86b0682e07f4293e44
diff --git a/TestON/drivers/common/cli/emulator/mininetclidriver.py b/TestON/drivers/common/cli/emulator/mininetclidriver.py
index 659a710..d726f2e 100644
--- a/TestON/drivers/common/cli/emulator/mininetclidriver.py
+++ b/TestON/drivers/common/cli/emulator/mininetclidriver.py
@@ -1267,6 +1267,35 @@
             main.exit()
         return main.TRUE
 
+    def node( self, nodeName, commandStr ):
+        """
+        Carry out a command line on a given node
+        @parm:
+            nodeName: the node name in Mininet testbed
+            commandStr: the command line will be carried out on the node
+        Example: main.Mininet.node( nodeName="h1", commandStr="ls" )
+        """
+        command = str( nodeName ) + " " + str( commandStr )
+        main.log.info( command )
+
+        try:
+            response = self.execute( cmd = command, prompt = "mininet>" )
+            if re.search( "Unknown command", response ):
+                main.log.warn( response )
+                return main.FALSE
+        except pexpect.TIMEOUT:
+            main.log.error( self.name + ": pexpect.TIMEOUT found" )
+            main.cleanup()
+            main.exit()
+        except pexpect.EOF:
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":     " + self.handle.before )
+            main.cleanup()
+            main.exit()
+        main.log.info( " response is :" )
+        main.log.info( response )
+        return response
+
     def yank( self, **yankargs ):
         """
            yank a mininet switch interface to a host"""
diff --git a/TestON/tests/USECASE_SdnipI2/Dependency/Functions.py b/TestON/tests/USECASE_SdnipFunction/Dependency/Functions.py
similarity index 98%
rename from TestON/tests/USECASE_SdnipI2/Dependency/Functions.py
rename to TestON/tests/USECASE_SdnipFunction/Dependency/Functions.py
index 1b93f49..0f25012 100644
--- a/TestON/tests/USECASE_SdnipI2/Dependency/Functions.py
+++ b/TestON/tests/USECASE_SdnipFunction/Dependency/Functions.py
@@ -66,11 +66,11 @@
     """
     if len( speakers ) == 0:
         main.log.error( "Parameter speakers can not be empty." )
-        main.clearUp()
+        main.cleanup()
         main.exit()
     if len( peers ) == 0:
         main.log.error( "Parameter speakers can not be empty." )
-        main.clearUp()
+        main.cleanup()
         main.exit()
 
     if expectAllSuccess:
@@ -98,7 +98,7 @@
                              onfail = "Ping test results are Not expected" )
 
     if result == False:
-        main.clearUp()
+        main.cleanup()
         main.exit()
 
 
@@ -114,7 +114,7 @@
     main.step( "Check ping between each host pair" )
     if len( hosts ) == 0:
         main.log.error( "Parameter hosts can not be empty." )
-        main.clearUp()
+        main.cleanup()
         main.exit()
 
     result = True
diff --git a/TestON/tests/USECASE_SdnipI2/Dependency/USECASE_SdnipI2MN.py b/TestON/tests/USECASE_SdnipFunction/Dependency/USECASE_SdnipI2MN.py
similarity index 99%
rename from TestON/tests/USECASE_SdnipI2/Dependency/USECASE_SdnipI2MN.py
rename to TestON/tests/USECASE_SdnipFunction/Dependency/USECASE_SdnipI2MN.py
index 30b7b25..17544d1 100755
--- a/TestON/tests/USECASE_SdnipI2/Dependency/USECASE_SdnipI2MN.py
+++ b/TestON/tests/USECASE_SdnipFunction/Dependency/USECASE_SdnipI2MN.py
@@ -25,8 +25,8 @@
 
 QUAGGA_DIR = '/usr/lib/quagga'
 QUAGGA_RUN_DIR = '/usr/local/var/run/quagga'
-QUAGGA_CONFIG_DIR = '~/OnosSystemTest/TestON/tests/USECASE_SdnipI2/Dependency/'
-onos1IP = '10.128.4.52'
+QUAGGA_CONFIG_DIR = '~/OnosSystemTest/TestON/tests/USECASE_SdnipFunction/Dependency/'
+# onos1IP = '10.254.1.201'
 numSw = 39
 
 
@@ -338,10 +338,11 @@
     swCtl100.cmd( 'ovs-vsctl set-fail-mode swCtl100 standalone' )
 
     # connect all switches to controller
+    '''
     for i in range ( 1, numSw + 1 ):
         swX = net.get( 'sw%s' % ( i ) )
         swX.cmd( 'ovs-vsctl set-controller sw%s tcp:%s:6653' % ( i, onos1IP ) )
-
+    '''
     # Start Quagga on border routers
     '''
     for i in range ( 64514, 64516 + 1 ):
@@ -367,12 +368,12 @@
     hosts = [ peer64514, peer64515, peer64516, host64514];
     startsshds( hosts )
     #
-
+    '''
     forwarding1 = '%s:2000:%s:2000' % ( '1.1.1.2', onos1IP )
     root.cmd( 'ssh -nNT -o "PasswordAuthentication no" \
     -o "StrictHostKeyChecking no" -l sdn -L %s %s & ' % ( forwarding1, onos1IP ) )
 
-
+    '''
     # time.sleep( 3000000000 )
     CLI( net )
 
diff --git a/TestON/tests/USECASE_SdnipI2/Dependency/quagga-sdn.conf b/TestON/tests/USECASE_SdnipFunction/Dependency/quagga-sdn.conf
similarity index 100%
rename from TestON/tests/USECASE_SdnipI2/Dependency/quagga-sdn.conf
rename to TestON/tests/USECASE_SdnipFunction/Dependency/quagga-sdn.conf
diff --git a/TestON/tests/USECASE_SdnipI2/Dependency/quagga64514.conf b/TestON/tests/USECASE_SdnipFunction/Dependency/quagga64514.conf
similarity index 100%
rename from TestON/tests/USECASE_SdnipI2/Dependency/quagga64514.conf
rename to TestON/tests/USECASE_SdnipFunction/Dependency/quagga64514.conf
diff --git a/TestON/tests/USECASE_SdnipI2/Dependency/quagga64515.conf b/TestON/tests/USECASE_SdnipFunction/Dependency/quagga64515.conf
similarity index 100%
rename from TestON/tests/USECASE_SdnipI2/Dependency/quagga64515.conf
rename to TestON/tests/USECASE_SdnipFunction/Dependency/quagga64515.conf
diff --git a/TestON/tests/USECASE_SdnipI2/Dependency/quagga64516.conf b/TestON/tests/USECASE_SdnipFunction/Dependency/quagga64516.conf
similarity index 100%
rename from TestON/tests/USECASE_SdnipI2/Dependency/quagga64516.conf
rename to TestON/tests/USECASE_SdnipFunction/Dependency/quagga64516.conf
diff --git a/TestON/tests/USECASE_SdnipI2/Dependency/zebra.conf b/TestON/tests/USECASE_SdnipFunction/Dependency/zebra.conf
similarity index 100%
rename from TestON/tests/USECASE_SdnipI2/Dependency/zebra.conf
rename to TestON/tests/USECASE_SdnipFunction/Dependency/zebra.conf
diff --git a/TestON/tests/USECASE_SdnipI2/USECASE_SdnipI2.params b/TestON/tests/USECASE_SdnipFunction/USECASE_SdnipFunction.params
similarity index 88%
rename from TestON/tests/USECASE_SdnipI2/USECASE_SdnipI2.params
rename to TestON/tests/USECASE_SdnipFunction/USECASE_SdnipFunction.params
index 1575799..5ba6b2d 100644
--- a/TestON/tests/USECASE_SdnipI2/USECASE_SdnipI2.params
+++ b/TestON/tests/USECASE_SdnipFunction/USECASE_SdnipFunction.params
@@ -9,7 +9,7 @@
 
     <CTRL>
         <numCtrl>1</numCtrl>
-        <ip1>10.128.4.52</ip1>
+        <ip1>OC1</ip1>
         <port1>6653</port1>
     </CTRL>
 
@@ -25,13 +25,14 @@
     </JSON>
 
     <DEPENDENCY>
-        <path>/USECASE_SdnipI2/Dependency/</path>
+        <path>/USECASE_SdnipFunction/Dependency/</path>
         <topology>USECASE_SdnipI2MN.py</topology>
         <wrapper1>Functions</wrapper1>
     </DEPENDENCY>
 
     <config>
         <peerNum> 3 </peerNum>
+        <switchNum> 39 </switchNum>
     </config>
 
     <timers>
diff --git a/TestON/tests/USECASE_SdnipI2/USECASE_SdnipI2.py b/TestON/tests/USECASE_SdnipFunction/USECASE_SdnipFunction.py
similarity index 92%
rename from TestON/tests/USECASE_SdnipI2/USECASE_SdnipI2.py
rename to TestON/tests/USECASE_SdnipFunction/USECASE_SdnipFunction.py
index ebc4545..ed93999 100644
--- a/TestON/tests/USECASE_SdnipI2/USECASE_SdnipI2.py
+++ b/TestON/tests/USECASE_SdnipFunction/USECASE_SdnipFunction.py
@@ -1,5 +1,5 @@
 # Testing the functionality of SDN-IP with single ONOS instance
-class USECASE_SdnipI2:
+class USECASE_SdnipFunction:
 
     def __init__( self ):
         self.default = ''
@@ -12,7 +12,7 @@
         """
         import os
         import imp
-        main.log.case( "Start Mininet topology" )
+        main.log.case( "This case is to setup the Mininet testbed" )
         main.dependencyPath = main.testDir + \
                               main.params[ 'DEPENDENCY' ][ 'path' ]
         main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ]
@@ -20,15 +20,46 @@
         main.step( "Starting Mininet Topology" )
         topology = main.dependencyPath + main.topology
         topoResult = main.Mininet.startNet( topoFile = topology )
-        stepResult = topoResult
         utilities.assert_equals( expect = main.TRUE,
-                                 actual = stepResult,
+                                 actual = topoResult,
                                  onpass = "Successfully loaded topology",
                                  onfail = "Failed to load topology" )
         # Exit if topology did not load properly
         if not topoResult:
             main.cleanup()
             main.exit()
+        main.step( "Connect switches to controller" )
+
+        global ONOS1Ip
+        ONOS1Ip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
+        # connect all switches to controller
+        swResult = main.TRUE
+        for i in range ( 1, int( main.params['config']['switchNum'] ) + 1 ):
+            sw = "sw%s" % ( i )
+            swResult = swResult and main.Mininet.assignSwController( sw, ONOS1Ip )
+            # swResult = swResult and main.Mininet.assignSwController( sw, ONOS1Ip, port = "6633" )
+        utilities.assert_equals( expect = main.TRUE,
+                             actual = swResult,
+                             onpass = "Successfully connect all switches to ONOS",
+                             onfail = "Failed to connect all switches to ONOS" )
+        if not swResult:
+            main.cleanup()
+            main.exit()
+
+        main.step( "Set up tunnel from Mininet node to onos node" )
+        forwarding1 = '%s:2000:%s:2000' % ( '1.1.1.2', ONOS1Ip )
+        command = 'ssh -nNT -o "PasswordAuthentication no" \
+        -o "StrictHostKeyChecking no" -l sdn -L %s %s & ' % ( forwarding1, ONOS1Ip )
+
+        tunnelResult = main.TRUE
+        tunnelResult = main.Mininet.node( "root", command )
+        if not tunnelResult:
+            main.log.report("Failed to create tunnel")
+            main.cleanup()
+            main.exit()
+        elif "PasswordAuthentication" in tunnelResult:
+            main.log.report("Successfully created tunnel")
+
 
     # This case is to setup ONOS
     def CASE101( self, main ):
@@ -50,8 +81,6 @@
         main.case( "Setting up test environment" )
 
         cellName = main.params[ 'ENV' ][ 'cellName' ]
-        global ONOS1Ip
-        ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
 
         main.step( "Applying cell variable to environment" )
         cellResult = main.ONOSbench.setCell( cellName )
diff --git a/TestON/tests/USECASE_SdnipI2/USECASE_SdnipI2.topo b/TestON/tests/USECASE_SdnipFunction/USECASE_SdnipFunction.topo
similarity index 96%
rename from TestON/tests/USECASE_SdnipI2/USECASE_SdnipI2.topo
rename to TestON/tests/USECASE_SdnipFunction/USECASE_SdnipFunction.topo
index 7259cb1..07109ba 100644
--- a/TestON/tests/USECASE_SdnipI2/USECASE_SdnipI2.topo
+++ b/TestON/tests/USECASE_SdnipFunction/USECASE_SdnipFunction.topo
@@ -20,7 +20,7 @@
         </ONOScli>
 
         <ONOS1>
-            <host>10.128.4.52</host>
+            <host>OC1</host>
             <user>sdn</user>
             <password></password>
             <type>OnosDriver</type>
diff --git a/TestON/tests/USECASE_SdnipI2/__init__.py b/TestON/tests/USECASE_SdnipFunction/__init__.py
similarity index 100%
rename from TestON/tests/USECASE_SdnipI2/__init__.py
rename to TestON/tests/USECASE_SdnipFunction/__init__.py
diff --git a/TestON/tests/USECASE_SdnipI2/network-cfg.json b/TestON/tests/USECASE_SdnipFunction/network-cfg.json
similarity index 100%
rename from TestON/tests/USECASE_SdnipI2/network-cfg.json
rename to TestON/tests/USECASE_SdnipFunction/network-cfg.json
diff --git a/TestON/tests/USECASE_SdnipFunction/sdnip_single_instance b/TestON/tests/USECASE_SdnipFunction/sdnip_single_instance
new file mode 100644
index 0000000..c2c51c6
--- /dev/null
+++ b/TestON/tests/USECASE_SdnipFunction/sdnip_single_instance
@@ -0,0 +1,13 @@
+export ONOS_CELL="sdnip_single_instance"
+
+export ONOS_INSTALL_DIR="/opt/onos"
+export ONOS_NIC=10.254.1.*
+export OC1="10.254.1.201"
+export OCN="127.0.0.1"
+export OCI="${OC1}"
+export ONOS_USER="sdn"                  # ONOS user on remote system
+export ONOS_PWD="rocks"
+
+#export ONOS_APPS="drivers,openflow,config,proxyarp"
+export ONOS_APPS="drivers,openflow,proxyarp"
+