Complete vDNS closed loop teardown

Change-Id: I0c680349bb120f274465de08f1a02e5deb2e0c5d
Signed-off-by: jf9860 <jf9860@att.com>
diff --git a/robot/resources/aai/service_instance.robot b/robot/resources/aai/service_instance.robot
index 5fffa02..adf59c2 100644
--- a/robot/resources/aai/service_instance.robot
+++ b/robot/resources/aai/service_instance.robot
@@ -26,8 +26,10 @@
 ${SERVCE INSTANCE TEMPLATE}    robot/assets/templates/aai/service_subscription.template    
 
 ${GENERIC_VNF_PATH_TEMPLATE}   /network/generic-vnfs/generic-vnf/\${vnf_id}/vf-modules/vf-module/\${vf_module_id}
+${GENERIC_VNF_QUERY_TEMPLATE}   /network/generic-vnfs/generic-vnf/\${vnf_id}/vf-modules/vf-module?vf-module-name=\${vf_module_name}
 ${VLB_CLOSED_LOOP_HACK_BODY}    robot/assets/templates/aai/vlb_closed_loop_hack.template
 ${VLB_CLOSED_LOOP_DELETE}
+${VLB_CLOSED_LOOP_VNF_ID}
 
 *** Keywords ***    
 Validate Service Instance
@@ -57,13 +59,31 @@
     ${vfmodule}=    Get From List    ${list}    0
     ${persona_model_id}=    Get From Dictionary    ${closedloop_vf_module}    invariantUUID
     ${persona_model_version}=   Get From Dictionary    ${closedloop_vf_module}    version
-    ${dict}=    Create Dictionary   vnf_id=${vnf_id}   vf_module_id=dummy   persona_model_id=${persona_model_id}   persona_model_version=${persona_model_version}    
+    ${dummy}=    Catenate   dummy_${vnf_id}
+    ${dict}=    Create Dictionary   vnf_id=${vnf_id}   vf_module_id=${dummy}   persona_model_id=${persona_model_id}   persona_model_version=${persona_model_version}    
     ${datapath}=    Template String    ${GENERIC_VNF_PATH_TEMPLATE}    ${dict}
     ${data}=	Fill JSON Template File    ${VLB_CLOSED_LOOP_HACK_BODY}    ${dict}    
 	${put_resp}=    Run A&AI Put Request     ${INDEX PATH}${datapath}   ${data}
     ${status_string}=    Convert To String    ${put_resp.status_code}
     Should Match Regexp    ${status_string}    ^(201|412)$  
     Set Test Variable   ${VLB_CLOSED_LOOP_DELETE}    ${datapath}   
+    Set Test Variable   ${VLB_CLOSED_LOOP_VNF_ID}    ${vnf_id}   
+
+
+VLB Closed Loop Hack Update
+    [Documentation]   Update the A&AI vDNS scaling vf module to have persona-model-version 1 rather than 1.0
+    [Arguments]   ${stack_name}
+    ${dict}=    Create Dictionary   vnf_id=${VLB_CLOSED_LOOP_VNF_ID}   vf_module_name=${stack_name}
+    ${query}=   Template String   ${GENERIC_VNF_QUERY_TEMPLATE}   ${dict} 
+    ${get_resp}=    Run A&AI Get Request     ${INDEX_PATH}${query}
+    ${json}=   Set Variable   ${get_resp.json()}
+    Set to Dictionary    ${json}   persona-model-version   1
+    ${vf_module_id}=   Get From Dictionary   ${json}   vf-module-id
+    Set to Dictionary   ${dict}   vf_module_id=${vf_module_id}
+    ${uri}=   Template String   ${GENERIC_VNF_PATH_TEMPLATE}   ${dict} 
+    ${resp}=   Run A&AI Put Request    ${INDEX_PATH}${uri}   ${json}
+    ${get_resp}=    Run A&AI Get Request     ${INDEX_PATH}${query}
+
 
 Teardown VLB Closed Loop Hack
     Return From Keyword If    ' ${VLB_CLOSED_LOOP_DELETE}' == ''
diff --git a/robot/resources/stack_validation/policy_check_vfw.robot b/robot/resources/stack_validation/policy_check_vfw.robot
index a1ed3fa..10b2584 100644
--- a/robot/resources/stack_validation/policy_check_vfw.robot
+++ b/robot/resources/stack_validation/policy_check_vfw.robot
@@ -17,6 +17,7 @@
 Resource          packet_generator_interface.robot
 Resource          darkstat_interface.robot
 Resource          validate_common.robot
+Resource          ../../resources/test_templates/vnf_orchestration_test_template.robot
 
 
 *** Variables ***
@@ -78,6 +79,7 @@
     ${prefix}=    Get DNSScaling Prefix
     ${dnsscaling}=    Replace String Using Regexp    ${stack_name}    ^Vfmodule_    ${prefix}    
     ${dnsscaling_info}=    Wait for Stack to Be Deployed    auth    ${dnsscaling}
+    VLB Closed Loop Hack Update   ${dnsscaling}
     # TO DO: Log into vLB and cehck that traffic is flowing to the new DNS
     [Return]    ${dnsscaling}   
 
diff --git a/robot/resources/test_templates/closedloop_test_template.robot b/robot/resources/test_templates/closedloop_test_template.robot
index 67bf0cb..e3f7327 100644
--- a/robot/resources/test_templates/closedloop_test_template.robot
+++ b/robot/resources/test_templates/closedloop_test_template.robot
@@ -119,18 +119,9 @@
 Teardown Closed Loop
     [Documentation]   Tear down a closed loop test case
     Terminate All Processes 
-    Teardown VDNS
     Teardown VNF   
-    #Clean A&AI Inventory    VFWPolicy_Customer   Rackspece    vFW   
-#    Delete Config Policy    ${CONFIG_POLICY_NAME}
-#    Delete Ops Policy    ${OPS_POLICY_NAME}  
     Log     Teardown complete  
 
-Teardown VDNS
-    Return From Keyword if    '${DNSSCALINGSTACK}' == ''
-    # This needs to be done via VID
-    Teardown Stack    ${DNSSCALINGSTACK}
-
 Create Config Policy
     [Documentation]    Create Config Policy 
     ${randompolicyname} =     Create Policy Name