Getting KV Store Prefix

Change-Id: I27f989c2c8f647c0c30624a298059ff436c707af
diff --git a/libraries/onu_utilities.robot b/libraries/onu_utilities.robot
index 88e0d72..6d6c30a 100755
--- a/libraries/onu_utilities.robot
+++ b/libraries/onu_utilities.robot
@@ -15,8 +15,6 @@
 *** Settings ***
 Documentation     Library for various openonu-go-adpter utilities
 
-*** Variables ***
-${defaultstackname}    voltha_voltha
 
 *** Keywords ***
 Calculate Timeout
@@ -219,10 +217,10 @@
     ...                It checks unique of  serial_number and combination of pon, onu and uni in tp_path.
     ...                Furthermore it evaluates the values of onu_id and uni_id with values read from tp_path.
     ...                Number of etcd entries has to match with the passed number.
-    [Arguments]    ${nbofetcddata}=${num_all_onus}
-    ${stackname}=    Get Stack Name
-    ${etcddata}=    Get ONU Go Adapter ETCD Data
-    ${etcddata}=    Remove Lines Containing String    ${etcddata}    service/${stackname}/openonu    \n
+    [Arguments]    ${nbofetcddata}=${num_all_onus}    ${defaultkvstoreprefix}=voltha_voltha
+    ${kvstoreprefix}=    Get Kv Store Prefix    ${defaultkvstoreprefix}
+    ${etcddata}=    Get ONU Go Adapter ETCD Data    ${kvstoreprefix}
+    ${etcddata}=    Remove Lines Containing String    ${etcddata}    service/${kvstoreprefix}/openonu    \n
     #prepare result for json convert
     ${result}=    Prepare ONU Go Adapter ETCD Data For Json    ${etcddata}
     ${jsondata}=    To Json    ${result}
@@ -258,9 +256,10 @@
     ...                In case of a passed dictionary containing set_vids these will be checked for to
     ...                current set-vid depending on setvidequal (True=equal, False=not equal).
     [Arguments]    ${nbofcookieslice}=1    ${reqmatchvid}=4096    ${prevvlanrules}=${NONE}    ${setvidequal}=False
-    ${stackname}=    Get Stack Name
-    ${etcddata}=    Get ONU Go Adapter ETCD Data
-    ${etcddata}=    Remove Lines Containing String    ${etcddata}    service/${stackname}/openonu    \n
+    ...            ${defaultkvstoreprefix}=voltha_voltha
+    ${kvstoreprefix}=    Get Kv Store Prefix    ${defaultkvstoreprefix}
+    ${etcddata}=    Get ONU Go Adapter ETCD Data    ${kvstoreprefix}
+    ${etcddata}=    Remove Lines Containing String    ${etcddata}    service/${kvstoreprefix}/openonu    \n
     #prepare result for json convert
     ${result}=    Prepare ONU Go Adapter ETCD Data For Json    ${etcddata}
     ${jsondata}=    To Json    ${result}
@@ -297,11 +296,12 @@
 
 Get ONU Go Adapter ETCD Data
     [Documentation]    This keyword delivers openonu-go-adapter Data stored in etcd
+    [Arguments]    ${defaultkvstoreprefix}=voltha_voltha
     ${namespace}=    Set Variable    default
     ${podname}=    Set Variable    etcd
-    ${stackname}=    Get Stack Name
+    ${kvstoreprefix}=    Get Kv Store Prefix    ${defaultkvstoreprefix}
     ${commandget}    Catenate
-    ...    /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix --prefix service/${stackname}/openonu'
+    ...    /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix --prefix service/${kvstoreprefix}/openonu'
     ${result}=    Exec Pod In Kube    ${namespace}    ${podname}    ${commandget}
     log    ${result}
     [Return]    ${result}
@@ -378,13 +378,6 @@
     Should Be Equal As Integers    ${uni}    ${uni_id}
     ...    msg=Uni-Id (${uni_id}) does not match onu (${uni}) from tp_path in etcd data!
 
-Get Stack Name
-    [Documentation]    This keyword delivers the stack name read from environment variable NAME if present.
-    ${env_name}=    Get Environment Variable    NAME    default=${defaultstackname}
-    # while Get Environment Variable does not work correctly, a manual correction follows
-    ${env_name}=    Set Variable If    "${env_name}"=="${EMPTY}"    ${defaultstackname}    ${env_name}
-    [Return]    ${env_name}
-
 Wait for Ports in ONOS for all OLTs
     [Documentation]    Waits untill a certain number of ports are enabled in all OLTs
     [Arguments]    ${onos_ssh_connection}    ${count}    ${filter}    ${max_wait_time}=10m
diff --git a/libraries/voltha.robot b/libraries/voltha.robot
old mode 100644
new mode 100755
index 1d7ba1e..c468d43
--- a/libraries/voltha.robot
+++ b/libraries/voltha.robot
@@ -53,3 +53,12 @@
     Should Be Equal as Integers    ${rc}    0
     Run Keyword If    '${pid}' != ''    Run And Return Rc    kill -9 ${pid}
     Should Be Equal as Integers    ${rc}    0
+
+Get Kv Store Prefix
+    [Documentation]    This keyword delivers the KV Store Prefix read from environment variable KVSTOREPREFIX if present.
+    [Arguments]    ${defaultkvstoreprefix}=voltha_voltha
+    ${kv_store_prefix}=    Get Environment Variable    KVSTOREPREFIX    default=${defaultkvstoreprefix}
+    # while Get Environment Variable does not work correctly, a manual correction follows
+    ${kv_store_prefix}=    Set Variable If    "${kv_store_prefix}"=="${EMPTY}"    ${defaultkvstoreprefix}    ${kv_store_prefix}
+    [Return]    ${kv_store_prefix}
+
diff --git a/tests/openonu-go-adapter/Voltha_ONUStateTests.robot b/tests/openonu-go-adapter/Voltha_ONUStateTests.robot
index e3593b5..cda0884 100755
--- a/tests/openonu-go-adapter/Voltha_ONUStateTests.robot
+++ b/tests/openonu-go-adapter/Voltha_ONUStateTests.robot
@@ -44,6 +44,9 @@
 ${scripts}        ../../scripts
 # Per-test logging on failure is turned off by default; set this variable to enable
 ${container_log_dir}    ${None}
+# KV Store Prefix
+# example: -v kvstoreprefix:voltha_voltha
+${kvstoreprefix}    voltha_voltha
 # state to test variable, can be passed via the command line too, valid values: 1-6
 # 1 -> activating-onu
 # 2 -> starting-openomci
@@ -220,7 +223,7 @@
     Run Keyword If    ${pausebeforecleanup}    Pause Execution    Press OK to continue with clean up!
     Run Keyword If    ${pausebeforecleanup}    Log    Teardown will be continued...    console=yes
     Run Keyword If    ${teardown_device}    Delete All Devices and Verify
-    Validate Onu Data In Etcd    0
+    Validate Onu Data In Etcd    0    ${kvstoreprefix}
     Wait for Ports in ONOS for all OLTs      ${onos_ssh_connection}  0   BBSM    ${timeout}
     Close All ONOS SSH Connections
     Remove Tech Profile
@@ -314,12 +317,13 @@
 
 Do Onu Etcd Data Check
     [Documentation]    Check Onu data stored in etcd
-    Validate Onu Data In Etcd
+    Validate Onu Data In Etcd    defaultkvstoreprefix=${kvstoreprefix}
 
 Do Onu Flow Check
     [Documentation]    This keyword iterate all OLTs and performs Do Onu Flow Checks Per OLT
     # Check and store vlan rules
     ${firstvlanrules}=    Run Keyword And Continue On Failure    Validate Vlan Rules In Etcd
+    ...    defaultkvstoreprefix=${kvstoreprefix}
     FOR    ${J}    IN RANGE    0    ${num_olts}
         ${olt_serial_number}=    Set Variable    ${list_olts}[${J}][sn]
         ${onu_count}=    Set Variable    ${list_olts}[${J}][onucount]
@@ -348,7 +352,7 @@
     Sleep    10s
     Run Keyword And Continue On Failure    Current State Test All Onus    ${state2test}
     ${secondvlanrules}=    Run Keyword And Continue On Failure    Validate Vlan Rules In Etcd    nbofcookieslice=3
-    ...    prevvlanrules=${firstvlanrules}
+    ...    prevvlanrules=${firstvlanrules}    defaultkvstoreprefix=${kvstoreprefix}
     FOR    ${J}    IN RANGE    0    ${num_olts}
         ${olt_serial_number}=    Set Variable    ${list_olts}[${J}][sn]
         ${onu_count}=    Set Variable    ${list_olts}[${J}][onucount]
@@ -367,7 +371,7 @@
     Run Keyword And Continue On Failure    Current State Test All Onus    ${state2test}
     Run Keyword If    ${print2console}    Log    \r\nFinished State Test All Onus.    console=yes
     Run Keyword And Continue On Failure    Validate Vlan Rules In Etcd    prevvlanrules=${firstvlanrules}
-    ...                                    setvidequal=True
+    ...                                    setvidequal=True    defaultkvstoreprefix=${kvstoreprefix}
 
 Do Onu Subscriber Add Per OLT
     [Documentation]    Add Subscriber per OLT
@@ -424,9 +428,9 @@
     [Documentation]    This keyword checks the loaded TechProfile
     ${namespace}=    Set Variable    default
     ${podname}=    Set Variable    etcd
-    ${stackname}=    Get Stack Name
+    ${kvstoreprefix}=    Get Kv Store Prefix
     ${commandget}    Catenate
-    ...    /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/${stackname}/technology_profiles/XGS-PON/64'
+    ...    /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/${kvstoreprefix}/technology_profiles/XGS-PON/64'
     ${result}=    Exec Pod In Kube    ${namespace}    ${podname}    ${commandget}
     ${num_gem_ports}=    Set Variable    1
     ${num_gem_ports}=    Set Variable If