Now test pushes SR configuration via REST

Fixed Styling

Change-Id: I481da929ce9818b3aa73f3386f6c135ed55686a6
diff --git a/TestON/tests/USECASE/SegmentRouting/SRSanity/SRSanity.py b/TestON/tests/USECASE/SegmentRouting/SRSanity/SRSanity.py
index 631248b..c69645f 100755
--- a/TestON/tests/USECASE/SegmentRouting/SRSanity/SRSanity.py
+++ b/TestON/tests/USECASE/SegmentRouting/SRSanity/SRSanity.py
@@ -1,13 +1,12 @@
 # This test should always succeed. it runs cases 1,2,3
-#CASE1: 2x2 Leaf-Spine topo and test IP connectivity
-#CASE2: 4x4 topo + IP connectivity test
-#CASE3: Single switch topo + IP connectivity test
-#CASE4: 2x2 topo + 3-node ONOS CLUSTER + IP connectivity test
-#CASE5: 4x4 topo + 3-node ONOS CLUSTER + IP connectivity test
-#CASE6: Single switch + 3-node ONOS CLUSTER + IP connectivity test
+# CASE1: 2x2 Leaf-Spine topo and test IP connectivity
+# CASE2: 4x4 topo + IP connectivity test
+# CASE3: Single switch topo + IP connectivity test
+# CASE4: 2x2 topo + 3-node ONOS CLUSTER + IP connectivity test
+# CASE5: 4x4 topo + 3-node ONOS CLUSTER + IP connectivity test
+# CASE6: Single switch + 3-node ONOS CLUSTER + IP connectivity test
 
 class SRSanity:
-
     def __init__( self ):
         self.default = ''
 
@@ -17,26 +16,27 @@
         Start 2x2 Leaf-Spine topology
         Pingall
         """
-        from tests.USECASE.SegmentRouting.dependencies.Testcaselib import Testcaselib as run
-        if not hasattr(main,'apps'):
-            run.initTest(main)
+        from tests.USECASE.SegmentRouting.dependencies.Testcaselib import \
+            Testcaselib as run
+        if not hasattr( main, 'apps' ):
+            run.initTest( main )
 
         description = "Bridging and Routing sanity test with 2x2 Leaf-spine "
         main.case( description )
 
         main.cfgName = '2x2'
         main.numCtrls = 1
-        run.installOnos(main)
-        run.startMininet(main, 'cord_fabric.py')
-        #pre-configured routing and bridging test
-        run.checkFlows(main, minFlowCount=116)
-        run.pingAll(main, "CASE1")
-        #TODO Dynamic config of hosts in subnet
-        #TODO Dynamic config of host not in subnet
-        #TODO Dynamic config of vlan xconnect
-        #TODO Vrouter integration
-        #TODO Mcast integration
-        run.cleanup(main)
+        run.installOnos( main )
+        run.startMininet( main, 'cord_fabric.py' )
+        # pre-configured routing and bridging test
+        run.checkFlows( main, minFlowCount=116 )
+        run.pingAll( main, "CASE1" )
+        # TODO Dynamic config of hosts in subnet
+        # TODO Dynamic config of host not in subnet
+        # TODO Dynamic config of vlan xconnect
+        # TODO Vrouter integration
+        # TODO Mcast integration
+        run.cleanup( main )
 
     def CASE2( self, main ):
         """
@@ -44,24 +44,25 @@
         Start 4x4 Leaf-Spine topology
         Pingall
         """
-        from tests.USECASE.SegmentRouting.dependencies.Testcaselib import Testcaselib as run
-        if not hasattr(main,'apps'):
-            run.initTest(main)
+        from tests.USECASE.SegmentRouting.dependencies.Testcaselib import \
+            Testcaselib as run
+        if not hasattr( main, 'apps' ):
+            run.initTest( main )
         description = "Bridging and Routing sanity test with 4x4 Leaf-spine "
         main.case( description )
         main.cfgName = '4x4'
         main.numCtrls = 1
-        run.installOnos(main)
-        run.startMininet(main, 'cord_fabric.py', args="--leaf=4 --spine=4")
-        #pre-configured routing and bridging test
-        run.checkFlows(main, minFlowCount=350)
-        run.pingAll(main, 'CASE2')
-        #TODO Dynamic config of hosts in subnet
-        #TODO Dynamic config of host not in subnet
-        #TODO Dynamic config of vlan xconnect
-        #TODO Vrouter integration
-        #TODO Mcast integration
-        run.cleanup(main)
+        run.installOnos( main )
+        run.startMininet( main, 'cord_fabric.py', args="--leaf=4 --spine=4" )
+        # pre-configured routing and bridging test
+        run.checkFlows( main, minFlowCount=350 )
+        run.pingAll( main, 'CASE2' )
+        # TODO Dynamic config of hosts in subnet
+        # TODO Dynamic config of host not in subnet
+        # TODO Dynamic config of vlan xconnect
+        # TODO Vrouter integration
+        # TODO Mcast integration
+        run.cleanup( main )
 
     def CASE3( self, main ):
         """
@@ -69,24 +70,25 @@
         Start single switch topology
         Pingall
         """
-        from tests.USECASE.SegmentRouting.dependencies.Testcaselib import Testcaselib as run
-        if not hasattr(main,'apps'):
-            run.initTest(main)
+        from tests.USECASE.SegmentRouting.dependencies.Testcaselib import \
+            Testcaselib as run
+        if not hasattr( main, 'apps' ):
+            run.initTest( main )
         description = "Bridging and Routing sanity test with single switch "
         main.case( description )
         main.cfgName = '0x1'
         main.numCtrls = 1
-        run.installOnos(main)
-        run.startMininet(main, 'cord_fabric.py', args="--leaf=1 --spine=0")
-        #pre-configured routing and bridging test
-        run.checkFlows(main, minFlowCount=15)
-        run.pingAll(main, 'CASE3')
-        #TODO Dynamic config of hosts in subnet
-        #TODO Dynamic config of host not in subnet
-        #TODO Dynamic config of vlan xconnect
-        #TODO Vrouter integration
-        #TODO Mcast integration
-        run.cleanup(main)
+        run.installOnos( main )
+        run.startMininet( main, 'cord_fabric.py', args="--leaf=1 --spine=0" )
+        # pre-configured routing and bridging test
+        run.checkFlows( main, minFlowCount=15 )
+        run.pingAll( main, 'CASE3' )
+        # TODO Dynamic config of hosts in subnet
+        # TODO Dynamic config of host not in subnet
+        # TODO Dynamic config of vlan xconnect
+        # TODO Vrouter integration
+        # TODO Mcast integration
+        run.cleanup( main )
 
     def CASE4( self, main ):
         """
@@ -94,24 +96,25 @@
         Start 2x2 Leaf-Spine topology
         Pingall
         """
-        from tests.USECASE.SegmentRouting.dependencies.Testcaselib import Testcaselib as run
-        if not hasattr(main,'apps'):
-            run.initTest(main)
+        from tests.USECASE.SegmentRouting.dependencies.Testcaselib import \
+            Testcaselib as run
+        if not hasattr( main, 'apps' ):
+            run.initTest( main )
         description = "Bridging and Routing sanity test with 2x2 Leaf-spine "
         main.case( description )
         main.cfgName = '2x2'
         main.numCtrls = 3
-        run.installOnos(main)
-        run.startMininet(main, 'cord_fabric.py')
-        #pre-configured routing and bridging test
-        run.checkFlows(main, minFlowCount=116)
-        run.pingAll(main, 'CASE4')
-        #TODO Dynamic config of hosts in subnet
-        #TODO Dynamic config of host not in subnet
-        #TODO Dynamic config of vlan xconnect
-        #TODO Vrouter integration
-        #TODO Mcast integration
-        run.cleanup(main)
+        run.installOnos( main )
+        run.startMininet( main, 'cord_fabric.py' )
+        # pre-configured routing and bridging test
+        run.checkFlows( main, minFlowCount=116 )
+        run.pingAll( main, 'CASE4' )
+        # TODO Dynamic config of hosts in subnet
+        # TODO Dynamic config of host not in subnet
+        # TODO Dynamic config of vlan xconnect
+        # TODO Vrouter integration
+        # TODO Mcast integration
+        run.cleanup( main )
 
     def CASE5( self, main ):
         """
@@ -119,24 +122,25 @@
         Start 4x4 Leaf-Spine topology
         Pingall
         """
-        from tests.USECASE.SegmentRouting.dependencies.Testcaselib import Testcaselib as run
-        if not hasattr(main,'apps'):
-            run.initTest(main)
+        from tests.USECASE.SegmentRouting.dependencies.Testcaselib import \
+            Testcaselib as run
+        if not hasattr( main, 'apps' ):
+            run.initTest( main )
         description = "Bridging and Routing sanity test with 4x4 Leaf-spine "
         main.case( description )
         main.cfgName = '4x4'
         main.numCtrls = 3
-        run.installOnos(main)
-        run.startMininet(main, 'cord_fabric.py', args="--leaf=4 --spine=4")
-        #pre-configured routing and bridging test
-        run.checkFlows(main, minFlowCount=350)
-        run.pingAll(main, 'CASE5')
-        #TODO Dynamic config of hosts in subnet
-        #TODO Dynamic config of host not in subnet
-        #TODO Dynamic config of vlan xconnect
-        #TODO Vrouter integration
-        #TODO Mcast integration
-        run.cleanup(main)
+        run.installOnos( main )
+        run.startMininet( main, 'cord_fabric.py', args="--leaf=4 --spine=4" )
+        # pre-configured routing and bridging test
+        run.checkFlows( main, minFlowCount=350 )
+        run.pingAll( main, 'CASE5' )
+        # TODO Dynamic config of hosts in subnet
+        # TODO Dynamic config of host not in subnet
+        # TODO Dynamic config of vlan xconnect
+        # TODO Vrouter integration
+        # TODO Mcast integration
+        run.cleanup( main )
 
     def CASE6( self, main ):
         """
@@ -144,21 +148,22 @@
         Start single switch topology
         Pingall
         """
-        from tests.USECASE.SegmentRouting.dependencies.Testcaselib import Testcaselib as run
-        if not hasattr(main,'apps'):
-            run.initTest(main)
+        from tests.USECASE.SegmentRouting.dependencies.Testcaselib import \
+            Testcaselib as run
+        if not hasattr( main, 'apps' ):
+            run.initTest( main )
         description = "Bridging and Routing sanity test with single switch "
         main.case( description )
         main.cfgName = '0x1'
         main.numCtrls = 3
-        run.installOnos(main)
-        run.startMininet(main, 'cord_fabric.py', args="--leaf=1 --spine=0")
-        #pre-configured routing and bridging test
-        run.checkFlows(main, minFlowCount=15)
-        run.pingAll(main, 'CASE4')
-        #TODO Dynamic config of hosts in subnet
-        #TODO Dynamic config of host not in subnet
-        #TODO Dynamic config of vlan xconnect
-        #TODO Vrouter integration
-        #TODO Mcast integration
-        run.cleanup(main)
\ No newline at end of file
+        run.installOnos( main )
+        run.startMininet( main, 'cord_fabric.py', args="--leaf=1 --spine=0" )
+        # pre-configured routing and bridging test
+        run.checkFlows( main, minFlowCount=15 )
+        run.pingAll( main, 'CASE4' )
+        # TODO Dynamic config of hosts in subnet
+        # TODO Dynamic config of host not in subnet
+        # TODO Dynamic config of vlan xconnect
+        # TODO Vrouter integration
+        # TODO Mcast integration
+        run.cleanup( main )
diff --git a/TestON/tests/USECASE/SegmentRouting/SRSanity/SRSanity.topo b/TestON/tests/USECASE/SegmentRouting/SRSanity/SRSanity.topo
index 546a023..c531f7d 100755
--- a/TestON/tests/USECASE/SegmentRouting/SRSanity/SRSanity.topo
+++ b/TestON/tests/USECASE/SegmentRouting/SRSanity/SRSanity.topo
@@ -42,13 +42,45 @@
             </COMPONENTS>
         </ONOScli3>
 
+        <ONOSrest1>
+            <host>OC1</host>
+            <port>8181</port>
+            <user>onos</user>
+            <password>rocks</password>
+            <type>OnosRestDriver</type>
+            <connect_order>5</connect_order>
+            <COMPONENTS>
+            </COMPONENTS>
+        </ONOSrest1>
+
+        <ONOSrest2>
+            <host>OC2</host>
+            <port>8181</port>
+            <user>onos</user>
+            <password>rocks</password>
+            <type>OnosRestDriver</type>
+            <connect_order>6</connect_order>
+            <COMPONENTS>
+            </COMPONENTS>
+        </ONOSrest2>
+
+        <ONOSrest3>
+            <host>OC3</host>
+            <port>8181</port>
+            <user>onos</user>
+            <password>rocks</password>
+            <type>OnosRestDriver</type>
+            <connect_order>6</connect_order>
+            <COMPONENTS>
+            </COMPONENTS>
+        </ONOSrest3>
 
         <Mininet1>
             <host>OCN</host>
             <user>sdn</user>
             <password>rocks</password>
             <type>MininetCliDriver</type>
-            <connect_order>5</connect_order>
+            <connect_order>7</connect_order>
             <COMPONENTS>
                 <home>~/mininet/custom/</home>
             </COMPONENTS>
diff --git a/TestON/tests/USECASE/SegmentRouting/dependencies/0x1.json b/TestON/tests/USECASE/SegmentRouting/dependencies/0x1.json
index 0ba5dbd..8232036 100755
--- a/TestON/tests/USECASE/SegmentRouting/dependencies/0x1.json
+++ b/TestON/tests/USECASE/SegmentRouting/dependencies/0x1.json
@@ -28,13 +28,6 @@
             }
         }
     },
-    "apps": {
-        "org.onosproject.segmentrouting": {
-          "segmentrouting": {
-            "hostLearning": true
-          }
-        }
-    },
     "hosts" : {
         "00:00:00:00:00:01/-1" : {
             "basic": {
diff --git a/TestON/tests/USECASE/SegmentRouting/dependencies/Testcaselib.py b/TestON/tests/USECASE/SegmentRouting/dependencies/Testcaselib.py
index 3ba3cc0..1e31cd3 100755
--- a/TestON/tests/USECASE/SegmentRouting/dependencies/Testcaselib.py
+++ b/TestON/tests/USECASE/SegmentRouting/dependencies/Testcaselib.py
@@ -1,6 +1,7 @@
 import os

 import imp

 import time

+import json

 

 from core import utilities

 

@@ -34,10 +35,12 @@
         main.cellData = {} # for creating cell file

         main.CLIs = []

         main.ONOSip = []

+        main.RESTs= []

 

         # Assigning ONOS cli handles to a list

         for i in range( 1,  main.maxNodes + 1 ):

             main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )

+            main.RESTs.append( getattr( main, 'ONOSrest' + str( i ) ) )

             main.ONOSip.append( main.CLIs[i-1].ip_address )

         # -- INIT SECTION, ONLY RUNS ONCE -- #

         main.startUp = imp.load_source( wrapperFile1,

@@ -108,7 +111,6 @@
         for i in range( main.maxNodes ):

             main.ONOSbench.onosDie( main.ONOSip[ i ] )

         main.step( "Create and Install ONOS package" )

-        main.ONOSbench.handle.sendline( "cp "+main.dependencyPath+"/"+main.cfgName+".json ~/onos/tools/package/config/network-cfg.json")

         packageResult = main.ONOSbench.onosPackage()

 

         onosInstallResult = main.TRUE

@@ -163,6 +165,9 @@
                                  onpass="ONOS summary command succeded",

                                  onfail="ONOS summary command failed" )

 

+        with open( main.dependencyPath + "/" + main.cfgName + ".json" ) as cfg:

+            main.RESTs[main.active].setNetCfg( json.load(cfg) )

+

         if not ready:

             main.log.error( "ONOS startup failed!" )

             main.cleanup()

@@ -245,7 +250,7 @@
         LinkDown = main.Mininet1.link( END1=end1, END2=end2, OPTION="down" )

         main.log.info( "Waiting %s seconds for link down to be discovered" % main.linkSleep )

         time.sleep( main.linkSleep )

-        topology =  utilities.retry( main.CLIs[main.active].checkStatus,

+        topology =  utilities.retry( main.CLIs[ main.active ].checkStatus,

                                      main.FALSE,

                                      kwargs={'numoswitch':switches, 'numolink':links},

                                      attempts=10,

@@ -334,9 +339,9 @@
         Copies ONOS log

         """

         main.Mininet1.stopNet()

-        main.ONOSbench.scp( main.ONOScli1 ,"/opt/onos/log/karaf.log",

+        main.ONOSbench.scp( main.ONOScli1, "/opt/onos/log/karaf.log",

                            "/tmp/karaf.log", direction="from" )

-        main.ONOSbench.cpLogsToDir("/tmp/karaf.log",main.logdir,

-                                   copyFileName="karaf.log."+main.cfgName)

-        for i in range(main.numCtrls):

+        main.ONOSbench.cpLogsToDir( "/tmp/karaf.log", main.logdir,

+                                   copyFileName="karaf.log."+main.cfgName )

+        for i in range( main.numCtrls ):

             main.ONOSbench.onosStop( main.ONOSip[i] )