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