First Pass Automated vFW control setup

Issue-ID: TEST-110
Change-Id: Ib3ea0120a72dc0b6932bb9e12c4ba385e89511c3
Signed-off-by: Brian Freeman <bf1936@att.com>
diff --git a/robot/assets/templates/policy/FirewallPolicy_delete.template b/robot/assets/templates/policy/FirewallPolicy_delete.template
new file mode 100644
index 0000000..c88d718
--- /dev/null
+++ b/robot/assets/templates/policy/FirewallPolicy_delete.template
@@ -0,0 +1,6 @@
+{
+  "pdpGroup": "default",
+  "policyComponent" : "PDP",
+  "policyName": "com.BRMSParamvFirewall",
+  "policyType": "BRMS_Param"
+}
diff --git a/robot/assets/templates/policy/FirewallPolicy_push.template b/robot/assets/templates/policy/FirewallPolicy_push.template
new file mode 100644
index 0000000..46033f8
--- /dev/null
+++ b/robot/assets/templates/policy/FirewallPolicy_push.template
@@ -0,0 +1,5 @@
+{
+  "pdpGroup": "default",
+  "policyName": "com.BRMSParamvFirewall",
+  "policyType": "BRMS_Param"
+}
diff --git a/robot/resources/demo_preload.robot b/robot/resources/demo_preload.robot
index 664525b..102305a 100644
--- a/robot/resources/demo_preload.robot
+++ b/robot/resources/demo_preload.robot
@@ -4,7 +4,9 @@
 Resource        test_templates/model_test_template.robot
 Resource        test_templates/vnf_orchestration_test_template.robot
 Resource        asdc_interface.robot
+Resource        mso_interface.robot
 Resource        vid/vid_interface.robot
+Resource	policy_interface.robot
 
 Library	        UUID
 Library	        Collections
@@ -152,6 +154,14 @@
     Save For Delete
     Log to Console   Customer Name=${CUSTOMER_NAME}
     Log to Console   VNF Module Name=${vf_module_name}
+    ${model_invariant_id}=   Run MSO Get ModelInvariantId   ${SUITE_SERVICE_MODEL_NAME} 
+    Log to Console   ModelInvariantID=${model_invariant_id}
+    Update vVFWCL Policy   ${model_invariant_id}
+    APPC Mount Point    ${vf_module_name}
+    
+    
+    
+
 
 Save For Delete
     [Documentation]   Create a variable file to be loaded for save for delete
@@ -182,5 +192,6 @@
     \    ${comma}=   Catenate   ,
     ${vars}=    Catenate  ${vars}]\n
     OperatingSystem.Create File   ${FILE_CACHE}/${STACK_NAME}.py   ${vars}
+    OperatingSystem.Create File   ${FILE_CACHE}/lastVNF4HEATBRIGE.py   ${vars}
 
 
diff --git a/robot/resources/global_properties.robot b/robot/resources/global_properties.robot
index 70909e2..e32b01e 100644
--- a/robot/resources/global_properties.robot
+++ b/robot/resources/global_properties.robot
@@ -28,6 +28,7 @@
 ${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_ONAP_PRIVATE_KEY}   ${EXECDIR}/robot/assets/keys/onap_dev.pvt
 ${GLOBAL_AAI_ZONE_ID}    nova1
 ${GLOBAL_AAI_ZONE_NAME}    nova
 ${GLOBAL_AAI_DESIGN_TYPE}    integration
diff --git a/robot/resources/mso_interface.robot b/robot/resources/mso_interface.robot
index 49965c8..200b270 100644
--- a/robot/resources/mso_interface.robot
+++ b/robot/resources/mso_interface.robot
@@ -20,6 +20,16 @@
     ${resp}= 	Get Request 	mso 	${MSO_HEALTH_CHECK_PATH}     headers=${headers}
     Should Be Equal As Strings 	${resp.status_code} 	200
 
+Run MSO Get ModelInvariantId
+    [Documentation]    Runs an MSO Get ModelInvariantID for ClosedLoop Polieis 
+    [Arguments]    ${service_model_name}    
+    ${param_dict}=    Create Dictionary    serviceModelName    ${service_model_name}
+    ${param}=   Evaluate   urllib.urlencode(${param_dict})    urllib
+    ${data_path}=   Catenate   SEPARATOR=     /ecomp/mso/catalog/v2/serviceVnfs?  ${param}
+    ${resp}=    Run MSO Get Request    ${data_path}
+    Log    ${resp.json()}
+    [Return]   ${resp.json()['serviceVnfs'][0]['modelInfo']['modelInvariantUuid']}
+    
 Run MSO Get Request
     [Documentation]    Runs an MSO get request
     [Arguments]    ${data_path}    ${accept}=application/json
diff --git a/robot/resources/policy_interface.robot b/robot/resources/policy_interface.robot
index f05f265..8bc9c3b 100644
--- a/robot/resources/policy_interface.robot
+++ b/robot/resources/policy_interface.robot
@@ -11,6 +11,7 @@
 ${POLICY_HEALTH_CHECK_PATH}        /healthcheck
 ${POLICY_ENDPOINT}     ${GLOBAL_POLICY_SERVER_PROTOCOL}://${GLOBAL_INJECTED_POLICY_IP_ADDR}:${GLOBAL_POLICY_SERVER_PORT}
 ${POLICY_HEALTHCHECK_ENDPOINT}     ${GLOBAL_POLICY_SERVER_PROTOCOL}://${GLOBAL_INJECTED_POLICY_IP_ADDR}:${GLOBAL_POLICY_HEALTHCHECK_PORT}
+${POLICY_TEMPLATES}        robot/assets/templates/policy
 
 *** Keywords ***
 
@@ -63,7 +64,7 @@
 
 Update vVFWCL Policy
     [Arguments]   ${resource_id}
-    Delete vFWCL Policy
+    Run Keyword and Ignore Error    Delete vFWCL Policy
     Sleep    20s
     Create vFWCL Policy     ${resource_id}
     Sleep    5s
diff --git a/robot/resources/test_templates/vnf_orchestration_test_template.robot b/robot/resources/test_templates/vnf_orchestration_test_template.robot
index 6e2cd9a..ae0ba02 100644
--- a/robot/resources/test_templates/vnf_orchestration_test_template.robot
+++ b/robot/resources/test_templates/vnf_orchestration_test_template.robot
@@ -58,6 +58,7 @@
     ${service_name}=    Catenate    Service_Ete_Name${uuid}
     ${service_type}=    Set Variable    ${service}
     ${service_model_type}     ${vnf_type}    ${vf_modules}   ${catalog_resources}=    Model Distribution For Directory    ${service}
+    Set Suite Variable    ${SUITE_SERVICE_MODEL_NAME}   ${service_model_type}
     Run Keyword If   '${service}' == 'vVG'    Create VVG Server    ${uuid}
     Create Customer For VNF    ${CUSTOMER_NAME}    ${CUSTOMER_NAME}    INFRA    ${service_type}    ${GLOBAL_AAI_CLOUD_OWNER}
     Setup Browser
diff --git a/robot/testsuites/demo.robot b/robot/testsuites/demo.robot
index 005b410..e7c47f4 100644
--- a/robot/testsuites/demo.robot
+++ b/robot/testsuites/demo.robot
@@ -43,6 +43,7 @@
     [Tags]   instantiateVFWCL
     Instantiate VNF   vFWCL
 
+
 Delete Instantiated VNF
     [Documentation]   This test assumes all necessary variables are loaded via the variable file create in  Save For Delete
     ...    The Teardown VNF needs to be in the teardown step of the test case...