Remove trailing spaces in robot scripts
[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        ../sdnc_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
22 Library         ONAPLibrary.Openstack
23 Library         ONAPLibrary.Utilities
24 Library         ONAPLibrary.Templating    WITH NAME    Templating
25 Library         Collections
26 Library         String
27 Library         ONAPLibrary.JSON
28
29 Library         RequestsLibrary
30 Library         Collections
31 Library        ONAPLibrary.SO    WITH NAME    SO
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
41 *** Keywords ***
42 Orchestrate VNF With CDS Template
43     [Documentation]   Use ONAP to Orchestrate a service.
44     [Arguments]    ${customer_name}    ${service_instance_name}    ${product_family}
45     ${uuid}=    Generate UUID4
46     Orchestrate VNF With CDS    ${customer_name}_${uuid}    ${service_instance_name}${uuid}    ${product_family}
47
48 Orchestrate VNF With CDS
49     [Documentation]   Use ONAP to Orchestrate a service.
50     [Arguments]    ${customer_name}    ${service_instance_name}    ${product_family}    ${project_name}=Project-Demonstration   ${owning_entity}=OE-Demonstration
51     ${lcp_region}=   Get Openstack Region
52     ${dict}=  Create Dictionary
53     Set To Dictionary   ${dict}   service_instance_name=${service_instance_name}
54     Set To Dictionary   ${dict}    owning_entity=${owning_entity}
55     Set To Dictionary   ${dict}    owning_entity_id=67f2e84c-734d-4e90-a1e4-d2ffa2e75849
56     ${templatedata}=    Template Yaml To Json    ${service_template}
57     ${jsondata}=     Evaluate     json.loads('''${templatedata}''')      json
58     Set To Dictionary   ${dict}   service_type=${jsondata['metadata']['type']}
59     Set To Dictionary   ${dict}   service_model_name=${jsondata['metadata']['name']}
60     Set To Dictionary   ${dict}   service_model_UUID=${jsondata['metadata']['UUID']}
61     Set To Dictionary   ${dict}   service_model_invariantUUID=${jsondata['metadata']['invariantUUID']}
62     Set To Dictionary   ${dict}   cloud_owner=${GLOBAL_AAI_CLOUD_OWNER}
63     Set To Dictionary   ${dict}   homing_solution=none
64     ${envdata}=    Env Yaml To Json    ${env}
65     ${envjson}=    Evaluate     json.loads('''${envdata}''')      json
66     Set To Dictionary   ${dict}   subscriber_id=${envjson['subscriber_id']}
67     Set To Dictionary   ${dict}   subscription_service_type=${envjson['subscription_service_type']}
68     Set To Dictionary   ${dict}   cloud_region=${envjson['cloud_region']}
69     Set To Dictionary   ${dict}   tenant_id=${envjson['tenant_id']}
70
71     ${vnfs}=   Get From Dictionary    ${jsondata['topology_template']}   node_templates
72     ${keys}=   Get Dictionary Keys    ${vnfs}
73     Templating.Create Environment    cds    ${GLOBAL_TEMPLATE_FOLDER}
74     :FOR   ${key}  IN  @{keys}
75     \    ${vnf}=   Get From Dictionary    ${vnfs}   ${key}
76     \    Get VNF Info   ${key}  ${vnf}  ${dict}
77     \    ${vf_modules}=    Get From Dictionary   ${jsondata['topology_template']}    groups
78     \    ${value}=      Evaluate        "${key}".replace("-","").replace(" ","")
79     \    ${value}=      Convert To Lowercase    ${value}
80     \    ${vfmodules}=  Get VFModule Info        ${jsondata}    ${value}          ${dict}
81     \    Set To Dictionary      ${dict}   vf_modules=${vfmodules}
82     \    ${vnf_payload}=   Templating.Apply Template    cds             ${vnf_template_name}            ${dict}
83     \    ${data}=       Catenate        [${vnf_payload}]
84
85     Set To Dictionary           ${dict}         vnfs=${data}
86     ${request}=     Templating.Apply Template    cds    ${so_request_template}    ${dict}
87     Log     --------request--------
88     Log     ${request}
89     Log     --------end request--------
90     ${auth}=  Create List  ${GLOBAL_SO_USERNAME}    ${GLOBAL_SO_PASSWORD}
91     ${resp}=    SO.Run Post Request  ${GLOBAL_SO_ENDPOINT}    ${so_uri_path}   ${data}    auth=${auth}
92     Log         --------response-------
93     ${json_string}=    Evaluate    json.dumps(${resp.json()})    json
94     Log ${json_string}
95     Log    instanceId=${resp.json()['requestReferences']['instanceId']}
96     ${requestId}=    Catenate    ${resp.json()['requestReferences']['requestId']}
97     Log    requestId=${requestId}
98     Log -------end response-------
99     # ${auth}=  Create List  ${GLOBAL_SO_USERNAME}    ${GLOBAL_SO_PASSWORD}
100     # Run Polling Get Request    ${SO_ENDPOINT}    ${GLOBAL_SO_STATUS_PATH}${request_id}    auth=${auth}
101
102 Get VNF Info
103     [Documentation]     Get VNF Info
104     [Arguments]         ${vnf_name}     ${vnfjson}      ${dict}
105     ${metadata}=        Get From Dictionary     ${vnfjson}      metadata
106     Set To Dictionary   ${dict}   vnf_name=${vnf_name}
107     Set To Dictionary   ${dict}   vnf_model_name=${metadata['name']}
108     Set To Dictionary   ${dict}   vnf_model_version_id=${metadata['UUID']}
109     Set To Dictionary   ${dict}   vnf_model_customization_name=${metadata['name']}
110     Set To Dictionary   ${dict}   vnf_model_customization_id=${metadata['customizationUUID']}
111
112
113 Get VFModule Info
114     [Documentation]   Dig the vf module names from the VID service model
115     [Arguments]   ${jsondata}   ${vnf}   ${dict}
116     ${vfModules}=   Get From Dictionary    ${jsondata['topology_template']}   groups
117     ${keys}=   Get Dictionary Keys    ${vfModules}
118     ${data}=   Catenate
119     ${delim}=   Catenate
120     Templating.Create Environment    cds    ${GLOBAL_TEMPLATE_FOLDER}
121     :FOR   ${key}  IN  @{keys}
122     \    ${module}=   Get From Dictionary    ${vfModules}   ${key}
123     \    Log    ${vnf} ${key}
124     \    Run keyword if         "${vnf}" in "${key}"    set vfmodule param      ${key}    ${module}     ${dict}
125     \    ${vfmodule_payload}=   Templating.Apply Template               cds    ${vfmodule_template_name}                ${dict}
126     \    ${data}=       Catenate    ${data}   ${delim}   ${vfmodule_payload}
127     \    ${delim}=      Catenate        ,
128     Log         ${data}
129     [Return]    ${data}
130
131 set vfmodule param
132     [Documentation]    Set vfmodule parameters
133     [Arguments]         ${vfmodule_name}   ${vfmodule}  ${dict}
134     Set To Dictionary   ${dict}   vf_module_model_type=${vfmodule['type']}
135     Set To Dictionary   ${dict}   vf_module_model_name=${vfmodule['metadata']['vfModuleModelName']}
136     Set To Dictionary   ${dict}   vf_module_model_version_id=${vfmodule['metadata']['vfModuleModelUUID']}
137     Set To Dictionary   ${dict}   vf_module_model_customization_id=${vfmodule['metadata']['vfModuleModelCustomizationUUID']}
138     Set To Dictionary   ${dict}   vf_module_name=${vfmodule_name}