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
6 # http://www.apache.org/licenses/LICENSE-2.0
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.
16 Documentation Library to manage VIM Targets.
20 Library OperatingSystem
22 Resource ../lib/prometheus_lib.resource
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
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}
49 ${rc} ${stdout}= Run And Return Rc And Output ${osm_vim_create_command}
51 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE}
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}
59 Wait Until Keyword Succeeds ${VIM_DELETE_MAX_WAIT_TIME} ${VIM_DELETE_POL_TIME} Check For VIM Target ${vim_name}
62 [Documentation] Get the list of VIM accounts in OSM.
63 ${rc} ${stdout}= Run And Return Rc And Output osm vim-list
65 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE}
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}
72 Should Not Be Equal As Strings ${stdout} ${vim_name}
74 Check 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.
76 [Arguments] ${vim_name} ${prometheus_host} ${prometheus_port} ${prometheus_user} ${prometheus_password}
77 ${vim_account_id}= Get VIM Target ID ${vim_name}
78 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}
80 Check 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).
82 [Arguments] ${vim_name} ${prometheus_host} ${prometheus_port} ${prometheus_user} ${prometheus_password}
83 ${vim_account_id}= Get VIM Target ID ${vim_name}
84 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}
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
94 Check 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}
99 Check 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
106 Check 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).
108 [Arguments] ${vim_account_id} ${prometheus_host} ${prometheus_port} ${prometheus_user} ${prometheus_password}
109 ${metric}= Get Metric ${prometheus_host} ${prometheus_port} ${prometheus_user} ${prometheus_password} osm_vim_status vim_account_id=${vim_account_id}
110 Should Be Equal As Integers ${metric} 1 msg=VIM Target '${vim_account_id}' is not active values=false
112 Check If VIM Target Has Metric
113 [Documentation] Check if the metric of osm_vim_status is present in Prometheus for the VIM account in OSM.
114 [Arguments] ${vim_account_id} ${prometheus_host} ${prometheus_port} ${prometheus_user} ${prometheus_password}
115 ${metric}= Get Metric ${prometheus_host} ${prometheus_port} ${prometheus_user} ${prometheus_password} osm_vim_status vim_account_id=${vim_account_id}
116 Should Be True ${metric} <2 msg=VIM Target '${vim_account_id}' has no metric