Add TOST spine failure tests

- Add SRONLReboot
- Add SRstratumRestart
- Refactoring SR Staging functions
- Use Network bench component to send traffic
- Add params file for 2x2 qa pod
- Add saving p4 write requests files

Change-Id: I60e43e2acde8b86cab0e47d62533fcf14937702d
diff --git a/TestON/tests/USECASE/SegmentRouting/SRBridging/SRBridging.params.tofino b/TestON/tests/USECASE/SegmentRouting/SRBridging/SRBridging.params.tofino
index 00666bc..04818d4 100644
--- a/TestON/tests/USECASE/SegmentRouting/SRBridging/SRBridging.params.tofino
+++ b/TestON/tests/USECASE/SegmentRouting/SRBridging/SRBridging.params.tofino
@@ -1,5 +1,5 @@
 <PARAMS>
-    <testcases>1</testcases>
+    <testcases>3</testcases>
 
     <GRAPH>
         <nodeCluster>QA-Pod</nodeCluster>
@@ -34,17 +34,28 @@
     </kubernetes>
 
     <PERF>
-        <traffic_host>Host3</traffic_host>
-        <traffic_container>mlabbe/iperf</traffic_container>
-        <traffic_container_arguments>--net=host  -v /proc/net/arp:/host/arp --rm</traffic_container_arguments>
-        <traffic_cmd_arguments> -u -b 20M -t 20</traffic_cmd_arguments>
-
-        <pcap_host>Host4</pcap_host>
-        <pcap_container>toendeavour/tshark</pcap_container>
-        <pcap_container_arguments>--cap-add=NET_RAW --cap-add=NET_ADMIN --net=host --rm -v ~/TestON/tshark/:/tshark</pcap_container_arguments>
-        <pcap_cmd_arguments>-t e -F pcap</pcap_cmd_arguments>
-        <pcap_cmd_arguments2>-t e -F pcap</pcap_cmd_arguments2>
-
+        <traffic_host>Host2</traffic_host>
+        <pcap_host>ng40vm</pcap_host>
+        <pcap_cmd_arguments>-t e -F pcap -s 100 </pcap_cmd_arguments>
+        <iterations>1</iterations>
+        <topo>
+            <leaf1>
+                <ports>260 268 276 284</ports>
+                <note>eNB</note>
+            </leaf1>
+            <leaf2>
+                <ports>132 140 148 156</ports>
+                <note>upstream</note>
+            </leaf2>
+            <spine1>
+                <ports>132 140 148 156</ports>
+                <note>spine</note>
+            </spine1>
+            <spine2>
+                <ports>132 140 148 156</ports>
+                <note>spine</note>
+            </spine2>
+        </topo>
     </PERF>
 
 
@@ -99,6 +110,7 @@
     <timers>
         <LinkDiscovery>12</LinkDiscovery>
         <SwitchDiscovery>12</SwitchDiscovery>
+        <TrafficDiscovery>10</TrafficDiscovery>
     </timers>
 
     <SLEEP>
@@ -106,8 +118,8 @@
     </SLEEP>
 
     <TOPO>
-        <switchNum>1</switchNum>
-        <linkNum>0</linkNum>
+        <switchNum>4</switchNum>
+        <linkNum>16</linkNum>
     </TOPO>
 
     <ALARM>
diff --git a/TestON/tests/USECASE/SegmentRouting/SRBridging/SRBridging.topo.2x2.physical b/TestON/tests/USECASE/SegmentRouting/SRBridging/SRBridging.topo.2x2.physical
new file mode 100644
index 0000000..a236f9f
--- /dev/null
+++ b/TestON/tests/USECASE/SegmentRouting/SRBridging/SRBridging.topo.2x2.physical
@@ -0,0 +1,173 @@
+<TOPOLOGY>
+    <COMPONENT>
+        <ONOScell>
+            <host>localhost</host>  # ONOS "bench" machine
+            <user>sdn</user>
+            <password>rocks</password>
+            <type>OnosClusterDriver</type>
+            <connect_order>1</connect_order>
+            <home></home>   # defines where onos home is on the build machine. Defaults to "~/onos/" if empty.
+            <COMPONENTS>
+                <kubeConfig>~/.kube/qa-ace-menlo</kubeConfig>  # If set, will attempt to use this file for setting up port-forwarding
+                <useDocker>True</useDocker>  # Whether to use docker for ONOS nodes
+                <docker_prompt>\$</docker_prompt>
+                <cluster_name></cluster_name>  # Used as a prefix for cluster components. Defaults to 'ONOS'
+                <diff_clihost>True</diff_clihost> # if it has different host other than localhost for CLI. True or empty. OC# will be used if True.
+                <karaf_username>karaf</karaf_username>
+                <karaf_password>karaf</karaf_password>
+                <web_user>karaf</web_user>
+                <web_pass>karaf</web_pass>
+                <rest_port></rest_port>
+                <prompt></prompt>  # TODO: we technically need a few of these, one per component
+                <onos_home></onos_home>  # defines where onos home is on the target cell machine. Defaults to entry in "home" if empty.
+                <nodes> 7 </nodes>  # number of nodes in the cluster
+            </COMPONENTS>
+        </ONOScell>
+
+        <Leaf1>
+            <host>10.128.13.209</host>
+            <user>root</user>
+            <password>onl</password>
+            <type>StratumOSSwitchDriver</type>
+            <connect_order>2</connect_order>
+            <COMPONENTS>
+                <prompt>#</prompt>
+                <shortName>leaf1</shortName>
+                <port1>1</port1>
+                <link1>Host1</link1>
+                <onosConfigPath></onosConfigPath>
+                <onosConfigFile></onosConfigFile>
+            </COMPONENTS>
+        </Leaf1>
+
+        <Leaf2>
+            <host>10.128.13.211</host>
+            <user>root</user>
+            <password>onl</password>
+            <type>StratumOSSwitchDriver</type>
+            <connect_order>2</connect_order>
+            <COMPONENTS>
+                <prompt>#</prompt>
+                <shortName>leaf2</shortName>
+                <port1>2</port1>
+                <link1>Host2</link1>
+                <onosConfigPath></onosConfigPath>
+                <onosConfigFile></onosConfigFile>
+            </COMPONENTS>
+        </Leaf2>
+
+        <Spine1>
+            <host>10.128.13.213</host>
+            <user>root</user>
+            <password>onl</password>
+            <type>StratumOSSwitchDriver</type>
+            <connect_order>2</connect_order>
+            <COMPONENTS>
+                <prompt>#</prompt>
+                <shortName>spine1</shortName>
+                <onosConfigPath></onosConfigPath>
+                <onosConfigFile></onosConfigFile>
+            </COMPONENTS>
+        </Spine1>
+
+        <Spine2>
+            <host>10.128.13.215</host>
+            <user>root</user>
+            <password>onl</password>
+            <type>StratumOSSwitchDriver</type>
+            <connect_order>2</connect_order>
+            <COMPONENTS>
+                <prompt>#</prompt>
+                <shortName>spine2</shortName>
+                <onosConfigPath></onosConfigPath>
+                <onosConfigFile></onosConfigFile>
+            </COMPONENTS>
+        </Spine2>
+
+        <Host1>
+            <host>10.128.13.253</host>
+            <user>sdn</user>
+            <password>rocks</password>
+            <type>HostDriver</type>
+            <connect_order>6</connect_order>
+            <COMPONENTS>
+                <mac>3c:fd:fe:a8:ea:30</mac>
+                <inband>false</inband>
+                <ip>192.168.102.3</ip>
+                <shortName>h1</shortName>
+                <port1>0</port1>
+                <link1>Leaf1</link1>
+                <interfaceName>ens6f0</interfaceName>
+                <routes>
+                    <route1>
+                        <network>192.168.101.1</network>
+                        <netmask>24</netmask>
+                        <gw>192.168.103.1</gw>
+                        <interface></interface>
+                    </route1>
+                </routes>
+            </COMPONENTS>
+        </Host1>
+
+        <Host2>
+            <host>10.128.13.253</host>
+            <user>sdn</user>
+            <password>rocks</password>
+            <type>HostDriver</type>
+            <connect_order>7</connect_order>
+            <COMPONENTS>
+                <mac>3c:fd:fe:a8:ea:31</mac>
+                <inband>false</inband>
+                <ip>192.168.103.3</ip>
+                <shortName>h2</shortName>
+                <port1>0</port1>
+                <link1>Leaf1</link1>
+                <interfaceName>ens6f1</interfaceName>
+                <routes>
+                    <route1>
+                        <network>192.168.101.1</network>
+                        <netmask>24</netmask>
+                        <gw>192.168.103.1</gw>
+                        <interface></interface>
+                    </route1>
+                </routes>
+            </COMPONENTS>
+        </Host2>
+
+        <ng40vm>
+            <host>10.92.1.71</host>
+            <user>ng40</user>
+            <password>ng40</password>
+            <type>HostDriver</type>
+            <connect_order>8</connect_order>
+            <COMPONENTS>
+                <mac>52:54:00:e3:88:36</mac>
+                <inband>false</inband>
+                <ip>192.168.101.101</ip>
+                <shortName>ng40</shortName>
+                <port1></port1>
+                <link1></link1>
+                <interfaceName>ens8</interfaceName>
+                <routes>
+                    <route1>
+                        <network>192.168.101.1</network>
+                        <netmask>24</netmask>
+                        <gw>192.168.103.1</gw>
+                        <interface>ens8</interface>
+                    </route1>
+                </routes>
+            </COMPONENTS>
+        </ng40vm>
+
+        <NetworkBench>
+            <host>10.128.13.253</host>
+            <user>sdn</user>
+            <password>rocks</password>
+            <type>NetworkDriver</type>
+            <connect_order>10</connect_order>
+            <COMPONENTS>
+            </COMPONENTS>
+        </NetworkBench>
+
+    </COMPONENT>
+</TOPOLOGY>
diff --git a/TestON/tests/USECASE/SegmentRouting/SRBridging/dependencies/SRBridgingTest.py b/TestON/tests/USECASE/SegmentRouting/SRBridging/dependencies/SRBridgingTest.py
index bfba8df..be98329 100644
--- a/TestON/tests/USECASE/SegmentRouting/SRBridging/dependencies/SRBridgingTest.py
+++ b/TestON/tests/USECASE/SegmentRouting/SRBridging/dependencies/SRBridgingTest.py
@@ -66,7 +66,7 @@
             run.installOnos( main, skipPackage=skipPackage, cliSleep=5 )
             if main.useBmv2:
                 switchPrefix = main.params[ 'DEPENDENCY' ].get( 'switchPrefix', '' )
-                if switchPrefix is None:
+                if switchPrefix is None or "None":
                     switchPrefix = ''
                 # Translate configuration file from OVS-OFDPA to BMv2 driver
                 translator.bmv2ToOfdpa( main )  # Try to cleanup if switching between switch types
@@ -102,6 +102,8 @@
             run.checkFlows( main, minFlowCount=self.topo[ topology ][ 5 if main.useBmv2 else 4 ] * self.topo[ topology ][ 1 ], sleep=5 )
             if main.useBmv2:
                 switchPrefix = main.params[ 'DEPENDENCY' ].get( 'switchPrefix', '' )
+                if switchPrefix is None or "None":
+                    switchPrefix = ''
                 if switchPrefix is not '' and switchPrefix is not None:
                     switchPrefix += ':'
                 leaf_dpid = [ "device:%sleaf%d" % ( switchPrefix, ls + 1 ) for ls in range( self.topo[ topology ][ 1 ]) ]