Using REST to provision subscribers in scale test

Change-Id: Ia1458e083f7c8982bb358f003d1a3b5f7ae4e126
diff --git a/libraries/onos.robot b/libraries/onos.robot
index a68292d..7bd72f5 100755
--- a/libraries/onos.robot
+++ b/libraries/onos.robot
@@ -307,6 +307,14 @@
     Execute ONOS CLI Command    ${ONOS_SSH_IP}    ${ONOS_SSH_PORT}
             ...    volt-add-subscriber-access ${of_id} ${onu_port}
 
+Provision subscriber REST
+    [Documentation]     Uses the rest APIs to provision a subscriber
+    [Arguments]     ${onos_ip}    ${onos_port}   ${of_id}    ${onu_port}
+    ${resp}=    Post Request    ONOS
+    ...    /onos/olt/oltapp/${of_id}/${onu_port}
+    Should Be Equal As Strings    ${resp.status_code}    200
+
+
 List Enabled UNI Ports
     [Documentation]  List all the UNI Ports, the only way we have is to filter out the one called NNI
     ...     Creates a list of dictionaries
@@ -325,11 +333,13 @@
     Return From Keyword     ${result}
 
 Provision all subscribers on device
-    [Documentation]  Calls volt-add-subscriber-access in ONOS for all the enabled UNI ports on a partivular device
-    [Arguments]     ${onos_ip}    ${onos_port}   ${of_id}
-    ${unis}=    List Enabled UNI Ports  ${onos_ip}  ${onos_port}   ${of_id}
+    [Documentation]  Provisions a subscriber in ONOS for all the enabled UNI ports on a particular device
+    [Arguments]     ${onos_ip}    ${onos_ssh_port}  ${onos_rest_port}   ${of_id}
+    ${unis}=    List Enabled UNI Ports  ${onos_ip}  ${onos_ssh_port}   ${of_id}
+    ${onos_auth}=    Create List    karaf    karaf
+    Create Session    ONOS    http://${onos_ip}:${onos_rest_port}    auth=${onos_auth}
     FOR     ${uni}  IN      @{unis}
-        Provision subscriber   ${onos_ip}  ${onos_port}   ${uni['of_id']}   ${uni['port']}
+        Provision Subscriber REST   ${onos_ip}  ${onos_rest_port}   ${uni['of_id']}   ${uni['port']}
     END
 
 List OLTs
diff --git a/libraries/voltctl.robot b/libraries/voltctl.robot
index 5724871..88127bb 100644
--- a/libraries/voltctl.robot
+++ b/libraries/voltctl.robot
@@ -527,10 +527,10 @@
     [Documentation]  Waits until the flows have been provisioned in the openolt devices
     [Arguments]  ${workflow}    ${uni_count}    ${olt_count}    ${provisioned}
     ...     ${withEapol}    ${withDhcp}     ${withIgmp}     ${withLldp}
-    ${targetFlows}=     Calculate flows by workflow     ${workflow}    ${uni_count}    ${olt_count}     ${provisioned}
-    ...     ${withEapol}    ${withDhcp}     ${withIgmp}     ${withLldp}
     # In the physical device we only have 2 data plane flows (on the PON) instead of 4
-    Run Keyword If  $provisioned=='true'
-    ...     ${targetFlows}=     Evaluate    ${targetFlows} - (${uni_count} * 2)
+    ${beforeFlows}=     Calculate flows by workflow     ${workflow}    ${uni_count}    ${olt_count}     ${provisioned}
+    ...     ${withEapol}    ${withDhcp}     ${withIgmp}     ${withLldp}
+    ${afterFlows}=      Evaluate    ${beforeFlows} - (${uni_count} * 2)
+    ${targetFlows}=    Set Variable If  $provisioned=='true'    ${afterFlows}   ${beforeFlows}
     Log     ${targetFlows}
     Wait Until Keyword Succeeds     10m     5s  Count OpenOLT Device Flows     ${targetFlows}
\ No newline at end of file
diff --git a/tests/scale/Voltha_Scale_Tests.robot b/tests/scale/Voltha_Scale_Tests.robot
index 328de27..d5a8f3a 100644
--- a/tests/scale/Voltha_Scale_Tests.robot
+++ b/tests/scale/Voltha_Scale_Tests.robot
@@ -56,6 +56,7 @@
 *** Variables ***
 ${ONOS_SSH_IP}  127.0.0.1
 ${ONOS_SSH_PORT}    8101
+${ONOS_REST_PORT}    8181
 
 # Scale pipeline values
 ${olt}  1
@@ -109,7 +110,7 @@
 
 Flows validation in VOLTHA Adapters before subscriber provisioning
     [Documentation]  Check that all flows has been store in devices of type openolt
-    [Tags]      non-critical    flow-before   plot-voltha-openolt-flows-before
+    [Tags]      non-critical    flow-before   plot-voltha-openolt-flows-before  only-me
     Should Be Equal   ${enableFlowProvisioning}     true
     Wait for OpenOLT Devices flows   ${workflow}    ${total_onus}    ${olt}    false
     ...     ${withEapol}    ${withDhcp}     ${withIgmp}    ${withLLDP}
@@ -134,7 +135,7 @@
     Should Be Equal   ${enableSubscriberProvisioning}     true
     ${olts}=    List OLTs   ${ONOS_SSH_IP}    ${ONOS_SSH_PORT}
     FOR     ${olt}  IN  @{olts}
-        Provision all subscribers on device  ${ONOS_SSH_IP}    ${ONOS_SSH_PORT}  ${olt}
+        Provision all subscribers on device  ${ONOS_SSH_IP}    ${ONOS_SSH_PORT}     ${ONOS_REST_PORT}  ${olt}
     END
 
 Flows validation in VOLTHA after subscriber provisioning
@@ -147,7 +148,7 @@
 
 Flows validation in VOLTHA Adapters after subscriber provisioning
     [Documentation]  Check that all flows has been store in devices of type openolt
-    [Tags]      non-critical    flow-after   plot-voltha-openolt-flows-after
+    [Tags]      non-critical    flow-after   plot-voltha-openolt-flows-after    only-me
     Should Be Equal   ${enableFlowProvisioning}     true
     Wait for OpenOLT Devices flows   ${workflow}    ${total_onus}    ${olt}    true
     ...     ${withEapol}    ${withDhcp}     ${withIgmp}    ${withLLDP}