[ONOS-7736] Add IPv6 cases to SRRouting test case 651

Change-Id: I521f97b878f3d23ac80e37cf83c82cf64f0baef2
diff --git a/TestON/drivers/common/cli/emulator/mininetclidriver.py b/TestON/drivers/common/cli/emulator/mininetclidriver.py
index 15bde0d..ddd72b3 100644
--- a/TestON/drivers/common/cli/emulator/mininetclidriver.py
+++ b/TestON/drivers/common/cli/emulator/mininetclidriver.py
@@ -912,7 +912,7 @@
         else:
             return main.TRUE
 
-    def moveHost( self, host, oldSw, newSw, macAddr=None, prefixLen=None ):
+    def moveHost( self, host, oldSw, newSw, macAddr=None, prefixLen=24 ):
         """
            Moves a host from one switch to another on the fly
            If macAddr is specified, change MAC address of the host interface
@@ -1019,7 +1019,7 @@
                 main.log.exception( self.name + ": Uncaught exception!" )
                 return main.FALSE
 
-    def moveHostv6( self, host, oldSw, newSw, macAddr=None ):
+    def moveHostv6( self, host, oldSw, newSw, macAddr=None, prefixLen=64 ):
         """
            Moves a host from one switch to another on the fly
            If macAddr is specified, change MAC address of the host interface
@@ -1032,7 +1032,7 @@
         """
         if self.handle:
             try:
-                IP = str( self.getIPAddress( host, proto='IPV6' ) ) + "/64"
+                IP = str( self.getIPAddress( host, proto='IPV6' ) ) + "/" + str( prefixLen )
                 # Bring link between oldSw-host down
                 cmd = "py net.configLinkStatus('" + oldSw + "'," + "'" + host +\
                       "'," + "'down')"
@@ -1049,7 +1049,7 @@
                 self.handle.expect( "mininet>" )
 
                 # Determine ip and mac address of the host-oldSw interface
-                cmd = "px ipaddr = " + str( IP )
+                cmd = 'px ipaddr = "{}"'.format( IP )
                 print "cmd3= ", cmd
                 self.handle.sendline( cmd )
                 self.handle.expect( "mininet>" )
@@ -1094,7 +1094,8 @@
                 self.handle.expect( "mininet>" )
 
                 # Set ipaddress of the host-newSw interface
-                cmd = "px " + host + ".setIP(ip = ipaddr, intf = hintf)"
+                cmd = "px " + host + ".setIP( ip = ipaddr, intf = hintf, " \
+                                     "prefixLen = %s )" % str( prefixLen )
                 print "cmd8 = ", cmd
                 self.handle.sendline( cmd )
                 self.handle.expect( "mininet>" )
@@ -1103,7 +1104,7 @@
                 print "cmd9 =", cmd
                 response = self.execute( cmd = cmd, prompt="mininet>", timeout=10 )
                 print response
-                pattern = "h\d-eth([\w])"
+                pattern = "-eth([\w])"
                 ipAddressSearch = re.search( pattern, response )
                 print ipAddressSearch.group( 1 )
                 intf = host + "-eth" + str( ipAddressSearch.group( 1 ) )
diff --git a/TestON/tests/USECASE/SegmentRouting/SRRouting/SRRouting.py b/TestON/tests/USECASE/SegmentRouting/SRRouting/SRRouting.py
index 204bfb8..ce3c666 100644
--- a/TestON/tests/USECASE/SegmentRouting/SRRouting/SRRouting.py
+++ b/TestON/tests/USECASE/SegmentRouting/SRRouting/SRRouting.py
@@ -1303,6 +1303,14 @@
         lib.moveHost( main, "h1v4", "leaf1", "leaf1", "10.1.0.254", prefixLen=24, cfg=h1v4cfg )
         verify( main )
 
-        h13v4cfg = '''{"of:0000000000000006/7" : { "interfaces" : [ { "ips" : [ "10.5.20.254/24" ], "vlan-untagged": 20 } ] } }'''
+        h1v6cfg = '{"of:0000000000000001/8" : { "interfaces" : [ { "ips" : [ "1000::3ff/120" ], "vlan-untagged": 21 } ] } }'
+        lib.moveHost( main, "h1v6", "leaf1", "leaf1", "1000::3fe", prefixLen=128, cfg=h1v6cfg, ipv6=True )
+        verify( main )
+
+        h13v4cfg = '{"of:0000000000000006/7" : { "interfaces" : [ { "ips" : [ "10.5.20.254/24" ], "vlan-untagged": 20 } ] } }'
         lib.moveHost( main, "h13v4", "leaf6", "leaf6", "10.5.20.254", prefixLen=24, cfg=h13v4cfg )
         verify( main )
+
+        h13v6cfg = '{"of:0000000000000006/8" : { "interfaces" : [ { "ips" : [ "1012::3ff/120" ], "vlan-untagged": 26 } ] } }'
+        lib.moveHost( main, "h13v6", "leaf6", "leaf6", "1012::3fe", prefixLen=128, cfg=h13v6cfg, ipv6=True )
+        verify( main )
diff --git a/TestON/tests/USECASE/SegmentRouting/dependencies/Testcaselib.py b/TestON/tests/USECASE/SegmentRouting/dependencies/Testcaselib.py
index ad39667..6c44c63 100644
--- a/TestON/tests/USECASE/SegmentRouting/dependencies/Testcaselib.py
+++ b/TestON/tests/USECASE/SegmentRouting/dependencies/Testcaselib.py
@@ -1251,20 +1251,21 @@
             cfg: port configuration as JSON string
             ipv6: Use True to move IPv6 host
         """
-
         if not hasattr( main, 'Mininet1' ):
             main.log.warn( "moveHost is supposed to be used only in Mininet." )
             return
 
+        main.step( "Moving host {} from {} to {}".format( hostName, srcSw, dstSw ) )
         if ipv6:
-            main.Mininet1.moveHostv6( hostName, srcSw, dstSw, macAddr )
+            main.Mininet1.moveHostv6( hostName, srcSw, dstSw, macAddr, prefixLen )
         else:
             main.Mininet1.moveHost( hostName, srcSw, dstSw, macAddr, prefixLen )
-
-        main.Mininet1.changeDefaultGateway( hostName, gw )
+            main.Mininet1.changeDefaultGateway( hostName, gw )
         if cfg:
             main.Cluster.active( 0 ).REST.setNetCfg( json.loads( cfg ),
                                                      subjectClass="ports" )
+            # Wait for the host to get RA for setting up default gateway
+            time.sleep( 5 )
 
         main.Mininet1.discoverHosts( [ hostName, ] )