blob: 2c96802c286e1519b294192480aa82f29c959672 [file] [log] [blame]
garciadeblas23ff8f92023-12-11 16:26:40 +01001# 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 ***
14Documentation Library to manage VIM Targets.
15
16Library String
17Library Collections
18Library OperatingSystem
19
20# Gerardo
21Resource %{ROBOT_DEVOPS_FOLDER}/lib/prometheus_lib.robot
22
23
24*** Variables ***
25${success_return_code} 0
26${delete_max_wait_time} 1min
27${delete_pol_time} 15sec
28${vim_status_max_wait_time} 3min
29${vim_status_pol_time} 15sec
30${vim_opstate_max_wait_time} 40sec
31${vim_opstate_pol_time} 10sec
32
33
34*** Keywords ***
35Create VIM Target
36 [Documentation] Create a VIM Target in OSM.
37 ... 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
38 ... Return the ID of the created VIM Target.
39 ... Example of execution:
40 ... \${vim_account_id}= Create VIM Target \${vim_name} \${vim_user} \${vim_password} \${vim_auth_url} \${vim_tenant} \${vim_account_type} config='{...}'
41
42 [Arguments] ${vim_name} ${vim_user} ${vim_password} ${vim_auth_url} ${vim_tenant} ${vim_account_type} @{optional_parameters}
43
44 ${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}
45 FOR ${param} IN @{optional_parameters}
46 ${match} ${param_name} ${param_value} = Should Match Regexp ${param} (.+)=(.+) msg=Syntax error in optional parameters
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
54
55Delete VIM Target
56 [Arguments] ${vim_name}
57
58 ${rc} ${stdout}= Run Keyword And Continue On Failure Run and Return RC and Output osm vim-delete ${vim_name}
59 Log ${stdout}
60 Wait Until Keyword Succeeds ${delete_max_wait_time} ${delete_pol_time} Check for VIM Target ${vim_name}
61
62
63Get VIM Targets
64 ${rc} ${stdout}= Run and Return RC and Output osm vim-list
65 Log ${stdout}
66 Should Be Equal As Integers ${rc} ${success_return_code}
67
68
69Check for VIM Target
70 [Arguments] ${vim_name}
71
72 ${rc} ${stdout}= Run and Return RC and Output osm vim-list | awk '{print $2}' | grep ${vim_name}
73 Should Not Be Equal As Strings ${stdout} ${vim_name}
74
75
76Check for VIM Target Metric
77 [Arguments] ${vim_name} ${prometheus_host} ${prometheus_port} ${prometheus_user} ${prometheus_password}
78
79 ${vim_account_id}= Get VIM Target ID ${vim_name}
80 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}
81
82
83Check for VIM Target Status
84 [Arguments] ${vim_name} ${prometheus_host} ${prometheus_port} ${prometheus_user} ${prometheus_password}
85
86 ${vim_account_id}= Get VIM Target ID ${vim_name}
87 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}
88
89
90Get VIM Target ID
91 [Arguments] ${vim_name}
92
93 ${rc} ${stdout}= Run and Return RC and Output osm vim-list | grep " ${vim_name} " | awk '{print $4}'
94 Should Be Equal As Integers ${rc} ${success_return_code}
95 Should Not Be Equal As Strings ${stdout} ${EMPTY} msg=VIM Target '${vim_name}' not found values=false
96 [Return] ${stdout}
97
98
99Check VIM Target Operational State
100 [Arguments] ${vim_name}
101
102 Wait Until Keyword Succeeds ${vim_opstate_max_wait_time} ${vim_opstate_pol_time} Check If VIM Target Is Enabled ${vim_name}
103
104
105Check If VIM Target Is Enabled
106 [Arguments] ${vim_name}
107
108 ${rc} ${stdout}= Run and Return RC and Output osm vim-list | grep " ${vim_name} " | awk '{print $6}'
109 Should Be Equal As Integers ${rc} ${success_return_code}
110 Should Be Equal As Strings ${stdout} ENABLED msg=VIM Target '${vim_name}' is not enabled values=false
111
112
113Check If VIM Target Is Available
114 [Arguments] ${vim_account_id} ${prometheus_host} ${prometheus_port} ${prometheus_user} ${prometheus_password}
115
116 ${metric}= Get Metric ${prometheus_host} ${prometheus_port} ${prometheus_user} ${prometheus_password} osm_vim_status vim_account_id=${vim_account_id}
117 Should Be Equal As Integers ${metric} 1 msg=VIM Target '${vim_account_id}' is not active values=false
118
119
120Check If VIM Target Has Metric
121 [Arguments] ${vim_account_id} ${prometheus_host} ${prometheus_port} ${prometheus_user} ${prometheus_password}
122
123 ${metric}= Get Metric ${prometheus_host} ${prometheus_port} ${prometheus_user} ${prometheus_password} osm_vim_status vim_account_id=${vim_account_id}
124 Should Be True ${metric} <2 msg=VIM Target '${vim_account_id}' has no metric