From 2794ebf3d533fff33b0c79e7eae7b1954b6c393f Mon Sep 17 00:00:00 2001 From: Srinivas Rachakonda Date: Mon, 13 Jul 2020 13:05:33 +0530 Subject: [PATCH] Correcting Get Value from JSON Signed-off-by: Srinivas Rachakonda Change-Id: Iff74a4a70536b4c233bdf2d2b8c014c8c724eafd Signed-off-by: Srinivas Rachakonda --- csit/libraries/AAAKeywords.robot | 2 +- csit/libraries/OpenStackOperations.robot | 3 ++- csit/libraries/Utils.robot | 7 +++---- .../SFC_Basic/070__sfc_rendered_service_paths.robot | 13 +++++++------ .../libraries/OpenStackOperations.robot | 3 ++- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/csit/libraries/AAAKeywords.robot b/csit/libraries/AAAKeywords.robot index d04b87de5b..daa5d20307 100644 --- a/csit/libraries/AAAKeywords.robot +++ b/csit/libraries/AAAKeywords.robot @@ -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 diff --git a/csit/libraries/OpenStackOperations.robot b/csit/libraries/OpenStackOperations.robot index aad16bbcc5..e47cef60b6 100644 --- a/csit/libraries/OpenStackOperations.robot +++ b/csit/libraries/OpenStackOperations.robot @@ -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 diff --git a/csit/libraries/Utils.robot b/csit/libraries/Utils.robot index c7beb64d6a..88611e6523 100644 --- a/csit/libraries/Utils.robot +++ b/csit/libraries/Utils.robot @@ -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 diff --git a/csit/suites/sfc/SFC_Basic/070__sfc_rendered_service_paths.robot b/csit/suites/sfc/SFC_Basic/070__sfc_rendered_service_paths.robot index 65f3befa67..a3266c5b90 100644 --- a/csit/suites/sfc/SFC_Basic/070__sfc_rendered_service_paths.robot +++ b/csit/suites/sfc/SFC_Basic/070__sfc_rendered_service_paths.robot @@ -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} diff --git a/tools/deployment/openstack_ha/libraries/OpenStackOperations.robot b/tools/deployment/openstack_ha/libraries/OpenStackOperations.robot index 437d20954a..c8f4c591af 100644 --- a/tools/deployment/openstack_ha/libraries/OpenStackOperations.robot +++ b/tools/deployment/openstack_ha/libraries/OpenStackOperations.robot @@ -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 -- 2.36.6