From 19345a71787aa318c05a4aa04c1abb014ad37704 Mon Sep 17 00:00:00 2001 From: Jerry Flood Date: Sat, 9 Dec 2017 16:20:42 -0500 Subject: Implement VFW policy update for demo.sh (trial) Issue-ID: TEST-72 Change-Id: I16eb3eee84dfef6dde430e4ed73b4cbcc0059757 Signed-off-by: Jerry Flood --- .../policy/FirewallPolicy_delete.template | 6 ++ robot/resources/demo_preload.robot | 48 ++++++++++--- robot/resources/global_properties.robot | 6 +- robot/resources/policy_interface.robot | 80 ++++++++++++++++++++-- robot/resources/sdngc_interface.robot | 5 +- .../stack_validation/validate_vfwcl.robot | 1 + .../vnf_orchestration_test_template.robot | 23 +++++-- robot/testsuites/demo.robot | 20 ++++-- 8 files changed, 158 insertions(+), 31 deletions(-) create mode 100644 robot/assets/templates/policy/FirewallPolicy_delete.template diff --git a/robot/assets/templates/policy/FirewallPolicy_delete.template b/robot/assets/templates/policy/FirewallPolicy_delete.template new file mode 100644 index 00000000..8bc9e887 --- /dev/null +++ b/robot/assets/templates/policy/FirewallPolicy_delete.template @@ -0,0 +1,6 @@ +{ + "pdpGroup": "default", + "policyComponent" : "PDP", + "policyName": "com.BRMSParamvFirewall", + "policyType": "BRMS_Param" +} \ No newline at end of file diff --git a/robot/resources/demo_preload.robot b/robot/resources/demo_preload.robot index 5b3e14c3..b1eff956 100644 --- a/robot/resources/demo_preload.robot +++ b/robot/resources/demo_preload.robot @@ -5,6 +5,7 @@ Resource test_templates/model_test_template.robot Resource test_templates/vnf_orchestration_test_template.robot Resource asdc_interface.robot Resource vid/vid_interface.robot +Resource policy_interface.robot Library UUID Library Collections @@ -72,14 +73,17 @@ Preload User Model ${status} ${generic_vnf}= Run Keyword And Ignore Error Get Service Instance ${vnf_name} Run Keyword If '${status}' == 'FAIL' FAIL VNF Name: ${vnf_name} is not found. ${vnf_type}= Set Variable ${generic_vnf['vnf-type']} - ${relationships}= Set Variable ${generic_vnf['relationship-list']['relationship']} - ${relationship_data}= Get Relationship Data ${relationships} - ${customer_id}= Catenate - :for ${r} in @{relationship_data} - \ ${service}= Set Variable If '${r['relationship-key']}' == 'service-subscription.service-type' ${r['relationship-value']} ${service} - \ ${service_instance_id}= Set Variable If '${r['relationship-key']}' == 'service-instance.service-instance-id' ${r['relationship-value']} ${service_instance_id} - \ ${customer_id}= Set Variable If '${r['relationship-key']}' == 'customer.global-customer-id' ${r['relationship-value']} ${customer_id} - ${invariantUUID}= Get Persona Model Id ${service_instance_id} ${service} ${customer_id} + ${invariantUUID} ${service} ${customer_id} ${service_instance_id}= Get Generic VNF Info ${generic_vnf} + + ## Reuse for VFW policy update... + ##${relationships}= Set Variable ${generic_vnf['relationship-list']['relationship']} + ##${relationship_data}= Get Relationship Data ${relationships} + ##${customer_id}= Catenate + ##:for ${r} in @{relationship_data} + ##\ ${service}= Set Variable If '${r['relationship-key']}' == 'service-subscription.service-type' ${r['relationship-value']} ${service} + ##\ ${service_instance_id}= Set Variable If '${r['relationship-key']}' == 'service-instance.service-instance-id' ${r['relationship-value']} ${service_instance_id} + ##\ ${customer_id}= Set Variable If '${r['relationship-key']}' == 'customer.global-customer-id' ${r['relationship-value']} ${customer_id} + ##${invariantUUID}= Get Persona Model Id ${service_instance_id} ${service} ${customer_id} # We still need the vf module names. We can get them from VID using the persona_model_id (invariantUUID) from A&AI Setup Browser @@ -92,6 +96,23 @@ Preload User Model Preload Vnf ${service_instance_id} ${vnf_name} ${vnf_type} ${vf_module_name} ${vf_modules} ${vnf_service} demo [Teardown] Close All Browsers +Get Generic VNF Info + [Documentation] Grab some selected informastion from the generic vnf relationships + [Arguments] ${generic_vnf} + ${relationships}= Set Variable ${generic_vnf['relationship-list']['relationship']} + ${relationship_data}= Get Relationship Data ${relationships} + ${customer_id}= Catenate + ${service_instance_id}= Catenate + ${service}= Catenate + :for ${r} in @{relationship_data} + \ ${service}= Set Variable If '${r['relationship-key']}' == 'service-subscription.service-type' ${r['relationship-value']} ${service} + \ ${service_instance_id}= Set Variable If '${r['relationship-key']}' == 'service-instance.service-instance-id' ${r['relationship-value']} ${service_instance_id} + \ ${customer_id}= Set Variable If '${r['relationship-key']}' == 'customer.global-customer-id' ${r['relationship-value']} ${customer_id} + ${invariantUUID}= Get Persona Model Id ${service_instance_id} ${service} ${customer_id} + [Return] ${invariantUUID} ${service} ${customer_id} ${service_instance_id} + + + Get The Selected Modules [Arguments] ${vf_modules} ${vnf_service} ${returnlist} Create List @@ -138,6 +159,17 @@ APPC Mount Point ${vpg_oam_ip}= Get From Dictionary ${stack_info} vpg_private_ip_1 ${appc}= Create Mount Point In APPC ${vnf_id} ${vpg_oam_ip} +Execute VFW Policy Update VNF Name + [Arguments] ${vnf_name} + ${status} ${generic_vnf}= Run Keyword And Ignore Error Get Service Instance ${vnf_name} + Run Keyword If '${status}' == 'FAIL' FAIL VNF Name: ${vnf_name} is not found. + ${invariantUUID} ${service} ${customer_id} ${service_instance_id}= Get Generic VNF Info ${generic_vnf} + Update vVFWCL Policy ${invariantUUID} + +Execute VFW Policy Update + [Arguments] ${resource_id} + Update vVFWCL Policy ${resource_id} + Instantiate VNF [Arguments] ${service} Setup Orchestrate VNF ${GLOBAL_AAI_CLOUD_OWNER} SharedNode OwnerType v1 CloudZone diff --git a/robot/resources/global_properties.robot b/robot/resources/global_properties.robot index 129f8d1a..fc40527a 100644 --- a/robot/resources/global_properties.robot +++ b/robot/resources/global_properties.robot @@ -27,10 +27,12 @@ ${GLOBAL_BUILD_NUMBER} 0 ${GLOBAL_VID_UI_TIMEOUT_SHORT} 20s ${GLOBAL_VID_UI_TIMEOUT_MEDIUM} 60s ${GLOBAL_VID_UI_TIMEOUT_LONG} 120s -${GLOBAL_VM_PRIVATE_KEY} ${EXECDIR}/robot/assets/keys/robot_ssh_private_key.pvt +${GLOBAL_VM_PRIVATE_KEY} ${EXECDIR}/robot/assets/keys/onap_dev.pvt +${GLOBAL_VM_PUBLIC_KEY} ${EXECDIR}/robot/assets/keys/onap_dev_public.txt ${GLOBAL_AAI_ZONE_ID} nova1 ${GLOBAL_AAI_ZONE_NAME} nova ${GLOBAL_AAI_DESIGN_TYPE} integration ${GLOBAL_AAI_ZONE_CONTEXT} labs ${GLOBAL_DCAE_COLLECTOR_HOST_NAME} dcaedoks00 - +${GLOBAL_DROOLS_USERNAME} @1b3rt +${GLOBAL_DROOLS_PASSWORD} 31nst31n diff --git a/robot/resources/policy_interface.robot b/robot/resources/policy_interface.robot index a622ae6c..e38d9445 100644 --- a/robot/resources/policy_interface.robot +++ b/robot/resources/policy_interface.robot @@ -4,19 +4,26 @@ Library RequestsClientCert Library RequestsLibrary Library String Library JSONUtils -Library Collections +Library Collections +Library OperatingSystem +Library SSHLibrary Resource global_properties.robot +Resource json_templater.robot +Resource ssh/files.robot *** Variables *** ${POLICY_HEALTH_CHECK_PATH} /healthcheck ${POLICY_ENDPOINT} ${GLOBAL_POLICY_SERVER_PROTOCOL}://${GLOBAL_INJECTED_POLICY_IP_ADDR}:${GLOBAL_POLICY_SERVER_PORT} +${DROOLS_ENDPOINT} http://${GLOBAL_INJECTED_POLICY_IP_ADDR}:9696 ${POLICY_HEALTHCHECK_ENDPOINT} ${GLOBAL_POLICY_SERVER_PROTOCOL}://${GLOBAL_INJECTED_POLICY_IP_ADDR}:${GLOBAL_POLICY_HEALTHCHECK_PORT} +${POLICY_TEMPLATES} robot/assets/templates/policy +${POLICY_PVT_KEY} robotassets/keys/onap_dev.pvt *** Keywords *** Run Policy Health Check [Documentation] Runs Policy Health check - ${auth}= Create List ${GLOBAL_POLICY_USERNAME} ${GLOBAL_POLICY_PASSWORD} + ${auth}= Create List ${GLOBAL_POLICY_USERNAME} ${GLOBAL_POLICY_PASSWORD} Log Creating session ${POLICY_ENDPOINT} ${session}= Create Session policy ${POLICY_HEALTHCHECK_ENDPOINT} auth=${auth} ${headers}= Create Dictionary Accept=application/json Content-Type=application/json @@ -28,7 +35,7 @@ Run Policy Health Check :FOR ${ELEMENT} IN @{ITEMS} \ Should Be Equal As Strings ${ELEMENT['code']} 200 \ Should Be True ${ELEMENT['healthy']} - + Run Policy Put Request [Documentation] Runs Policy Put request [Arguments] ${data_path} ${data} @@ -38,7 +45,7 @@ Run Policy Put Request ${resp}= Put Request policy ${data_path} data=${data} headers=${headers} Log Received response from policy ${resp.text} [Return] ${resp} - + Run Policy Delete Request [Documentation] Runs Policy Delete request [Arguments] ${data_path} ${data} @@ -48,13 +55,72 @@ Run Policy Delete Request ${resp}= Delete Request policy ${data_path} data=${data} headers=${headers} Log Received response from policy ${resp.text} [Return] ${resp} - + +Run Drools Get Request + [Documentation] Runs Policy Delete request + [Arguments] ${data_path} + Log Creating session ${POLICY_ENDPOINT} + ${auth}= Create List ${GLOBAL_DROOLS_USERNAME} ${GLOBAL_DROOLS_PASSWORD} + ${session}= Create Session policy ${DROOLS_ENDPOINT} auth=${auth} + ${resp}= Get Request policy ${data_path} + Log Received response from policy ${resp.text} + [Return] ${resp} + + Run Policy Get Configs Request [Documentation] Runs Policy Get Configs request [Arguments] ${data_path} ${data} Log Creating session ${POLICY_ENDPOINT} ${session}= Create Session policy ${POLICY_ENDPOINT} - ${headers}= Create Dictionary Accept=application/json Content-Type=application/json Authorization=Basic ${GLOBAL_POLICY_AUTH} ClientAuth=${GLOBAL_POLICY_CLIENTAUTH} + ${headers}= Create Dictionary Accept=application/json Content-Type=application/json Authorization=Basic ${GLOBAL_POLICY_AUTH} ClientAuth=${GLOBAL_POLICY_CLIENTAUTH} ${resp}= Post Request policy ${data_path} data=${data} headers=${headers} Log Received response from policy ${resp.text} - [Return] ${resp} \ No newline at end of file + [Return] ${resp} + + + +Update vVFWCL Policy + [Arguments] ${resource_id} + Delete vFWCL Policy + Create vFWCL Policy ${resource_id} + Push vFWCL Policy + Reboot Drools + Validate the vFWCL Policy + +Delete vFWCL Policy + ${data}= OperatingSystem.Get File ${POLICY_TEMPLATES}/FirewallPolicy_delete.template + ${resp}= Run Policy Delete Request /pdp/api/deletePolicy ${data} + Should Be Equal As Strings ${resp.status_code} 200 + +Create vFWCL Policy + [Arguments] ${resource_id} + ${dict}= Create Dictionary RESOURCE_ID=${resource_id} + ${data}= Fill JSON Template File ${POLICY_TEMPLATES}/FirewallPolicy_update.template ${dict} + ${resp}= Run Policy Put Request /pdp/api/updatePolicy ${data} + Should Be Equal As Strings ${resp.status_code} 200 + +Push vFWCL Policy + ${data}= OperatingSystem.Get File ${POLICY_TEMPLATES}/FirewallPolicy_push.template + ${resp}= Run Policy Put Request /pdp/api/pushPolicy ${data} + Should Be Equal As Strings ${resp.status_code} 200 + +Reboot Drools + ${stop}= Catenate docker exec -t -u policy drools bash -c "source /opt/app/policy/etc/profile.d/env.sh; policy stop" + ${start}= Catenate docker exec -t -u policy drools bash -c "source /opt/app/policy/etc/profile.d/env.sh; policy start" + Wait Until Keyword Succeeds 120 5 sec Open Connection And Log In ${GLOBAL_INJECTED_POLICY_IP_ADDR} root ${GLOBAL_VM_PRIVATE_KEY} + Write ${stop} + ${status} ${stdout}= Run Keyword And Ignore Error SSHLibrary.Read Until Regexp is running + Log ${status}: stdout=${stdout} + ${ctrlc}= Evaluate '\x03' + Run Keyword If '${status}' == 'FAIL' Write ${ctrlc} + Sleep 5s + Write ${start} + ${stdout}= SSHLibrary.Read Until Regexp is running + Log stdout=${stdout} + Should Contain ${stdout} is running + +Validate the vFWCL Policy + ${resp}= Run Drools Get Request /policy/pdp/engine/controllers/amsterdam/drools + Should Be Equal As Strings ${resp.status_code} 200 + ${resp}= Run Drools Get Request /policy/pdp/engine/controllers/amsterdam/drools/facts/closedloop-amsterdam/org.onap.policy.controlloop.Params + Should Be Equal As Strings ${resp.status_code} 200 \ No newline at end of file diff --git a/robot/resources/sdngc_interface.robot b/robot/resources/sdngc_interface.robot index c4dadc2d..794c0772 100644 --- a/robot/resources/sdngc_interface.robot +++ b/robot/resources/sdngc_interface.robot @@ -122,7 +122,8 @@ Preload One Vnf Topology [Arguments] ${service_type_uuid} ${generic_vnf_name} ${generic_vnf_type} ${vf_module_name} ${vf_module_type} ${service} ${filename} ${uuid} ${servers} Return From Keyword If '${filename}' == '' ${data_template}= OperatingSystem.Get File ${PRELOAD_VNF_TOPOLOGY_OPERATION_BODY}/preload.template - ${robot_values}= Create Dictionary generic_vnf_name=${generic_vnf_name} generic_vnf_type=${generic_vnf_type} service_type=${service_type_uuid} vf_module_name=${vf_module_name} vf_module_type=${vf_module_type} + ${pub_key}= OperatingSystem.Get File ${GLOBAL_VM_PUBLIC_KEY} + ${robot_values}= Create Dictionary pub_key=${pub_key} generic_vnf_name=${generic_vnf_name} generic_vnf_type=${generic_vnf_type} service_type=${service_type_uuid} vf_module_name=${vf_module_name} vf_module_type=${vf_module_type} ${parameters}= Get Template Parameters ${filename} ${uuid} ${servers} ${robot_values} ${data}= Fill JSON Template ${data_template} ${parameters} ${put_resp}= Run SDNGC Post Request ${SDNGC_INDEX_PATH}${PRELOAD_VNF_TOPOLOGY_OPERATION_PATH} ${data} @@ -146,7 +147,7 @@ Get Template Parameters :for ${key} in @{robot_keys} \ ${value}= Get From Dictionary ${robot_values} ${key} \ Set To Dictionary ${valuemap} ${key} ${value} - + # These should be deprecated by the above.... Set To Dictionary ${valuemap} artifacts_version=${GLOBAL_INJECTED_ARTIFACTS_VERSION} Set To Dictionary ${valuemap} network=${GLOBAL_INJECTED_NETWORK} diff --git a/robot/resources/stack_validation/validate_vfwcl.robot b/robot/resources/stack_validation/validate_vfwcl.robot index 2671d453..076e2f08 100644 --- a/robot/resources/stack_validation/validate_vfwcl.robot +++ b/robot/resources/stack_validation/validate_vfwcl.robot @@ -58,6 +58,7 @@ Validate FirewallSNK Stack ${vsn_public_ip}= Get Server Ip ${server_list} ${stack_info} vsn_name_0 network_name=public Wait For Server ${vfw_public_ip} + Wait For Server ${vsn_public_ip} Log Accessed all servers Wait For Firewall ${vfw_public_ip} Wait For Packet Sink ${vsn_public_ip} diff --git a/robot/resources/test_templates/vnf_orchestration_test_template.robot b/robot/resources/test_templates/vnf_orchestration_test_template.robot index 14bba6be..1d84426e 100644 --- a/robot/resources/test_templates/vnf_orchestration_test_template.robot +++ b/robot/resources/test_templates/vnf_orchestration_test_template.robot @@ -67,13 +67,14 @@ Orchestrate VNF Validate Service Instance ${service_instance_id} ${service} ${customer_name} ${vnflist}= Get From Dictionary ${GLOBAL_SERVICE_VNF_MAPPING} ${service} ${vnfmap}= Create Dictionary - # For vFWLC closed loop test generic-vnf-name (${vnf_name} will be used as the FWL hostname so we - # now need to make it be a valid hostname + # For vFWLC closed loop test generic-vnf-name (${vnf_name} will be used as the FWL hostname so we + # now need to make it be a valid hostname :for ${vnf} in @{vnflist} - \ ${shortuuid}= Catenate ${uuid} + \ ${shortuuid}= Catenate ${uuid} \ ${shortuuid}= Replace String ${shortuuid} - ${SPACE} - \ ${shortuuid}= Get Substring ${shortuuid} -8 + \ ${shortuuid}= Get Substring ${shortuuid} -8 \ ${vnf_name}= Catenate ${vnf}${shortuuid} + \ ${vnf_name}= Convert To Lowercase ${vnf_name} \ ${vf_module_name}= Catenate Vfmodule_Ete_${vnf}_${uuid} \ ${vnf_type}= Get VNF Type ${catalog_resources} ${vnf} \ ${vf_module}= Get VF Module ${catalog_resources} ${vnf} @@ -114,9 +115,21 @@ Get Catalog Resource :for ${key} in @{keys} \ ${cr}= Get From Dictionary ${resources} ${key} - \ Return From Keyword If '${base_name}' in '${cr['allArtifacts']['heat1']['artifactDisplayName']}' ${cr} + \ ${status} ${value}= Run Keyword and Ignore Error Get Catalog Resource Info from Heat Artifact ${cr['allArtifacts']} ${base_name} + \ Return From Keyword If '${status}' == 'PASS' ${cr} Fail Unable to find catalog resource for ${vnf} ${base_name} +Get Catalog Resource Info from Heat Artifact + [Documentation] Need to look though the list of heats.... heat1, heat2... + [Arguments] ${artifacts} ${base_name} + ${keys}= Get Dictionary Keys ${artifacts} + ${heatArtifacts}= Create List + :for ${key} in @{keys} + \ Run Keyword If 'heat' in '${key}' and 'env' not in '${key}' Append To List ${heatArtifacts} ${artifacts['${key}']} + :for ${ha} in @{heatArtifacts} + \ Return From Keyword If '${base_name}' in '${ha['artifactDisplayName']}' + Fail Unable to find ${base_name} in heatArtifacts + Get Name Pattern [Documentation] To support services with multiple VNFs, we need to dig the vnf type out of the SDC catalog resources to select in the VID UI [Arguments] ${vnf} diff --git a/robot/testsuites/demo.robot b/robot/testsuites/demo.robot index d0063d73..78649c5a 100644 --- a/robot/testsuites/demo.robot +++ b/robot/testsuites/demo.robot @@ -9,6 +9,8 @@ Resource ../resources/demo_preload.robot ${VNF_NAME} DemoVNF ${MODULE_NAME} DemoModuleName ${VNF_SERVICE} default +${GENERIC_VNF_NAME} DemoVNF +${RESOURCE_ID} DemoResourceId ${HB_STACK} ${HB_SERVICE_INSTANCE_ID} @@ -16,13 +18,6 @@ ${HB_SERVICE} *** Test Cases *** -Jerry - ${uuid}= Generate UUID - ${shortuuid}= Catenate ${uuid} - ${shortuuid}= Replace String ${shortuuid} - ${SPACE} - ${shortuuid}= Get Substring ${shortuuid} -8 - Log ${shortuuid} - Initialize Customer And Models [Tags] InitDemo Load Customer And Models Demonstration @@ -62,3 +57,14 @@ Run Heatbridge [Tags] heatbridge Execute Heatbridge ${HB_STACK} ${HB_SERVICE_INSTANCE_ID} ${HB_SERVICE} +Run vFWCL Policy Update By ID + [Documentation] + ... Update the vFW policy for the given generic VNF name + [Tags] vfwpolicyById + Execute VFW Policy Update ${RESOURCE_ID} + +Run vFWCL Policy Update By Name + [Documentation] + ... Update the vFW policy for the given generic VNF name + [Tags] vfwpolicyByName + Execute VFW Policy Update VNF Name ${GENERIC_VNF_NAME} -- cgit 1.2.3-korg