Migrate Get Requests invocations(libraries)
[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 On Session    ${odl_session}    url=${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 On Session
284     ...    ${odl_session}
285     ...    url=${CONFIG_API}/ebgp:bgp/
286     ...    expected_status=200
287     Log    ${resp.text}
288     RETURN    ${resp.text}
289
290 Create External Tunnel Endpoint Configuration
291     [Documentation]    Create Tunnel End point
292     [Arguments]    &{Kwargs}
293     TemplatedRequests.Post_As_Json_Templated
294     ...    folder=${VAR_BASE_BGP}/create_etep
295     ...    mapping=${Kwargs}
296     ...    session=session
297
298 Delete External Tunnel Endpoint Configuration
299     [Documentation]    Delete Tunnel End point
300     [Arguments]    &{Kwargs}
301     TemplatedRequests.Post_As_Json_Templated
302     ...    folder=${VAR_BASE_BGP}/delete_etep
303     ...    mapping=${Kwargs}
304     ...    session=session
305
306 Teardown_Everything
307     [Documentation]    Create and Log the diff between expected and actual responses, make sure Python tool was killed.
308     ...    Tear down imported Resources.
309     KillPythonTool.Search_And_Kill_Remote_Python    'play\.py'
310     RequestsLibrary.Delete_All_Sessions
311     SSHLibrary.Close_All_Connections
312
313 Check_Example_Bgp_Rib_Content
314     [Documentation]    Check the example-bgp-rib content for string
315     [Arguments]    ${session}    ${substr}    ${error_message}=${JSONKEYSTR} not found, but expected.
316     ${response} =    RequestsLibrary.GET On Session
317     ...    ${session}
318     ...    url=${REST_API}/${BGP_RIB_URI}?content=nonconfig
319     BuiltIn.Log    ${response.status_code}
320     BuiltIn.Log    ${response.text}
321     BuiltIn.Should_Contain    ${response.text}    ${substr}    ${error_message}    values=False
322
323 Check_Example_Bgp_Rib_Does_Not_Contain
324     [Documentation]    Check the example-bgp-rib does not contain the string
325     [Arguments]    ${session}    ${substr}    ${error_message}=${JSONKEYSTR} found, but not expected.
326     ${response} =    RequestsLibrary.GET On Session
327     ...    ${session}
328     ...    url=${REST_API}/${BGP_RIB_URI}?content=nonconfig
329     BuiltIn.Log    ${response.status_code}
330     BuiltIn.Log    ${response.text}
331     BuiltIn.Should_Not_Contain    ${response.text}    ${substr}    ${error_message}    values=False
332
333 Check_Example_IPv4_Topology_Content
334     [Documentation]    Check the example-ipv4-topology content for string
335     [Arguments]    ${session}    ${string_to_check}=${EMPTY}
336     ${response} =    RequestsLibrary.GET On Session
337     ...    ${session}
338     ...    url=${REST_API}/${BGP_TOPOLOGY_URI}?content=nonconfig
339     BuiltIn.Log    ${response.status_code}
340     BuiltIn.Log    ${response.text}
341     BuiltIn.Should_Contain    ${response.text}    ${string_to_check}
342
343 Check_Example_IPv4_Topology_Does_Not_Contain
344     [Documentation]    Check the example-ipv4-topology does not contain the string
345     [Arguments]    ${session}    ${string_to_check}
346     ${response} =    RequestsLibrary.GET On Session
347     ...    ${session}
348     ...    url=${REST_API}/${BGP_TOPOLOGY_URI}?content=nonconfig
349     BuiltIn.Log    ${response.status_code}
350     BuiltIn.Log    ${response.text}
351     BuiltIn.Should_Not_Contain    ${response.text}    ${string_to_check}
352
353 Bmp_Monitor_Precondition
354     [Documentation]    Verify example-bmp-monitor presence in bmp-monitors
355     [Arguments]    ${session}
356     &{mapping} =    BuiltIn.Create_Dictionary    TOOL_IP=${TOOLS_SYSTEM_IP}
357     BuiltIn.Wait_Until_Keyword_Succeeds
358     ...    6x
359     ...    10s
360     ...    TemplatedRequests.Get_As_Json_Templated
361     ...    folder=${BGP_BMP_FEAT_DIR}
362     ...    mapping=${mapping}
363     ...    verify=True
364     ...    session=${session}
365
366 Bmp_Monitor_Postcondition
367     [Documentation]    Verifies if example-bmp-monitor data contains one peer.
368     [Arguments]    ${session}
369     &{mapping} =    BuiltIn.Create_Dictionary    TOOL_IP=${TOOLS_SYSTEM_IP}
370     ${output} =    BuiltIn.Wait_Until_Keyword_Succeeds
371     ...    10x
372     ...    5s
373     ...    TemplatedRequests.Get_As_Json_Templated
374     ...    folder=${BGP_BMP_DIR}
375     ...    mapping=${mapping}
376     ...    session=${session}
377     ...    verify=True
378     BuiltIn.Log    ${output}
379
380 Odl_To_Play_Template
381     [Arguments]    ${totest}    ${dir}    ${remove}=True
382     ${announce_hex} =    OperatingSystem.Get_File    ${dir}/${totest}/announce_${totest}.hex
383     ${announce_hex} =    String.Remove_String    ${announce_hex}    \n
384     ${withdraw_hex} =    OperatingSystem.Get_File    ${dir}/${totest}/withdraw_${totest}.hex
385     ${withdraw_hex} =    String.Remove_String    ${withdraw_hex}    \n
386     IF    '${remove}' == 'True'    BgpRpcClient.play_clean
387     TemplatedRequests.Post_As_Xml_Templated    ${dir}/${totest}/app    mapping=${APP_PEER}    session=${CONFIG_SESSION}
388     ${update} =    BuiltIn.Wait_Until_Keyword_Succeeds    3x    2s    Get_Update_Message
389     Verify_Two_Hex_Messages_Are_Equal    ${update}    ${announce_hex}
390     BgpRpcClient.play_clean
391     Remove_Configured_Routes    ${totest}    ${dir}
392     ${update} =    BuiltIn.Wait_Until_Keyword_Succeeds    3x    2s    Get_Update_Message
393     Verify_Two_Hex_Messages_Are_Equal    ${update}    ${withdraw_hex}
394     [Teardown]    Remove_Configured_Routes    ${totest}    ${dir}
395
396 Play_To_Odl_Template
397     [Arguments]    ${totest}    ${dir}    ${ipv}=ipv4
398     &{adj_rib_in} =    BuiltIn.Create_Dictionary
399     ...    PATH=peer\=bgp:%2F%2F${TOOLS_SYSTEM_IP}/adj-rib-in
400     ...    BGP_RIB=${RIB_NAME}
401     &{effective_rib_in} =    BuiltIn.Create_Dictionary
402     ...    PATH=peer\=bgp:%2F%2F${TOOLS_SYSTEM_IP}/effective-rib-in
403     ...    BGP_RIB=${RIB_NAME}
404     &{loc_rib} =    BuiltIn.Create_Dictionary    PATH=loc-rib    BGP_RIB=${RIB_NAME}
405     ${announce_hex} =    OperatingSystem.Get_File    ${dir}/${totest}/announce_${totest}.hex
406     ${withdraw_hex} =    OperatingSystem.Get_File    ${dir}/${totest}/withdraw_${totest}.hex
407     BgpRpcClient.play_clean
408     BgpRpcClient.play_send    ${announce_hex}
409     BuiltIn.Wait_Until_Keyword_Succeeds
410     ...    3x
411     ...    2s
412     ...    TemplatedRequests.Get_As_Json_Templated
413     ...    ${dir}/${totest}/rib
414     ...    mapping=${adj_rib_in}
415     ...    session=${CONFIG_SESSION}
416     ...    verify=True
417     BuiltIn.Wait_Until_Keyword_Succeeds
418     ...    3x
419     ...    2s
420     ...    TemplatedRequests.Get_As_Json_Templated
421     ...    ${dir}/${totest}/rib
422     ...    mapping=${effective_rib_in}
423     ...    session=${CONFIG_SESSION}
424     ...    verify=True
425     BuiltIn.Wait_Until_Keyword_Succeeds
426     ...    3x
427     ...    2s
428     ...    TemplatedRequests.Get_As_Json_Templated
429     ...    ${dir}/${totest}/rib
430     ...    mapping=${loc_rib}
431     ...    session=${CONFIG_SESSION}
432     ...    verify=True
433     BgpRpcClient.play_send    ${withdraw_hex}
434     BuiltIn.Wait_Until_Keyword_Succeeds
435     ...    3x
436     ...    2s
437     ...    TemplatedRequests.Get_As_Json_Templated
438     ...    ${dir}/empty_routes/${ipv}
439     ...    mapping=${loc_rib}
440     ...    session=${CONFIG_SESSION}
441     ...    verify=True
442     [Teardown]    BgpRpcClient.play_send    ${withdraw_hex}
443
444 Play_To_Odl_Non_Removal_Template
445     [Arguments]    ${totest}    ${dir}    ${ipv}=ipv4
446     ${announce_hex} =    OperatingSystem.Get_File    ${dir}/${totest}/announce_${totest}.hex
447     BgpRpcClient.play_clean
448     BgpRpcClient.play_send    ${announce_hex}
449     &{loc_rib} =    BuiltIn.Create_Dictionary    PATH=loc-rib    BGP_RIB=${RIB_NAME}
450     BuiltIn.Wait_Until_Keyword_Succeeds
451     ...    3x
452     ...    2s
453     ...    TemplatedRequests.Get_As_Json_Templated
454     ...    ${dir}/${totest}/rib
455     ...    mapping=${loc_rib}
456     ...    session=${CONFIG_SESSION}
457     ...    verify=True
458
459 Get_Update_Message
460     [Documentation]    Returns hex update message.
461     ${update} =    BgpRpcClient.play_get
462     BuiltIn.Should_Not_Be_Equal    ${update}    ${Empty}
463     RETURN    ${update}
464
465 Remove_Configured_Routes
466     [Documentation]    Removes the route if present.
467     [Arguments]    ${totest}    ${dir}
468     BuiltIn.Run_Keyword_And_Ignore_Error
469     ...    TemplatedRequests.Delete_Templated
470     ...    ${dir}/${totest}/app
471     ...    mapping=${APP_PEER}
472     ...    session=${CONFIG_SESSION}
473
474 Verify_Two_Hex_Messages_Are_Equal
475     [Documentation]    Verifies two hex messages are equal even in case, their arguments are misplaced.
476     ...    Compares length of the hex messages and sums hex messages arguments as integers and compares results.
477     [Arguments]    ${hex_1}    ${hex_2}
478     ${len_1} =    BuiltIn.Get_Length    ${hex_1}
479     ${len_2} =    BuiltIn.Get_Length    ${hex_2}
480     BuiltIn.Should_Be_Equal    ${len_1}    ${len_2}
481     ${sum_1} =    BgpRpcClient.Sum_Hex_Message    ${hex_1}
482     ${sum_2} =    BgpRpcClient.Sum_Hex_Message    ${hex_2}
483     BuiltIn.Should_Be_Equal    ${sum_1}    ${sum_2}
484
485 Check BGP VPNv4 Nbr On ODL
486     [Documentation]    Check all BGP VPNv4 neighbor on ODL
487     [Arguments]    ${dcgw_count}    ${flag}=True    ${start}=${START_VALUE}
488     ${output} =    KarafKeywords.Issue Command On Karaf Console    ${DISPLAY_VPN4_ALL}
489     FOR    ${index}    IN RANGE    ${start}    ${dcgw_count}
490         IF    ${flag}==True
491             BuiltIn.Should Contain    ${output}    ${DCGW_IP_LIST[${index}]}
492         ELSE
493             BuiltIn.Should Not Contain    ${output}    ${DCGW_IP_LIST[${index}]}
494         END
495     END