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
5 # http://www.apache.org/licenses/LICENSE-2.0
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.
14 Documentation Library to manage VIM Targets.
18 Library OperatingSystem
21 Resource %{ROBOT_DEVOPS_FOLDER}/lib/prometheus_lib.robot
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
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='{...}'
42 [Arguments] ${vim_name} ${vim_user} ${vim_password} ${vim_auth_url} ${vim_tenant} ${vim_account_type} @{optional_parameters}
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}
49 ${rc} ${stdout}= Run and Return RC and Output ${osm_vim_create_command}
51 Should Be Equal As Integers ${rc} ${success_return_code}
56 [Arguments] ${vim_name}
58 ${rc} ${stdout}= Run Keyword And Continue On Failure Run and Return RC and Output osm vim-delete ${vim_name}
60 Wait Until Keyword Succeeds ${delete_max_wait_time} ${delete_pol_time} Check for VIM Target ${vim_name}
64 ${rc} ${stdout}= Run and Return RC and Output osm vim-list
66 Should Be Equal As Integers ${rc} ${success_return_code}
70 [Arguments] ${vim_name}
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}
76 Check for VIM Target Metric
77 [Arguments] ${vim_name} ${prometheus_host} ${prometheus_port} ${prometheus_user} ${prometheus_password}
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}
83 Check for VIM Target Status
84 [Arguments] ${vim_name} ${prometheus_host} ${prometheus_port} ${prometheus_user} ${prometheus_password}
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}
91 [Arguments] ${vim_name}
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
99 Check VIM Target Operational State
100 [Arguments] ${vim_name}
102 Wait Until Keyword Succeeds ${vim_opstate_max_wait_time} ${vim_opstate_pol_time} Check If VIM Target Is Enabled ${vim_name}
105 Check If VIM Target Is Enabled
106 [Arguments] ${vim_name}
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
113 Check If VIM Target Is Available
114 [Arguments] ${vim_account_id} ${prometheus_host} ${prometheus_port} ${prometheus_user} ${prometheus_password}
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
120 Check If VIM Target Has Metric
121 [Arguments] ${vim_account_id} ${prometheus_host} ${prometheus_port} ${prometheus_user} ${prometheus_password}
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