Correctly space expected_status
[integration/test.git] / csit / libraries / BgpOperations.robot
1 *** Settings ***
2 Documentation       This library contains keywords related to the BGP functionality.
3
4 Library             SSHLibrary
5 Library             String
6 Library             BgpRpcClient.py    ${TOOLS_SYSTEM_IP}
7 Resource            ../variables/Variables.robot
8 Resource            CompareStream.robot
9 Resource            Utils.robot
10 Resource            KillPythonTool.robot
11 Resource            TemplatedRequests.robot
12
13
14 *** Variables ***
15 ${BGP_BMP_DIR}              ${CURDIR}/../variables/bgpfunctional/bmp_basic/filled_structure
16 ${BGP_BMP_FEAT_DIR}         ${CURDIR}/../variables/bgpfunctional/bmp_basic/empty_structure
17 ${BGP_RIB_URI}              bgp-rib:bgp-rib/rib=example-bgp-rib
18 ${BGP_TOPOLOGY_URI}         ${TOPOLOGY_URL}=example-ipv4-topology
19 ${VAR_BASE_BGP}             ${CURDIR}/../variables/bgpfunctional
20 ${RIB_NAME}                 example-bgp-rib
21 &{APP_PEER}                 IP=${ODL_SYSTEM_IP}    BGP_RIB=${RIB_NAME}
22 ${BGP_CONFIG_SERVER_CMD}    bgp-connect -h ${ODL_SYSTEM_IP} -p 7644 add
23 ${VPNV4_ADDR_FAMILY}        vpnv4
24 ${DISPLAY_VPN4_ALL}         show-bgp --cmd "ip bgp ${VPNV4_ADDR_FAMILY} all"
25
26
27 *** Keywords ***
28 Start Quagga Processes On ODL
29     [Documentation]    To start the zrpcd processes on ODL VM
30     [Arguments]    ${odl_ip}
31     ${conn_id} =    Open_Connection_To_ODL_System    ip_address=${odl_ip}
32     Switch Connection    ${conn_id}
33     Write Commands Until Expected Prompt    cd /opt/quagga/etc/    ${DEFAULT_LINUX_PROMPT_STRICT}
34     Write Commands Until Expected Prompt    sudo cp zebra.conf.sample zebra.conf    ${DEFAULT_LINUX_PROMPT_STRICT}
35     Write Commands Until Expected Prompt    sudo /opt/quagga/etc/init.d/zrpcd start    ${DEFAULT_LINUX_PROMPT_STRICT}
36     Write Commands Until Expected Prompt    ps -ef | grep zrpcd    ${DEFAULT_LINUX_PROMPT_STRICT}
37     Write Commands Until Expected Prompt    netstat -nap | grep 7644    ${DEFAULT_LINUX_PROMPT_STRICT}
38     Close Connection
39
40 Restart BGP Processes On ODL
41     [Documentation]    To restart the bgpd , qthriftd processes on ODL VM
42     [Arguments]    ${odl_ip}
43     ${conn_id} =    Open_Connection_To_ODL_System    ip_address=${odl_ip}
44     Switch Connection    ${conn_id}
45     Write Commands Until Expected Prompt    sudo pkill -f bgpd    ${DEFAULT_LINUX_PROMPT_STRICT}
46     Start Quagga Processes On ODL    ${odl_ip}
47
48 Start Quagga Processes On DCGW
49     [Documentation]    To start the zrpcd, bgpd,and zebra processes on DCGW
50     [Arguments]    ${dcgw_ip}
51     ${dcgw_conn_id} =    Open_Connection_To_Tools_System    ip_address=${dcgw_ip}
52     Switch Connection    ${dcgw_conn_id}
53     Write Commands Until Expected Prompt    cd /opt/quagga/etc/    ${DEFAULT_LINUX_PROMPT_STRICT}
54     Write Commands Until Expected Prompt    sudo cp zebra.conf.sample zebra.conf    ${DEFAULT_LINUX_PROMPT_STRICT}
55     Write Commands Until Expected Prompt    sudo /opt/quagga/etc/init.d/zrpcd start    ${DEFAULT_LINUX_PROMPT_STRICT}
56     Write Commands Until Expected Prompt    ps -ef | grep zrpcd    ${DEFAULT_LINUX_PROMPT_STRICT}
57     Write Commands Until Expected Prompt    cd /opt/quagga/sbin/    ${DEFAULT_LINUX_PROMPT_STRICT}
58     ${output} =    Write    sudo ./bgpd &
59     ${output} =    Read Until    pid
60     Log    ${output}
61     ${output} =    Write    sudo ./zebra &
62     ${output} =    Read
63     Log    ${output}
64     Write Commands Until Expected Prompt    ps -ef | grep bgpd    ${DEFAULT_LINUX_PROMPT_STRICT}
65     Write Commands Until Expected Prompt    ps -ef | grep zebra    ${DEFAULT_LINUX_PROMPT_STRICT}
66     Write Commands Until Expected Prompt    netstat -nap | grep 7644    ${DEFAULT_LINUX_PROMPT_STRICT}
67
68 Restart BGP Processes On DCGW
69     [Documentation]    To Restart the zrpcd, bgpd and zebra processes on DCGW
70     [Arguments]    ${dcgw_ip}
71     ${dcgw_conn_id} =    Open_Connection_To_Tools_System    ip_address=${dcgw_ip}
72     Switch Connection    ${dcgw_conn_id}
73     Write Commands Until Expected Prompt    sudo pkill -f bgpd    ${DEFAULT_LINUX_PROMPT_STRICT}
74     Start Quagga Processes On DCGW    ${dcgw_ip}
75
76 Stop BGP Processes On Node
77     [Documentation]    To stop the bgpd , qthriftd processes on specific node given by user.
78     [Arguments]    ${node_ip}
79     Utils.Run Command On Remote System    ${node_ip}    sudo pkill -f bgpd
80     Utils.Run Command On Remote System    ${node_ip}    sudo pkill -f zrpcd
81
82 Show Quagga Configuration On ODL
83     [Documentation]    Show quagga config from ODL
84     [Arguments]    ${odl_ip}    ${rd}
85     Create Quagga Telnet Session    ${odl_ip}    bgpd    sdncbgpc
86     Execute Command On Quagga Telnet Session    show running-config
87     Execute Command On Quagga Telnet Session    show bgp neighbors
88     Execute Command On Quagga Telnet Session    show ip bgp vrf ${rd}
89     Execute Command On Quagga Telnet Session    exit
90     Close Connection
91
92 Create Quagga Telnet Session
93     [Documentation]    Create telnet session for Quagga
94     [Arguments]    ${ip}    ${user}    ${password}
95     ${conn_id} =    Open_Connection_To_Tools_System    ip_address=${ip}
96     Switch Connection    ${conn_id}
97     ${output} =    Write    telnet localhost ${user}
98     ${output} =    Read Until    Password:
99     ${output} =    Write    ${password}
100     ${output} =    Read
101     ${output} =    Write    terminal length 512
102     ${output} =    Read
103
104 Execute Command On Quagga Telnet Session
105     [Documentation]    Execute command on Quagga telnet session(session should exist) and returns the output.
106     [Arguments]    ${command}
107     SSHLibrary.Write    ${command}
108     ${output} =    SSHLibrary.Read
109     Log    ${output}
110     RETURN    ${output}
111
112 Configure BGP And Add Neighbor On DCGW
113     [Documentation]    Configure BGP and add neighbor on the dcgw
114     [Arguments]    ${dcgw_ip}    ${as_id}    ${router_id}    ${neighbor_ip}    ${vrf_name}    ${rd}
115     ...    ${loopback_ip}
116     Create Quagga Telnet Session    ${dcgw_ip}    bgpd    sdncbgpc
117     Execute Command On Quagga Telnet Session    configure terminal
118     Execute Command On Quagga Telnet Session    router bgp ${as_id}
119     Execute Command On Quagga Telnet Session    bgp router-id ${router_id}
120     Execute Command On Quagga Telnet Session    redistribute static
121     Execute Command On Quagga Telnet Session    redistribute connected
122     Execute Command On Quagga Telnet Session    neighbor ${neighbor_ip} send-remote-as ${as_id}
123     Execute Command On Quagga Telnet Session    vrf ${vrf_name}
124     Execute Command On Quagga Telnet Session    rd ${rd}
125     Execute Command On Quagga Telnet Session    rt import ${rd}
126     Execute Command On Quagga Telnet Session    rt export ${rd}
127     Execute Command On Quagga Telnet Session    exit
128     Execute Command On Quagga Telnet Session    address-family vpnv4 unicast
129     Execute Command On Quagga Telnet Session    network ${loopback_ip}/32 rd ${rd} tag ${as_id}
130     Execute Command On Quagga Telnet Session    neighbor ${neighbor_ip} activate
131     Execute Command On Quagga Telnet Session    end
132     Execute Command On Quagga Telnet Session    show running-config
133     Execute Command On Quagga Telnet Session    exit
134
135 Add Loopback Interface On DCGW
136     [Documentation]    Add loopback interface on DCGW
137     [Arguments]    ${dcgw_ip}    ${loopback_name}    ${loopback_ip}    ${user}=zebra    ${password}=zebra
138     Create Quagga Telnet Session    ${dcgw_ip}    ${user}    ${password}
139     Execute Command On Quagga Telnet Session    enable
140     Execute Command On Quagga Telnet Session    ${password}
141     Execute Command On Quagga Telnet Session    configure terminal
142     Execute Command On Quagga Telnet Session    interface ${loopback_name}
143     Execute Command On Quagga Telnet Session    ip address ${loopback_ip}/32
144     Execute Command On Quagga Telnet Session    exit
145     Execute Command On Quagga Telnet Session    end
146     Execute Command On Quagga Telnet Session    show running-config
147     Execute Command On Quagga Telnet Session    exit
148
149 Execute Show Command On Quagga
150     [Documentation]    Execute command on quagga and returns the ouput.
151     [Arguments]    ${dcgw_ip}    ${cmd}    ${user}=bgpd    ${password}=sdncbgpc
152     Create Quagga Telnet Session    ${dcgw_ip}    ${user}    ${password}
153     ${output} =    Execute Command On Quagga Telnet Session    ${cmd}
154     Log    ${output}
155     Execute Command On quagga Telnet Session    exit
156     RETURN    ${output}
157
158 Verify BGP Neighbor Status On Quagga
159     [Documentation]    Verify bgp neighbor status on quagga
160     [Arguments]    ${dcgw_ip}    ${neighbor_ip}
161     ${output} =    Execute Show Command On quagga    ${dcgw_ip}    show bgp neighbors ${neighbor_ip}
162     Log    ${output}
163     Should Contain    ${output}    BGP state = Established
164
165 Setup BGP Peering On ODL
166     [Documentation]    Setup BGP peering between ODL and given neighbor IP.
167     ...    Configuring and starting BGP on ODL node with given AS number
168     ...    Adding and verifying BGP neighbor
169     [Arguments]    ${odl_ip}    ${as_id}    ${nbr_ip}
170     KarafKeywords.Issue Command On Karaf Console    ${BGP_CONFIG_SERVER_CMD}
171     BgpOperations.Create BGP Configuration On ODL    localas=${as_id}    routerid=${odl_ip}
172     BgpOperations.AddNeighbor To BGP Configuration On ODL    remoteas=${as_id}    neighborAddr=${nbr_ip}
173     ${output} =    BgpOperations.Get BGP Configuration On ODL    session
174     BuiltIn.Should Contain    ${output}    ${nbr_ip}
175
176 Setup BGP Peering On DCGW
177     [Documentation]    Setup BGP peering between DCGW and given neighbor IP.
178     ...    Configuring,adding neighbor on DCGW node and verifying BGP neighbor.
179     [Arguments]    ${dcgw_ip}    ${as_id}    ${nbr_ip}    ${vrf_name}    ${rd}    ${loopback_ip}
180     BgpOperations.Configure BGP And Add Neighbor On DCGW
181     ...    ${dcgw_ip}
182     ...    ${as_id}
183     ...    ${dcgw_ip}
184     ...    ${nbr_ip}
185     ...    ${vrf_name}
186     ...    ${rd}
187     ...    ${loopback_ip}
188     ${output} =    BgpOperations.Execute Show Command On Quagga    ${dcgw_ip}    ${RUN_CONFIG}
189     BuiltIn.Should Contain    ${output}    ${nbr_ip}
190
191 Verify Routes On Quagga
192     [Documentation]    Verify routes on quagga
193     [Arguments]    ${dcgw_ip}    ${rd}    ${ip_list}
194     ${output} =    Execute Show Command On quagga    ${dcgw_ip}    show ip bgp vrf ${rd}
195     Log    ${output}
196     FOR    ${ip}    IN    @{ip_list}
197         Should Contain    ${output}    ${ip}
198     END
199
200 Delete BGP Config On Quagga
201     [Documentation]    Delete BGP Config on Quagga
202     [Arguments]    ${dcgw_ip}    ${bgp_id}    ${user}=bgpd    ${password}=sdncbgpc
203     Create Quagga Telnet Session    ${dcgw_ip}    ${user}    ${password}
204     Execute Command On Quagga Telnet Session    configure terminal
205     Execute Command On Quagga Telnet Session    no router bgp ${bgp_id}
206     Execute Command On Quagga Telnet Session    end
207     ${output} =    Execute Command On Quagga Telnet Session    show running-config
208     Execute Command On Quagga Telnet Session    exit
209     RETURN    ${output}
210
211 Create L3VPN on DCGW
212     [Documentation]    Creating L3VPN on DCGW
213     [Arguments]    ${dcgw_ip}    ${as_id}    ${vpn_name}    ${rd}
214     BgpOperations.Create Quagga Telnet Session    ${dcgw_ip}    bgpd    sdncbgpc
215     BgpOperations.Execute Command On Quagga Telnet Session    configure terminal
216     BgpOperations.Execute Command On Quagga Telnet Session    router bgp ${as_id}
217     BgpOperations.Execute Command On Quagga Telnet Session    vrf ${vpn_name}
218     BgpOperations.Execute Command On Quagga Telnet Session    rd ${rd}
219     BgpOperations.Execute Command On Quagga Telnet Session    rt export ${rd}
220     BgpOperations.Execute Command On Quagga Telnet Session    rt import ${rd}
221     BgpOperations.Execute Command On Quagga Telnet Session    end
222
223 Delete L3VPN on DCGW
224     [Documentation]    Deleting L3VPN on DCGW
225     [Arguments]    ${dcgw_ip}    ${as_id}    @{vpns}
226     BgpOperations.Create Quagga Telnet Session    ${dcgw_ip}    bgpd    sdncbgpc
227     BgpOperations.Execute Command On Quagga Telnet Session    configure terminal
228     BgpOperations.Execute Command On Quagga Telnet Session    router bgp ${as_id}
229     FOR    ${vpn}    IN    @{vpns}
230         BgpOperations.Execute Command On Quagga Telnet Session    no vrf ${vpn}
231     END
232     BgpOperations.Execute Command On Quagga Telnet Session    end
233
234 Verify L3VPN On DCGW
235     [Documentation]    Verify L3VPN vrf name and rd value on DCGW
236     [Arguments]    ${dcgw_ip}    ${vpn_name}    ${rd}
237     ${output} =    BgpOperations.Execute Show Command On Quagga    ${dcgw_ip}    show running-config
238     BuiltIn.Should Contain    ${output}    vrf ${vpn_name}
239     BuiltIn.Should Contain    ${output}    rd ${rd}
240
241 Add Routes On DCGW
242     [Documentation]    Add routes on DCGW
243     [Arguments]    ${dcgw_ip}    ${rd}    ${network_ip}    ${label}
244     BgpOperations.Create Quagga Telnet Session    ${dcgw_ip}    bgpd    sdncbgpc
245     BgpOperations.Execute Command On Quagga Telnet Session    configure terminal
246     BgpOperations.Execute Command On Quagga Telnet Session    router bgp ${AS_ID}
247     BgpOperations.Execute Command On Quagga Telnet Session    address-family vpnv4 unicast
248     BgpOperations.Execute Command On Quagga Telnet Session    network ${network_ip}/32 rd ${rd} tag ${label}
249     BgpOperations.Execute Command On Quagga Telnet Session    end
250
251 Create BGP Configuration On ODL
252     [Documentation]    Associate the created L3VPN to a network-id received as dictionary argument
253     [Arguments]    &{Kwargs}
254     TemplatedRequests.Post_As_Json_Templated
255     ...    folder=${VAR_BASE_BGP}/create_bgp
256     ...    mapping=${Kwargs}
257     ...    session=session
258
259 AddNeighbor To BGP Configuration On ODL
260     [Documentation]    Associate the created L3VPN to a network-id received as dictionary argument
261     [Arguments]    &{Kwargs}
262     CompareStream.Run_Keyword_If_Less_Than_Magnesium
263     ...    TemplatedRequests.Post_As_Json_Templated
264     ...    folder=${VAR_BASE_BGP}/addNeighbor_bgp
265     ...    mapping=${Kwargs}
266     ...    session=session
267     CompareStream.Run_Keyword_If_At_Least_Magnesium
268     ...    TemplatedRequests.Post_As_Json_Templated
269     ...    folder=${VAR_BASE_BGP}/addNeighborsContainer_bgp
270     ...    mapping=${Kwargs}
271     ...    session=session
272
273 Get BGP Configuration On ODL
274     [Documentation]    Get bgp configuration
275     [Arguments]    ${odl_session}
276     ${resp} =    RequestsLibrary.Get Request    ${odl_session}    ${CONFIG_API}/ebgp:bgp/
277     Log    ${resp.text}
278     RETURN    ${resp.text}
279
280 Delete BGP Configuration On ODL
281     [Documentation]    Delete BGP
282     [Arguments]    ${odl_session}
283     ${resp} =    RequestsLibrary.Delete Request    ${odl_session}    ${CONFIG_API}/ebgp:bgp/
284     Log    ${resp.text}
285     Should Be Equal As Strings    ${resp.status_code}    200
286     RETURN    ${resp.text}
287
288 Create External Tunnel Endpoint Configuration
289     [Documentation]    Create Tunnel End point
290     [Arguments]    &{Kwargs}
291     TemplatedRequests.Post_As_Json_Templated
292     ...    folder=${VAR_BASE_BGP}/create_etep
293     ...    mapping=${Kwargs}
294     ...    session=session
295
296 Delete External Tunnel Endpoint Configuration
297     [Documentation]    Delete Tunnel End point
298     [Arguments]    &{Kwargs}
299     TemplatedRequests.Post_As_Json_Templated
300     ...    folder=${VAR_BASE_BGP}/delete_etep
301     ...    mapping=${Kwargs}
302     ...    session=session
303
304 Get External Tunnel Endpoint Configuration
305     [Documentation]    Get bgp configuration
306     [Arguments]    ${ip}
307     ${resp} =    RequestsLibrary.Get Request    session    ${CONFIG_API}/itm:dc-gateway-ip-list/dc-gateway-ip/${ip}/
308     Log    ${resp.text}
309     RETURN    ${resp.text}
310
311 Teardown_Everything
312     [Documentation]    Create and Log the diff between expected and actual responses, make sure Python tool was killed.
313     ...    Tear down imported Resources.
314     KillPythonTool.Search_And_Kill_Remote_Python    'play\.py'
315     RequestsLibrary.Delete_All_Sessions
316     SSHLibrary.Close_All_Connections
317
318 Check_Example_Bgp_Rib_Content
319     [Documentation]    Check the example-bgp-rib content for string
320     [Arguments]    ${session}    ${substr}    ${error_message}=${JSONKEYSTR} not found, but expected.
321     ${response} =    RequestsLibrary.Get Request    ${session}    ${REST_API}/${BGP_RIB_URI}?content=nonconfig
322     BuiltIn.Log    ${response.status_code}
323     BuiltIn.Log    ${response.text}
324     BuiltIn.Should_Contain    ${response.text}    ${substr}    ${error_message}    values=False
325
326 Check_Example_Bgp_Rib_Does_Not_Contain
327     [Documentation]    Check the example-bgp-rib does not contain the string
328     [Arguments]    ${session}    ${substr}    ${error_message}=${JSONKEYSTR} found, but not expected.
329     ${response} =    RequestsLibrary.Get Request    ${session}    ${REST_API}/${BGP_RIB_URI}?content=nonconfig
330     BuiltIn.Log    ${response.status_code}
331     BuiltIn.Log    ${response.text}
332     BuiltIn.Should_Not_Contain    ${response.text}    ${substr}    ${error_message}    values=False
333
334 Check_Example_IPv4_Topology_Content
335     [Documentation]    Check the example-ipv4-topology content for string
336     [Arguments]    ${session}    ${string_to_check}=${EMPTY}
337     ${response} =    RequestsLibrary.Get Request    ${session}    ${REST_API}/${BGP_TOPOLOGY_URI}?content=nonconfig
338     BuiltIn.Log    ${response.status_code}
339     BuiltIn.Log    ${response.text}
340     BuiltIn.Should_Contain    ${response.text}    ${string_to_check}
341
342 Check_Example_IPv4_Topology_Does_Not_Contain
343     [Documentation]    Check the example-ipv4-topology does not contain the string
344     [Arguments]    ${session}    ${string_to_check}
345     ${response} =    RequestsLibrary.Get Request    ${session}    ${REST_API}/${BGP_TOPOLOGY_URI}?content=nonconfig
346     BuiltIn.Log    ${response.status_code}
347     BuiltIn.Log    ${response.text}
348     BuiltIn.Should_Not_Contain    ${response.text}    ${string_to_check}
349
350 Bmp_Monitor_Precondition
351     [Documentation]    Verify example-bmp-monitor presence in bmp-monitors
352     [Arguments]    ${session}
353     &{mapping} =    BuiltIn.Create_Dictionary    TOOL_IP=${TOOLS_SYSTEM_IP}
354     BuiltIn.Wait_Until_Keyword_Succeeds
355     ...    6x
356     ...    10s
357     ...    TemplatedRequests.Get_As_Json_Templated
358     ...    folder=${BGP_BMP_FEAT_DIR}
359     ...    mapping=${mapping}
360     ...    verify=True
361     ...    session=${session}
362
363 Bmp_Monitor_Postcondition
364     [Documentation]    Verifies if example-bmp-monitor data contains one peer.
365     [Arguments]    ${session}
366     &{mapping} =    BuiltIn.Create_Dictionary    TOOL_IP=${TOOLS_SYSTEM_IP}
367     ${output} =    BuiltIn.Wait_Until_Keyword_Succeeds
368     ...    10x
369     ...    5s
370     ...    TemplatedRequests.Get_As_Json_Templated
371     ...    folder=${BGP_BMP_DIR}
372     ...    mapping=${mapping}
373     ...    session=${session}
374     ...    verify=True
375     BuiltIn.Log    ${output}
376
377 Odl_To_Play_Template
378     [Arguments]    ${totest}    ${dir}    ${remove}=True
379     ${announce_hex} =    OperatingSystem.Get_File    ${dir}/${totest}/announce_${totest}.hex
380     ${announce_hex} =    String.Remove_String    ${announce_hex}    \n
381     ${withdraw_hex} =    OperatingSystem.Get_File    ${dir}/${totest}/withdraw_${totest}.hex
382     ${withdraw_hex} =    String.Remove_String    ${withdraw_hex}    \n
383     IF    '${remove}' == 'True'    BgpRpcClient.play_clean
384     TemplatedRequests.Post_As_Xml_Templated    ${dir}/${totest}/app    mapping=${APP_PEER}    session=${CONFIG_SESSION}
385     ${update} =    BuiltIn.Wait_Until_Keyword_Succeeds    3x    2s    Get_Update_Message
386     Verify_Two_Hex_Messages_Are_Equal    ${update}    ${announce_hex}
387     BgpRpcClient.play_clean
388     Remove_Configured_Routes    ${totest}    ${dir}
389     ${update} =    BuiltIn.Wait_Until_Keyword_Succeeds    3x    2s    Get_Update_Message
390     Verify_Two_Hex_Messages_Are_Equal    ${update}    ${withdraw_hex}
391     [Teardown]    Remove_Configured_Routes    ${totest}    ${dir}
392
393 Play_To_Odl_Template
394     [Arguments]    ${totest}    ${dir}    ${ipv}=ipv4
395     &{adj_rib_in} =    BuiltIn.Create_Dictionary
396     ...    PATH=peer\=bgp:%2F%2F${TOOLS_SYSTEM_IP}/adj-rib-in
397     ...    BGP_RIB=${RIB_NAME}
398     &{effective_rib_in} =    BuiltIn.Create_Dictionary
399     ...    PATH=peer\=bgp:%2F%2F${TOOLS_SYSTEM_IP}/effective-rib-in
400     ...    BGP_RIB=${RIB_NAME}
401     &{loc_rib} =    BuiltIn.Create_Dictionary    PATH=loc-rib    BGP_RIB=${RIB_NAME}
402     ${announce_hex} =    OperatingSystem.Get_File    ${dir}/${totest}/announce_${totest}.hex
403     ${withdraw_hex} =    OperatingSystem.Get_File    ${dir}/${totest}/withdraw_${totest}.hex
404     BgpRpcClient.play_clean
405     BgpRpcClient.play_send    ${announce_hex}
406     BuiltIn.Wait_Until_Keyword_Succeeds
407     ...    3x
408     ...    2s
409     ...    TemplatedRequests.Get_As_Json_Templated
410     ...    ${dir}/${totest}/rib
411     ...    mapping=${adj_rib_in}
412     ...    session=${CONFIG_SESSION}
413     ...    verify=True
414     BuiltIn.Wait_Until_Keyword_Succeeds
415     ...    3x
416     ...    2s
417     ...    TemplatedRequests.Get_As_Json_Templated
418     ...    ${dir}/${totest}/rib
419     ...    mapping=${effective_rib_in}
420     ...    session=${CONFIG_SESSION}
421     ...    verify=True
422     BuiltIn.Wait_Until_Keyword_Succeeds
423     ...    3x
424     ...    2s
425     ...    TemplatedRequests.Get_As_Json_Templated
426     ...    ${dir}/${totest}/rib
427     ...    mapping=${loc_rib}
428     ...    session=${CONFIG_SESSION}
429     ...    verify=True
430     BgpRpcClient.play_send    ${withdraw_hex}
431     BuiltIn.Wait_Until_Keyword_Succeeds
432     ...    3x
433     ...    2s
434     ...    TemplatedRequests.Get_As_Json_Templated
435     ...    ${dir}/empty_routes/${ipv}
436     ...    mapping=${loc_rib}
437     ...    session=${CONFIG_SESSION}
438     ...    verify=True
439     [Teardown]    BgpRpcClient.play_send    ${withdraw_hex}
440
441 Play_To_Odl_Non_Removal_Template
442     [Arguments]    ${totest}    ${dir}    ${ipv}=ipv4
443     ${announce_hex} =    OperatingSystem.Get_File    ${dir}/${totest}/announce_${totest}.hex
444     BgpRpcClient.play_clean
445     BgpRpcClient.play_send    ${announce_hex}
446     &{loc_rib} =    BuiltIn.Create_Dictionary    PATH=loc-rib    BGP_RIB=${RIB_NAME}
447     BuiltIn.Wait_Until_Keyword_Succeeds
448     ...    3x
449     ...    2s
450     ...    TemplatedRequests.Get_As_Json_Templated
451     ...    ${dir}/${totest}/rib
452     ...    mapping=${loc_rib}
453     ...    session=${CONFIG_SESSION}
454     ...    verify=True
455
456 Get_Update_Message
457     [Documentation]    Returns hex update message.
458     ${update} =    BgpRpcClient.play_get
459     BuiltIn.Should_Not_Be_Equal    ${update}    ${Empty}
460     RETURN    ${update}
461
462 Remove_Configured_Routes
463     [Documentation]    Removes the route if present.
464     [Arguments]    ${totest}    ${dir}
465     BuiltIn.Run_Keyword_And_Ignore_Error
466     ...    TemplatedRequests.Delete_Templated
467     ...    ${dir}/${totest}/app
468     ...    mapping=${APP_PEER}
469     ...    session=${CONFIG_SESSION}
470
471 Verify_Two_Hex_Messages_Are_Equal
472     [Documentation]    Verifies two hex messages are equal even in case, their arguments are misplaced.
473     ...    Compares length of the hex messages and sums hex messages arguments as integers and compares results.
474     [Arguments]    ${hex_1}    ${hex_2}
475     ${len_1} =    BuiltIn.Get_Length    ${hex_1}
476     ${len_2} =    BuiltIn.Get_Length    ${hex_2}
477     BuiltIn.Should_Be_Equal    ${len_1}    ${len_2}
478     ${sum_1} =    BgpRpcClient.Sum_Hex_Message    ${hex_1}
479     ${sum_2} =    BgpRpcClient.Sum_Hex_Message    ${hex_2}
480     BuiltIn.Should_Be_Equal    ${sum_1}    ${sum_2}
481
482 Check BGP VPNv4 Nbr On ODL
483     [Documentation]    Check all BGP VPNv4 neighbor on ODL
484     [Arguments]    ${dcgw_count}    ${flag}=True    ${start}=${START_VALUE}
485     ${output} =    KarafKeywords.Issue Command On Karaf Console    ${DISPLAY_VPN4_ALL}
486     FOR    ${index}    IN RANGE    ${start}    ${dcgw_count}
487         IF    ${flag}==True
488             BuiltIn.Should Contain    ${output}    ${DCGW_IP_LIST[${index}]}
489         ELSE
490             BuiltIn.Should Not Contain    ${output}    ${DCGW_IP_LIST[${index}]}
491         END
492     END