2 Documentation This library contains keywords related to the BGP functionality.
5 Resource ../variables/Variables.robot
6 Resource TemplatedRequests.robot
7 Resource KillPythonTool.robot
10 ${BGP_BMP_DIR} ${CURDIR}/../variables/bgpfunctional/bmp_basic/filled_structure
11 ${BGP_BMP_FEAT_DIR} ${CURDIR}/../variables/bgpfunctional/bmp_basic/empty_structure
12 ${BGP_RIB_URI} ${OPERATIONAL_API}/bgp-rib:bgp-rib/rib/example-bgp-rib
13 ${BGP_TOPOLOGY_URI} ${OPERATIONAL_TOPO_API}/topology/example-ipv4-topology
14 ${VAR_BASE_BGP} ${CURDIR}/../variables/bgpfunctional
17 Start Quagga Processes On ODL
19 [Documentation] To start the zrpcd processes on ODL VM
20 ${conn_id}= Open_Connection_To_ODL_System ip_address=${odl_ip}
21 Switch Connection ${conn_id}
22 Write Commands Until Expected Prompt cd /opt/quagga/etc/ ${DEFAULT_LINUX_PROMPT_STRICT}
23 Write Commands Until Expected Prompt sudo cp zebra.conf.sample zebra.conf ${DEFAULT_LINUX_PROMPT_STRICT}
24 Write Commands Until Expected Prompt sudo /opt/quagga/etc/init.d/zrpcd start ${DEFAULT_LINUX_PROMPT_STRICT}
25 Write Commands Until Expected Prompt ps -ef | grep zrpcd ${DEFAULT_LINUX_PROMPT_STRICT}
26 Write Commands Until Expected Prompt netstat -nap | grep 7644 ${DEFAULT_LINUX_PROMPT_STRICT}
29 Restart BGP Processes On ODL
31 [Documentation] To restart the bgpd , qthriftd processes on ODL VM
32 ${conn_id} = Open_Connection_To_ODL_System ip_address=${odl_ip}
33 Switch Connection ${conn_id}
34 Write Commands Until Expected Prompt sudo pkill -f bgpd ${DEFAULT_LINUX_PROMPT_STRICT}
35 Start Quagga Processes On ODL ${odl_ip}
37 Start Quagga Processes On DCGW
38 [Arguments] ${dcgw_ip}
39 [Documentation] To start the zrpcd, bgpd,and zebra processes on DCGW
40 ${dcgw_conn_id} = Open_Connection_To_Tools_System ip_address=${dcgw_ip}
41 Switch Connection ${dcgw_conn_id}
42 Write Commands Until Expected Prompt cd /opt/quagga/etc/ ${DEFAULT_LINUX_PROMPT_STRICT}
43 Write Commands Until Expected Prompt sudo cp zebra.conf.sample zebra.conf ${DEFAULT_LINUX_PROMPT_STRICT}
44 Write Commands Until Expected Prompt sudo /opt/quagga/etc/init.d/zrpcd start ${DEFAULT_LINUX_PROMPT_STRICT}
45 Write Commands Until Expected Prompt ps -ef | grep zrpcd ${DEFAULT_LINUX_PROMPT_STRICT}
46 Write Commands Until Expected Prompt cd /opt/quagga/sbin/ ${DEFAULT_LINUX_PROMPT_STRICT}
47 ${output} = Write sudo ./bgpd &
48 ${output} = Read Until pid
50 ${output} = Write sudo ./zebra &
53 Write Commands Until Expected Prompt ps -ef | grep bgpd ${DEFAULT_LINUX_PROMPT_STRICT}
54 Write Commands Until Expected Prompt ps -ef | grep zebra ${DEFAULT_LINUX_PROMPT_STRICT}
55 Write Commands Until Expected Prompt netstat -nap | grep 7644 ${DEFAULT_LINUX_PROMPT_STRICT}
57 Restart BGP Processes On DCGW
58 [Arguments] ${dcgw_ip}
59 [Documentation] To Restart the zrpcd, bgpd,and zebra processes on DCGW
60 ${dcgw_conn_id} = Open_Connection_To_Tools_System ip_address=${dcgw_ip}
61 Switch Connection ${dcgw_conn_id}
62 Write Commands Until Expected Prompt sudo pkill -f bgpd ${DEFAULT_LINUX_PROMPT_STRICT}
63 Start Quagga Processes On DCGW ${dcgw_ip}
65 Show Quagga Configuration On ODL
66 [Arguments] ${odl_ip} ${rd}
67 [Documentation] Show quagga config from ODL
68 Create Quagga Telnet Session ${odl_ip} bgpd sdncbgpc
69 Execute Command On Quagga Telnet Session show running-config
70 Execute Command On Quagga Telnet Session show bgp neighbors
71 Execute Command On Quagga Telnet Session show ip bgp vrf ${rd}
72 Execute Command On Quagga Telnet Session exit
75 Create Quagga Telnet Session
76 [Arguments] ${ip} ${user} ${password}
77 [Documentation] Create telnet session for Quagga
78 ${conn_id}= Open_Connection_To_Tools_System ip_address=${ip}
79 Switch Connection ${conn_id}
80 ${output} = Write telnet localhost ${user}
81 ${output} = Read Until Password:
82 ${output} = Write ${password}
84 ${output} = Write terminal length 512
87 Execute Command On Quagga Telnet Session
88 [Arguments] ${command}
89 [Documentation] Execute command on Quagga telnet session(session should exist) and returns the output.
90 SSHLibrary.Write ${command}
91 ${output} = SSHLibrary.Read
95 Configure BGP And Add Neighbor On DCGW
96 [Arguments] ${dcgw_ip} ${as_id} ${router_id} ${neighbor_ip} ${vrf_name} ${rd}
98 [Documentation] Configure BGP and add neighbor on the dcgw
99 Create Quagga Telnet Session ${dcgw_ip} bgpd sdncbgpc
100 Execute Command On Quagga Telnet Session configure terminal
101 Execute Command On Quagga Telnet Session router bgp ${as_id}
102 Execute Command On Quagga Telnet Session bgp router-id ${router_id}
103 Execute Command On Quagga Telnet Session redistribute static
104 Execute Command On Quagga Telnet Session redistribute connected
105 Execute Command On Quagga Telnet Session neighbor ${neighbor_ip} send-remote-as ${as_id}
106 Execute Command On Quagga Telnet Session vrf ${vrf_name}
107 Execute Command On Quagga Telnet Session rd ${rd}
108 Execute Command On Quagga Telnet Session rt import ${rd}
109 Execute Command On Quagga Telnet Session rt export ${rd}
110 Execute Command On Quagga Telnet Session exit
111 Execute Command On Quagga Telnet Session address-family vpnv4 unicast
112 Execute Command On Quagga Telnet Session network ${loopback_ip}/32 rd ${rd} tag ${as_id}
113 Execute Command On Quagga Telnet Session neighbor ${neighbor_ip} activate
114 Execute Command On Quagga Telnet Session end
115 Execute Command On Quagga Telnet Session show running-config
116 Execute Command On Quagga Telnet Session exit
118 Add Loopback Interface On DCGW
119 [Arguments] ${dcgw_ip} ${loopback_name} ${loopback_ip} ${user}=zebra ${password}=zebra
120 [Documentation] Add loopback interface on DCGW
121 Create Quagga Telnet Session ${dcgw_ip} ${user} ${password}
122 Execute Command On Quagga Telnet Session enable
123 Execute Command On Quagga Telnet Session ${password}
124 Execute Command On Quagga Telnet Session configure terminal
125 Execute Command On Quagga Telnet Session interface ${loopback_name}
126 Execute Command On Quagga Telnet Session ip address ${loopback_ip}/32
127 Execute Command On Quagga Telnet Session exit
128 Execute Command On Quagga Telnet Session end
129 Execute Command On Quagga Telnet Session show running-config
130 Execute Command On Quagga Telnet Session exit
132 Execute Show Command On Quagga
133 [Arguments] ${dcgw_ip} ${cmd} ${user}=bgpd ${password}=sdncbgpc
134 [Documentation] Execute command on quagga and returns the ouput.
135 Create Quagga Telnet Session ${dcgw_ip} ${user} ${password}
136 ${output} = Execute Command On Quagga Telnet Session ${cmd}
138 Execute Command On quagga Telnet Session exit
141 Verify BGP Neighbor Status On Quagga
142 [Arguments] ${dcgw_ip} ${neighbor_ip}
143 [Documentation] Verify bgp neighbor status on quagga
144 ${output} = Execute Show Command On quagga ${dcgw_ip} show bgp neighbors ${neighbor_ip}
146 Should Contain ${output} BGP state = Established
148 Verify Routes On Quagga
149 [Arguments] ${dcgw_ip} ${rd} ${ip_list}
150 [Documentation] Verify routes on quagga
151 ${output} = Execute Show Command On quagga ${dcgw_ip} show ip bgp vrf ${rd}
153 : FOR ${ip} IN @{ip_list}
154 \ Should Contain ${output} ${ip}
156 Delete BGP Config On Quagga
157 [Arguments] ${dcgw_ip} ${bgp_id} ${user}=bgpd ${password}=sdncbgpc
158 [Documentation] Delete BGP Config on Quagga
159 Create Quagga Telnet Session ${dcgw_ip} ${user} ${password}
160 Execute Command On Quagga Telnet Session configure terminal
161 Execute Command On Quagga Telnet Session no router bgp ${bgp_id}
162 Execute Command On Quagga Telnet Session end
163 ${output} = Execute Command On Quagga Telnet Session show running-config
164 Execute Command On Quagga Telnet Session exit
168 [Arguments] ${dcgw_ip} ${as_id} ${vpn_name} ${rd}
169 [Documentation] Creating L3VPN on DCGW
170 BgpOperations.Create Quagga Telnet Session ${dcgw_ip} bgpd sdncbgpc
171 BgpOperations.Execute Command On Quagga Telnet Session configure terminal
172 BgpOperations.Execute Command On Quagga Telnet Session router bgp ${as_id}
173 BgpOperations.Execute Command On Quagga Telnet Session vrf ${vpn_name}
174 BgpOperations.Execute Command On Quagga Telnet Session rd ${rd}
175 BgpOperations.Execute Command On Quagga Telnet Session rt export ${rd}
176 BgpOperations.Execute Command On Quagga Telnet Session rt import ${rd}
177 BgpOperations.Execute Command On Quagga Telnet Session end
180 [Arguments] ${dcgw_ip} ${as_id} @{vpns}
181 [Documentation] Deleting L3VPN on DCGW
182 BgpOperations.Create Quagga Telnet Session ${dcgw_ip} bgpd sdncbgpc
183 BgpOperations.Execute Command On Quagga Telnet Session configure terminal
184 BgpOperations.Execute Command On Quagga Telnet Session router bgp ${as_id}
185 : FOR ${vpn} IN @{vpns}
186 \ BgpOperations.Execute Command On Quagga Telnet Session no vrf ${vpn}
187 BgpOperations.Execute Command On Quagga Telnet Session end
190 [Arguments] ${dcgw_ip} ${vpn_name} ${rd}
191 [Documentation] Verify L3VPN vrf name and rd value on DCGW
192 ${output} = BgpOperations.Execute Show Command On Quagga ${dcgw_ip} show running-config
193 BuiltIn.Should Contain ${output} vrf ${vpn_name}
194 BuiltIn.Should Contain ${output} rd ${rd}
197 [Arguments] ${dcgw_ip} ${rd} ${network_ip} ${label}
198 [Documentation] Add routes on DCGW
199 BgpOperations.Create Quagga Telnet Session ${dcgw_ip} bgpd sdncbgpc
200 BgpOperations.Execute Command On Quagga Telnet Session configure terminal
201 BgpOperations.Execute Command On Quagga Telnet Session router bgp ${AS_ID}
202 BgpOperations.Execute Command On Quagga Telnet Session address-family vpnv4 unicast
203 BgpOperations.Execute Command On Quagga Telnet Session network ${network_ip}/32 rd ${rd} tag ${label}
204 BgpOperations.Execute Command On Quagga Telnet Session end
206 Create BGP Configuration On ODL
207 [Arguments] &{Kwargs}
208 [Documentation] Associate the created L3VPN to a network-id received as dictionary argument
209 TemplatedRequests.Post_As_Json_Templated folder=${VAR_BASE_BGP}/create_bgp mapping=${Kwargs} session=session
211 AddNeighbor To BGP Configuration On ODL
212 [Arguments] &{Kwargs}
213 [Documentation] Associate the created L3VPN to a network-id received as dictionary argument
214 TemplatedRequests.Post_As_Json_Templated folder=${VAR_BASE_BGP}/addNeighbor_bgp mapping=${Kwargs} session=session
216 Get BGP Configuration On ODL
217 [Arguments] ${odl_session}
218 [Documentation] Get bgp configuration
219 ${resp} = RequestsLibrary.Get Request ${odl_session} ${CONFIG_API}/ebgp:bgp/
221 [Return] ${resp.content}
223 Delete BGP Configuration On ODL
224 [Arguments] ${odl_session}
225 [Documentation] Delete BGP
226 ${resp} = RequestsLibrary.Delete Request ${odl_session} ${CONFIG_API}/ebgp:bgp/
228 Should Be Equal As Strings ${resp.status_code} 200
229 [Return] ${resp.content}
231 Create External Tunnel Endpoint Configuration
232 [Arguments] &{Kwargs}
233 [Documentation] Create Tunnel End point
234 TemplatedRequests.Post_As_Json_Templated folder=${VAR_BASE_BGP}/create_etep mapping=${Kwargs} session=session
236 Delete External Tunnel Endpoint Configuration
237 [Arguments] &{Kwargs}
238 [Documentation] Delete Tunnel End point
239 TemplatedRequests.Post_As_Json_Templated folder=${VAR_BASE_BGP}/delete_etep mapping=${Kwargs} session=session
241 Get External Tunnel Endpoint Configuration
243 [Documentation] Get bgp configuration
244 ${resp} = RequestsLibrary.Get Request session ${CONFIG_API}/itm:dc-gateway-ip-list/dc-gateway-ip/${ip}/
246 [Return] ${resp.content}
249 [Documentation] Create and Log the diff between expected and actual responses, make sure Python tool was killed.
250 ... Tear down imported Resources.
251 KillPythonTool.Search_And_Kill_Remote_Python 'play\.py'
252 RequestsLibrary.Delete_All_Sessions
253 SSHLibrary.Close_All_Connections
255 Check_Example_Bgp_Rib_Content
256 [Arguments] ${session} ${substr} ${error_message}=${JSONKEYSTR} not found, but expected.
257 [Documentation] Check the example-bgp-rib content for string
258 ${response}= RequestsLibrary.Get Request ${session} ${BGP_RIB_URI}
259 BuiltIn.Log ${response.status_code}
260 BuiltIn.Log ${response.text}
261 BuiltIn.Should_Contain ${response.text} ${substr} ${error_message} values=False
263 Check_Example_Bgp_Rib_Does_Not_Contain
264 [Arguments] ${session} ${substr} ${error_message}=${JSONKEYSTR} found, but not expected.
265 [Documentation] Check the example-bgp-rib does not contain the string
266 ${response}= RequestsLibrary.Get Request ${session} ${BGP_RIB_URI}
267 BuiltIn.Log ${response.status_code}
268 BuiltIn.Log ${response.text}
269 BuiltIn.Should_Not_Contain ${response.text} ${substr} ${error_message} values=False
271 Check_Example_IPv4_Topology_Content
272 [Arguments] ${session} ${string_to_check}=${EMPTY}
273 [Documentation] Check the example-ipv4-topology content for string
274 ${response}= RequestsLibrary.Get Request ${session} ${BGP_TOPOLOGY_URI}
275 BuiltIn.Log ${response.status_code}
276 BuiltIn.Log ${response.text}
277 BuiltIn.Should_Contain ${response.text} ${string_to_check}
279 Check_Example_IPv4_Topology_Does_Not_Contain
280 [Arguments] ${session} ${string_to_check}
281 [Documentation] Check the example-ipv4-topology does not contain the string
282 ${response}= RequestsLibrary.Get Request ${session} ${BGP_TOPOLOGY_URI}
283 BuiltIn.Log ${response.status_code}
284 BuiltIn.Log ${response.text}
285 BuiltIn.Should_Not_Contain ${response.text} ${string_to_check}
287 Bmp_Monitor_Precondition
288 [Arguments] ${session}
289 [Documentation] Verify example-bmp-monitor presence in bmp-monitors
290 &{mapping} BuiltIn.Create_Dictionary TOOL_IP=${TOOLS_SYSTEM_IP}
291 BuiltIn.Wait_Until_Keyword_Succeeds 6x 10s TemplatedRequests.Get_As_Json_Templated folder=${BGP_BMP_FEAT_DIR} mapping=${mapping} verify=True
292 ... session=${session}
294 Bmp_Monitor_Postcondition
295 [Arguments] ${session}
296 [Documentation] Verifies if example-bmp-monitor data contains one peer.
297 &{mapping} BuiltIn.Create_Dictionary TOOL_IP=${TOOLS_SYSTEM_IP}
298 ${output} BuiltIn.Wait_Until_Keyword_Succeeds 10x 5s TemplatedRequests.Get_As_Json_Templated folder=${BGP_BMP_DIR} mapping=${mapping}
299 ... session=${session} verify=True
300 BuiltIn.Log ${output}