Correcting Get Value from JSON 89/91289/10
authorSrinivas Rachakonda <srinivas.rachakonda@gmail.com>
Mon, 13 Jul 2020 07:35:33 +0000 (13:05 +0530)
committerJamo Luhrsen <jluhrsen@gmail.com>
Wed, 15 Jul 2020 18:07:13 +0000 (18:07 +0000)
Signed-off-by: Srinivas Rachakonda <srinivas.rachakonda@gmail.com>
Change-Id: Iff74a4a70536b4c233bdf2d2b8c014c8c724eafd
Signed-off-by: Srinivas Rachakonda <srinivas.rachakonda@gmail.com>
csit/libraries/AAAKeywords.robot
csit/libraries/OpenStackOperations.robot
csit/libraries/Utils.robot
csit/suites/sfc/SFC_Basic/070__sfc_rendered_service_paths.robot
tools/deployment/openstack_ha/libraries/OpenStackOperations.robot

index d04b87de5b3aaeab54afc0e69922189c02c44b45..daa5d203074d766552e5d9c8a1d86172dd75e7ab 100644 (file)
@@ -51,7 +51,7 @@ Get Auth Token
     ${auth_data}=    Create Auth Data    ${USER}    ${PWD}    ${scope}    ${client_id}    ${client_secret}
     ${resp}=    AAA Login    ${ODL_SYSTEM_IP}    ${auth_data}
     Should Be Equal As Strings    ${resp.status_code}    201
-    ${auth_token}=    Extract Value From Content    ${resp.text}    /access_token    strip
+    ${auth_token} =    Extract Value From Content    ${resp.text}    'access_token'
     [Return]    ${auth_token}
 
 Revoke Auth Token
index aad16bbcc59abf71bdd5eac85695c3bf2cf78ddf..e47cef60b642cdf629b8ec74cee2c10dd7d642a6 100644 (file)
@@ -34,7 +34,8 @@ Get Tenant ID From Network
     [Arguments]    ${network_uuid}
     [Documentation]    Returns tenant ID by reading it from existing network.
     ${resp} =    TemplatedRequests.Get_From_Uri    uri=${CONFIG_API}/neutron:neutron/networks/network/${network_uuid}/    accept=${ACCEPT_EMPTY}    session=session
-    ${tenant_id} =    Utils.Extract Value From Content    ${resp}    /network/0/tenant-id    strip
+    ${temp_vars} =    BuiltIn.Set Variable    ['network'][0]['tenant-id']
+    ${tenant_id} =    Utils.Extract Value From Content    ${resp}    ${temp_vars}
     [Return]    ${tenant_id}
 
 Create Network
index c7beb64d6a9d17e953621eeddb6f50bcd6eec24a..88611e65232b5cf297a5f3a0095aade02eca1091 100644 (file)
@@ -149,11 +149,10 @@ Clean Up Ovs
     Run Command On Mininet    ${system}    sudo ovs-vsctl del-manager
 
 Extract Value From Content
-    [Arguments]    ${content}    ${index}    ${strip}=nostrip
+    [Arguments]    ${content}    ${index}
     [Documentation]    Will take the given response content and return the value at the given index as a string
-    ${value}=    Get Json Value    ${content}    ${index}
-    ${value}=    Convert To String    ${value}
-    ${value}=    Run Keyword If    '${strip}' == 'strip'    Strip Quotes    ${value}
+    ${JSON} =    Evaluate    json.loads('''${content}''')    json
+    ${value} =    Set Variable    ${JSON${index}}
     [Return]    ${value}
 
 Get Process ID Based On Regex On Remote System
index 65f3befa675d6b21470bc8ea2b1ca653d5fef23e..a3266c5b90575e045ba97056912ce8de78e022d9 100644 (file)
@@ -142,24 +142,25 @@ Generate RSPs with Shortest Path Schedule Algorithm type
     Utils.Check For Elements At URI    ${OPERATIONAL_RSP_URI}/${rsp1_name}/rendered-service-path-hop/2/    ${elements}
     ${resp} =    RequestsLibrary.Get Request    session    ${OPERATIONAL_RSP_URI}/${rsp1_name}/rendered-service-path-hop/0/
     BuiltIn.Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
-    ${fwd_hop1} =    Utils.Extract Value From Content    ${resp.content}    /rendered-service-path-hop/0/service-function-forwarder
+    ${temp_vars} =    BuiltIn.Set Variable    ['rendered-service-path-hop'][0]['service-function-forwarder']
+    ${fwd_hop1} =    Utils.Extract Value From Content    ${resp.content}    ${temp_vars}
     ${resp} =    RequestsLibrary.Get Request    session    ${OPERATIONAL_RSP_URI}/${rsp1_name}/rendered-service-path-hop/1/
     BuiltIn.Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
-    ${fwd_hop2} =    Utils.Extract Value From Content    ${resp.content}    /rendered-service-path-hop/0/service-function-forwarder
+    ${fwd_hop2} =    Utils.Extract Value From Content    ${resp.content}    ${temp_vars}
     ${resp} =    RequestsLibrary.Get Request    session    ${OPERATIONAL_RSP_URI}/${rsp1_name}/rendered-service-path-hop/2/
     BuiltIn.Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
-    ${fwd_hop3} =    Utils.Extract Value From Content    ${resp.content}    /rendered-service-path-hop/0/service-function-forwarder
+    ${fwd_hop3} =    Utils.Extract Value From Content    ${resp.content}    ${temp_vars}
     BuiltIn.Should Be Equal    ${fwd_hop1}    ${fwd_hop2}
     BuiltIn.Should Be Equal    ${fwd_hop2}    ${fwd_hop3}
     ${resp} =    RequestsLibrary.Get Request    session    ${OPERATIONAL_RSP_URI}/${rsp2_name}/rendered-service-path-hop/0/
     BuiltIn.Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
-    ${fwd_hop1} =    Utils.Extract Value From Content    ${resp.content}    /rendered-service-path-hop/0/service-function-forwarder
+    ${fwd_hop1} =    Utils.Extract Value From Content    ${resp.content}    ${temp_vars}
     ${resp} =    RequestsLibrary.Get Request    session    ${OPERATIONAL_RSP_URI}/${rsp2_name}/rendered-service-path-hop/1/
     BuiltIn.Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
-    ${fwd_hop2} =    Utils.Extract Value From Content    ${resp.content}    /rendered-service-path-hop/0/service-function-forwarder
+    ${fwd_hop2} =    Utils.Extract Value From Content    ${resp.content}    ${temp_vars}
     ${resp} =    RequestsLibrary.Get Request    session    ${OPERATIONAL_RSP_URI}/${rsp2_name}/rendered-service-path-hop/2/
     BuiltIn.Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
-    ${fwd_hop3} =    Utils.Extract Value From Content    ${resp.content}    /rendered-service-path-hop/0/service-function-forwarder
+    ${fwd_hop3} =    Utils.Extract Value From Content    ${resp.content}    ${temp_vars}
     BuiltIn.Should Be Equal    ${fwd_hop1}    ${fwd_hop2}
     BuiltIn.Should Be Equal    ${fwd_hop2}    ${fwd_hop3}
 
index 437d20954a60516d2b1ca19296acbe49f32695b1..c8f4c591afaad67a6c2e43b49a2dc0ed6e8968d9 100644 (file)
@@ -27,7 +27,8 @@ Get Tenant ID From Network
     [Arguments]    ${network_uuid}
     [Documentation]    Returns tenant ID by reading it from existing network.
     ${resp} =    TemplatedRequests.Get_From_Uri    uri=${CONFIG_API}/neutron:neutron/networks/network/${network_uuid}/    accept=${ACCEPT_EMPTY}    session=session
-    ${tenant_id} =    Utils.Extract Value From Content    ${resp}    /network/0/tenant-id    strip
+    ${temp_vars} =    BuiltIn.Set Variable    ['network'][0]['tenant-id']
+    ${tenant_id} =    Utils.Extract Value From Content    ${resp}    ${temp_vars}
     [Return]    ${tenant_id}
 
 Create Network