[ONOS-7356] Initial commit to decouple Mininet from TestON tests:
  - Add Network class
  - Allow ONOS start up without Mininet component
  - Migrate SAMP tests and FUNCintent to use Network class

Change-Id: I81b4a4dd27ff6b3a7f2b60abbbcef078b0fa0438
diff --git a/TestON/tests/FUNC/FUNCintent/FUNCintent.py b/TestON/tests/FUNC/FUNCintent/FUNCintent.py
index 24d2f75..34c2674 100644
--- a/TestON/tests/FUNC/FUNCintent/FUNCintent.py
+++ b/TestON/tests/FUNC/FUNCintent/FUNCintent.py
@@ -47,6 +47,9 @@
         main.testSetUp.envSetupDescription()
         stepResult = main.FALSE
 
+        from tests.dependencies.Network import Network
+        main.Network = Network()
+
         # Test variables
         try:
             main.apps = main.params[ 'ENV' ][ 'cellApps' ]
@@ -89,11 +92,12 @@
                                             wrapperFile2 +
                                             ".py" )
 
-            copyResult1 = main.ONOSbench.scp( main.Mininet1,
-                                              main.dependencyPath +
-                                              main.topology,
-                                              main.Mininet1.home + "custom/",
-                                              direction="to" )
+            if hasattr( main, "Mininet1" ):
+                copyResult1 = main.ONOSbench.scp( main.Mininet1,
+                                                  main.dependencyPath +
+                                                  main.topology,
+                                                  main.Mininet1.home + "custom/",
+                                                  direction="to" )
 
             stepResult = main.testSetUp.envSetup()
         except Exception as e:
@@ -113,7 +117,7 @@
         - Connect to cli
         """
         main.flowCompiler = "Flow Rules"
-        main.initialized = main.testSetUp.ONOSSetUp( main.Mininet1, main.Cluster, True )
+        main.initialized = main.testSetUp.ONOSSetUp( main.Cluster, True )
         main.intents.report( main )
 
     def CASE8( self, main ):
@@ -212,7 +216,7 @@
 
         tempONOSip = main.Cluster.getIps()
 
-        assignResult = main.Mininet1.assignSwController( sw=switchList,
+        assignResult = main.Network.assignSwController( sw=switchList,
                                                          ip=tempONOSip,
                                                          port="6653" )
         if not assignResult:
@@ -221,7 +225,7 @@
             main.skipCase()
 
         for i in range( 1, ( main.numSwitch + 1 ) ):
-            response = main.Mininet1.getSwController( "s" + str( i ) )
+            response = main.Network.getSwController( "s" + str( i ) )
             main.log.debug( "Response is " + str( response ) )
             if re.search( "tcp:" + main.Cluster.active( 0 ).ipAddress, response ):
                 assignResult = assignResult and main.TRUE
@@ -463,12 +467,6 @@
         # if you want to use the wrapper function
         assert main, "There is no main"
         try:
-            assert main.Mininet1
-        except AssertionError:
-            main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
-            main.initialized = main.FALSE
-            main.skipCase()
-        try:
             assert main.numSwitch
         except AssertionError:
             main.log.error( "Place the total number of switch topology in " +
@@ -757,12 +755,6 @@
         # if you want to use the wrapper function
         assert main, "There is no main"
         try:
-            assert main.Mininet1
-        except AssertionError:
-            main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
-            main.initialized = main.FALSE
-            main.skipCase()
-        try:
             assert main.numSwitch
         except AssertionError:
             main.log.error( "Place the total number of switch topology in " +
@@ -1254,12 +1246,6 @@
             main.skipCase()
         assert main, "There is no main"
         try:
-            assert main.Mininet1
-        except AssertionError:
-            main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
-            main.initialized = main.FALSE
-            main.skipCase()
-        try:
             assert main.numSwitch
         except AssertionError:
             main.log.error( "Place the total number of switch topology in " +
@@ -1550,12 +1536,6 @@
             main.skipCase()
         assert main, "There is no main"
         try:
-            assert main.Mininet1
-        except AssertionError:
-            main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
-            main.initialized = main.FALSE
-            main.skipCase()
-        try:
             assert main.numSwitch
         except AssertionError:
             main.log.error( "Place the total number of switch topology in " +
@@ -1875,12 +1855,6 @@
             main.skipCase()
         assert main, "There is no main"
         try:
-            assert main.Mininet1
-        except AssertionError:
-            main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
-            main.initialized = main.FALSE
-            main.skipCase()
-        try:
             assert main.numSwitch
         except AssertionError:
             main.log.error( "Place the total number of switch topology in " +
@@ -1892,7 +1866,7 @@
         main.step( "Testing host mobility by moving h1 from s5 to s6" )
 
         main.log.info( "Moving h1 from s5 to s6" )
-        main.Mininet1.moveHost( "h1", "s5", "s6" )
+        main.Network.moveHost( "h1", "s5", "s6" )
 
         # Send discovery ping from moved host
         # Moving the host brings down the default interfaces and creates a new one.
@@ -1957,12 +1931,6 @@
             main.skipCase()
         assert main, "There is no main"
         try:
-            assert main.Mininet1
-        except AssertionError:
-            main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
-            main.initialized = main.FALSE
-            main.skipCase()
-        try:
             assert main.numSwitch
         except AssertionError:
             main.log.error( "Place the total number of switch topology in " + main.numSwitch )
diff --git a/TestON/tests/FUNC/FUNCintent/dependencies/FuncIntentFunction.py b/TestON/tests/FUNC/FUNCintent/dependencies/FuncIntentFunction.py
index 1a7002b..0fcd334 100644
--- a/TestON/tests/FUNC/FUNCintent/dependencies/FuncIntentFunction.py
+++ b/TestON/tests/FUNC/FUNCintent/dependencies/FuncIntentFunction.py
@@ -743,7 +743,7 @@
     checkFlowsState( main )
 
     # Run iperf to both host
-    iperfTemp = main.Mininet1.iperftcp( host1, host2, 10 )
+    iperfTemp = main.Network.iperftcp( host1, host2, 10 )
     iperfResult = iperfResult and iperfTemp
     if iperfTemp:
         main.assertReturnString += 'Initial Iperf Passed\n'
@@ -773,7 +773,7 @@
             main.assertReturnString += 'Link Down Topology State Failed\n'
 
         # Run iperf to both host
-        iperfTemp = main.Mininet1.iperftcp( host1, host2, 10 )
+        iperfTemp = main.Network.iperftcp( host1, host2, 10 )
         iperfResult = iperfResult and iperfTemp
         if iperfTemp:
             main.assertReturnString += 'Link Down Iperf Passed\n'
@@ -822,7 +822,7 @@
             main.assertReturnString += 'Link Up Topology State Failed\n'
 
         # Run iperf to both host
-        iperfTemp = main.Mininet1.iperftcp( host1, host2, 10 )
+        iperfTemp = main.Network.iperftcp( host1, host2, 10 )
         iperfResult = iperfResult and iperfTemp
         if iperfTemp:
             main.assertReturnString += 'Link Up Iperf Passed\n'
@@ -1904,7 +1904,7 @@
         Ping all host in the hosts list variable
     """
     main.log.info( "Pinging: " + str( hostList ) )
-    return main.Mininet1.pingallHosts( hostList )
+    return main.Network.pingallHosts( hostList )
 
 
 def fwdPingall( main ):
@@ -1928,7 +1928,7 @@
 
     # Send pingall in mininet
     main.log.info( "Run Pingall" )
-    pingResult = main.Mininet1.pingall( timeout=600 )
+    pingResult = main.Network.pingall( timeout=600 )
 
     main.log.info( "Deactivating reactive forwarding app " )
     deactivateResult = main.Cluster.active( 0 ).CLI.deactivateApp( "org.onosproject.fwd" )
@@ -2025,12 +2025,12 @@
     import json
     try:
         hostsJson = json.loads( main.Cluster.active( 0 ).CLI.hosts() )
-        hosts = main.Mininet1.getHosts().keys()
+        hosts = main.Network.getHosts().keys()
         # TODO: Make better use of new getHosts function
         for host in hosts:
             main.hostsData[ host ] = {}
             main.hostsData[ host ][ 'mac' ] =  \
-                main.Mininet1.getMacAddress( host ).upper()
+                main.Network.getMacAddress( host ).upper()
             for hostj in hostsJson:
                 if main.hostsData[ host ][ 'mac' ] == hostj[ 'mac' ]:
                     main.hostsData[ host ][ 'id' ] = hostj[ 'id' ]
@@ -2116,7 +2116,7 @@
     # link down
     main.log.info( itemName + ": Bring link " + option + " between " +
                        sw1 + " and " + sw2 )
-    linkResult = main.Mininet1.link( end1=sw1, end2=sw2, option=option )
+    linkResult = main.Network.link( end1=sw1, end2=sw2, option=option )
     return linkResult