ebcdc3a25382a73058db32c6dca662f9c32bdf04
[testsuite.git] / robot / resources / sdnc_interface.robot
1 *** Settings ***
2 Documentation     The main interface for interacting with SDN-GC. It handles low level stuff like managing the http request library and SDN-GC required fields
3 Library               RequestsLibrary
4 Library           ONAPLibrary.Utilities
5 Library             SeleniumLibrary
6 Library        OperatingSystem
7 Library         Collections
8 Library      String
9 Library           ONAPLibrary.ServiceMapping    WITH NAME     ServiceMapping
10 Library           ONAPLibrary.PreloadData    WITH NAME     PreloadData
11 Library           ONAPLibrary.Templating    WITH NAME     Templating
12 Library           ONAPLibrary.SDNC        WITH NAME     SDNC
13 Resource          global_properties.robot
14 Resource        browser_setup.robot
15
16
17 *** Variables ***
18 ${PRELOAD_VNF_TOPOLOGY_OPERATION_PATH}  /operations/VNF-API:preload-vnf-topology-operation
19 ${PRELOAD_NETWORK_TOPOLOGY_OPERATION_PATH}  /operations/VNF-API:preload-network-topology-operation
20 ${PRELOAD_VNF_CONFIG_PATH}  /config/VNF-API:preload-vnfs/vnf-preload-list
21 ${PRELOAD_GRA_TOPOLOGY_OPERATION_PATH}     /operations/GENERIC-RESOURCE-API:preload-vf-module-topology-operation
22 ${PRELOAD_GRA_CONFIG_PATH}  /config/GENERIC-RESOURCE-API:preload-information
23 ${PRELOAD_TOPOLOGY_OPERATION_BODY}  sdnc
24 ${SDNC_INDEX_PATH}    /restconf
25 ${SDNCGC_HEALTHCHECK_OPERATION_PATH}  /operations/SLI-API:healthcheck
26 ${SDNC_REST_ENDPOINT}    ${GLOBAL_SDNC_SERVER_PROTOCOL}://${GLOBAL_INJECTED_SDNC_IP_ADDR}:${GLOBAL_SDNC_REST_PORT}
27 ${SDNC_ADMIN_ENDPOINT}    ${GLOBAL_SDNC_SERVER_PROTOCOL}://${GLOBAL_INJECTED_SDNC_PORTAL_IP_ADDR}:${GLOBAL_SDNC_ADMIN_PORT}
28 ${SDNC_ADMIN_SIGNUP_URL}    ${SDNC_ADMIN_ENDPOINT}/signup
29 ${SDNC_ADMIN_LOGIN_URL}    ${SDNC_ADMIN_ENDPOINT}/login
30 ${SDNC_ADMIN_VNF_PROFILE_URL}    ${SDNC_ADMIN_ENDPOINT}/mobility/getVnfProfile
31
32 *** Keywords ***
33 Run SDNC Health Check
34     [Documentation]    Runs an SDNC healthcheck
35     ${resp}=    SDNC.Run Post Request   ${SDNC_REST_ENDPOINT}   ${SDNC_INDEX PATH}${SDNCGC_HEALTHCHECK_OPERATION_PATH}     data=${None}    auth=${GLOBAL_SDNC_AUTHENTICATION}
36     Should Be Equal As Strings  ${resp.status_code}     200
37     Should Be Equal As Strings  ${resp.json()['output']['response-code']}       200
38
39 Preload Vcpe Networks
40     Preload Network    cpe_public    10.2.0.2    10.2.0.1
41     Preload Network    cpe_signal    10.4.0.2    10.4.0.1
42     Preload Network    brg_bng    10.3.0.2    10.3.0.1
43     Preload Network    bng_mux    10.1.0.10    10.1.0.1
44     Preload Network    mux_gw    10.5.0.10    10.5.0.1
45
46 Preload Network
47     [Arguments]    ${network_role}     ${subnet_start_ip}    ${subnet_gateway}
48     ${name_suffix}=    Generate Timestamp
49     ${network_name}=     Catenate    SEPARATOR=_    net     ${network_role}         ${name_suffix}
50     ${subnet_name}=     Catenate    SEPARATOR=_    net      ${network_role}         subnet    ${name_suffix}
51     ${parameters}=     Create Dictionary    network_role=${network_role}    service_type=vCPE    network_type=Generic NeutronNet    network_name=${network_name}    subnet_start_ip=${subnet_start_ip}    subnet_gateway=${subnet_gateway}
52     Templating.Create Environment    sdnc    ${GLOBAL_TEMPLATE_FOLDER}
53     ${data}=   Templating.Apply Template    sdnc   ${PRELOAD_TOPOLOGY_OPERATION_BODY}/template.network.jinja   ${parameters}
54     ${post_resp}=       SDNC.Run Post Request   ${SDNC_REST_ENDPOINT}   ${SDNC_INDEX_PATH}${PRELOAD_NETWORK_TOPOLOGY_OPERATION_PATH}     data=${data}    auth=${GLOBAL_SDNC_AUTHENTICATION}
55     [Return]    ${network_name}   ${subnet_name}
56
57 Preload Vcpe vGW
58     [Arguments]    ${brg_mac}    ${cpe_network_name}   ${cpe_subnet_name}    ${mux_gw_net}    ${mux_gw_subnet}
59     ${name_suffix}=    Generate Timestamp
60     ${parameters}=     Create Dictionary    pub_key=${GLOBAL_INJECTED_PUBLIC_KEY}    brg_mac=${brg_mac}    cpe_public_net=${cpe_network_name}     cpe_public_subnet=${cpe_subnet_name}    mux_gw_net=${mux_gw_net}      mux_gw_subnet=${mux_gw_subnet}    suffix=${name_suffix}    oam_onap_net=oam_network_2No2        oam_onap_subnet=oam_network_2No2        public_net_id=${GLOBAL_INJECTED_PUBLIC_NET_ID}
61     Templating.Create Environment    sdnc    ${GLOBAL_TEMPLATE_FOLDER}
62     ${data}=   Templating.Apply Template    sdnc   ${PRELOAD_TOPOLOGY_OPERATION_BODY}/template.vcpe_vgw_vfmodule.jinja   ${parameters}
63     ${post_resp}=       SDNC.Run Post Request   ${SDNC_REST_ENDPOINT}   ${SDNC_INDEX_PATH}${PRELOAD_VNF_TOPOLOGY_OPERATION_PATH}     data=${data}    auth=${GLOBAL_SDNC_AUTHENTICATION}
64
65 Preload Vcpe vGW Gra
66     [Arguments]    ${brg_mac}   ${cpe_public_network_name}   ${cpe_public_subnet_name}    ${mux_gw_net}    ${mux_gw_subnet}
67     ${name_suffix}=    Generate Timestamp
68     ${parameters}=     Create Dictionary    pub_key=${GLOBAL_INJECTED_PUBLIC_KEY}    brg_mac=${brg_mac}    cpe_public_net=${cpe_public_network_name}     cpe_public_subnet=${cpe_public_subnet_name}    mux_gw_net=${mux_gw_net}        mux_gw_subnet=${mux_gw_subnet}    suffix=${name_suffix}    oam_onap_net=oam_network_2No2        oam_onap_subnet=oam_network_2No2        public_net_id=${GLOBAL_INJECTED_PUBLIC_NET_ID}
69     Templating.Create Environment    sdnc    ${GLOBAL_TEMPLATE_FOLDER}
70     ${data}=   Templating.Apply Template    sdnc   ${PRELOAD_TOPOLOGY_OPERATION_BODY}/template.vcpe_gwgra_vfmodule.jinja   ${parameters}
71     ${post_resp}=       SDNC.Run Post Request   ${SDNC_REST_ENDPOINT}   ${SDNC_INDEX_PATH}${PRELOAD_GRA_TOPOLOGY_OPERATION_PATH}     data=${data}    auth=${GLOBAL_SDNC_AUTHENTICATION}
72
73 Preload Generic VfModule
74     [Arguments]    ${service_instance_id}       ${vnf_model}   ${model_customization_name}    ${short_model_customization_name}     ${cpe_public_network_name}=None   ${cpe_public_subnet_name}=None   ${cpe_signal_network_name}=None   ${cpe_signal_subnet_name}=None
75     ${name_suffix}=    Generate Timestamp
76     ${vfmodule_name}=     Catenate    SEPARATOR=_    vf     ${short_model_customization_name}       ${name_suffix}
77     #TODO this became a mess, need to fix
78     ${parameters}=     Create Dictionary    pub_key=${GLOBAL_INJECTED_PUBLIC_KEY}    suffix=${name_suffix}    mr_ip_addr=${GLOBAL_INJECTED_MR_IP_ADDR}    mr_ip_port=${GLOBAL_MR_SERVER_PORT}
79     Set To Dictionary    ${parameters}    oam_onap_net=oam_network_2No2        oam_onap_subnet=oam_network_2No2    cpe_public_net=${cpe_public_network_name}     cpe_public_subnet=${cpe_public_subnet_name}    
80     Set To Dictionary    ${parameters}    cpe_signal_subnet=${cpe_signal_subnet_name}    cpe_signal_net=${cpe_signal_network_name}    public_net_id=${GLOBAL_INJECTED_PUBLIC_NET_ID}
81     # vnf_type and generic_vnf_type are identical
82     Set To Dictionary    ${parameters}    vnf_type=${model_customization_name}    generic_vnf_type=${model_customization_name}    generic_vnf_name=${model_customization_name}    vnf_name=${vfmodule_name}    
83     Set To Dictionary    ${parameters}    service_type=${service_instance_id}    sdnc_oam_ip=${GLOBAL_INJECTED_SDNC_IP_ADDR}
84         ${post_resp}=    SDNC.Preload Vfmodule    ${SDNC_REST_ENDPOINT}    ${SDNC_INDEX_PATH}${PRELOAD_VNF_TOPOLOGY_OPERATION_PATH}    ${GLOBAL_TEMPLATE_FOLDER}    ${PRELOAD_TOPOLOGY_OPERATION_BODY}/template.vcpe_infra_vfmodule.jinja    ${parameters}
85     [Return]    ${post_resp}
86             
87 Preload Vnf
88     [Arguments]    ${service_type_uuid}    ${generic_vnf_name}    ${generic_vnf_type}     ${vf_module_name}    ${vf_modules}    ${vnf}   ${uuid}    ${service}     ${server_id}
89     ${base_vf_module_type}=    Catenate
90     ${closedloop_vf_module}=    Create Dictionary
91     ServiceMapping.Set Directory    default    ${GLOBAL_SERVICE_MAPPING_DIRECTORY}
92     ${templates}=    ServiceMapping.Get Service Template Mapping    default    ${service}    ${vnf}
93     :FOR    ${vf_module}    IN      @{vf_modules}
94     \       ${vf_module_type}=    Get From Dictionary    ${vf_module}    name
95     #     need to pass in vnf_index if non-zero
96     \       ${dict}   Run Keyword If    "${generic_vnf_name}".endswith('0')      Get From Mapping With Index    ${templates}    ${vf_module}   0
97             ...    ELSE IF  "${generic_vnf_name}".endswith('1')      Get From Mapping With Index    ${templates}    ${vf_module}   1
98             ...    ELSE IF  "${generic_vnf_name}".endswith('2')      Get From Mapping With Index    ${templates}    ${vf_module}   2
99             ...    ELSE   Get From Mapping    ${templates}    ${vf_module}
100     #     skip this iteration if no template 
101     \       ${test_dict_length} =  Get Length  ${dict}
102     \       Continue For Loop If   ${test_dict_length} == 0
103     \       ${filename}=    Get From Dictionary    ${dict}    template
104     \       ${base_vf_module_type}=   Set Variable If    '${dict['isBase']}' == 'true'     ${vf_module_type}    ${base_vf_module_type}
105     \       ${closedloop_vf_module}=   Set Variable If    '${dict['isBase']}' == 'false'     ${vf_module}    ${closedloop_vf_module}
106     \       ${vf_name}=     Update Module Name    ${dict}    ${vf_module_name}
107     #    Admin portal update no longer 
108     #\       Preload Vnf Profile    ${vf_module_type}
109     \       Preload One Vnf Topology    ${service_type_uuid}    ${generic_vnf_name}    ${generic_vnf_type}     ${vf_name}    ${vf_module_type}    ${service}    ${filename}   ${uuid}     ${server_id}
110     [Return]    ${base_vf_module_type}   ${closedloop_vf_module}
111
112 Preload Gra
113     [Arguments]    ${service_type_uuid}    ${generic_vnf_name}    ${generic_vnf_type}     ${vf_module_name}    ${vf_modules}    ${vnf}   ${uuid}    ${service}     ${server_id}
114     ${base_vf_module_type}=    Catenate
115     ${closedloop_vf_module}=    Create Dictionary
116     ServiceMapping.Set Directory    default    ${GLOBAL_SERVICE_MAPPING_DIRECTORY}
117     ${templates}=    ServiceMapping.Get Service Template Mapping    default    ${service}    ${vnf}
118     :FOR    ${vf_module}    IN      @{vf_modules}
119     \       ${vf_module_type}=    Get From Dictionary    ${vf_module}    name
120     #     need to pass in vnf_index if non-zero
121     \       ${dict}   Run Keyword If    "${generic_vnf_name}".endswith('0')      Get From Mapping With Index    ${templates}    ${vf_module}   0
122             ...    ELSE IF  "${generic_vnf_name}".endswith('1')      Get From Mapping With Index    ${templates}    ${vf_module}   1
123             ...    ELSE IF  "${generic_vnf_name}".endswith('2')      Get From Mapping With Index    ${templates}    ${vf_module}   2
124             ...    ELSE   Get From Mapping    ${templates}    ${vf_module}
125     #     skip this iteration if no template
126     \       ${test_dict_length} =  Get Length  ${dict}
127     \       Continue For Loop If   ${test_dict_length} == 0
128     \       ${filename}=    Get From Dictionary    ${dict}    template
129     \       ${base_vf_module_type}=   Set Variable If    '${dict['isBase']}' == 'true'     ${vf_module_type}    ${base_vf_module_type}
130     \       ${closedloop_vf_module}=   Set Variable If    '${dict['isBase']}' == 'false'     ${vf_module}    ${closedloop_vf_module}
131     \       ${vf_name}=     Update Module Name    ${dict}    ${vf_module_name}
132     \       Preload One Gra Topology    ${service_type_uuid}    ${generic_vnf_name}    ${generic_vnf_type}     ${vf_name}    ${vf_module_type}    ${service}    ${filename}   ${uuid}     ${server_id}
133     [Return]    ${base_vf_module_type}   ${closedloop_vf_module}
134
135
136
137 Update Module Name
138     [Arguments]    ${dict}    ${vf_module_name}
139     Return From Keyword If    'prefix' not in ${dict}    ${vf_module_name}
140     Return From Keyword If    '${dict['prefix']}' == ''    ${vf_module_name}
141     ${name}=    Replace String   ${vf_module_name}   Vfmodule_    ${dict['prefix']}
142     [Return]    ${name}
143
144 Get From Mapping With Index
145     [Documentation]    Retrieve the appropriate prelad template entry for the passed vf_module
146     [Arguments]    ${templates}    ${vf_module}   ${vnf_index}=0
147     ${vf_module_name}=    Get From DIctionary    ${vf_module}    name
148     :FOR    ${template}   IN   @{templates}
149     \    Return From Keyword If    '${template['name_pattern']}' in '${vf_module_name}' and ('${template['vnf_index']}' == '${vnf_index}')     ${template}
150     ${result}=    Create Dictionary
151     [Return]    ${result}
152
153 Get From Mapping
154     [Documentation]    Retrieve the appropriate prelad template entry for the passed vf_module
155     [Arguments]    ${templates}    ${vf_module}
156     ${vf_module_name}=    Get From DIctionary    ${vf_module}    name
157     :FOR    ${template}   IN   @{templates}
158     \    Return From Keyword If    '${template['name_pattern']}' in '${vf_module_name}'     ${template}
159     ${result}=    Create Dictionary
160     [Return]    ${result}
161
162 Preload One Vnf Topology
163     [Arguments]    ${service_type_uuid}    ${generic_vnf_name}    ${generic_vnf_type}       ${vf_module_name}    ${vf_module_type}    ${service}    ${filename}   ${uuid}     ${server_id}
164     Return From Keyword If    '${filename}' == ''
165     ${parameters}=    Get Template Parameters    ${generic_vnf_name}    ${filename}   ${uuid}    ${service}    ${server_id}
166     Set To Dictionary   ${parameters}   generic_vnf_name=${generic_vnf_name}     generic_vnf_type=${generic_vnf_type}  service_type=${service_type_uuid}    vf_module_name=${vf_module_name}    vf_module_type=${vf_module_type}
167     Templating.Create Environment    sdnc    ${GLOBAL_TEMPLATE_FOLDER}
168     ${data}=   Templating.Apply Template    sdnc   ${PRELOAD_TOPOLOGY_OPERATION_BODY}/preload.jinja    ${parameters}
169     ${post_resp}=       SDNC.Run Post Request   ${SDNC_REST_ENDPOINT}   ${SDNC_INDEX_PATH}${PRELOAD_VNF_TOPOLOGY_OPERATION_PATH}     data=${data}    auth=${GLOBAL_SDNC_AUTHENTICATION}
170     Should Be Equal As Strings  ${post_resp.json()['output']['response-code']}  200
171     ${get_resp}=        SDNC.Run Get Request    ${SDNC_REST_ENDPOINT}    ${SDNC_INDEX_PATH}${PRELOAD_VNF_CONFIG_PATH}/${vf_module_name}/${vf_module_type}     auth=${GLOBAL_SDNC_AUTHENTICATION}
172
173
174 Preload One Gra Topology
175     [Arguments]    ${service_type_uuid}    ${generic_vnf_name}    ${generic_vnf_type}       ${vf_module_name}    ${vf_module_type}    ${service}    ${filename}   ${uuid}     ${server_id}
176     Return From Keyword If    '${filename}' == ''
177     ${parameters}=    Get Template Parameters    ${generic_vnf_name}    ${filename}   ${uuid}    ${service}    ${server_id}    gr_api
178     Set To Dictionary   ${parameters}   generic_vnf_name=${generic_vnf_name}     generic_vnf_type=${generic_vnf_type}  service_type=${service_type_uuid}    vf_module_name=${vf_module_name}    vf_module_type=${vf_module_type}
179     Templating.Create Environment    sdnc    ${GLOBAL_TEMPLATE_FOLDER}
180     ${data}=   Templating.Apply Template    sdnc   ${PRELOAD_TOPOLOGY_OPERATION_BODY}/preload.GRA.jinja    ${parameters}
181     ${post_resp}=       SDNC.Run Post Request   ${SDNC_REST_ENDPOINT}   ${SDNC_INDEX_PATH}${PRELOAD_GRA_TOPOLOGY_OPERATION_PATH}     data=${data}    auth=${GLOBAL_SDNC_AUTHENTICATION}
182     Should Be Equal As Strings  ${post_resp.json()['output']['response-code']}  200
183     ${get_resp}=        SDNC.Run Get Request    ${SDNC_REST_ENDPOINT}    ${SDNC_INDEX_PATH}${PRELOAD_GRA_CONFIG_PATH}/preload-list/${vf_module_name}/vf-module     auth=${GLOBAL_SDNC_AUTHENTICATION}
184     Should Be Equal As Strings  ${get_resp.status_code}         200
185
186
187
188 Get Template Parameters
189     [Arguments]   ${generic_vnf_name}    ${template}    ${uuid}    ${service}     ${server_id}   ${api_type}=vnf_api
190     ${hostid}=    Get Substring    ${uuid}    -4
191     ${ecompnet}=    Evaluate    (${GLOBAL_BUILD_NUMBER}%128)+128
192
193     ${valuemap}=   Get Globally Injected Parameters
194     # update the value map with unique values.
195     Set To Dictionary   ${valuemap}   uuid=${uuid}   hostid=${hostid}    ecompnet=${ecompnet}    generic_vnf_name=${generic_vnf_name}      server_id=${server_id}
196
197     #
198     # Mash together the defaults dict with the test case dict to create the set of
199     # preload parameters
200     #
201     PreloadData.Set Directory    preload    ./demo/preload_data
202     ${defaults}=       PreloadData.Get Default Preload Data    preload
203     ${template}=    PreloadData.Get Preload Data    preload    ${service}    ${template}
204     # add all of the defaults to template...
205     @{keys}=    Get Dictionary Keys    ${defaults}
206     :FOR   ${key}   IN   @{keys}
207     \    ${value}=   Get From Dictionary    ${defaults}    ${key}
208     \    Set To Dictionary    ${template}  ${key}    ${value}
209
210     #
211     # Get the vnf_parameters to preload
212     #
213     ${vnf_parameters}=   Run Keyword If   '${api_type}'=='gr_api'   Resolve GRA Parameters Into Array   ${valuemap}   ${template}
214     ...   ELSE  Resolve VNF Parameters Into Array   ${valuemap}   ${template}
215     ${vnf_parameters_json}=   Evaluate    json.dumps(${vnf_parameters})    json
216     ${parameters}=   Create Dictionary   vnf_parameters=${vnf_parameters_json}
217     [Return]    ${parameters}
218
219 Resolve VNF Parameters Into Array
220     [Arguments]   ${valuemap}    ${from}
221     ${vnf_parameters}=   Create List
222     ${keys}=    Get Dictionary Keys    ${from}
223     :FOR   ${key}   IN  @{keys}
224     \    ${value}=    Get From Dictionary    ${from}   ${key}
225     \    ${value}=    Templating.Template String    ${value}    ${valuemap}
226     \    ${parameter}=   Create Dictionary   vnf-parameter-name=${key}    vnf-parameter-value=${value}
227     \    Append To List    ${vnf_parameters}   ${parameter}
228     [Return]   ${vnf_parameters}
229
230 Resolve GRA Parameters Into Array
231     [Arguments]   ${valuemap}    ${from}
232     ${vnf_parameters}=   Create List
233     ${keys}=    Get Dictionary Keys    ${from}
234     :FOR   ${key}   IN  @{keys}
235     \    ${value}=    Get From Dictionary    ${from}   ${key}
236     \    ${value}=    Templating.Template String    ${value}    ${valuemap}
237     \    ${parameter}=   Create Dictionary   name=${key}    value=${value}
238     \    Append To List    ${vnf_parameters}   ${parameter}
239     [Return]   ${vnf_parameters}
240
241
242 Preload Vnf Profile
243     [Arguments]    ${vnf_name}
244     Login To SDNC Admin GUI
245     Go To    ${SDNC_ADMIN_VNF_PROFILE_URL}
246     Click Button    xpath=//button[@data-target='#add_vnf_profile']
247     Input Text    xpath=//input[@id='nf_vnf_type']    ${vnf_name}
248     Input Text    xpath=//input[@id='nf_availability_zone_count']    999
249     Input Text    xpath=//input[@id='nf_equipment_role']    robot-ete-test
250     Click Button    xpath=//button[contains(.,'Submit')]
251     Page Should Contain  VNF Profile
252     Input Text    xpath=//div[@id='vnf_profile_filter']//input    ${vnf_name}
253     Page Should Contain  ${vnf_name}
254
255 Delete Vnf Profile
256     [Arguments]    ${vnf_name}
257     Login To SDNC Admin GUI
258     Go To    ${SDNC_ADMIN_VNF_PROFILE_URL}
259     Page Should Contain  VNF Profile
260     Input Text    xpath=//div[@id='vnf_profile_filter']//input    ${vnf_name}
261     Page Should Contain  ${vnf_name}
262     Click Button    xpath=//button[contains(@onclick, '${vnf_name}')]
263     Page Should Contain    Are you sure you want to delete VNF_PROFILE
264     Click Button    xpath=//button[contains(text(), 'Yes')]
265     Page Should Not Contain  ${vnf_name}
266
267 Login To SDNC Admin GUI
268     [Documentation]   Login To SDNC Admin GUI
269     ## Setup Browser is now being managed by the test case
270     ## Setup Browser
271     Go To    ${SDNC_ADMIN_SIGNUP_URL}
272     ##Maximize Browser Window
273     Set Selenium Speed    ${GLOBAL_SELENIUM_DELAY}
274     Set Browser Implicit Wait    ${GLOBAL_SELENIUM_BROWSER_IMPLICIT_WAIT}
275     Log    Logging in to ${SDNC_ADMIN_LOGIN_URL}
276     Handle Proxy Warning
277     Title Should Be    AdminPortal
278     ${uuid}=    Generate UUID4
279     ${shortened_uuid}=     Evaluate    str("${uuid}")[:12]
280     ${email}=        Catenate    ${shortened_uuid}@robotete.com
281     Input Text    xpath=//input[@id='nf_email']    ${email}
282     Input Password    xpath=//input[@id='nf_password']    ${shortened_uuid}
283     Click Button    xpath=//button[@type='submit']
284     Wait Until Page Contains    User created   20s
285     Go To    ${SDNC_ADMIN_LOGIN_URL}
286     Input Text    xpath=//input[@id='email']    ${email}
287     Input Password    xpath=//input[@id='password']    ${shortened_uuid}
288     Click Button    xpath=//button[@type='submit']
289     Title Should Be    SDN-C AdminPortal
290     Log    Logged in to ${SDNC_ADMIN_LOGIN_URL}
291
292 Create Preload From JSON
293     [Documentation]   Fill vf-module parameters in an already created preload json file.
294     [Arguments]    ${preload_file}     ${api_type}    ${vf_module_name}     ${vf_module_type}    ${vnf_name}    ${generic_vnf_type}
295     Log To Console    Uploading ${preload_file} to SDNC
296
297     ${preload_vnf}=    Run keyword if  "${api_type}"=="gr_api" Preload GR API    ${vf_module_name}     ${vf_module_type}    ${vnf_name}    ${generic_vnf_type}    ${preload_file}
298     ...  ELSE  Preload VNF API    ${vf_module_name}     ${vf_module_type}    ${vnf_name}    ${generic_vnf_type}    ${preload_file}
299
300     ${uri}=    Set Variable If     "${api_type}"=="gr_api"    ${SDNC_INDEX_PATH}${PRELOAD_GRA_TOPOLOGY_OPERATION_PATH}    ${SDNC_INDEX_PATH}${PRELOAD_VNF_TOPOLOGY_OPERATION_PATH}
301
302     ${post_resp}=    SDNC.Run Post Request   ${SDNC_REST_ENDPOINT}   ${uri}     data=${preload_vnf}    auth=${GLOBAL_SDNC_AUTHENTICATION}
303     Should Be Equal As Strings    ${post_resp.json()['output']['response-code']}    200
304     [Return]    ${post_resp}
305
306 Preload GR API
307     [Documentation]   Retrieves a preload JSON file and fills in service instance values.
308     [Arguments]    ${vnf_name}     ${vnf_type}    ${generic_vnf_name}    ${generic_vnf_type}    ${preload_path}
309
310     ${json}=    OperatingSystem.Get File    ${preload_path}
311     ${object}=    Evaluate    json.loads('''${json}''')    json
312     ${req_dict}    Create Dictionary    vnf-name=${generic_vnf_name}    vnf-type=${generic_vnf_type}
313     set to dictionary    ${object["input"]["preload-vf-module-topology-information"]}    vnf-topology-identifier-structure=${req_dict}
314     ${req_dict_new}    Create Dictionary    vf-module-name=${vnf_name}
315     set to dictionary    ${object["input"]["preload-vf-module-topology-information"]["vf-module-topology"]}    vf-module-topology-identifier=${req_dict_new}
316     ${req_json}    Evaluate    json.dumps(${object})    json
317     [Return]    ${req_json}
318
319 Preload VNF API
320     [Documentation]   Retrieves a preload JSON file and fills in service instance values.
321     [Arguments]    ${vnf_name}     ${vnf_type}    ${generic_vnf_name}    ${generic_vnf_type}    ${preload_path}
322
323     ${json}=    OperatingSystem.Get File    ${preload_path}
324     ${object}=    Evaluate    json.loads('''${json}''')    json
325     ${req_dict}    Create Dictionary    vnf-name=${vnf_name}    vnf-type=${vnf_type}    generic-vnf-type=${generic_vnf_type}    generic-vnf-name=${generic_vnf_name}
326     set to dictionary    ${object["input"]["vnf-topology-information"]}    vnf-topology-identifier=${req_dict}
327
328     ${req_json}    Evaluate    json.dumps(${object})    json
329     [Return]    ${req_json}