| garciaale | 6403533 | 2020-07-14 11:41:06 -0400 | [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 SDNCs. |
| garciaale | 6403533 | 2020-07-14 11:41:06 -0400 | [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 |
| 27 | ${sdnc_status_max_wait_time} 6min |
| 28 | ${sdnc_status_pol_time} 1min |
| 29 | |
| 30 | |
| 31 | *** Keywords *** |
| 32 | Create SDNC |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 33 | [Documentation] Creates an SDNC in OSM. |
| garciaale | 6403533 | 2020-07-14 11:41:06 -0400 | [diff] [blame] | 34 | ... The optional parameters (such as 'switch_dpid' or 'ip-address') are given to this function in name=value format. These parameters will be appended to the 'osm sdnc-create' command with the next syntax: --param_name=param_value |
| 35 | ... Returns the ID of the created SDNC Target. |
| 36 | ... Example of execution: |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 37 | ... \${sdnc_id}= Create SDNC \${sdnc_name} \${sdnc_user} \${sdnc_password} \${sdnc_url} \${sdnc_type} switch_dpid='{...}' |
| garciaale | 6403533 | 2020-07-14 11:41:06 -0400 | [diff] [blame] | 38 | |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 39 | [Arguments] ${sdnc_name} ${sdnc_user} ${sdnc_password} ${sdnc_url} ${sdnc_type} @{optional_parameters} |
| garciaale | 6403533 | 2020-07-14 11:41:06 -0400 | [diff] [blame] | 40 | |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 41 | ${osm_sdnc_create_command}= Set Variable osm sdnc-create --name ${sdnc_name} --user ${sdnc_user} --password ${sdnc_password} --url ${sdnc_url} --type ${sdnc_type} |
| 42 | FOR ${param} IN @{optional_parameters} |
| 43 | ${match} ${param_name} ${param_value} = Should Match Regexp ${param} (.+)=(.+) msg=Syntax error in optional parameters |
| 44 | ${osm_sdnc_create_command}= Catenate ${osm_sdnc_create_command} --${param_name}=${param_value} |
| garciaale | 6403533 | 2020-07-14 11:41:06 -0400 | [diff] [blame] | 45 | END |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 46 | ${rc} ${stdout}= Run and Return RC and Output ${osm_sdnc_create_command} |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 47 | Log ${stdout} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 48 | Should Be Equal As Integers ${rc} ${success_return_code} |
| 49 | [Return] ${stdout} |
| garciaale | 6403533 | 2020-07-14 11:41:06 -0400 | [diff] [blame] | 50 | |
| 51 | |
| aguilarherna | 347a779 | 2020-11-16 18:18:25 +0100 | [diff] [blame] | 52 | Check for SDNC To Be Deleted |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 53 | [Arguments] ${sdnc_name} |
| aguilarherna | 347a779 | 2020-11-16 18:18:25 +0100 | [diff] [blame] | 54 | |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 55 | ${rc} ${stdout}= Run and Return RC and Output osm sdnc-list | awk '{print $2}' | grep ${sdnc_name} |
| aguilarherna | 347a779 | 2020-11-16 18:18:25 +0100 | [diff] [blame] | 56 | Should Not Be Equal As Strings ${stdout} ${sdnc_name} |
| 57 | |
| 58 | |
| garciaale | 6403533 | 2020-07-14 11:41:06 -0400 | [diff] [blame] | 59 | Delete SDNC |
| 60 | [Arguments] ${sdnc_name} |
| 61 | |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 62 | ${rc} ${stdout}= Run Keyword And Continue On Failure Run and Return RC and Output osm sdnc-delete ${sdnc_name} |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 63 | Log ${stdout} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 64 | Should Be Equal As Integers ${rc} ${success_return_code} msg=${stdout} values=False |
| 65 | Wait Until Keyword Succeeds ${delete_max_wait_time} ${delete_pol_time} Check for SDNC To Be Deleted ${sdnc_name} |
| garciaale | 6403533 | 2020-07-14 11:41:06 -0400 | [diff] [blame] | 66 | |
| 67 | |
| 68 | Get SDNC List |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 69 | ${rc} ${stdout}= Run and Return RC and Output osm sdnc-list |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 70 | Log ${stdout} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 71 | Should Be Equal As Integers ${rc} ${success_return_code} |
| garciaale | 6403533 | 2020-07-14 11:41:06 -0400 | [diff] [blame] | 72 | |
| 73 | |
| 74 | Check for SDNC |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 75 | [Arguments] ${sdnc_id} |
| garciaale | 6403533 | 2020-07-14 11:41:06 -0400 | [diff] [blame] | 76 | |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 77 | ${rc} ${stdout}= Run and Return RC and Output osm sdnc-show ${sdnc_id} | grep -io ENABLED |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 78 | Log ${stdout} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 79 | Should Be Equal As Integers ${rc} ${success_return_code} |
| garciaale | 6403533 | 2020-07-14 11:41:06 -0400 | [diff] [blame] | 80 | |
| 81 | |
| 82 | Check for SDNC Status |
| Guillermo Calvino | 063677c | 2022-11-21 18:13:58 +0100 | [diff] [blame] | 83 | [Arguments] ${sdnc_id} ${prometheus_host} ${prometheus_port} ${prometheus_user} ${prometheus_password} |
| garciaale | 6403533 | 2020-07-14 11:41:06 -0400 | [diff] [blame] | 84 | |
| Guillermo Calvino | 063677c | 2022-11-21 18:13:58 +0100 | [diff] [blame] | 85 | Wait Until Keyword Succeeds ${sdnc_status_max_wait_time} ${sdnc_status_pol_time} Check If SDNC Is Available ${sdnc_id} ${prometheus_host} ${prometheus_port} ${prometheus_user} ${prometheus_password} |
| garciaale | 6403533 | 2020-07-14 11:41:06 -0400 | [diff] [blame] | 86 | |
| 87 | |
| 88 | Get SDNC ID |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 89 | [Arguments] ${sdnc_name} |
| garciaale | 6403533 | 2020-07-14 11:41:06 -0400 | [diff] [blame] | 90 | |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 91 | ${rc} ${stdout}= Run and Return RC and Output osm sdnc-list | grep " ${sdnc_name} " | awk '{print $4}' |
| 92 | Should Be Equal As Integers ${rc} ${success_return_code} |
| 93 | Should Not Be Equal As Strings ${stdout} ${EMPTY} msg=SDNC '${sdnc_name}' not found values=false |
| 94 | [Return] ${stdout} |
| garciaale | 6403533 | 2020-07-14 11:41:06 -0400 | [diff] [blame] | 95 | |
| 96 | |
| 97 | Check If SDNC Is Available |
| aguilard | e94b5c5 | 2022-11-30 08:27:49 +0100 | [diff] [blame] | 98 | [Arguments] ${sdnc_id} ${prometheus_host} ${prometheus_port} ${prometheus_user} ${prometheus_password} |
| garciaale | 6403533 | 2020-07-14 11:41:06 -0400 | [diff] [blame] | 99 | |
| aguilard | e94b5c5 | 2022-11-30 08:27:49 +0100 | [diff] [blame] | 100 | ${metric}= Get Metric ${prometheus_host} ${prometheus_port} ${prometheus_user} ${prometheus_password} osm_sdnc_status sdnc_id=${sdnc_id} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 101 | Should Be Equal As Integers ${metric} 1 msg=SDNC '${sdnc_id}' is not active values=false |