ONOS-2508 FUNCovsdbtest flows install and vm go-online scripts

Change-Id: I9ba54e5432908316141cb59b6645973d8419665f
diff --git a/TestON/drivers/common/cli/ovsdbdriver.py b/TestON/drivers/common/cli/ovsdbdriver.py
index bd55c91..4b78665 100644
--- a/TestON/drivers/common/cli/ovsdbdriver.py
+++ b/TestON/drivers/common/cli/ovsdbdriver.py
@@ -194,6 +194,7 @@
             main.log.error( self.name + ":     " + self.handle.before )
             main.cleanup()
             main.exit()
+
     def show( self ):
         """
         Parameters:
@@ -215,3 +216,182 @@
             main.log.error( self.name + ":     " + self.handle.before )
             main.cleanup()
             main.exit()
+
+    def dumpFlows( self, sw, protocols=None ):
+        """
+        Parameters:
+            sw: The name of an OVS switch. Example "s1"
+        Return:
+            The output of the command from the linux
+            or main.FALSE on timeout"""
+        if protocols:
+            command = "sudo ovs-ofctl -O " + \
+                protocols + " dump-flows " + str( sw )
+        else:
+            command = "sudo ovs-ofctl dump-flows " + str( sw )
+        try:
+            response = self.execute(
+                cmd=command,
+                timeout=10 )
+            if response:
+                return response
+            else:
+                return main.FALSE
+        except pexpect.EOF:
+            main.log.error(self.name + ": EOF exception found")
+            main.log.error(self.name + ":     " + self.handle.before)
+            main.cleanup()
+            main.exit()
+
+    def createHost( self, hostname ):
+        command = "sudo ip netns add " + str( hostname )
+        try:
+            handle = self.execute(
+                cmd=command,
+                timeout=10)
+            if re.search( "Error", handle ):
+                main.log.error( "Error in create host" + str( hostname ) )
+                main.log.error( handle )
+                return main.FALSE
+            else:
+                main.log.info( "Create " + str( hostname ) + " sucess" )
+                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()
+
+    def createHostport(self, hostname="host1", hostport="host1-eth0", ovsport="port1", hostportmac="000000000001" ):
+        command = "sudo ip link add " + str(hostport) +" type veth peer name " + str(ovsport)
+        command += ";" +" sudo ifconfig " + str(hostport) + " hw ether " + str(hostportmac)
+        command += ";" +" sudo ip link set " + str(hostport) + " netns " + str(hostname)
+        try:
+            handle = self.execute(
+                cmd=command,
+                timeout=10)
+            if re.search( "Error", handle ):
+                main.log.error( "Error in create host port " + str( hostport ) + " on " + str( hostname ) )
+                main.log.error( handle )
+                return main.FALSE
+            else:
+                main.log.info( "Create host port " + str( hostport ) + " on " + str( hostname ) + " sucess" )
+                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()
+
+    def addPortToOvs(self, ifaceId, attachedMac, vmuuid, port="port1", ovsname="br-int" ):
+        command = "sudo ovs-vsctl add-port " + str(ovsname) +" " + str(port)
+        if ifaceId:
+            command += " -- set Interface " + str(port) + " external-ids:iface-id=" + str(ifaceId) + " external-ids:iface-status=active"
+        if attachedMac:
+            command += " external-ids:attached-mac=" + str(attachedMac)
+        if vmuuid:
+            command += " external-ids:vm-uuid=" + str(vmuuid)
+        try:
+            handle = self.execute(
+                cmd=command,
+                timeout=10)
+            if re.search( "Error", handle ):
+                main.log.error( "Error in add port " + str(port) + " to ovs " + str( ovsname ) )
+                main.log.error( handle )
+                return main.FALSE
+            else:
+                main.log.info( "Add port " + str(port) + " to ovs " + str( ovsname )  + " sucess" )
+                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()
+
+    def setHostportIp(self, ip, hostname="host1", hostport1="host1-eth0" ):
+        command = "sudo ip netns exec " + str(hostname) +" ifconfig " + str(hostport1) + " " + str(ip)
+        try:
+            handle = self.execute(
+                cmd=command,
+                timeout=10)
+            if re.search( "Error", handle ):
+                main.log.error( "Error in set host ip for " + str( hostport1 ) + " on host " + str( hostname ) )
+                main.log.error( handle )
+                return main.FALSE
+            else:
+                main.log.info( "Set host ip for " + str( hostport1 ) + " on host " + str( hostname ) + " sucess" )
+                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()
+
+    def hostPing(self, src, target, hostname="host1" ):
+        if src:
+            command = "sudo ip netns exec " + str( hostname ) +" ping -c 1 -S " +\
+             str( src ) + " " + str( target )
+        else:
+            command = "sudo ip netns exec " + str( hostname ) +" ping -c 1 " + str( target )
+        try:
+            for i in range(1,5):
+                handle = self.execute(
+                    cmd=command,
+                    timeout=10)
+                if re.search(',\s0\%\spacket\sloss', handle):
+                    main.log.info(self.name + ": no packets lost, host is reachable")
+                    return main.TRUE
+                    break
+                time.sleep(5)
+            else:
+                main.log.info(self.name + ": packets lost, host is unreachable")
+                return main.FALSE
+        except pexpect.EOF:
+            main.log.error(self.name + ": EOF exception found")
+            main.log.error(self.name + ":     " + self.handle.before)
+            main.cleanup()
+            main.exit()
+
+    def delBr( self, sw ):
+        """
+        Parameters:
+            sw: The name of an OVS switch. Example "br-int"
+        Return:
+            Delete sucess return main.TRUE or main.FALSE on delete failed
+        """
+        command= "sudo ovs-vsctl del-br " + str( sw )
+        try:
+            response = self.execute(
+                cmd=command,
+                timeout=10 )
+            if response:
+                return main.TRUE
+            else:
+                return main.FALSE
+        except pexpect.EOF:
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":     " + self.handle.before )
+            main.cleanup()
+            main.exit()
+
+    def delHost( self, hostname ):
+        """
+        Parameters:
+            hostname: The name of an ip netns name. Example "host1"
+        Return:
+            Delete sucess return main.TRUE or main.FALSE on delete failed
+        """
+        command= "sudo ip netns delete " + str( hostname )
+        try:
+            response = self.execute(
+                cmd=command,
+                timeout=10 )
+            if response:
+                return main.TRUE
+            else:
+                return main.FALSE
+        except pexpect.EOF:
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":     " + self.handle.before )
+            main.cleanup()
+            main.exit()
\ No newline at end of file
diff --git a/TestON/tests/FUNCovsdbtest/FUNCovsdbtest.params b/TestON/tests/FUNCovsdbtest/FUNCovsdbtest.params
index 1f83b50..cadb81b 100644
--- a/TestON/tests/FUNCovsdbtest/FUNCovsdbtest.params
+++ b/TestON/tests/FUNCovsdbtest/FUNCovsdbtest.params
@@ -3,8 +3,13 @@
     # 1 - Compile ONOS and push it to the test machines
     # 2 - Test ovsdb connection and tearDown
     # 3 - Test default br-int configuration and vxlan port
+    # 4 - Test default openflow configuration
+    # 5 - Test default flows
+    # 6 - Configure Network Subnet Port
+    # 7 - Test host go online and ping each other
+    # 8 - Clear ovs configuration and host configuration
 
-    <testcases>1,2,3</testcases>
+    <testcases>1,3,4,2,5,6,7,8</testcases>
 
     <DEPENDENCY>
         <path>/tests/FUNCovsdbtest/Dependency/</path>
@@ -26,8 +31,8 @@
     </TIMER>
 
     <HTTP>
-        <port>False</port>
-        <path>/onos/vtn</path>
+        <port>8181</port>
+        <path>/onos/vtn/</path>
     </HTTP>
 
     <GIT>
diff --git a/TestON/tests/FUNCovsdbtest/FUNCovsdbtest.py b/TestON/tests/FUNCovsdbtest/FUNCovsdbtest.py
index 6d921be..95e90fd 100644
--- a/TestON/tests/FUNCovsdbtest/FUNCovsdbtest.py
+++ b/TestON/tests/FUNCovsdbtest/FUNCovsdbtest.py
@@ -7,8 +7,9 @@
 CASE3: Test default br-int configuration and vxlan port
 CASE4: Test default openflow configuration
 CASE5: Test default flows
-CASE6: Configure Network Subnet Port And Check On ONOS
+CASE6: Configure Network Subnet Port
 CASE7: Test host go online and ping each other
+CASE8: Clear ovs configuration and host configuration
 zhanghaoyu7@huawei.com
 """
 import os
@@ -340,3 +341,447 @@
                                  actual=stepResult,
                                  onpass="onos add default vxlan port on the node 2 sucess",
                                  onfail="onos add default vxlan port on the node 2 failed" )
+
+    def CASE4( self, main ):
+
+        """
+        Test default openflow configuration
+        """
+        import re
+        import time
+        import os,sys
+
+        ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
+        ovsdbport = main.params[ 'CTRL' ][ 'ovsdbport' ]
+        delaytime = main.params[ 'TIMER' ][ 'delaytime' ]
+
+        main.step( "ovsdb node 1 set ovs manager to " + str( ctrlip ) )
+        assignResult = main.OVSDB1.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime )
+        stepResult = assignResult
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="ovsdb node 1 set ovs manager to  to " +\
+                                  str( ctrlip ) + " sucess",
+                                 onfail="ovsdb node 1 set ovs manager to  to " +\
+                                  str( ctrlip ) + " failed" )
+
+        main.step( "ovsdb node 2 set ovs manager to " + str( ctrlip ) )
+        assignResult = main.OVSDB2.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime )
+        stepResult = assignResult
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="ovsdb node 2 set ovs manager to  to " +\
+                                  str( ctrlip ) + " sucess",
+                                 onfail="ovsdb node 2 set ovs manager to  to " +\
+                                  str( ctrlip ) + " failed" )
+
+        main.step( "Check ovsdb node 1 manager is " + str( ctrlip ) )
+        response = main.OVSDB1.getManager()
+        if re.search( ctrlip, response ):
+            stepResult = main.TRUE
+        else:
+            stepResult = main.FALSE
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="ovsdb node 1 manager is " + str( response ) ,
+                                 onfail="ovsdb node 1 manager check failed" )
+
+        main.step( "Check ovsdb node 2 manager is " + str( ctrlip ) )
+        response = main.OVSDB2.getManager()
+        if re.search( ctrlip, response ):
+            stepResult = main.TRUE
+        else:
+            stepResult = main.FALSE
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="ovsdb node 2 manager is " + str( response ) ,
+                                 onfail="ovsdb node 2 manager check failed" )
+
+        main.step( "Check ovsdb node 1 bridge br-int controller set to " + str( ctrlip ) )
+        response = main.OVSDB1.getController( "br-int" )
+        if re.search( ctrlip, response ):
+            stepResult = main.TRUE
+        else:
+            stepResult = main.FALSE
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="Check ovsdb node 1 bridge br-int controller set to " +\
+                                  str( ctrlip ) + " sucess",
+                                 onfail="Check ovsdb node 1 bridge br-int controller set to " +\
+                                  str( ctrlip ) + " failed" )
+
+        main.step( "Check ovsdb node 2 bridge br-int controller set to  " + str( ctrlip ) )
+        response = main.OVSDB2.getController( "br-int" )
+        if re.search( ctrlip, response ):
+            stepResult = main.TRUE
+        else:
+            stepResult = main.FALSE
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="Check ovsdb node 2 bridge br-int controller set to " +\
+                                  str( ctrlip ) + " sucess",
+                                 onfail="Check ovsdb node 2 bridge br-int controller set to " +\
+                                  str( ctrlip ) + " failed" )
+
+        main.step( "Check onoscli devices have ovs " + str( OVSDB1Ip ) )
+        response = main.ONOScli1.devices()
+        if re.search( OVSDB1Ip, response ) and not re.search( "false", response ):
+            stepResult = main.TRUE
+        else:
+            stepResult = main.FALSE
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="Check onoscli devices have ovs " + str( OVSDB1Ip ) + " sucess",
+                                 onfail="Check onoscli devices have ovs " + str( OVSDB1Ip ) + " failed" )
+
+        main.step( "Check onoscli devices have ovs " + str( OVSDB2Ip ) )
+        response = main.ONOScli1.devices()
+        if re.search( OVSDB2Ip, response ) and not re.search( "false", response ):
+            stepResult = main.TRUE
+        else:
+            stepResult = main.FALSE
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="Check onoscli devices have ovs " + str( OVSDB2Ip ) + " sucess",
+                                 onfail="Check onoscli devices have ovs " + str( OVSDB2Ip ) + " failed" )
+
+    def CASE5( self, main ):
+
+        """
+        Test default flows
+        """
+        import re
+        import time
+        import os,sys
+
+        ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
+        ovsdbport = main.params[ 'CTRL' ][ 'ovsdbport' ]
+        delaytime = main.params[ 'TIMER' ][ 'delaytime' ]
+
+        main.step( "ovsdb node 1 set ovs manager to onos" )
+        assignResult = main.OVSDB1.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime )
+        stepResult = assignResult
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="ovsdb node 1 set ovs manager to  to " +\
+                                  str( ctrlip ) + " sucess",
+                                 onfail="ovsdb node 1 set ovs manager to  to " +\
+                                  str( ctrlip ) + " failed" )
+
+        main.step( "Check ovsdb node 1 manager is " + str( ctrlip ) )
+        response = main.OVSDB1.getManager()
+        if re.search( ctrlip, response ):
+            stepResult = main.TRUE
+        else:
+            stepResult = main.FALSE
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="ovsdb node 1 manager is " + str( response ) ,
+                                 onfail="ovsdb node 1 manager check failed" )
+
+        main.step( "Check ovsdb node 1 bridge br-int default flows on " + str( OVSDB1Ip ) )
+        response = main.OVSDB1.dumpFlows( sw="br-int", protocols="OpenFlow13" )
+        if re.search( "actions=CONTROLLER", response ):
+            stepResult = main.TRUE
+        else:
+            stepResult = main.FALSE
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="Successfully set default flows " + str( ctrlip ) ,
+                                 onfail="Failed to set default flows " + str( ctrlip ) )
+
+    def CASE6( self, main ):
+        """
+        Configure Network Subnet Port
+        """
+        import os
+
+        try:
+            from tests.FUNCovsdbtest.dependencies.Nbdata import NetworkData
+            from tests.FUNCovsdbtest.dependencies.Nbdata import SubnetData
+            from tests.FUNCovsdbtest.dependencies.Nbdata import VirtualPortData
+        except ImportError:
+            main.log.exception( "Something wrong with import file or code error." )
+            main.log.info( "Import Error, please check!" )
+            main.cleanup()
+            main.exit()
+
+        main.log.info( "Configure Network Subnet Port Start" )
+        main.case( "Configure Network Subnet Port" )
+        main.caseExplanation = "Configure Network Subnet Port " +\
+                                "Verify post is OK"
+
+        ctrlip = os.getenv( main.params['CTRL']['ip1'] )
+        httpport = main.params['HTTP']['port']
+        path = main.params['HTTP']['path']
+
+        main.step( "Generate Post Data" )
+        network = NetworkData()
+        network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
+        network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
+        subnet = SubnetData()
+        subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
+        subnet.tenant_id = network.tenant_id
+        subnet.network_id = network.id
+        subnet.start = "10.0.0.1"
+        subnet.end = "10.0.0.254"
+        subnet.cidr = "10.0.0.0/24"
+        port1 = VirtualPortData()
+        port1.id = "00000000-0000-0000-0000-000000000001"
+        port1.subnet_id = subnet.id
+        port1.tenant_id = network.tenant_id
+        port1.network_id = network.id
+        port1.macAddress = "00:00:00:00:00:01"
+        port1.ip_address = "10.0.0.1"
+        port2 = VirtualPortData()
+        port2.id = "00000000-0000-0000-0000-000000000002"
+        port2.subnet_id = subnet.id
+        port2.tenant_id = network.tenant_id
+        port2.network_id = network.id
+        port2.macAddress = "00:00:00:00:00:02"
+        port2.ip_address = "10.0.0.2"
+
+        networkpostdata = network.DictoJson()
+        subnetpostdata = subnet.DictoJson()
+        port1postdata = port1.DictoJson()
+        port2postdata = port2.DictoJson()
+
+        main.step( "Post Network Data via HTTP(Post port need post network)" )
+        Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'networks/',
+                                                 'POST', None, networkpostdata )
+        utilities.assert_equals(
+                expect='200',
+                actual=Poststatus,
+                onpass="Post Network Success",
+                onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
+
+        main.step( "Post Subnet Data via HTTP(Post port need post subnet)" )
+        Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'subnets/',
+                                                 'POST', None, subnetpostdata )
+        utilities.assert_equals(
+                expect='202',
+                actual=Poststatus,
+                onpass="Post Subnet Success",
+                onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
+
+        main.step( "Post Port1 Data via HTTP" )
+        Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'ports/',
+                                                 'POST', None, port1postdata )
+        utilities.assert_equals(
+                expect='200',
+                actual=Poststatus,
+                onpass="Post Port Success",
+                onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) )
+
+        main.step( "Post Port2 Data via HTTP" )
+        Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'ports/',
+                                                 'POST', None, port2postdata )
+        utilities.assert_equals(
+                expect='200',
+                actual=Poststatus,
+                onpass="Post Port Success",
+                onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) )
+
+    def CASE7( self, main ):
+
+        """
+        Test host go online and ping each other
+        """
+        import re
+        import time
+        import os,sys
+
+        ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
+        ovsdbport = main.params[ 'CTRL' ][ 'ovsdbport' ]
+        delaytime = main.params[ 'TIMER' ][ 'delaytime' ]
+
+        main.step( "ovsdb node 1 set ovs manager to " + str( ctrlip ) )
+        assignResult = main.OVSDB1.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime )
+        stepResult = assignResult
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="ovsdb node 1 set ovs manager to  to " +\
+                                  str( ctrlip ) + " sucess",
+                                 onfail="ovsdb node 1 set ovs manager to  to " +\
+                                  str( ctrlip ) + " failed" )
+
+        main.step( "ovsdb node 2 set ovs manager to " + str( ctrlip ) )
+        assignResult = main.OVSDB2.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime )
+        stepResult = assignResult
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="ovsdb node 2 set ovs manager to " +\
+                                  str( ctrlip ) + " sucess",
+                                 onfail="ovsdb node 2 set ovs manager to " +\
+                                  str( ctrlip ) + " failed" )
+
+        main.step( "Create host1 on node 1 " + str( OVSDB1Ip ) )
+        stepResult = main.OVSDB1.createHost( hostname="host1" )
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="Create host1 on node 1 " + str( OVSDB1Ip ) + " sucess",
+                                 onfail="Create host1 on node 1 " + str( OVSDB1Ip ) + " failed" )
+
+        main.step( "Create host2 on node 2 " + str( OVSDB2Ip ) )
+        stepResult = main.OVSDB2.createHost( hostname="host2" )
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="Create host2 on node 2 " + str( OVSDB2Ip ) + " sucess",
+                                 onfail="Create host2 on node 2 " + str( OVSDB2Ip ) + " failed" )
+
+        main.step( "Create port on host1 on the node " + str ( OVSDB1Ip ) )
+        stepResult = main.OVSDB1.createHostport( hostname="host1", hostport="host1-eth0", hostportmac="000000000001" )
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="Create port on host1 on the node " + str( OVSDB1Ip ) + " sucess",
+                                 onfail="Create port on host1 on the node " + str( OVSDB1Ip ) + " failed" )
+
+        main.step( "Create port on host2 on the node " + str ( OVSDB2Ip ) )
+        stepResult = main.OVSDB2.createHostport( hostname="host2", hostport="host2-eth0", hostportmac="000000000002" )
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="Create port on host1 on the node " + str( OVSDB2Ip ) + " sucess",
+                                 onfail="Create port on host1 on the node " + str( OVSDB2Ip ) + " failed" )
+
+        main.step( "Add port to ovs br-int and host go-online on the node " + str ( OVSDB1Ip ) )
+        stepResult = main.OVSDB1.addPortToOvs( ovsname="br-int", ifaceId="00000000-0000-0000-0000-000000000001",
+                                               attachedMac="00:00:00:00:00:01", vmuuid="10000000-0000-0000-0000-000000000001" )
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="Add port to ovs br-int and host go-online on the node " +\
+                                  str( OVSDB1Ip ) + " sucess",
+                                 onfail="Add port to ovs br-int and host go-online on the node " +\
+                                  str( OVSDB1Ip ) + " failed" )
+
+        main.step( "Add port to ovs br-int and host go-online on the node " + str ( OVSDB2Ip ) )
+        stepResult = main.OVSDB2.addPortToOvs( ovsname="br-int", ifaceId="00000000-0000-0000-0000-000000000002",
+                                               attachedMac="00:00:00:00:00:02", vmuuid="10000000-0000-0000-0000-000000000001" )
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="Add port to ovs br-int and host go-online on the node " +\
+                                  str( OVSDB2Ip ) + " sucess",
+                                 onfail="Add port to ovs br-int and host go-online on the node " +\
+                                  str( OVSDB2Ip ) + " failed" )
+
+        main.step( "Check onos set host flows on the node " + str( OVSDB1Ip ) )
+        response = main.OVSDB1.dumpFlows( sw="br-int", protocols="OpenFlow13" )
+        if re.search( "00:00:00:00:00:01", response ):
+            stepResult = main.TRUE
+        else:
+            stepResult = main.FALSE
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="Check onos set host flows on the node " +\
+                                  str( OVSDB1Ip ) + " sucess",
+                                 onfail="Check onos set host flows on the node " +\
+                                  str( OVSDB1Ip ) + " failed" )
+
+        main.step( "Check onos set host flows on the node " + str( OVSDB2Ip ) )
+        response = main.OVSDB2.dumpFlows( sw="br-int", protocols="OpenFlow13" )
+        if re.search( "00:00:00:00:00:02", response ):
+            stepResult = main.TRUE
+        else:
+            stepResult = main.FALSE
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="Check onos set host flows on the node " +\
+                                  str( OVSDB2Ip ) + " sucess",
+                                 onfail="Check onos set host flows on the node " +\
+                                  str( OVSDB2Ip ) + " failed" )
+
+        main.step( "Check hosts can ping each other" )
+        main.OVSDB1.setHostportIp( hostname="host1", hostport1="host1-eth0", ip="10.0.0.1" )
+        main.OVSDB2.setHostportIp( hostname="host2", hostport1="host2-eth0", ip="10.0.0.2" )
+        pingResult1 = main.OVSDB1.hostPing( src="10.0.0.1", hostname="host1", target="10.0.0.2" )
+        pingResult2 = main.OVSDB2.hostPing( src="10.0.0.2", hostname="host2", target="10.0.0.1" )
+        stepResult = pingResult1 and pingResult2
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="Successfully host go online and ping each other,controller is " +\
+                                        str( ctrlip ),
+                                 onfail="Failed to host go online and ping each other,controller is " +\
+                                        str( ctrlip ) )
+
+    def CASE8( self, main ):
+
+        """
+        Clear ovs configuration and host configuration
+        """
+        import re
+        import time
+        import os,sys
+
+        ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
+        OVSDB1Ip = os.getenv( main.params[ 'OVSDB' ][ 'ip1' ] )
+        OVSDB2Ip = os.getenv( main.params[ 'OVSDB' ][ 'ip2' ] )
+        delaytime = main.params[ 'TIMER' ][ 'delaytime' ]
+
+        main.step( "Delete ovsdb node 1 manager" )
+        deleteResult = main.OVSDB1.delManager( delaytime=delaytime )
+        stepResult = deleteResult
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="ovsdb node 1 delete manager sucess",
+                                 onfail="ovsdb node 1 delete manager failed" )
+
+        main.step( "Delete ovsdb node 2 manager" )
+        deleteResult = main.OVSDB2.delManager( delaytime=delaytime )
+        stepResult = deleteResult
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="ovsdb node 2 delete manager sucess",
+                                 onfail="ovsdb node 2 delete manager failed" )
+
+        main.step( "Delete ovsdb node 1 bridge br-int" )
+        deleteResult = main.OVSDB1.delBr( sw="br-int" )
+        stepResult = deleteResult
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="Delete ovsdb node 1 bridge br-int sucess",
+                                 onfail="Delete ovsdb node 1 bridge br-int failed" )
+
+        main.step( "Delete ovsdb node 2 bridge br-int" )
+        deleteResult = main.OVSDB2.delBr( sw="br-int" )
+        stepResult = deleteResult
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="Delete ovsdb node 2 bridge br-int sucess",
+                                 onfail="Delete ovsdb node 2 bridge br-int failed" )
+
+        main.step( "Delete ip netns host on the ovsdb node 1" )
+        deleteResult = main.OVSDB1.delHost( hostname="host1" )
+        stepResult = deleteResult
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="Delete ip netns host on the ovsdb node 1 sucess",
+                                 onfail="Delete ip netns host on the ovsdb node 1 failed" )
+
+        main.step( "Delete ip netns host on the ovsdb node 2" )
+        deleteResult = main.OVSDB2.delHost( hostname="host2" )
+        stepResult = deleteResult
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="Delete ip netns host on the ovsdb node 2 sucess",
+                                 onfail="Delete ip netns host on the ovsdb node 2 failed" )
+
+        main.step( "Check onoscli devices openflow session is false " + str( OVSDB1Ip ) )
+        response = main.ONOScli1.devices()
+        if re.search( OVSDB1Ip, response ) and not re.search( "true", response ):
+            stepResult = main.TRUE
+        else:
+            stepResult = main.FALSE
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="Check openflow session is false " + str( OVSDB1Ip ) + " sucess",
+                                 onfail="Check openflow session is false " + str( OVSDB1Ip ) + " failed" )
+
+        main.step( "Check onoscli devices have ovs " + str( OVSDB2Ip ) )
+        response = main.ONOScli1.devices()
+        if re.search( OVSDB2Ip, response ) and not re.search( "true", response ):
+            stepResult = main.TRUE
+        else:
+            stepResult = main.FALSE
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="Check openflow session is false " + str( OVSDB2Ip ) + " sucess",
+                                 onfail="Check openflow session is false " + str( OVSDB2Ip ) + " failed" )
\ No newline at end of file
diff --git a/TestON/tests/FUNCovsdbtest/dependencies/Nbdata.py b/TestON/tests/FUNCovsdbtest/dependencies/Nbdata.py
new file mode 100644
index 0000000..3fde20d
--- /dev/null
+++ b/TestON/tests/FUNCovsdbtest/dependencies/Nbdata.py
@@ -0,0 +1,212 @@
+"""
+This file provide the data
+lanqinglong@huawei.com
+"""
+import json
+
+class NetworkData:
+
+    def __init__(self):
+        self.id = ''
+        self.state = 'ACTIVE'
+        self.name = 'onosfw-1'
+        self.physicalNetwork = 'none'
+        self.admin_state_up = True
+        self.tenant_id = ''
+        self.routerExternal = False
+        self.type ='LOCAL'
+        self.segmentationID = '6'
+        self.shared = False
+
+    def DictoJson(self):
+
+        if self.id =='' or self.tenant_id == '':
+            print 'Id and tenant id is necessary!'
+
+        Dicdata = {}
+        if self.id !='':
+            Dicdata['id'] = self.id
+        if self.state != '':
+            Dicdata['status'] = self.state
+        if self.name !='':
+            Dicdata['name'] = self.name
+        if self.physicalNetwork !='':
+            Dicdata['provider:physical_network'] = self.physicalNetwork
+        if self.admin_state_up !='':
+            Dicdata['admin_state_up'] = self.admin_state_up
+        if self.tenant_id !='':
+            Dicdata['tenant_id'] = self.tenant_id
+        if self.routerExternal !='':
+            Dicdata['router:external'] = self.routerExternal
+        if self.type !='':
+            Dicdata['provider:network_type'] = self.type
+        if self.segmentationID !='':
+            Dicdata['provider:segmentation_id'] = self.segmentationID
+        if self.shared !='':
+            Dicdata['shared'] = self.shared
+
+        Dicdata = {'network': Dicdata}
+
+        return json.dumps(Dicdata,indent=4)
+
+    def Ordered(self,obj):
+
+        if isinstance(obj, dict):
+            return sorted((k,self.Ordered(v)) for k,  v in obj.items())
+        if isinstance(obj, list):
+            return sorted(self.Ordered(x) for x in obj )
+        else:
+            return obj
+
+    def JsonCompare(self,SourceData,DestiData,FirstPara,SecondPara):
+
+        try:
+            SourceCompareDataDic = json.loads(SourceData)
+            DestiCompareDataDic = json.loads(DestiData)
+        except ValueError:
+            print "SourceData or DestData is not JSON Type!"
+            return False
+
+        try:
+            Socom = SourceCompareDataDic[FirstPara][SecondPara]
+            Decom = DestiCompareDataDic[FirstPara][SecondPara]
+        except KeyError,error:
+            print "Key error ,This key is not found:%s"%error
+            return False
+
+        if str(Socom).lower()== str(Decom).lower():
+            return True
+        else:
+            print "Source Compare data:"+FirstPara+"."+SecondPara+"="+str(Socom)
+            print "Dest Compare data: "+FirstPara+"."+SecondPara+"="+str(Decom)
+            return False
+
+class SubnetData(NetworkData):
+
+    def __init__(self):
+        self.id = ''
+        self.tenant_id = ''
+        self.network_id = ''
+        self.nexthop = '192.168.1.1'
+        self.destination = '192.168.1.1/24'
+        self.start = '192.168.2.2'
+        self.end = '192.168.2.254'
+        self.ipv6_address_mode = 'DHCPV6_STATELESS'
+        self.ipv6_ra_mode = 'DHCPV6_STATELESS'
+        self.cidr = '192.168.1.1/24'
+        self.enable_dhcp = True
+        self.dns_nameservers = 'aaa'
+        self.gateway_ip = '192.168.2.1'
+        self.ip_version = '4'
+        self.shared = False
+        self.name = 'demo-subnet'
+
+    def DictoJson(self):
+        if self.id =='' or self.tenant_id == '':
+            print 'Id and tenant id is necessary!'
+
+        Dicdata = {}
+        host_routesdata = []
+        host_routesdata.append({'nexthop': self.nexthop,'destination': self.destination})
+        allocation_pools = []
+        allocation_pools.append({'start': self.start,'end':self.end})
+
+        if self.id != '':
+            Dicdata['id'] = self.id
+        if self.network_id != '':
+            Dicdata['network_id'] = self.network_id
+        if self.name != '':
+            Dicdata['name'] = self.name
+        if self.nexthop != '':
+            Dicdata['host_routes'] = host_routesdata
+        if self.tenant_id != '':
+            Dicdata['tenant_id'] = self.tenant_id
+        if self.start != '':
+            Dicdata['allocation_pools'] = allocation_pools
+        if self.shared != '':
+            Dicdata['shared'] = self.shared
+        if self.ipv6_address_mode != '':
+            Dicdata['ipv6_address_mode'] = self.ipv6_address_mode
+        if self.ipv6_ra_mode != '':
+            Dicdata['ipv6_ra_mode'] = self.ipv6_ra_mode
+        if self.cidr != '':
+            Dicdata['cidr'] = self.cidr
+        if self.enable_dhcp != '':
+            Dicdata['enable_dhcp'] = self.enable_dhcp
+        if self.dns_nameservers != '':
+            Dicdata['dns_nameservers'] = self.dns_nameservers
+        if self.gateway_ip != '':
+            Dicdata['gateway_ip'] = self.gateway_ip
+        if self.ip_version != '':
+            Dicdata['ip_version'] = self.ip_version
+
+        Dicdata = {'subnet': Dicdata}
+
+        return json.dumps(Dicdata,indent=4)
+
+class VirtualPortData(NetworkData):
+
+    def __init__(self):
+        self.id = ''
+        self.state = 'ACTIVE'
+        self.bindingHostId = 'fa:16:3e:76:8e:88'
+        self.allowedAddressPairs = [{'mac_address':'fa:16:3e:76:8e:88','ip_address':'192.168.1.1'}]
+        self.deviceOwner = 'none'
+        self.fixedIp = []
+        self.securityGroups = [{'securityGroup':'asd'}]
+        self.adminStateUp = True
+        self.network_id = ''
+        self.tenant_id = ''
+        self.subnet_id = ''
+        self.bindingvifDetails = 'port_filter'
+        self.bindingvnicType = 'normal'
+        self.bindingvifType = 'ovs'
+        self.macAddress = 'fa:16:3e:76:8e:88'
+        self.deviceId = 'a08aa'
+        self.name = 'u'
+
+    def DictoJson(self):
+        if self.id == '' or self.tenant_id == ' ' or \
+           self.network_id == '' or self.subnet_id == '':
+            print 'Id/tenant id/networkid/subnetId is necessary!'
+
+        Dicdata = {}
+        fixedIp =[]
+        fixedIp.append({'subnet_id':self.subnet_id,'ip_address':'192.168.1.4'})
+        allocation_pools = []
+
+        if self.id != '':
+            Dicdata['id'] = self.id
+        if self.state != '':
+            Dicdata['status'] = self.state
+        if self.bindingHostId != '':
+            Dicdata['binding:host_id'] = self.bindingHostId
+        if self.allowedAddressPairs != '':
+            Dicdata['allowed_address_pairs'] = self.allowedAddressPairs
+        if self.deviceOwner != '':
+            Dicdata['device_owner'] = self.deviceOwner
+        if self.securityGroups != '':
+            Dicdata['security_groups'] = self.securityGroups
+        if self.adminStateUp != '':
+            Dicdata['admin_state_up'] = self.adminStateUp
+        if self.network_id != '':
+            Dicdata['network_id'] = self.network_id
+        if self.tenant_id != '':
+            Dicdata['tenant_id'] = self.tenant_id
+        if self.bindingvifDetails != '':
+            Dicdata['binding:vif_details'] = self.bindingvifDetails
+        if self.bindingvnicType != '':
+            Dicdata['binding:vnic_type'] = self.bindingvnicType
+        if self.bindingvifType != '':
+            Dicdata['binding:vif_type'] = self.bindingvifType
+        if self.macAddress != '':
+            Dicdata['mac_address'] = self.macAddress
+        if self.deviceId != '':
+            Dicdata['device_id'] = self.deviceId
+        if self.name != '':
+            Dicdata['name'] = self.name
+
+        Dicdata['fixed_ips'] = fixedIp
+        Dicdata = {'port': Dicdata}
+
+        return json.dumps(Dicdata,indent=4)