Implement VFW policy update for demo.sh (trial) 65/25965/1
authorJerry Flood <jf9860@att.com>
Sat, 9 Dec 2017 21:20:42 +0000 (16:20 -0500)
committerJerry Flood <jf9860@att.com>
Sat, 9 Dec 2017 21:20:59 +0000 (16:20 -0500)
Issue-ID: TEST-72
Change-Id: I16eb3eee84dfef6dde430e4ed73b4cbcc0059757
Signed-off-by: Jerry Flood <jf9860@att.com>
robot/assets/templates/policy/FirewallPolicy_delete.template [new file with mode: 0644]
robot/resources/demo_preload.robot
robot/resources/global_properties.robot
robot/resources/policy_interface.robot
robot/resources/sdngc_interface.robot
robot/resources/stack_validation/validate_vfwcl.robot
robot/resources/test_templates/vnf_orchestration_test_template.robot
robot/testsuites/demo.robot

diff --git a/robot/assets/templates/policy/FirewallPolicy_delete.template b/robot/assets/templates/policy/FirewallPolicy_delete.template
new file mode 100644 (file)
index 0000000..8bc9e88
--- /dev/null
@@ -0,0 +1,6 @@
+{
+  "pdpGroup": "default",
+  "policyComponent" : "PDP",
+  "policyName": "com.BRMSParamvFirewall",
+  "policyType": "BRMS_Param"
+}
\ No newline at end of file
index 5b3e14c..b1eff95 100644 (file)
@@ -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
index 129f8d1..fc40527 100644 (file)
@@ -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
index a622ae6..e38d944 100644 (file)
@@ -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
index c4dadc2..794c077 100644 (file)
@@ -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}
index 2671d45..076e2f0 100644 (file)
@@ -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}
index 14bba6b..1d84426 100644 (file)
@@ -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}
index d0063d7..78649c5 100644 (file)
@@ -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}