| dhanasekaran | 6f0aed3 | 2022-05-17 14:12:40 +0200 | [diff] [blame] | 1 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 2 | # you may not use this file except in compliance with the License. |
| 3 | # You may obtain a copy of the License at |
| 4 | # |
| 5 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 6 | # |
| 7 | # Unless required by applicable law or agreed to in writing, software |
| 8 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 9 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 10 | # See the License for the specific language governing permissions and |
| 11 | # limitations under the License |
| 12 | |
| 13 | *** Settings *** |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 14 | Documentation Library with sol003 keywords and variables . |
| dhanasekaran | 6f0aed3 | 2022-05-17 14:12:40 +0200 | [diff] [blame] | 15 | |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 16 | Library RequestsLibrary |
| 17 | Library JsonValidator |
| 18 | Library yaml |
| 19 | Library JSONLibrary |
| 20 | Library String |
| 21 | Library OperatingSystem |
| 22 | Resource %{ROBOT_DEVOPS_FOLDER}/lib/vim_lib.robot |
| Guillermo Calvino | b3d11c0 | 2022-11-22 13:34:31 +0100 | [diff] [blame] | 23 | Variables %{ROBOT_DEVOPS_FOLDER}/resources/sol003_01-vnf_lifecycle_management.py |
| dhanasekaran | 6f0aed3 | 2022-05-17 14:12:40 +0200 | [diff] [blame] | 24 | |
| 25 | *** Variables *** |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 26 | @{success_status_code_list} 200 201 202 204 |
| 27 | ${descriptor_content_type_gzip} application/gzip |
| 28 | ${auth_token_uri} /osm/admin/v1/tokens |
| 29 | ${HOST} ${EMPTY} |
| 30 | ${vnf_instance_uri} /osm/vnflcm/v1/vnf_instances |
| 31 | ${vnf_instantiate_uri} /osm/vnflcm/v1/vnf_instances |
| 32 | ${vnf_instance_lcm_ops} /osm/vnflcm/v1/vnf_lcm_op_occs |
| dhanasekaran | 6f0aed3 | 2022-05-17 14:12:40 +0200 | [diff] [blame] | 33 | |
| 34 | *** Keywords *** |
| 35 | Get Auth Token |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 36 | [Tags] auth_token |
| dhanasekaran | 6f0aed3 | 2022-05-17 14:12:40 +0200 | [diff] [blame] | 37 | Get Hostname |
| garciadeblas | 43f3448 | 2023-02-23 17:37:47 +0100 | [diff] [blame] | 38 | Create Session osmhit ${HOST} disable_warnings=1 |
| dhanasekaran | d90c14a | 2022-06-21 07:19:17 +0000 | [diff] [blame] | 39 | &{headers} Create Dictionary Content-Type=application/json Accept=application/json |
| Guillermo Calvino | b3d11c0 | 2022-11-22 13:34:31 +0100 | [diff] [blame] | 40 | &{data} Create Dictionary username=${osm_user} password=${osm_password} project-id=${osm_project} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 41 | ${resp}= Post On Session osmhit ${auth_token_uri} json=${data} headers=${headers} |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 42 | Log ${resp} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 43 | Pass Execution If ${resp.status_code} in ${success_status_code_list} Get Auth Token completed |
| 44 | Set Suite Variable ${token_status_code} ${resp.status_code} |
| 45 | ${access_token}= Get Value From Json ${resp.json()} $..id |
| 46 | Set Test Variable ${access_token} ${access_token[0]} |
| 47 | Set Test Variable ${token_response} ${resp} |
| 48 | sleep 2s |
| dhanasekaran | 6f0aed3 | 2022-05-17 14:12:40 +0200 | [diff] [blame] | 49 | |
| 50 | Set Dockerized Host |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 51 | [Arguments] ${env_host} |
| 52 | Set Suite Variable ${HOST} https://${env_host} |
| dhanasekaran | 6f0aed3 | 2022-05-17 14:12:40 +0200 | [diff] [blame] | 53 | |
| 54 | Set Standalone Host |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 55 | [Arguments] ${env_host} |
| 56 | Set Suite Variable ${HOST} https://${env_host}:9999 |
| dhanasekaran | 6f0aed3 | 2022-05-17 14:12:40 +0200 | [diff] [blame] | 57 | |
| 58 | Read Directory |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 59 | [Documentation] To Read Current Direct ory |
| 60 | ${Directory}= Replace String ${CURDIR} lib resources/ |
| 61 | ${json_path}= Set Variable ${Directory} |
| 62 | [Return] ${JsonPath} |
| dhanasekaran | 6f0aed3 | 2022-05-17 14:12:40 +0200 | [diff] [blame] | 63 | |
| 64 | Post Api Request |
| 65 | [Arguments] ${PostApi} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 66 | [Documentation] Keword to Post API Request |
| 67 | Create Session APISession ${HOST} |
| 68 | &{headers} Create Dictionary Content-Type=application/json Accept=application/json Authorization=Bearer ${access_token} |
| 69 | ${request_response}= Post On Session APISession ${PostApi} json=${updated_json_obj} headers=${headers} |
| 70 | Set Suite Variable ${request_response} |
| 71 | ${response_statuscode} Convert To String ${request_response.status_code} |
| 72 | Set Suite Variable ${response_statuscode} |
| dhanasekaran | 6f0aed3 | 2022-05-17 14:12:40 +0200 | [diff] [blame] | 73 | |
| 74 | Get HostName |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 75 | [Documentation] Keyword to get the default osm Hostname |
| 76 | ${nbi_host}= Get Environment Variable OSM_HOSTNAME |
| 77 | ${passed}= Run Keyword And Return Status Should Contain ${nbi_host} : |
| 78 | Run Keyword If ${passed} Set Dockerized Host ${nbi_host} |
| 79 | ... ELSE Set Standalone Host ${nbi_host} |
| dhanasekaran | 6f0aed3 | 2022-05-17 14:12:40 +0200 | [diff] [blame] | 80 | |
| 81 | Get ID |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 82 | [Arguments] ${Key} |
| 83 | Pass Execution If ${request_response.status_code} in ${success_status_code_list} Get Auth Token completed |
| 84 | ${id}= Get Value From Json ${request_response.json()} $..${Key} |
| 85 | Set Suite Variable ${value} ${id[0]} |
| 86 | [Return] ${value} |
| dhanasekaran | 6f0aed3 | 2022-05-17 14:12:40 +0200 | [diff] [blame] | 87 | |
| 88 | Update Json Value |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 89 | [Arguments] ${JsonInput} ${key} |
| 90 | ${json_path}= Read Directory |
| 91 | ${json_obj}= Load JSON From File ${json_path}/${JsonInput} |
| garciadeblas | 43f3448 | 2023-02-23 17:37:47 +0100 | [diff] [blame] | 92 | ${updated_json_obj}= JSONLibrary.Update Value To Json ${json_obj} $..${key} ${created_vim_account_id} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 93 | Set Suite Variable ${updated_json_obj} |
| dhanasekaran | 6f0aed3 | 2022-05-17 14:12:40 +0200 | [diff] [blame] | 94 | |
| 95 | Get Api Request |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 96 | [Arguments] ${uri} |
| 97 | [Documentation] Keyword to Get API Request |
| 98 | Create Session Session ${HOST} |
| 99 | &{headers} Create Dictionary Content-Type=application/json Accept=application/json Authorization=Bearer ${access_token} |
| 100 | ${request_response}= Get On Session Session ${uri} headers=${Headers} |
| 101 | Set Suite Variable ${request_response} |
| 102 | ${response_statuscode} Convert To String ${request_response.status_code} |
| 103 | Set Suite Variable ${response_statuscode} |