Merge "change hard-coded fsfw controller address to BM1"
diff --git a/TestON/drivers/common/cli/emulator/mininetclidriver.py b/TestON/drivers/common/cli/emulator/mininetclidriver.py
index 8165d3a..b38e257 100644
--- a/TestON/drivers/common/cli/emulator/mininetclidriver.py
+++ b/TestON/drivers/common/cli/emulator/mininetclidriver.py
@@ -2174,71 +2174,80 @@
         returns: A list of flows in json format
         '''
         jsonFlowTable = []
-        for flow in flowTable:
-            jsonFlow = {}
-            # split up the fields of the flow
-            parsedFlow = flow.split(", ")
-            # get rid of any spaces in front of the field
-            for i in range( len(parsedFlow) ):
-                item = parsedFlow[i]
-                if item[0] == " ":
-                    parsedFlow[i] = item[1:]
-            # grab the selector and treatment from the parsed flow
-            # the last element is the selector and the treatment
-            temp = parsedFlow.pop(-1)
-            # split up the selector and the treatment
-            temp = temp.split(" ")
-            index = 0
-            # parse the flags
-            # NOTE: This only parses one flag
-            flag = {}
-            if version == "1.3":
-                flag = {"flag":[temp[index]]}
+        try:
+            for flow in flowTable:
+                jsonFlow = {}
+                # split up the fields of the flow
+                parsedFlow = flow.split(", ")
+                # get rid of any spaces in front of the field
+                for i in range( len(parsedFlow) ):
+                    item = parsedFlow[i]
+                    if item[0] == " ":
+                        parsedFlow[i] = item[1:]
+                # grab the selector and treatment from the parsed flow
+                # the last element is the selector and the treatment
+                temp = parsedFlow.pop(-1)
+                # split up the selector and the treatment
+                temp = temp.split(" ")
+                index = 0
+                # parse the flags
+                # NOTE: This only parses one flag
+                flag = {}
+                if version == "1.3":
+                    flag = {"flag":[temp[index]]}
+                    index += 1
+                # the first element is the selector and split it up
+                sel = temp[index]
                 index += 1
-            # the first element is the selector and split it up
-            sel = temp[index]
-            index += 1
-            sel = sel.split(",")
-            # the priority is stuck in the selecter so put it back
-            # in the flow
-            parsedFlow.append(sel.pop(0))
-            # parse selector
-            criteria = []
-            for item in sel:
-                # this is the type of the packet e.g. "arp"
-                if "=" not in item:
-                    criteria.append( {"type":item} )
-                else:
+                sel = sel.split(",")
+                # the priority is stuck in the selecter so put it back
+                # in the flow
+                parsedFlow.append(sel.pop(0))
+                # parse selector
+                criteria = []
+                for item in sel:
+                    # this is the type of the packet e.g. "arp"
+                    if "=" not in item:
+                        criteria.append( {"type":item} )
+                    else:
+                        field = item.split("=")
+                        criteria.append( {field[0]:field[1]} )
+                selector = {"selector": {"criteria":sorted(criteria)} }
+                treat = temp[index]
+                # get rid of the action part e.g. "action=output:2"
+                # we will add it back later
+                treat = treat.split("=")
+                treat.pop(0)
+                # parse treatment
+                action = []
+                for item in treat:
+                    field = item.split(":")
+                    action.append( {field[0]:field[1]} )
+                # create the treatment field and add the actions
+                treatment = {"treatment": {"action":sorted(action)} }
+                # parse the rest of the flow
+                for item in parsedFlow:
                     field = item.split("=")
-                    criteria.append( {field[0]:field[1]} )
-            selector = {"selector": {"criteria":sorted(criteria)} }
-            treat = temp[index]
-            # get rid of the action part e.g. "action=output:2"
-            # we will add it back later
-            treat = treat.split("=")
-            treat.pop(0)
-            # parse treatment
-            action = []
-            for item in treat:
-                field = item.split(":")
-                action.append( {field[0]:field[1]} )
-            # create the treatment field and add the actions
-            treatment = {"treatment": {"action":sorted(action)} }
-            # parse the rest of the flow
-            for item in parsedFlow:
-                field = item.split("=")
-                jsonFlow.update( {field[0]:field[1]} )
-            # add the treatment and the selector to the json flow
-            jsonFlow.update( selector )
-            jsonFlow.update( treatment )
-            jsonFlow.update( flag )
+                    jsonFlow.update( {field[0]:field[1]} )
+                # add the treatment and the selector to the json flow
+                jsonFlow.update( selector )
+                jsonFlow.update( treatment )
+                jsonFlow.update( flag )
 
-            if debug: main.log.debug( "\033[94mJson flow:\033[0m\n{}\n".format(jsonFlow) )
+                if debug: main.log.debug( "\033[94mJson flow:\033[0m\n{}\n".format(jsonFlow) )
 
-            # add the json flow to the json flow table
-            jsonFlowTable.append( jsonFlow )
+                # add the json flow to the json flow table
+                jsonFlowTable.append( jsonFlow )
 
-        return jsonFlowTable
+            return jsonFlowTable
+
+        except IndexError:
+            main.log.exception( self.name + ": IndexError found" )
+            return None
+        except Exception:
+            main.log.exception( self.name + ": Uncaught exception!" )
+            main.cleanup()
+            main.exit()
 
     def getFlowTable( self, sw, version="", debug=False):
         '''
@@ -2312,6 +2321,8 @@
         try:
             main.log.info( "Getting flows from Mininet" )
             flows = self.getFlowTable( sw, version, debug )
+            if flows == None:
+                return main.ERROR
 
             if debug: print "flow ids:\n{}\n\n".format(flowId)
 
diff --git a/TestON/tests/HA/HAscaling/HAscaling.params b/TestON/tests/HA/HAscaling/HAscaling.params
index ff4e306..388f432 100644
--- a/TestON/tests/HA/HAscaling/HAscaling.params
+++ b/TestON/tests/HA/HAscaling/HAscaling.params
@@ -17,9 +17,9 @@
     #CASE15: Check that Leadership Election is still functional
     #CASE16: Install Distributed Primitives app
     #CASE17: Check for basic functionality with distributed primitives
-    <testcases>1,[2,8,21,3,8,4,5,14,16,17]*1,[6,8,3,7,4,15,17,9,8,4,10,8,4,11,8,4,12,8,4]*13,13</testcases>
+    <testcases>1,2,8,21,3,8,4,5,14,16,17,[6,8,7,4,15,17]*9,9,8,4,10,8,4,11,8,4,12,8,4,13</testcases>
 
-    <scaling>1,3b,3,5b,5,7b,7,7b,5,5b,3,3b,1</scaling>
+    <scaling>1,3b,5b,7b,7,7b,5b,3b,1</scaling>
     <server>
         <port>8000</port>
         <interface>eth0</interface>
diff --git a/TestON/tests/SCPF/SCPFscalingMaxIntents/SCPFscalingMaxIntents.py b/TestON/tests/SCPF/SCPFscalingMaxIntents/SCPFscalingMaxIntents.py
index 608f0e6..a6f4445 100644
--- a/TestON/tests/SCPF/SCPFscalingMaxIntents/SCPFscalingMaxIntents.py
+++ b/TestON/tests/SCPF/SCPFscalingMaxIntents/SCPFscalingMaxIntents.py
@@ -483,6 +483,7 @@
                 if not intentsState:
                     # If some intents are not installed, grep the previous flows list, and finished this test case
                     main.log.warn( "Some intens did not install" )
+                    verifyTotalIntents = main.CLIs[0].getTotalIntentsNum(timeout=600)
                     main.log.info("Total Intents: {}".format( verifyTotalIntents) )
                     break
 
diff --git a/TestON/tests/SCPF/SCPFscalingMaxIntentsWithFlowObj/SCPFscalingMaxIntentsWithFlowObj.py b/TestON/tests/SCPF/SCPFscalingMaxIntentsWithFlowObj/SCPFscalingMaxIntentsWithFlowObj.py
index 97dc6f3..438338a 100644
--- a/TestON/tests/SCPF/SCPFscalingMaxIntentsWithFlowObj/SCPFscalingMaxIntentsWithFlowObj.py
+++ b/TestON/tests/SCPF/SCPFscalingMaxIntentsWithFlowObj/SCPFscalingMaxIntentsWithFlowObj.py
@@ -486,6 +486,7 @@
                 if not intentsState:
                     # If some intents are not installed, grep the previous flows list, and finished this test case
                     main.log.warn( "Some intens did not install" )
+                    verifyTotalIntents = main.CLIs[0].getTotalIntentsNum(timeout=600)
                     main.log.info("Total Intents: {}".format( totalIntents) )
                     break
 
diff --git a/TestON/tests/USECASE/USECASE_SdnipFunction_fsfw/USECASE_SdnipFunction_fsfw.topo b/TestON/tests/USECASE/USECASE_SdnipFunction_fsfw/USECASE_SdnipFunction_fsfw.topo
index 28ee510..9ba2e9e 100644
--- a/TestON/tests/USECASE/USECASE_SdnipFunction_fsfw/USECASE_SdnipFunction_fsfw.topo
+++ b/TestON/tests/USECASE/USECASE_SdnipFunction_fsfw/USECASE_SdnipFunction_fsfw.topo
@@ -17,7 +17,7 @@
             <type>OnosCliDriver</type>
             <connect_order>2</connect_order>
             <COMPONENTS> </COMPONENTS>
-        </ONOScli>
+        </ONOScli1>
 
         <ONOS1>
             <host>OC1</host>
diff --git a/TestON/tests/USECASE/USECASE_SegmentRouting/2x2.json b/TestON/tests/USECASE/USECASE_SegmentRouting/2x2.json
index 31b2cc8..a5ec00d 100644
--- a/TestON/tests/USECASE/USECASE_SegmentRouting/2x2.json
+++ b/TestON/tests/USECASE/USECASE_SegmentRouting/2x2.json
@@ -36,7 +36,7 @@
                 "name" : "Leaf-R1",
                 "nodeSid" : 1,
                 "routerIp" : "192.168.0.1",
-                "routerMac" : "00:00:00:00:00:01",
+                "routerMac" : "10:00:00:00:00:01",
                 "isEdgeRouter" : true,
                 "adjacencySids" : []
             }
@@ -47,7 +47,7 @@
                 "name" : "Leaf-R2",
                 "nodeSid" : 2,
                 "routerIp" : "192.168.0.2",
-                "routerMac" : "00:00:00:00:00:02",
+                "routerMac" : "10:00:00:00:00:02",
                 "isEdgeRouter" : true,
                 "adjacencySids" : []
             }
@@ -58,7 +58,7 @@
                 "name" : "Spine-R1",
                 "nodeSid" : 101,
                 "routerIp" : "192.168.0.101",
-                "routerMac" : "00:00:00:00:01:01",
+                "routerMac" : "10:00:00:00:01:01",
                 "isEdgeRouter" : false,
                 "adjacencySids" : []
             }
@@ -69,7 +69,7 @@
                 "name" : "Spine-R2",
                 "nodeSid" : 102,
                 "routerIp" : "192.168.0.102",
-                "routerMac" : "00:00:00:00:01:02",
+                "routerMac" : "10:00:00:00:01:02",
                 "isEdgeRouter" : false,
                 "adjacencySids" : []
             }
diff --git a/TestON/tests/USECASE/USECASE_SegmentRouting/4x4.json b/TestON/tests/USECASE/USECASE_SegmentRouting/4x4.json
index dee6bc3..7442359 100644
--- a/TestON/tests/USECASE/USECASE_SegmentRouting/4x4.json
+++ b/TestON/tests/USECASE/USECASE_SegmentRouting/4x4.json
@@ -64,7 +64,7 @@
                 "name" : "Leaf-R1",
                 "nodeSid" : 1,
                 "routerIp" : "192.168.0.1",
-                "routerMac" : "00:00:00:00:00:01",
+                "routerMac" : "10:00:00:00:00:01",
                 "isEdgeRouter" : true,
                 "adjacencySids" : []
             }
@@ -75,7 +75,7 @@
                 "name" : "Leaf-R2",
                 "nodeSid" : 2,
                 "routerIp" : "192.168.0.2",
-                "routerMac" : "00:00:00:00:00:02",
+                "routerMac" : "10:00:00:00:00:02",
                 "isEdgeRouter" : true,
                 "adjacencySids" : []
             }
@@ -86,7 +86,7 @@
                 "name" : "Leaf-R3",
                 "nodeSid" : 3,
                 "routerIp" : "192.168.0.3",
-                "routerMac" : "00:00:00:00:00:03",
+                "routerMac" : "10:00:00:00:00:03",
                 "isEdgeRouter" : true,
                 "adjacencySids" : []
             }
@@ -97,7 +97,7 @@
                 "name" : "Leaf-R4",
                 "nodeSid" : 4,
                 "routerIp" : "192.168.0.4",
-                "routerMac" : "00:00:00:00:00:04",
+                "routerMac" : "10:00:00:00:00:04",
                 "isEdgeRouter" : true,
                 "adjacencySids" : []
             }
@@ -108,7 +108,7 @@
                 "name" : "Spine-R1",
                 "nodeSid" : 101,
                 "routerIp" : "192.168.0.101",
-                "routerMac" : "00:00:00:00:01:01",
+                "routerMac" : "10:00:00:00:01:01",
                 "isEdgeRouter" : false,
                 "adjacencySids" : []
             }
@@ -119,7 +119,7 @@
                 "name" : "Spine-R2",
                 "nodeSid" : 102,
                 "routerIp" : "192.168.0.102",
-                "routerMac" : "00:00:00:00:01:02",
+                "routerMac" : "10:00:00:00:01:02",
                 "isEdgeRouter" : false,
                 "adjacencySids" : []
             }
@@ -130,7 +130,7 @@
                 "name" : "Spine-R3",
                 "nodeSid" : 103,
                 "routerIp" : "192.168.0.103",
-                "routerMac" : "00:00:00:00:01:03",
+                "routerMac" : "10:00:00:00:01:03",
                 "isEdgeRouter" : false,
                 "adjacencySids" : []
             }
@@ -141,7 +141,7 @@
                 "name" : "Spine-R4",
                 "nodeSid" : 104,
                 "routerIp" : "192.168.0.104",
-                "routerMac" : "00:00:00:00:01:04",
+                "routerMac" : "10:00:00:00:01:04",
                 "isEdgeRouter" : false,
                 "adjacencySids" : []
             }
diff --git a/TestON/tests/USECASE/USECASE_SegmentRouting/USECASE_SegmentRouting.params b/TestON/tests/USECASE/USECASE_SegmentRouting/USECASE_SegmentRouting.params
index 1ef9eea..15ce439 100755
--- a/TestON/tests/USECASE/USECASE_SegmentRouting/USECASE_SegmentRouting.params
+++ b/TestON/tests/USECASE/USECASE_SegmentRouting/USECASE_SegmentRouting.params
@@ -1,6 +1,6 @@
 <PARAMS>
 
-    <testcases>1,[2,3,4,10]*4</testcases>
+    <testcases>1,[2,3,4,4,10]*2</testcases>
 
     <SCALE>
         <size>1</size>
diff --git a/TestON/tests/USECASE/USECASE_SegmentRouting/USECASE_SegmentRouting.py b/TestON/tests/USECASE/USECASE_SegmentRouting/USECASE_SegmentRouting.py
index 9d96a43..f44966b 100755
--- a/TestON/tests/USECASE/USECASE_SegmentRouting/USECASE_SegmentRouting.py
+++ b/TestON/tests/USECASE/USECASE_SegmentRouting/USECASE_SegmentRouting.py
@@ -36,10 +36,10 @@
         main.path = os.path.dirname( main.testFile )
         main.dependencyPath = main.path + "/dependencies/"
         main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ]
-        #main.json = ["4x4"]
+        #main.json = ["0x1","0x1"]
         main.json = ["2x2", "2x2","4x4","4x4"]
         main.args = [" ", " ", " --spine 4 --leaf 4 ", " --spine 4 --leaf 4 "]
-        #main.args = [" --spine 4 --leaf 4 "]
+        #main.args = [" --spine 0 --leaf 1 "," --spine 0 --leaf 1 "]
         main.scale = ( main.params[ 'SCALE' ][ 'size' ] ).split( "," )
         main.maxNodes = int( main.params[ 'SCALE' ][ 'max' ] )
         main.ONOSport = main.params[ 'CTRL' ][ 'port' ]
@@ -114,18 +114,12 @@
         else: main.log.error( "App list is empty" )
         main.case( "Package and start ONOS using apps:" + apps)
 
-        #kill off all onos processes
-        main.log.info( "Safety check, killing all ONOS processes" +
-                       " before initiating environment setup" )
-
-        for i in range( main.maxNodes ):
-            main.ONOSbench.onosDie( main.ONOSip[ i ] )
-
         print "NODE COUNT = ", main.numCtrls
 
         tempOnosIp = []
         for i in range( main.numCtrls ):
             tempOnosIp.append( main.ONOSip[i] )
+
         onosUser = main.params[ 'ENV' ][ 'cellUser' ]
         main.step("Create and Apply cell file")
         main.ONOSbench.createCellFile( main.ONOSbench.ip_address,
@@ -143,6 +137,12 @@
                                  onpass="Successfully applied cell to " + \
                                         "environment",
                                  onfail="Failed to apply cell to environment " )
+        #kill off all onos processes
+        main.log.info( "Safety check, killing all ONOS processes" +
+                       " before initiating environment setup" )
+
+        for i in range( main.maxNodes ):
+            main.ONOSbench.onosDie( main.ONOSip[ i ] )
 
         main.step( "Create and Install ONOS package" )
         main.jsonFile=main.json.pop(0)
@@ -193,8 +193,10 @@
         #time.sleep( 2*main.startUpSleep )
         #main.ONOSbench.handle.sendline( "onos-secure-ssh")
         main.step( "Checking if ONOS CLI is ready" )
+        cellResult = main.CLIs[0].setCell( "temp" )
+
         cliResult = main.CLIs[0].startOnosCli( main.ONOSip[ 0 ],
-                                           commandlineTimeout=100, onosStartTimeout=600 )
+                                           commandlineTimeout=60, onosStartTimeout=100 )
         utilities.assert_equals( expect=main.TRUE,
                              actual=cliResult,
                              onpass="ONOS CLI is ready",
@@ -216,27 +218,6 @@
             main.cleanup()
             main.exit()
 
-    def CASE10( self, main ):
-        '''
-            Report errors/warnings/exceptions
-        '''
-        main.case( "Logging test for " + main.jsonFile )
-        #if len(main.json) > 0 :
-        main.ONOSbench.cpLogsToDir("/opt/onos/log/karaf.log",main.logdir, 
-                           copyFileName="karaf.log."+main.jsonFile+str(len(main.json)))
-        #main.ONOSbench.logReport( main.ONOSip[ 0 ],
-        #                          [ "INFO" ],
-        #                          "a" )
-        #main.log.info("Error report: \n" )
-        main.ONOSbench.logReport( main.ONOSip[ 0 ],
-                                  [ "INFO",
-                                    "FOLLOWER",
-                                    "WARN",
-                                    "flow",
-                                    "ERROR",
-                                    "Except" ],
-                                  "s" )
-
     def CASE3( self, main ):
         """
             Start mininet
@@ -267,7 +248,7 @@
         main.step(" Check whether the flow count is bigger than 80" )
         count =  utilities.retry( main.CLIs[0].checkFlowCount,
                                  main.FALSE,
-                                 kwargs={'min':80},
+                                 kwargs={'min':10},
                                  attempts=10 )
         utilities.assertEquals( \
             expect=True,
@@ -290,37 +271,45 @@
         main.ONOSbench.dumpGroups( main.ONOSip[0],
                                    main.logdir, "groupsBefore" + main.jsonFile)
         #time.sleep( 3*main.startUpSleep)
+        main.count=1
 
     def CASE4( self, main ):
         main.case( "Check full connectivity" )
         main.log.report( "Check full connectivity" )
 
-        main.step("1st Check full connectivity")
+        main.step("Check full connectivity"+str(main.count))
         pa = main.Mininet1.pingall()
         utilities.assert_equals( expect=main.TRUE, actual=pa,
                                  onpass="Full connectivity successfully tested",
                                  onfail="Full connectivity failed" )
         # cleanup mininet
         main.ONOSbench.dumpFlows( main.ONOSip[0],
-                 main.logdir, "flowsAfter" + main.jsonFile)
+                 main.logdir, "flowsAfter" + str(main.count) + main.jsonFile)
         main.ONOSbench.dumpGroups( main.ONOSip[0],
-                           main.logdir, "groupsAfter" + main.jsonFile)
-        main.step("2nd Check full connectivity")
-        pa = main.Mininet1.pingall()
-        utilities.assert_equals( expect=main.TRUE, actual=pa,
-                                 onpass="Full connectivity successfully tested",
-                                 onfail="Full connectivity failed" )
+                           main.logdir, "groupsAfter" + str(main.count) + main.jsonFile)
 
-        main.ONOSbench.dumpFlows( main.ONOSip[0],
-                 main.logdir, "flowsAfter2nd" + main.jsonFile)
-
-        main.ONOSbench.dumpGroups( main.ONOSip[0],
-                                  main.logdir, "groupsAfter2nd" + main.jsonFile)
-
+    def CASE10( self, main ):
+        '''
+            Report errors/warnings/exceptions
+        '''
+        main.case( "Logging test for " + main.jsonFile )
+        #if len(main.json) > 0 :
         main.ONOSbench.onosStop( main.ONOSip[0] )
         main.Mininet1.stopNet()
-
-
+        main.ONOSbench.cpLogsToDir("/opt/onos/log/karaf.log",main.logdir,
+                                   copyFileName="karaf.log."+main.jsonFile+str(len(main.json)))
+        #main.ONOSbench.logReport( main.ONOSip[ 0 ],
+        #                          [ "INFO" ],
+        #                          "a" )
+        #main.log.info("Error report: \n" )
+        main.ONOSbench.logReport( main.ONOSip[ 0 ],
+                                  [ "INFO",
+                                    "FOLLOWER",
+                                    "WARN",
+                                    "flow",
+                                    "ERROR",
+                                    "Except" ],
+                                  "s" )