1 # Copyright (c) 2017 Cisco and/or its affiliates.
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.
15 | Library | resources.libraries.python.honeycomb.BGP.BGPKeywords
16 | Library | resources.libraries.python.honeycomb.HcAPIKwInterfaces.InterfaceKeywords
19 | Configure BGP module
20 | | [Documentation] | Edit Honeycomb's configuration file for the BGP feature.\
21 | | ... | Honeycomb needs to be restarted for the changes to take effect.
23 | | ... | *Arguments:*
24 | | ... | - node - information about a DUT node. Type: dictionary
25 | | ... | - ip_address - IP address to bind BGP listener to. Type: string
26 | | ... | - port - Port number to bind BGP listener to. Type: integer
27 | | ... | - as_number - Autonomous System (AS) ID number. Type: integer
31 | | ... | \| Configure BGP module \| ${nodes['DUT1']} \| 192.168.0.1 \| ${179} \
32 | | ... | \| ${65000} \|
34 | | [Arguments] | ${node} | ${ip_address} | ${port} | ${as_number}
35 | | Configure BGP base | ${node} | ${ip_address} | ${port} | ${as_number}
37 | No BGP peers should be configured
38 | | [Documentation] | Uses Honeycomb API to read BGP configuration and checks
39 | | ... | if there ary BGP peers conffigured.
41 | | ... | *Arguments:*
42 | | ... | - node - information about a DUT node. Type: dictionary
46 | | ... | \| No BGP peers should be configured \| ${nodes['DUT1']} \|
48 | | [Arguments] | ${node}
50 | | ${oper_data}= | Get Full BGP Configuration | ${node}
51 | | Should be Empty | ${oper_data['bgp-openconfig-extensions:bgp']}
53 | Honeycomb adds BGP peer
54 | | [Documentation] | Uses Honeycomb API to add a BGP peer.
56 | | ... | *Arguments:*
57 | | ... | - node - Information about a DUT node. Type: dictionary
58 | | ... | - address - IP address of the peer. Type: string
59 | | ... | - data - Peer configuration data. Type: dictionary
63 | | ... | \| Honeycomb adds BGP peer \| ${nodes['DUT1']} \| 192.168.0.1 \
64 | | ... | \| ${data} \|
66 | | [Arguments] | ${node} | ${address} | ${data}
68 | | Add BGP Peer | ${node} | ${address} | ${data}
70 | BGP Peer From Honeycomb Should be
71 | | [Documentation] | Uses Honeycomb API to verify BGP peer config data.
73 | | ... | *Arguments:*
74 | | ... | - node - Information about a DUT node. Type: dictionary
75 | | ... | - address - IP address of the peer. Type: string
76 | | ... | - data - Peer configuration data. Type: dictionary
80 | | ... | \| BGP Peer From Honeycomb Should be \
81 | | ... | \| ${nodes['DUT1']} \| 192.168.0.1 \| ${data} \|
83 | | [Arguments] | ${node} | ${address} | ${data}
85 | | ${oper_data}= | Get BGP Peer | ${node} | ${address}
86 | | Compare Data Structures | ${oper_data} | ${data}
88 | Peer Operational Data From Honeycomb Should be
89 | | [Documentation] | Uses Honeycomb API to verify BGP peer operational data.
91 | | ... | *Arguments:*
92 | | ... | - node - Information about a DUT node. Type: dictionary
93 | | ... | - address - IP address of the peer. Type: string
94 | | ... | - data - Peer configuration data. Type: dictionary
98 | | ... | \| BGP Peer From Honeycomb Should be \
99 | | ... | \| ${nodes['DUT1']} \| 192.168.0.1 \| ${data} \|
101 | | [Arguments] | ${node} | ${address}
103 | | ${oper_data}= | Get BGP Peer | ${node} | ${address} | operational
104 | | Should be Equal | ${oper_data['peer'][0]['peer-id']} | bgp://${address}
106 | Honeycomb removes BGP peer
107 | | [Documentation] | Uses Honeycomb API to add a BGP peer.
109 | | ... | *Arguments:*
110 | | ... | - node - Information about a DUT node. Type: dictionary
111 | | ... | - address - IP address of the peer. Type: string
115 | | ... | \| Honeycomb adds BGP peer \| ${nodes['DUT1']} \| 192.168.0.1 \|
117 | | [Arguments] | ${node} | ${address}
119 | | Remove BGP Peer | ${node} | ${address}
121 | Honeycomb configures BGP route
122 | | [Documentation] | Uses Honeycomb API to add a BGP route\
123 | | ... | to the specified peer.
125 | | ... | *Arguments:*
126 | | ... | - node - Information about a DUT node. Type: dictionary
127 | | ... | - peer_address - IP address of the peer. Type: string
128 | | ... | - data - Peer configuration data. Type: dictionary
129 | | ... | - route_address - IP address of the route. Type: string
130 | | ... | - route_index - Numeric index of the route under the peer.\
131 | | ... | Type: integer
132 | | ... | - ip_version - IP protocol version, ipv4 or ipv6. Type: string
136 | | ... | \| Honeycomb adds BGP peer \| ${nodes['DUT1']} \| 192.168.0.1 \
137 | | ... | \| ${data} \| 192.168.0.2 \| ${0} \| ipv4 \|
139 | | [Arguments] | ${node} | ${peer_address} | ${data}
140 | | ... | ${route_address} | ${route_index} | ${ip_version}
142 | | Configure BGP Route | ${node} | ${peer_address} | ${data}
143 | | ... | ${route_address} | ${route_index} | ${ip_version}
145 | BGP Route From Honeycomb Should be
146 | | [Documentation] | Uses Honeycomb API to verify BGP route operational data.
148 | | ... | *Arguments:*
149 | | ... | - node - Information about a DUT node. Type: dictionary
150 | | ... | - peer_address - IP address of the peer. Type: string
151 | | ... | - data - Peer configuration data. Type: dictionary
152 | | ... | - route_address - IP address of the route. Type: string
153 | | ... | - route_index - Numeric index of the route under the peer.\
154 | | ... | Type: integer
155 | | ... | - ip_version - IP protocol version, ipv4 or ipv6. Type: string
159 | | ... | \| BGP Peers From Honeycomb Should Include \
160 | | ... | \| ${nodes['DUT1']} \| ${data} \|
162 | | [Arguments] | ${node} | ${peer_address} | ${data}
163 | | ... | ${route_address} | ${route_index} | ${ip_version}
165 | | ${oper_data}= | Get BGP Route | ${node} | ${peer_address}
166 | | ... | ${route_address} | ${route_index} | ${ip_version}
167 | | Compare Data Structures | ${oper_data} | ${data}
169 | Honeycomb removes BGP route
170 | | [Documentation] | Uses Honeycomb API to remove a BGP route.
172 | | ... | *Arguments:*
173 | | ... | - node - Information about a DUT node. Type: dictionary
174 | | ... | - peer_address - IP address of the peer. Type: string
175 | | ... | - route_address - IP address of the route. Type: string
176 | | ... | - route_index - Numeric index of the route under the peer.\
177 | | ... | Type: integer
178 | | ... | - ip_version - IP protocol version, ipv4 or ipv6. Type: string
182 | | ... | \| Honeycomb removes BGP route \| ${nodes['DUT1']} \| 192.168.0.1 \
183 | | ... | \| 192.168.0.2 \| ${0} \| ipv4 \|
185 | | [Arguments] | ${node} | ${peer_address} | ${route_address}
186 | | ... | ${route_index} | ${ip_version}
188 | | Remove BGP Route | ${node} | ${peer_address} | ${route_address}
189 | | ... | ${route_index} | ${ip_version}
191 | No BGP routes should be configured
192 | | [Documentation] | Uses Honeycomb API to verify that no BGP routes\
193 | | ... | are configured under the specified peer.
195 | | ... | *Arguments:*
196 | | ... | - node - Information about a DUT node. Type: dictionary
197 | | ... | - peer_address - IP address of the peer. Type: string
198 | | ... | - ip_version - IP protocol version, ipv4 or ipv6. Type: string
202 | | ... | \| No BGP routes should be configured \| ${nodes['DUT1']} \
203 | | ... | \| 192.168.0.1 \| ipv4 \|
205 | | [Arguments] | ${node} | ${peer_address} | ${ip_version}
207 | | ${oper_data}= | Get All Peer Routes
208 | | ... | ${node} | ${peer_address} | ${ip_version}
209 | | Should be Empty | ${oper_data['bgp-inet:${ip_version}-routes']}
211 | No BGP routes should exist
212 | | [Documentation] | Uses Honeycomb API to verify that no BGP routes\
213 | | ... | exist under the specified peer.
215 | | ... | *Arguments:*
216 | | ... | - node - Information about a DUT node. Type: dictionary
217 | | ... | - peer_address - IP address of the peer. Type: string
218 | | ... | - ip_version - IP protocol version, ipv4 or ipv6. Type: string
222 | | ... | \| No BGP routes should be configured \| ${nodes['DUT1']} \
223 | | ... | \| 192.168.0.1 \| ipv4 \|
225 | | [Arguments] | ${node} | ${peer_address} | ${ip_version}
227 | | Run keyword and expect error | *Status code: 404*
228 | | ... | Get All Peer Routes
229 | | ... | ${node} | ${peer_address} | ${ip_version}
231 | BGP Loc-RIB table should include
232 | | [Documentation] | Uses Honeycomb API to retrieve local BGP RIB table\
233 | | ... | And verifies that it contains the specified entry.
235 | | ... | *Arguments:*
236 | | ... | - node - Information about a DUT node. Type: dictionary
237 | | ... | - data - RIB that should be present in operational data.\
238 | | ... | Type: dictionary
242 | | ... | \| BGP Loc-RIB table should include \| ${nodes['DUT1']} \| ${data} \|
244 | | [Arguments] | ${node} | ${data}
246 | | ${oper_data}= | Get BGP Local RIB | ${node}
247 | | ${oper_data}= | Set Variable | ${oper_data['loc-rib']['tables']}
248 | | ${data}= | Set Variable | ${data['loc-rib']['tables']}
249 | | Compare RIB Tables | ${oper_data} | ${data}
251 | Receive BGP OPEN message
252 | | [Documentation] | Open a TCP listener on BGP port(179) and listen\
253 | | ... | for BGP OPEN message. Verify ID and holdtime fields.
255 | | ... | *Arguments:*
256 | | ... | - tg_node - Information about the TG node. Type: dictionary
257 | | ... | - rx_ip - IP address to listen on. Type: string
258 | | ... | - src_ip - IP address of the BGP speaker. Also acts as BGP peer ID.\
259 | | ... | Type: string
260 | | ... | - holdtime - Expected value of HOLD_TIME field in received message.\
261 | | ... | Type: integer
265 | | ... | \| Receive BGP OPEN message \| ${node['TG']} \
266 | | ... | \| 192.168.0.1 \| 192.168.0.2 \| ${0}
268 | | [Arguments] | ${tg_node} | ${rx_ip} | ${src_ip} | ${port} | ${as_number}
269 | | ... | ${holdtime}
271 | | ${args}= | Catenate | --rx_ip | ${rx_ip}
272 | | ... | --src_ip | ${src_ip}
273 | | ... | --rx_port | ${port}
274 | | ... | --as_number | ${as_number}
275 | | ... | --holdtime | ${holdtime}
276 | | Run Traffic Script On Node | honeycomb/bgp_open.py
277 | | ... | ${tg_node} | ${args}