summaryrefslogtreecommitdiffstats
path: root/robot/resources/test_templates/vnf_orchestration_with_cds_test_template.robot
blob: 34a1be8fa239f973e2b5bc8fb4745a60f8c65970 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
*** Settings ***
Documentation   This test template encapsulates the VNF Orchestration use case.

Resource        ../vid/create_service_instance.robot
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

Resource        ../aai/create_zone.robot
Resource        ../aai/create_customer.robot
Resource        ../aai/create_complex.robot
Resource        ../aai/create_tenant.robot
Resource        ../aai/create_service.robot
Resource        ../openstack/neutron_interface.robot
Resource        ../heatbridge.robot

Resource      ../global_properties.robot
Resource      ../so_interface.robot

Library         ONAPLibrary.Openstack
Library         ONAPLibrary.Utilities
Library         ONAPLibrary.Templating
Library         Collections
Library         String
Library         ONAPLibrary.JSON

Library         RequestsLibrary
Library         Collections

*** Variables ***
${service_template}    robot/assets/cds/service-Vfirewall0911-template.yml
${env}      robot/assets/cds/env.yml
${so_request_template}    so/cds_request.jinja    
${vnf_template_name}  so/cds_vnf.jinja
${vfmodule_template_name}   so/cds_vfmodule.jinja
${so_uri_path}    /onap/so/infra/serviceInstantiation/v7/serviceInstances
*** Variables ***

#**************** TEST CASE VARIABLES **************************
${CUSTOMER_NAME}
${STACK_NAME}
${STACK_NAMES}
${SERVICE_INSTANCE_ID}

*** Keywords ***
Orchestrate VNF With CDS Template
    [Documentation]   Use openECOMP to Orchestrate a service.
    [Arguments]    ${customer_name}    ${service}    ${product_family}
    Orchestrate VNF With CDS  ${customer_name}    ${service}    ${product_family}

Orchestrate VNF With CDS
    [Documentation]   Use openECOMP to Orchestrate a service.
    [Arguments]    ${customer_name}    ${service}    ${product_family}    ${project_name}=Project-Demonstration   ${owning_entity}=OE-Demonstration
    ${lcp_region}=   Get Openstack Region
    ${uuid}=    Generate UUID4
    Set Test Variable    ${CUSTOMER_NAME}    ${customer_name}_${uuid}
    ${list}=    Create List
    Set Test Variable    ${STACK_NAMES}   ${list}
    ${service_instance_name}=    Catenate    Service_Ete_Name${uuid}
    ${dict}=  Create Dictionary
    Set To Dictionary ${dict}   service_instance_name=${service_instance_name}

    ${templatedata}=    Template Yaml To Json    ${service_template}
    ${jsondata}=     Evaluate     json.loads('''${templatedata}''')      json
    Set To Dictionary   ${dict}   service_type=${jsondata['metadata']['type']}
    Set To Dictionary   ${dict}   service_model_name=${jsondata['metadata']['name']}
    Set To Dictionary   ${dict}   service_model_UUID=${jsondata['metadata']['UUID']}
    Set To Dictionary   ${dict}   service_model_invariantUUID=${jsondata['metadata']['invariantUUID']}
    
    ${envdata}=    Env Yaml To Json    ${env}
    ${envjson}=    Evaluate     json.loads('''${envdata}''')      json
    Set To Dictionary   ${dict}   subscriber_id=${envjson['subscriber_id']}
    Set To Dictionary ${dict}   subscription_service_type=${envjson['subscription_service_type']}
    Set To Dictionary   ${dict}   cloud_region=${envjson['cloud_region']}
    Set To Dictionary   ${dict}   tenant_id=${envjson['tenant_id']}

    ${list}=    Create List
    ${vnfs}=   Get From Dictionary    ${jsondata['topology_template']}   node_templates
    ${keys}=   Get Dictionary Keys    ${vnfs}
    Create Environment    cds    ${GLOBAL_TEMPLATE_FOLDER}
    :FOR   ${key}  IN  @{keys}
    \  ${vnf}=   Get From Dictionary    ${vnfs}   ${key}
    \    Get VNF Info ${key}  ${vnf}  ${dict}
    \  ${vf_modules}=    Get From Dictionary   ${jsondata['topology_template']}    groups
    \    ${value}=  Evaluate  "${key}".replace("-","").replace(" ","")
    \    ${value}=  Convert To Lowercase  ${value}
    \    ${vfmodules}=  Get VFModule Info  ${jsondata}  ${value}    ${dict}
    \  Set To Dictionary  ${dict}   vf_modules=${vfmodules}
    \    ${vnf_payload}=   Apply Template    cds    ${vnf_template_name}    ${dict}
    \  ${data}=   Catenate  [${vnf_payload}]
   
    Set To Dictionary     ${dict}   vnfs=${data}
    ${request}=     Apply Template    cds    ${so_request_template}    ${dict}
    Log     --------request--------
    Log     ${request}
    Log     --------end request--------
    ${resp}=  Run MSO Post Request  ${so_uri_path}    ${request}
    Log   --------response-------
    ${json_string}=    Evaluate    json.dumps(${resp.json()})    json
    Log ${json_string}
    Log    instanceId=${resp.json()['requestReferences']['instanceId']}
    ${requestId}=    Catenate    ${resp.json()['requestReferences']['requestId']}
    Log    requestId=${requestId}
    Log -------end response-------
    # Poll MSO Get Request    ${GLOBAL_MSO_STATUS_PATH}${request_id}   COMPLETE


Get VNF Info
    [Documentation]   Get VNF Info
    [Arguments]   ${vnf_name}   ${vnfjson}  ${dict}
    ${metadata}=  Get From Dictionary ${vnfjson}  metadata
    Set To Dictionary ${dict}   vnf_name=${vnf_name}
    Set To Dictionary   ${dict}   vnf_model_name=${metadata['name']}
    Set To Dictionary   ${dict}   vnf_model_version_id=${metadata['UUID']}
    Set To Dictionary   ${dict}   vnf_model_customization_name=${metadata['name']}
    Set To Dictionary   ${dict}   vnf_model_customization_id=${metadata['customizationUUID']}
  

Get VFModule Info
    [Documentation]   Dig the vf module names from the VID service model
    [Arguments]   ${jsondata} ${vnf}   ${dict}
    ${vfModules}=   Get From Dictionary    ${jsondata['topology_template']}   groups
    ${keys}=   Get Dictionary Keys    ${vfModules}
    ${data}=   Catenate
    ${delim}=   Catenate
    Create Environment    cds    ${GLOBAL_TEMPLATE_FOLDER}
    :FOR   ${key}  IN  @{keys}
    \    ${module}=   Get From Dictionary    ${vfModules}   ${key}
    \    Log  ${vnf} ${key}
    \    Run keyword if   "${vnf}" in "${key}"  set vfmodule param  ${key}    ${module} ${dict}
    \    ${vfmodule_payload}=   Apply Template    cds    ${vfmodule_template_name}    ${dict}
    \  ${data}=   Catenate    ${data}   ${delim}   ${vfmodule_payload}
    \  ${delim}=  Catenate  ,
    Log   ${data}
    [Return]  ${data}

set vfmodule param
    [Documentation]    Set vfmodule parameters
    [Arguments]   ${vfmodule_name}   ${vfmodule}  ${dict}
    Set To Dictionary   ${dict}   vf_module_model_type=${vfmodule['type']}
    Set To Dictionary   ${dict}   vf_module_model_name=${vfmodule['metadata']['vfModuleModelName']}
    Set To Dictionary   ${dict}   vf_module_model_version_id=${vfmodule['metadata']['vfModuleModelUUID']}
    Set To Dictionary   ${dict}   vf_module_model_customization_id=${vfmodule['metadata']['vfModuleModelCustomizationUUID']}
    Set To Dictionary   ${dict}   vf_module_name=${vfmodule_name}