| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +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 to manage VIM Targets. |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 15 | |
| 16 | Library String |
| 17 | Library Collections |
| 18 | Library OperatingSystem |
| 19 | |
| 20 | Resource %{ROBOT_DEVOPS_FOLDER}/lib/prometheus_lib.robot |
| 21 | |
| 22 | |
| 23 | *** Variables *** |
| 24 | ${success_return_code} 0 |
| 25 | ${delete_max_wait_time} 1min |
| 26 | ${delete_pol_time} 15sec |
| aguilard | 0a36632 | 2021-09-09 07:52:37 +0000 | [diff] [blame] | 27 | ${vim_status_max_wait_time} 3min |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 28 | ${vim_status_pol_time} 15sec |
| aguilard | 0a36632 | 2021-09-09 07:52:37 +0000 | [diff] [blame] | 29 | ${vim_opstate_max_wait_time} 40sec |
| 30 | ${vim_opstate_pol_time} 10sec |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 31 | |
| 32 | |
| 33 | *** Keywords *** |
| 34 | Create VIM Target |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 35 | [Documentation] Create a VIM Target in OSM. |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 36 | ... The optional parameters (such as 'config' or 'sdn_controller') are given to this function in name=value format. These parameters will be appended to the 'osm vim-create' command with the next syntax: --param_name=param_value |
| 37 | ... Return the ID of the created VIM Target. |
| 38 | ... Example of execution: |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 39 | ... \${vim_account_id}= Create VIM Target \${vim_name} \${vim_user} \${vim_password} \${vim_auth_url} \${vim_tenant} \${vim_account_type} config='{...}' |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 40 | |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 41 | [Arguments] ${vim_name} ${vim_user} ${vim_password} ${vim_auth_url} ${vim_tenant} ${vim_account_type} @{optional_parameters} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 42 | |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 43 | ${osm_vim_create_command}= Set Variable osm vim-create --name ${vim_name} --user ${vim_user} --password ${vim_password} --auth_url ${vim_auth_url} --tenant ${vim_tenant} --account_type ${vim_account_type} |
| 44 | FOR ${param} IN @{optional_parameters} |
| 45 | ${match} ${param_name} ${param_value} = Should Match Regexp ${param} (.+)=(.+) msg=Syntax error in optional parameters |
| 46 | ${osm_vim_create_command}= Catenate ${osm_vim_create_command} --${param_name}=${param_value} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 47 | END |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 48 | ${rc} ${stdout}= Run and Return RC and Output ${osm_vim_create_command} |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame^] | 49 | Log ${stdout} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 50 | Should Be Equal As Integers ${rc} ${success_return_code} |
| 51 | [Return] ${stdout} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 52 | |
| 53 | |
| 54 | Delete VIM Target |
| 55 | [Arguments] ${vim_name} |
| 56 | |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 57 | ${rc} ${stdout}= Run Keyword And Continue On Failure Run and Return RC and Output osm vim-delete ${vim_name} |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame^] | 58 | Log ${stdout} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 59 | Wait Until Keyword Succeeds ${delete_max_wait_time} ${delete_pol_time} Check for VIM Target ${vim_name} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 60 | |
| 61 | |
| 62 | Get VIM Targets |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 63 | ${rc} ${stdout}= Run and Return RC and Output osm vim-list |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame^] | 64 | Log ${stdout} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 65 | Should Be Equal As Integers ${rc} ${success_return_code} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 66 | |
| 67 | |
| 68 | Check for VIM Target |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 69 | [Arguments] ${vim_name} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 70 | |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 71 | ${rc} ${stdout}= Run and Return RC and Output osm vim-list | awk '{print $2}' | grep ${vim_name} |
| 72 | Should Not Be Equal As Strings ${stdout} ${vim_name} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 73 | |
| 74 | |
| garciadeblas | 1558905 | 2020-10-02 15:40:25 +0000 | [diff] [blame] | 75 | Check for VIM Target Metric |
| Guillermo Calvino | 063677c | 2022-11-21 18:13:58 +0100 | [diff] [blame] | 76 | [Arguments] ${vim_name} ${prometheus_host} ${prometheus_port} ${prometheus_user} ${prometheus_password} |
| garciadeblas | 1558905 | 2020-10-02 15:40:25 +0000 | [diff] [blame] | 77 | |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 78 | ${vim_account_id}= Get VIM Target ID ${vim_name} |
| Guillermo Calvino | 063677c | 2022-11-21 18:13:58 +0100 | [diff] [blame] | 79 | Wait Until Keyword Succeeds ${vim_status_max_wait_time} ${vim_status_pol_time} Check If VIM Target Has Metric ${vim_account_id} ${prometheus_host} ${prometheus_port} ${prometheus_user} ${prometheus_password} |
| garciadeblas | 1558905 | 2020-10-02 15:40:25 +0000 | [diff] [blame] | 80 | |
| 81 | |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 82 | Check for VIM Target Status |
| Guillermo Calvino | 063677c | 2022-11-21 18:13:58 +0100 | [diff] [blame] | 83 | [Arguments] ${vim_name} ${prometheus_host} ${prometheus_port} ${prometheus_user} ${prometheus_password} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 84 | |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 85 | ${vim_account_id}= Get VIM Target ID ${vim_name} |
| Guillermo Calvino | 063677c | 2022-11-21 18:13:58 +0100 | [diff] [blame] | 86 | Wait Until Keyword Succeeds ${vim_status_max_wait_time} ${vim_status_pol_time} Check If VIM Target Is Available ${vim_account_id} ${prometheus_host} ${prometheus_port} ${prometheus_user} ${prometheus_password} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 87 | |
| 88 | |
| 89 | Get VIM Target ID |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 90 | [Arguments] ${vim_name} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 91 | |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 92 | ${rc} ${stdout}= Run and Return RC and Output osm vim-list | grep " ${vim_name} " | awk '{print $4}' |
| 93 | Should Be Equal As Integers ${rc} ${success_return_code} |
| 94 | Should Not Be Equal As Strings ${stdout} ${EMPTY} msg=VIM Target '${vim_name}' not found values=false |
| 95 | [Return] ${stdout} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 96 | |
| 97 | |
| aguilard | 0a36632 | 2021-09-09 07:52:37 +0000 | [diff] [blame] | 98 | Check VIM Target Operational State |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 99 | [Arguments] ${vim_name} |
| aguilard | 0a36632 | 2021-09-09 07:52:37 +0000 | [diff] [blame] | 100 | |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 101 | Wait Until Keyword Succeeds ${vim_opstate_max_wait_time} ${vim_opstate_pol_time} Check If VIM Target Is Enabled ${vim_name} |
| aguilard | 0a36632 | 2021-09-09 07:52:37 +0000 | [diff] [blame] | 102 | |
| 103 | |
| 104 | Check If VIM Target Is Enabled |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 105 | [Arguments] ${vim_name} |
| aguilard | 0a36632 | 2021-09-09 07:52:37 +0000 | [diff] [blame] | 106 | |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 107 | ${rc} ${stdout}= Run and Return RC and Output osm vim-list | grep " ${vim_name} " | awk '{print $6}' |
| 108 | Should Be Equal As Integers ${rc} ${success_return_code} |
| 109 | Should Be Equal As Strings ${stdout} ENABLED msg=VIM Target '${vim_name}' is not enabled values=false |
| aguilard | 0a36632 | 2021-09-09 07:52:37 +0000 | [diff] [blame] | 110 | |
| 111 | |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 112 | Check If VIM Target Is Available |
| Guillermo Calvino | 063677c | 2022-11-21 18:13:58 +0100 | [diff] [blame] | 113 | [Arguments] ${vim_account_id} ${prometheus_host} ${prometheus_port} ${prometheus_user} ${prometheus_password} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 114 | |
| Guillermo Calvino | 063677c | 2022-11-21 18:13:58 +0100 | [diff] [blame] | 115 | ${metric}= Get Metric ${prometheus_host} ${prometheus_port} ${prometheus_user} ${prometheus_password} osm_vim_status vim_account_id=${vim_account_id} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 116 | Should Be Equal As Integers ${metric} 1 msg=VIM Target '${vim_account_id}' is not active values=false |
| garciadeblas | 1558905 | 2020-10-02 15:40:25 +0000 | [diff] [blame] | 117 | |
| 118 | |
| 119 | Check If VIM Target Has Metric |
| Guillermo Calvino | 063677c | 2022-11-21 18:13:58 +0100 | [diff] [blame] | 120 | [Arguments] ${vim_account_id} ${prometheus_host} ${prometheus_port} ${prometheus_user} ${prometheus_password} |
| garciadeblas | 1558905 | 2020-10-02 15:40:25 +0000 | [diff] [blame] | 121 | |
| Guillermo Calvino | 063677c | 2022-11-21 18:13:58 +0100 | [diff] [blame] | 122 | ${metric}= Get Metric ${prometheus_host} ${prometheus_port} ${prometheus_user} ${prometheus_password} osm_vim_status vim_account_id=${vim_account_id} |
| garciadeblas | 1558905 | 2020-10-02 15:40:25 +0000 | [diff] [blame] | 123 | Should Be True ${metric} <2 msg=VIM Target '${vim_account_id}' has no metric |