blob: 4688bf929ecb573dbb5fc35626ee53bb94eb655c [file] [log] [blame]
garciadeblas7a9e0312023-12-11 22:24:46 +01001*** Comments ***
2# Licensed under the Apache License, Version 2.0 (the "License");
3# you may not use this file except in compliance with the License.
4# You may obtain a copy of the License at
5#
6# http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS,
10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13
14
15*** Settings ***
16Documentation Library to manage VIM Targets.
17
18Library String
19Library Collections
20Library OperatingSystem
21
22Resource ../lib/prometheus_lib.resource
23
24
25*** Variables ***
26${SUCCESS_RETURN_CODE} 0
27${VIM_DELETE_MAX_WAIT_TIME} 1min
28${VIM_DELETE_POL_TIME} 15sec
29${VIM_STATUS_MAX_WAIT_TIME} 3min
30${VIM_STATUS_POL_TIME} 15sec
31${VIM_OPSTATE_MAX_WAIT_TIME} 40sec
32${VIM_OPSTATE_POL_TIME} 10sec
33
34
35*** Keywords ***
36Create VIM Target
37 [Documentation] Register a VIM account in OSM and return the id.
38 ... 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
39 ... Return the ID of the created VIM Target.
40 ... Example of execution:
41 ... \${vim_account_id}= Create VIM Target \${vim_name} \${vim_user} \${vim_password} \${vim_auth_url} \${vim_tenant} \${vim_account_type} config='{...}'
42 [Arguments] ${vim_name} ${vim_user} ${vim_password} ${vim_auth_url} ${vim_tenant} ${vim_account_type} @{optional_parameters}
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 Log ${match},${param_name},${param_value}
47 ${osm_vim_create_command}= Catenate ${osm_vim_create_command} --${param_name}=${param_value}
48 END
49 ${rc} ${stdout}= Run And Return Rc And Output ${osm_vim_create_command}
50 Log ${stdout}
51 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE}
52 RETURN ${stdout}
53
54Delete VIM Target
55 [Documentation] Unregister/delete a VIM account from OSM.
56 [Arguments] ${vim_name}
57 ${rc} ${stdout}= Run Keyword And Continue On Failure Run And Return Rc And Output osm vim-delete ${vim_name}
58 Log ${rc},${stdout}
59 Wait Until Keyword Succeeds ${VIM_DELETE_MAX_WAIT_TIME} ${VIM_DELETE_POL_TIME} Check For VIM Target ${vim_name}
60
61Get VIM Targets
62 [Documentation] Get the list of VIM accounts in OSM.
63 ${rc} ${stdout}= Run And Return Rc And Output osm vim-list
64 Log ${stdout}
65 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE}
66
67Check For VIM Target
68 [Documentation] Check if a VIM account has been registered in OSM.
69 [Arguments] ${vim_name}
70 ${rc} ${stdout}= Run And Return Rc And Output osm vim-list | awk '{print $2}' | grep ${vim_name}
71 Log ${rc},${stdout}
72 Should Not Be Equal As Strings ${stdout} ${vim_name}
73
74Check For VIM Target Metric
75 [Documentation] Check in a loop if the metric of osm_vim_status is present in Prometheus for the VIM account in OSM.
garciadeblasd5691062024-09-15 22:35:20 +020076 [Arguments] ${vim_name} ${prometheus_url} ${prometheus_user} ${prometheus_password}
garciadeblas7a9e0312023-12-11 22:24:46 +010077 ${vim_account_id}= Get VIM Target ID ${vim_name}
garciadeblasd5691062024-09-15 22:35:20 +020078 Wait Until Keyword Succeeds ${VIM_STATUS_MAX_WAIT_TIME} ${VIM_STATUS_POL_TIME} Check If VIM Target Has Metric ${vim_account_id} ${prometheus_url} ${prometheus_user} ${prometheus_password}
garciadeblas7a9e0312023-12-11 22:24:46 +010079
80Check For VIM Target Status
81 [Documentation] Check in a loop if the value of the metric osm_vim_status in Prometheus for the VIM account is 1 (reachable).
garciadeblasd5691062024-09-15 22:35:20 +020082 [Arguments] ${vim_name} ${prometheus_url} ${prometheus_user} ${prometheus_password}
garciadeblas7a9e0312023-12-11 22:24:46 +010083 ${vim_account_id}= Get VIM Target ID ${vim_name}
garciadeblasd5691062024-09-15 22:35:20 +020084 Wait Until Keyword Succeeds ${VIM_STATUS_MAX_WAIT_TIME} ${VIM_STATUS_POL_TIME} Check If VIM Target Is Available ${vim_account_id} ${prometheus_url} ${prometheus_user} ${prometheus_password}
garciadeblas7a9e0312023-12-11 22:24:46 +010085
86Get VIM Target ID
87 [Documentation] Get from OSM the VIM account id associated to the VIM account name passed as parameter.
88 [Arguments] ${vim_name}
89 ${rc} ${stdout}= Run And Return Rc And Output osm vim-list | grep " ${vim_name} " | awk '{print $4}'
90 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE}
91 Should Not Be Equal As Strings ${stdout} ${EMPTY} msg=VIM Target '${vim_name}' not found values=false
92 RETURN ${stdout}
93
94Check VIM Target Operational State
95 [Documentation] Check if the VIM account in OSM is enabled.
96 [Arguments] ${vim_name}
97 Wait Until Keyword Succeeds ${VIM_OPSTATE_MAX_WAIT_TIME} ${VIM_OPSTATE_POL_TIME} Check If VIM Target Is Enabled ${vim_name}
98
99Check If VIM Target Is Enabled
100 [Documentation] Check if the VIM account passed as argument is enabled in OSM (meaning that the RO could reach the VIM account).
101 [Arguments] ${vim_name}
102 ${rc} ${stdout}= Run And Return Rc And Output osm vim-list | grep " ${vim_name} " | awk '{print $6}'
103 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE}
104 Should Be Equal As Strings ${stdout} ENABLED msg=VIM Target '${vim_name}' is not enabled values=false
105
106Check If VIM Target Is Available
107 [Documentation] Check if the value of the metric osm_vim_status in Prometheus for the VIM account is 1 (reachable).
garciadeblasd5691062024-09-15 22:35:20 +0200108 [Arguments] ${vim_account_id} ${prometheus_url} ${prometheus_user} ${prometheus_password}
109 Log ${prometheus_url}
110 Log ${prometheus_user}
111 Log ${prometheus_password}
112 Log ${vim_account_id}
113 ${metric}= Get Metric ${prometheus_url} ${prometheus_user} ${prometheus_password} osm_vim_status vim_account_id=${vim_account_id}
garciadeblas7a9e0312023-12-11 22:24:46 +0100114 Should Be Equal As Integers ${metric} 1 msg=VIM Target '${vim_account_id}' is not active values=false
115
116Check If VIM Target Has Metric
117 [Documentation] Check if the metric of osm_vim_status is present in Prometheus for the VIM account in OSM.
garciadeblasd5691062024-09-15 22:35:20 +0200118 [Arguments] ${vim_account_id} ${prometheus_url} ${prometheus_user} ${prometheus_password}
119 ${metric}= Get Metric ${prometheus_url} ${prometheus_user} ${prometheus_password} osm_vim_status vim_account_id=${vim_account_id}
garciadeblas7a9e0312023-12-11 22:24:46 +0100120 Should Be True ${metric} <2 msg=VIM Target '${vim_account_id}' has no metric