Update A&AI api to v11 and create complex
[testsuite.git] / robot / resources / test_templates / vnf_orchestration_test_template.robot
1 *** Settings ***
2 Documentation     This test template encapsulates the VNF Orchestration use case.
3
4 Resource        ../vid/create_service_instance.robot
5 Resource        ../vid/vid_interface.robot
6 Resource        ../aai/service_instance.robot
7 Resource        ../vid/create_vid_vnf.robot
8 Resource        ../vid/teardown_vid.robot
9 Resource        ../sdngc_interface.robot
10 Resource        model_test_template.robot
11
12 Resource        ../aai/create_zone.robot
13 Resource        ../aai/create_customer.robot
14 Resource        ../aai/create_complex.robot
15 Resource        ../aai/create_tenant.robot
16 Resource        ../aai/create_service.robot
17 Resource        ../openstack/neutron_interface.robot
18 Resource        ../heatbridge.robot
19
20
21 Library         OpenstackLibrary
22 Library             ExtendedSelenium2Library
23 Library         UUID
24 Library         Collections
25
26
27
28 *** Variables ***
29
30 #**************** TEST CASE VARIABLES **************************
31 ${TENANT_NAME}
32 ${TENANT_ID}
33 ${REGIONS}
34 ${CUSTOMER_NAME}
35 ${STACK_NAME}
36 ${SERVICE}
37 ${VVG_SERVER_ID}
38 ${SERVICE_INSTANCE_ID}
39
40 *** Keywords ***
41 Orchestrate VNF Template
42     [Documentation]   Use openECOMP to Orchestrate a service.
43     [Arguments]    ${customer_name}    ${service}    ${product_family}    ${tenant}
44     Orchestrate VNF   ${customer_name}    ${service}    ${product_family}    ${tenant}
45     Delete VNF
46
47 Orchestrate VNF
48     [Documentation]   Use openECOMP to Orchestrate a service.
49     [Arguments]    ${customer_name}    ${service}    ${product_family}    ${tenant}
50     ${lcp_region}=   Get Openstack Region
51     ${uuid}=    Generate UUID
52     Set Test Variable    ${CUSTOMER_NAME}    ${customer_name}_${uuid}
53     Set Test Variable    ${SERVICE}    ${service}
54     ${vnf_name}=    Catenate    Vnf_Ete_Name${uuid}
55     ${service_name}=    Catenate    Service_Ete_Name${uuid}
56     ${service_type}=    Set Variable    ${service}
57     ${vf_module_name}=    Catenate    Vfmodule_Ete_Name${uuid}
58     ${service_model_type}     ${vnf_type}    ${vf_modules} =    Model Distribution For Directory    ${service}
59     Run Keyword If   '${service}' == 'vVG'    Create VVG Server    ${uuid}
60     Create Customer For VNF    ${CUSTOMER_NAME}    ${CUSTOMER_NAME}    INFRA    ${service_type}    ${GLOBAL_AAI_CLOUD_OWNER}
61     Setup Browser
62     Login To VID GUI
63     ${service_instance_id}=    Create VID Service Instance    ${customer_name}    ${service_model_type}    ${service}     ${service_name}
64     Set Test Variable   ${SERVICE_INSTANCE_ID}   ${service_instance_id}
65     Validate Service Instance    ${service_instance_id}    ${service}      ${customer_name}
66     Create VID VNF    ${service_instance_id}    ${vnf_name}    ${product_family}    ${lcp_region}    ${tenant}    ${vnf_type}
67     ${vf_module_type}   ${closedloop_vf_module}=   Preload Vnf    ${service_instance_id}   ${vnf_name}   ${vnf_type}   ${vf_module_name}    ${vf_modules}    ${service}    ${uuid}
68     ${vf_module_id}=   Create VID VNF module    ${service_instance_id}    ${vf_module_name}    ${lcp_region}    ${tenant}     ${vf_module_type}
69     ${generic_vnf}=   Validate Generic VNF    ${vnf_name}    ${vnf_type}    ${service_instance_id}
70     VLB Closed Loop Hack   ${service}   ${generic_vnf}   ${closedloop_vf_module}
71     Set Test Variable    ${STACK_NAME}   ${vf_module_name}
72     Execute Heatbridge    ${vf_module_name}    ${service_instance_id}    ${service}
73     Validate VF Module      ${vf_module_name}    ${service}
74     [Return]     ${vf_module_name}    ${service}
75
76
77 Create Customer For VNF
78     [Documentation]    VNF Orchestration Test setup....
79     ...                Create Tenant if not exists, Create Customer, Create Service and related relationships
80     [Arguments]    ${customer_name}    ${customer_id}    ${customer_type}    ${service_type}    ${cloud_owner}
81     ${cloud_region_id}=   Get Openstack Region
82     Create Service If Not Exists    ${service_type}
83     ${resp}=    Create Customer    ${customer_name}    ${customer_id}    ${customer_type}    ${service_type}   ${cloud_owner}  ${cloud_region_id}    ${TENANT_ID}
84         Should Be Equal As Strings      ${resp}         201
85
86 Setup Orchestrate VNF
87     [Documentation]    Called before each test case to ensure tenant and region data
88     ...                required by the Orchstrate VNF exists in A&AI
89     [Arguments]        ${cloud_owner}  ${cloud_type}    ${owner_defined_type}    ${cloud_region_version}    ${cloud_zone}
90     Initialize Tenant From Openstack
91     Initialize Regions From Openstack
92     :FOR    ${region}    IN    @{REGIONS}
93     \    Inventory Tenant If Not Exists    ${cloud_owner}  ${region}  ${cloud_type}    ${owner_defined_type}    ${cloud_region_version}    ${cloud_zone}    ${TENANT_ID}    ${TENANT_NAME}
94     Inventory Zone If Not Exists
95     Inventory Complex If Not Exists    ${GLOBAL_AAI_COMPLEX_NAME}   ${GLOBAL_AAI_PHYSICAL_LOCATION_ID}   ${GLOBAL_AAI_CLOUD_OWNER}   ${GLOBAL_INJECTED_REGION}   ${GLOBAL_AAI_CLOUD_OWNER_DEFINED_TYPE}
96     Log   Orchestrate VNF setup complete
97
98 Initialize Tenant From Openstack
99     [Documentation]    Initialize the tenant test variables
100     Run Openstack Auth Request    auth
101     ${tenants}=    Get Current Openstack Tenant     auth
102     ${tenant_name}=    Evaluate    $tenants.get("name")
103     ${tenant_id}=     Evaluate    $tenants.get("id")
104     Set Test Variable   ${TENANT_NAME}   ${tenant_name}
105     Set Test Variable   ${TENANT_ID}     ${tenant_id}
106
107 Initialize Regions From Openstack
108     [Documentation]    Initialize the regions test variable
109     Run Openstack Auth Request    auth
110     ${regs}=    Get Openstack Regions    auth
111     Set Test Variable   ${REGIONS}     ${regs}
112
113 Create VVG Server
114     [Documentation]    For the VolumeGroup test case, create a server to attach the volume group to be orchestrated.
115     [Arguments]    ${uuid}
116     Run Openstack Auth Request    auth
117     ${vvg_server_name}=    Catenate   vVG_${uuid}
118     ${server}=   Add Server For Image Name  auth    ${vvg_server_name}   ${GLOBAL_INJECTED_VM_IMAGE_NAME}   ${GLOBAL_INJECTED_VM_FLAVOR}   ${GLOBAL_INJECTED_PUBLIC_NET_ID}
119     ${server}=       Get From Dictionary   ${server}   server
120     ${server_id}=    Get From Dictionary   ${server}   id
121     Set Test Variable    ${VVG_SERVER_ID}   ${server_id}
122     ${vvg_params}=    Get VVG Preload Parameters
123     Set To Dictionary   ${vvg_params}   nova_instance   ${server_id}
124     Wait for Server to Be Active    auth    ${server_id}
125
126 Get VVG Preload Parameters
127     [Documentation]   Get preload parameters for the VVG test case so we can include
128     ...               the nova_instance id of the attached server
129     ${test_dict}=    Get From Dictionary    ${GLOBAL_PRELOAD_PARAMETERS}    Vnf-Orchestration
130     ${vvg_params}   Get From Dictionary    ${test_dict}    vvg_preload.template
131     [Return]    ${vvg_params}
132
133 Delete VNF
134     [Documentation]    Called at the end of a test case to tear down the VNF created by Orchestrate VNF
135     ${lcp_region}=   Get Openstack Region
136     Teardown VVG Server
137     Teardown VLB Closed Loop Hack
138     Teardown VID   ${SERVICE_INSTANCE_ID}   ${lcp_region}   ${TENANT_ID}
139     Log    VNF Deleted
140
141 Teardown VNF
142     [Documentation]    Called at the end of a test case to tear down the VNF created by Orchestrate VNF
143     Run Keyword If   '${TEST STATUS}' == 'PASS'   Teardown Model Distribution
144     Run Keyword If   '${TEST STATUS}' == 'PASS'   Clean A&AI Inventory
145     Close All Browsers
146     Log    Teardown VNF implemented for successful tests only
147
148 Teardown VVG Server
149     [Documentation]   Teardown the server created as a place to mount the Volume Group.
150     Return From Keyword if   '${VVG_SERVER_ID}' == ''
151     Delete Server   auth   ${VVG_SERVER_ID}
152     Wait for Server To Be Deleted    auth    ${VVG_SERVER_ID}
153     ${vvg_params}=    Get VVG Preload Parameters
154     Remove from Dictionary   ${vvg_params}   nova_instance
155     Log    Teardown VVG Server Completed
156
157 Teardown Stack
158     [Documentation]    OBSOLETE - Called at the end of a test case to tear down the Stack created by Orchestrate VNF
159     [Arguments]   ${stack}
160     Run Openstack Auth Request    auth
161     ${stack_info}=    Get Stack Details    auth    ${stack}
162     Log    ${stack_info}
163     ${stack_id}=    Get From Dictionary    ${stack_info}    id
164     ${key_pair_status}   ${keypair_name}=   Run Keyword And Ignore Error   Get From Dictionary    ${stack_info}    key_name
165     Delete Openstack Stack      auth    ${stack}    ${stack_id}
166     Log    Deleted ${stack} ${stack_id}
167     Run Keyword If   '${key_pair_status}' == 'PASS'   Delete Openstack Keypair    auth    ${keypair_name}
168     Teardown VLB Closed Loop Hack
169
170 Clean A&AI Inventory
171     [Documentation]    Clean up Tenant in A&AI, Create Customer, Create Service and related relationships
172     Delete Customer    ${CUSTOMER_NAME}