Complete teardown implementation.

Add demo.sh to support hands on demo

Change-Id: Idf235957bd992e6d7482c8241f6ba8b8944c2826
Signed-off-by: jf9860 <jf9860@att.com>
diff --git a/robot/resources/test_templates/model_test_template.robot b/robot/resources/test_templates/model_test_template.robot
index 263c592..e97984d 100644
--- a/robot/resources/test_templates/model_test_template.robot
+++ b/robot/resources/test_templates/model_test_template.robot
@@ -23,7 +23,7 @@
 *** Keywords ***
 
 Model Distribution For Directory
-    [Arguments]    ${service}
+    [Arguments]    ${service}   ${catalog_service_name}=
     ${directory_list}=    Get From Dictionary    ${GLOBAL_SERVICE_FOLDER_MAPPING}    ${service}
     ${ziplist}=    Create List
     :for   ${directory}    in    @{directory_list}
@@ -32,7 +32,7 @@
     \    OperatingSystem.Create Directory    ${ASDC_ASSETS_DIRECTORY}/temp
     \    Create Zip From Files In Directory        ${folder}    ${zip}
     \    Append To List    ${ziplist}    ${zip}    
-    ${catalog_service_name}    ${catalog_resource_name}    ${vf_modules}    ${catalog_resource_ids}   ${catalog_service_id}   Distribute Model From ASDC    ${ziplist}
+    ${catalog_service_name}    ${catalog_resource_name}    ${vf_modules}    ${catalog_resource_ids}   ${catalog_service_id}   Distribute Model From ASDC    ${ziplist}    ${catalog_service_name}
     Set Test Variable   ${CATALOG_RESOURCE_IDS}   ${catalog_resource_ids}
     Set Test Variable   ${CATALOG_SERVICE_ID}   ${catalog_service_id}
     [Return]    ${catalog_service_name}    ${catalog_resource_name}    ${vf_modules}        
diff --git a/robot/resources/test_templates/vnf_orchestration_test_template.robot b/robot/resources/test_templates/vnf_orchestration_test_template.robot
index 00f15cf..a149745 100644
--- a/robot/resources/test_templates/vnf_orchestration_test_template.robot
+++ b/robot/resources/test_templates/vnf_orchestration_test_template.robot
@@ -5,6 +5,7 @@
 Resource        ../vid/vid_interface.robot
 Resource        ../aai/service_instance.robot
 Resource        ../vid/create_vid_vnf.robot
+Resource        ../vid/teardown_vid.robot
 Resource        ../sdngc_interface.robot
 Resource        model_test_template.robot
 
@@ -31,10 +32,12 @@
 ${STACK_NAME}
 ${SERVICE} 
 ${VVG_SERVER_ID}
+${SERVICE_INSTANCE_ID}
 
 *** Keywords ***     
  
 Orchestrate VNF
+    [Documentation]   Use openECOMP to Orchestrate a service.
     [Arguments]    ${customer_name}    ${service}    ${product_family}    ${lcp_region}    ${tenant}
     ${uuid}=    Generate UUID  
     Set Test Variable    ${CUSTOMER_NAME}    ${customer_name}_${uuid}
@@ -51,6 +54,7 @@
     Setup Browser   
     Login To VID GUI
     ${service_instance_id}=    Create VID Service Instance    ${customer_name}    ${service_model_type}    ${service}     ${service_name}
+    Set Test Variable   ${SERVICE_INSTANCE_ID}   ${service_instance_id}
     Validate Service Instance    ${service_instance_id}    ${service}      ${customer_name}     
     Create VID VNF    ${service_instance_id}    ${vnf_name}    ${product_family}    ${lcp_region}    ${tenant}    ${vnf_type}
     ${vf_module_type}   ${closedloop_vf_module}=   Preload Vnf    ${service_instance_id}   ${vnf_name}   ${vnf_type}   ${vf_module_name}    ${vf_modules}    ${service}    ${uuid}
@@ -61,7 +65,6 @@
     Execute Heatbridge    ${vf_module_name}    ${service_instance_id}    ${service}
     Validate VF Module      ${vf_module_name}    ${service}
     [Return]     ${vf_module_name}    ${service}
-    [Teardown]    Close All Browsers
 
 
 Create Customer For VNF
@@ -73,7 +76,8 @@
     Create Service If Not Exists    ${service_type}
 
 Setup Orchestrate VNF
-    [Documentation]    Called before each test case to ensure data required by the Orchstrate VNF exists 
+    [Documentation]    Called before each test case to ensure tenant and region data 
+    ...                required by the Orchstrate VNF exists in A&AI 
     [Arguments]        ${cloud_owner}  ${cloud_region_id}   ${cloud_type}    ${owner_defined_type}    ${cloud_region_version}    ${cloud_zone}
     Initialize Tenant From Openstack
     Initialize Regions From Openstack
@@ -82,19 +86,22 @@
     Log   Orchestrate VNF setup complete    
         
 Initialize Tenant From Openstack
+    [Documentation]    Initialize the tenant test variables
     Run Openstack Auth Request    auth
     ${tenants}=    Get Current Openstack Tenant     auth
     ${tenant_name}=    Evaluate    $tenants.get("name")
     ${tenant_id}=     Evaluate    $tenants.get("id")  
-    Set Suite Variable	${TENANT_NAME}   ${tenant_name}
-    Set Suite Variable	${TENANT_ID}     ${tenant_id}   
+    Set Test Variable	${TENANT_NAME}   ${tenant_name}
+    Set Test Variable	${TENANT_ID}     ${tenant_id}   
 
 Initialize Regions From Openstack
+    [Documentation]    Initialize the regions test variable
     Run Openstack Auth Request    auth
     ${regs}=    Get Openstack Regions    auth
-    Set Suite Variable	${REGIONS}     ${regs} 
+    Set Test Variable	${REGIONS}     ${regs} 
 
 Create VVG Server
+    [Documentation]    For the VolumeGroup test case, create a server to attach the volume group to be orchestrated.
     [Arguments]    ${uuid}            
     Run Openstack Auth Request    auth
     ${vvg_server_name}=    Catenate   vVG_${uuid}
@@ -106,7 +113,9 @@
     Set To Dictionary   ${vvg_params}   nova_instance   ${server_id}
     Wait for Server to Be Active    auth    ${server_id}    
 
-Get VVG Preload Parameters    
+Get VVG Preload Parameters
+    [Documentation]   Get preload parameters for the VVG test case so we can include 
+    ...               the nova_instance id of the attached server    
     ${test_dict}=    Get From Dictionary    ${GLOBAL_PRELOAD_PARAMETERS}    Vnf-Orchestration
     ${vvg_params}   Get From Dictionary    ${test_dict}    vvg_preload.template
     [Return]    ${vvg_params}
@@ -114,15 +123,15 @@
 Teardown VNF
     [Documentation]    Called at the end of a test case to tear down the VNF created by Orchestrate VNF
     Teardown VVG Server  
-    # Free up rackspace resources until true teardown is implemented
-    Run Keyword If   '${TEST STATUS}' == 'PASS'    Teardown Stack   ${STACK_NAME}
-    Set Test Variable     ${VVG_SERVER_ID}   ''
-    
-    ## Conditional remove so as to enable manual teardown testing of failed stacks
+    Teardown VLB Closed Loop Hack
+    Run Keyword If   '${TEST STATUS}' == 'PASS'  Teardown VID   ${SERVICE_INSTANCE_ID}   ${GLOBAL_OPENSTACK_SERVICE_REGION}   ${TENANT_ID}
     Run Keyword If   '${TEST STATUS}' == 'PASS'    Teardown Model Distribution  
-    Log    Teardown VNF not completely implemented
+    Run Keyword If   '${TEST STATUS}' == 'PASS'    Clean A&AI Inventory 
+    Close All Browsers 
+    Log    Teardown VNF implemented for successful tests only
 
 Teardown VVG Server
+    [Documentation]   Teardown the server created as a place to mount the Volume Group.
     Return From Keyword if   '${VVG_SERVER_ID}' == ''
     Delete Server   auth   ${VVG_SERVER_ID}
     Wait for Server To Be Deleted    auth    ${VVG_SERVER_ID}    
@@ -131,7 +140,7 @@
     Log    Teardown VVG Server Completed
     
 Teardown Stack
-    [Documentation]    Called at the end of a test case to tear down the Stack created by Orchestrate VNF
+    [Documentation]    OBSOLETE - Called at the end of a test case to tear down the Stack created by Orchestrate VNF
     [Arguments]   ${stack}
     Run Openstack Auth Request    auth
     ${stack_info}=    Get Stack Details    auth    ${stack}
@@ -141,43 +150,13 @@
     Delete Openstack Stack      auth    ${stack}    ${stack_id}
     Log    Deleted ${stack} ${stack_id}
     Run Keyword If   '${key_pair_status}' == 'PASS'   Delete Openstack Keypair    auth    ${keypair_name}
-    ## Removed  code to remove all of the IPs from the oam network - didn't help
-
-
-Get Ecomp Private Net Ports
-    [Arguments]    ${alias}    ${stack_info}    ${service}
-    ${list}=    Create List
-    ${netid}=    Get From Dictionary    ${stack_info}    ecomp_private_net_id
-    ${cidr}=    Get From Dictionary    ${stack_info}    ecomp_private_net_cidr
-    ${ip_addresses}=    Get Ecomp Ip Addresses    ${stack_info}    ${service}
-    ${net_ports}=    Get Openstack Ports For Subnet    ${alias}    ${netid}    ${cidr}
-    :for    ${ip_address}    in    @{ip_addresses}
-    \    ${port}=    Find Ecomp Port     ${net_ports}    ${ip_address}
-    \     Run Keyword If    ${port} is not None    Append To List    ${list}    ${port}        
-    [Return]    ${list}
-    
-Get Ecomp Ip Addresses
-    [Arguments]    ${stack_info}    ${service}
-    ${ip_addresses}=    Create List
-    ${names}=    Get From Dictionary    ${GLOBAL_SERVICE_ECOMP_IP_MAPPING}    ${service}
-    :for    ${name}    in    @{names}
-    \    ${ip}=    Get From Dictionary    ${stack_info}    ${name}
-    \    Append To List    ${ip_addresses}    ${ip}
-    [Return]    ${ip_addresses}
-
-Find Ecomp Port
-    [Arguments]    ${ports}    ${ip_address}
-   :for    ${port}   in   @{ports}
-    \    Return From Keyword If    '${port['fixed_ips'][0]['ip_address']}' == '${ip_address}'    ${port}
-    [Return]    None
- 
+    Teardown VLB Closed Loop Hack
 
 Clean A&AI Inventory 
     [Documentation]    Clean up Tenant in A&AI, Create Customer, Create Service and related relationships	
-    [Arguments]    ${customer_id}    ${cloud_owner}    ${service_type}
     :FOR    ${region}    IN    @{REGIONS}
-    \      Delete Tenant  ${TENANT_ID}    ${cloud_owner}  ${region}
-    \      Delete Cloud Region  ${TENANT_ID}    ${cloud_owner}  ${region}
-    Delete Customer    ${customer_id}
-    Delete Service If Exists    ${service_type}    	
+    \      Delete Tenant  ${TENANT_ID}    ${GLOBAL_AAI_CLOUD_OWNER}  ${region}
+    \      Delete Cloud Region  ${TENANT_ID}    ${GLOBAL_AAI_CLOUD_OWNER}  ${region}
+    Delete Customer    ${CUSTOMER_NAME}
+    Delete Service If Exists    ${SERVICE}