blob: 13cb6dc824d4502aab6c8cdec17b2bf08e291037 [file] [log] [blame]
garciaale64035332020-07-14 11:41:06 -04001# 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 SDNCs.
15
16Library String
17Library Collections
18Library OperatingSystem
19
20Resource %{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 ***
32Create SDNC
33 [Documentation] Creates an SDNC in OSM.
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:
37 ... \${sdnc_id}= Create SDNC \${sdnc_name} \${sdnc_user} \${sdnc_password} \${sdnc_url} \${sdnc_type} switch_dpid='{...}'
38
aguilarherna347a7792020-11-16 18:18:25 +010039 [Arguments] ${sdnc_name} ${sdnc_user} ${sdnc_password} ${sdnc_url} ${sdnc_type} @{optional_parameters}
garciaale64035332020-07-14 11:41:06 -040040
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}
45 END
46 ${rc} ${stdout}= Run and Return RC and Output ${osm_sdnc_create_command}
47 log ${stdout}
48 Should Be Equal As Integers ${rc} ${success_return_code}
49 [Return] ${stdout}
50
51
aguilarherna347a7792020-11-16 18:18:25 +010052Check for SDNC To Be Deleted
53 [Arguments] ${sdnc_name}
54
55 ${rc} ${stdout}= Run and Return RC and Output osm sdnc-list | awk '{print $2}' | grep ${sdnc_name}
56 Should Not Be Equal As Strings ${stdout} ${sdnc_name}
57
58
garciaale64035332020-07-14 11:41:06 -040059Delete SDNC
60 [Arguments] ${sdnc_name}
61
62 ${rc} ${stdout}= Run Keyword And Continue On Failure Run and Return RC and Output osm sdnc-delete ${sdnc_name}
63 log ${stdout}
aguilarherna347a7792020-11-16 18:18:25 +010064 Wait Until Keyword Succeeds ${delete_max_wait_time} ${delete_pol_time} Check for SDNC To Be Deleted ${sdnc_name}
garciaale64035332020-07-14 11:41:06 -040065
66
67Get SDNC List
68 ${rc} ${stdout}= Run and Return RC and Output osm sdnc-list
69 log ${stdout}
70 Should Be Equal As Integers ${rc} ${success_return_code}
71
72
73Check for SDNC
74 [Arguments] ${sdnc_name}
75
76 ${rc} ${stdout}= Run and Return RC and Output osm sdnc-list | awk '{print $2}' | grep ${sdnc_name}
77 Should Be Equal As Strings ${stdout} ${sdnc_name}
78
79
80Check for SDNC Status
81 [Arguments] ${sdnc_name} ${prometheus_host} ${prometheus_port}
82
83 ${sdnc_id}= Get SDNC ID ${sdnc_name}
84 Wait Until Keyword Succeeds ${sdnc_status_max_wait_time} ${sdnc_status_pol_time} Check If SDNC Is Available ${sdnc_id} ${prometheus_host} ${prometheus_port}
85
86
87Get SDNC ID
88 [Arguments] ${sdnc_name}
89
90 ${rc} ${stdout}= Run and Return RC and Output osm sdnc-list | grep " ${sdnc_name} " | awk '{print $4}'
91 Should Be Equal As Integers ${rc} ${success_return_code}
92 Should Not Be Equal As Strings ${stdout} ${EMPTY} msg=SDNC '${sdnc_name}' not found values=false
93 [Return] ${stdout}
94
95
96Check If SDNC Is Available
97 [Arguments] ${sdnc_id} ${prometheus_host} ${prometheus_port}
98
99 ${metric}= Get Metric ${prometheus_host} ${prometheus_port} osm_sdnc_status sdnc_id=${sdnc_id}
100 Should Be Equal As Integers ${metric} 0 msg=SDNC '${sdnc_id}' is not active values=false