move rest of stirngtemplating off old format
[testsuite.git] / robot / resources / test_templates / vnf_orchestration_with_cds_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 Resource        ../global_properties.robot
21 Resource        ../so_interface.robot
22
23 Library         ONAPLibrary.Openstack
24 Library         ONAPLibrary.Utilities
25 Library         ONAPLibrary.Templating
26 Library         Collections
27 Library         String
28 Library         ONAPLibrary.JSON
29
30 Library         RequestsLibrary
31 Library         Collections
32
33 *** Variables ***
34 ${service_template}    robot/assets/cds/service-Vfirewall0911-template.yml
35 ${env}      robot/assets/cds/env.yml
36 ${so_request_template}    so/cds_request.jinja    
37 ${vnf_template_name}    so/cds_vnf.jinja
38 ${vfmodule_template_name}       so/cds_vfmodule.jinja
39 ${so_uri_path}          /onap/so/infra/serviceInstantiation/v7/serviceInstances
40 *** Variables ***
41
42 #**************** TEST CASE VARIABLES **************************
43 ${TENANT_NAME}
44 ${TENANT_ID}
45 ${REGIONS}
46 ${CUSTOMER_NAME}
47 ${STACK_NAME}
48 ${STACK_NAMES}
49 ${SERVICE}
50 ${VVG_SERVER_ID}
51 ${SERVICE_INSTANCE_ID}
52
53 *** Keywords ***
54 Orchestrate VNF With CDS Template
55     [Documentation]   Use openECOMP to Orchestrate a service.
56     [Arguments]    ${customer_name}    ${service}    ${product_family}    ${tenant}
57     Orchestrate VNF With CDS    ${customer_name}    ${service}    ${product_family}    ${tenant}
58
59 Orchestrate VNF With CDS
60     [Documentation]   Use openECOMP to Orchestrate a service.
61     [Arguments]    ${customer_name}    ${service}    ${product_family}    ${tenant}     ${project_name}=Project-Demonstration   ${owning_entity}=OE-Demonstration
62     ${lcp_region}=   Get Openstack Region
63     ${uuid}=    Generate UUID4
64     Set Test Variable    ${CUSTOMER_NAME}    ${customer_name}_${uuid}
65     Set Test Variable    ${SERVICE}    ${service}
66     ${list}=    Create List
67     Set Test Variable    ${STACK_NAMES}   ${list}
68     ${service_instance_name}=    Catenate    Service_Ete_Name${uuid}
69     ${dict}=  Create Dictionary
70     Set To Dictionary   ${dict}   service_instance_name=${service_instance_name}
71
72     ${templatedata}=    Template Yaml To Json    ${service_template}
73     ${jsondata}=     Evaluate     json.loads('''${templatedata}''')      json
74     Set To Dictionary   ${dict}   service_type=${jsondata['metadata']['type']}
75     Set To Dictionary   ${dict}   service_model_name=${jsondata['metadata']['name']}
76     Set To Dictionary   ${dict}   service_model_UUID=${jsondata['metadata']['UUID']}
77     Set To Dictionary   ${dict}   service_model_invariantUUID=${jsondata['metadata']['invariantUUID']}
78     
79     ${envdata}=    Env Yaml To Json    ${env}
80     ${envjson}=    Evaluate     json.loads('''${envdata}''')      json
81     Set To Dictionary   ${dict}   subscriber_id=${envjson['subscriber_id']}
82     Set To Dictionary   ${dict}   subscription_service_type=${envjson['subscription_service_type']}
83     Set To Dictionary   ${dict}   cloud_region=${envjson['cloud_region']}
84     Set To Dictionary   ${dict}   tenant_id=${envjson['tenant_id']}
85
86     ${list}=    Create List
87     ${vnfs}=   Get From Dictionary    ${jsondata['topology_template']}   node_templates
88     ${keys}=   Get Dictionary Keys    ${vnfs}
89     Create Environment    cds    ${GLOBAL_TEMPLATE_FOLDER}
90     :FOR   ${key}  IN  @{keys}
91     \    ${vnf}=   Get From Dictionary    ${vnfs}   ${key}
92     \    Get VNF Info   ${key}  ${vnf}  ${dict}
93     \    ${vf_modules}=    Get From Dictionary   ${jsondata['topology_template']}    groups
94     \    ${value}=      Evaluate        "${key}".replace("-","").replace(" ","")
95     \    ${value}=      Convert To Lowercase    ${value}
96     \    ${vfmodules}=  Get VFModule Info        ${jsondata}    ${value}          ${dict}
97     \    Set To Dictionary      ${dict}   vf_modules=${vfmodules}
98     \    ${vnf_payload}=   Apply Template    cds                ${vnf_template_name}            ${dict}
99     \    ${data}=       Catenate        [${vnf_payload}]
100    
101     Set To Dictionary           ${dict}         vnfs=${data}
102     ${request}=     Apply Template    cds    ${so_request_template}    ${dict}
103     Log To Console     --------request--------
104     Log to console     ${request}
105     Log To Console     --------end request--------
106     ${resp}=    Run MSO Post Request    ${so_uri_path}          ${request}
107     Log To Console      --------response-------
108     ${json_string}=    Evaluate    json.dumps(${resp.json()})    json
109     Log To Console      ${json_string}
110     Log To Console    instanceId=${resp.json()['requestReferences']['instanceId']}
111     ${requestId}=    Catenate    ${resp.json()['requestReferences']['requestId']}
112     Log To Console    requestId=${requestId}
113     Log To Console      -------end response-------
114     # Poll MSO Get Request    ${GLOBAL_MSO_STATUS_PATH}${request_id}   COMPLETE
115
116
117 Get VNF Info
118     [Documentation]     Get VNF Info
119     [Arguments]         ${vnf_name}     ${vnfjson}      ${dict}
120     ${metadata}=        Get From Dictionary     ${vnfjson}      metadata
121     Set To Dictionary   ${dict}   vnf_name=${vnf_name}
122     Set To Dictionary   ${dict}   vnf_model_name=${metadata['name']}
123     Set To Dictionary   ${dict}   vnf_model_version_id=${metadata['UUID']}
124     Set To Dictionary   ${dict}   vnf_model_customization_name=${metadata['name']}
125     Set To Dictionary   ${dict}   vnf_model_customization_id=${metadata['customizationUUID']}
126         
127
128 Get VFModule Info
129     [Documentation]   Dig the vf module names from the VID service model
130     [Arguments]   ${jsondata}   ${vnf}   ${dict}
131     ${vfModules}=   Get From Dictionary    ${jsondata['topology_template']}   groups
132     ${keys}=   Get Dictionary Keys    ${vfModules}
133     ${data}=   Catenate
134     ${delim}=   Catenate
135     Create Environment    cds    ${GLOBAL_TEMPLATE_FOLDER}
136     :FOR   ${key}  IN  @{keys}
137     \    ${module}=   Get From Dictionary    ${vfModules}   ${key}
138     \    Log to console         ${vnf} ${key}
139     \    Run keyword if         "${vnf}" in "${key}"    set vfmodule param      ${key}    ${module}     ${dict}
140     \    ${vfmodule_payload}=   Apply Template          cds    ${vfmodule_template_name}                ${dict}
141     \    ${data}=       Catenate    ${data}   ${delim}   ${vfmodule_payload}
142     \    ${delim}=      Catenate        ,
143     Log To Console      ${data}
144     [Return]    ${data}
145
146 set vfmodule param
147     [Documentation]    Set vfmodule parameters
148     [Arguments]         ${vfmodule_name}   ${vfmodule}  ${dict}
149     Set To Dictionary   ${dict}   vf_module_model_type=${vfmodule['type']}
150     Set To Dictionary   ${dict}   vf_module_model_name=${vfmodule['metadata']['vfModuleModelName']}
151     Set To Dictionary   ${dict}   vf_module_model_version_id=${vfmodule['metadata']['vfModuleModelUUID']}
152     Set To Dictionary   ${dict}   vf_module_model_customization_id=${vfmodule['metadata']['vfModuleModelCustomizationUUID']}
153     Set To Dictionary   ${dict}   vf_module_name=${vfmodule_name}
154