Merge "[ONOS-7430] Add option to use portstate for link-down/up in FUNCintent test"
diff --git a/TestON/tests/FUNC/FUNCintent/FUNCintent.params b/TestON/tests/FUNC/FUNCintent/FUNCintent.params
index f1ba155..4976a0f 100644
--- a/TestON/tests/FUNC/FUNCintent/FUNCintent.params
+++ b/TestON/tests/FUNC/FUNCintent/FUNCintent.params
@@ -49,6 +49,10 @@
         <branch>master</branch>
     </GIT>
 
+    <TEST>
+        <usePortstate>False</usePortstate>
+    </TEST>
+
     <SLEEP>
         <startup>15</startup>
         <reroute>5</reroute>
@@ -73,6 +77,23 @@
     <MININET>
         <switch>7</switch>
         <links>20</links>
+        <dpids>
+            <s4>of:0000000000000004</s4>
+            <s5>of:0000000000000005</s5>
+            <s6>of:0000000000000006</s6>
+        </dpids>
+        <ports>
+            <s4>
+                <s1>1</s1>
+                <s3>2</s3>
+            </s4>
+            <s5>
+                <s2>10</s2>
+            </s5>
+            <s6>
+                <s2>9</s2>
+            </s6>
+        </ports>
     </MININET>
 
     <SCAPY>
diff --git a/TestON/tests/FUNC/FUNCintent/FUNCintent.py b/TestON/tests/FUNC/FUNCintent/FUNCintent.py
index 4f6b715..c7ae062 100644
--- a/TestON/tests/FUNC/FUNCintent/FUNCintent.py
+++ b/TestON/tests/FUNC/FUNCintent/FUNCintent.py
@@ -84,6 +84,7 @@
             main.scapyHosts = []  # List of scapy hosts for iterating
             main.assertReturnString = ''  # Assembled assert return string
             main.cycle = 0  # How many times FUNCintent has run through its tests
+            main.usePortstate = True if main.params[ 'TEST' ][ 'usePortstate' ] == "True" else False
 
             # -- INIT SECTION, ONLY RUNS ONCE -- #
 
diff --git a/TestON/tests/FUNC/FUNCintent/dependencies/FuncIntentFunction.py b/TestON/tests/FUNC/FUNCintent/dependencies/FuncIntentFunction.py
index 0fcd334..afe4c4a 100644
--- a/TestON/tests/FUNC/FUNCintent/dependencies/FuncIntentFunction.py
+++ b/TestON/tests/FUNC/FUNCintent/dependencies/FuncIntentFunction.py
@@ -2112,12 +2112,19 @@
 
 
 def link( main, sw1, sw2, option ):
-
-    # link down
-    main.log.info( itemName + ": Bring link " + option + " between " +
-                       sw1 + " and " + sw2 )
-    linkResult = main.Network.link( end1=sw1, end2=sw2, option=option )
-    return linkResult
+    if main.usePortstate:
+        # port down
+        dpid = main.params[ 'MININET' ][ 'dpids' ][ sw1 ]
+        port = main.params[ 'MININET' ][ 'ports' ][ sw1 ][ sw2 ]
+        main.log.info( itemName + ": Bring port " + sw1 + "/" + port + " " + option )
+        state = "disable" if option == "down" else "enable"
+        result = main.Cluster.active( 0 ).CLI.portstate( dpid=dpid, port=port, state=state )
+    else:
+        # link down
+        main.log.info( itemName + ": Bring link " + option + " between " +
+                           sw1 + " and " + sw2 )
+        result = main.Network.link( end1=sw1, end2=sw2, option=option )
+    return result
 
 
 def scapyCheckConnection( main,