2 Documentation Robot keyword library (Resource) for handling the ExaBgp tool.
4 ... Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
6 ... This program and the accompanying materials are made available under the
7 ... terms of the Eclipse Public License v1.0 which accompanies this distribution,
8 ... and is available at http://www.eclipse.org/legal/epl-v10.html
11 ... This library assumes that a SSH connection exists (and is switched to)
12 ... to a Linux machine (usualy TOOLS_SYSTEM) where the ExaBgp should be run.
14 ... TODO: RemoteBash.robot contains logic which could be reused here.
16 Library RequestsLibrary
18 Resource ${CURDIR}/SSHKeywords.robot
19 Resource ${CURDIR}/RemoteBash.robot
20 Resource ${CURDIR}/BGPcliKeywords.robot
24 ${EXABGP_KILL_COMMAND} ps axf | grep exabgp | grep -v grep | awk '{print \"kill -9 \" $1}' | sh
25 ${CMD} env exabgp.tcp.port=1790 exabgp --debug
30 [Documentation] Dump the start command into prompt. It assumes that no exabgp is running. For verified
31 ... start use Start_ExaBgp_And_Verify_Connected keyword.
32 [Arguments] ${cfg_file}
33 ${start_cmd}= BuiltIn.Set_Variable ${CMD} ${cfg_file}
34 BuiltIn.Log ${start_cmd}
35 SSHKeywords.Virtual_Env_Activate_On_Current_Session log_output=${True}
36 ${output}= SSHLibrary.Write ${start_cmd}
40 [Documentation] Stops the ExaBgp by sending ctrl+c
41 ${output}= SSHLibrary.Read
43 RemoteBash.Write_Bare_Ctrl_C
44 ${output}= SSHLibrary.Read_Until_Prompt
46 SSHKeywords.Virtual_Env_Deactivate_On_Current_Session log_output=${True}
49 [Documentation] Sends kill command to stop all exabgps running
50 ${output}= SSHLibrary.Read
52 ${output}= SSHLibrary.Write ${EXABGP_KILL_COMMAND}
55 Start_ExaBgp_And_Verify_Connected
56 [Documentation] Starts the ExaBgp and verifies its connection. The verification is done by checking the presence
57 ... of the peer in the bgp rib.
58 [Arguments] ${cfg_file} ${session} ${exabgp_ip} ${connection_retries}=${3}
59 FOR ${idx} IN RANGE ${connection_retries}
60 Start_ExaBgp ${cfg_file}
61 ${status} ${value}= BuiltIn.Run_Keyword_And_Ignore_Error
62 ... BuiltIn.Wait_Until_Keyword_Succeeds
65 ... Verify_ExaBgps_Connection
69 IF "${status}" != "PASS" Stop_ExaBgp
70 IF "${status}" == "PASS" RETURN
72 BuiltIn.Fail Unable to connect ExaBgp to ODL
74 Verify_ExaBgps_Connection
75 [Documentation] Checks peer presence in operational datastore
76 [Arguments] ${session} ${exabgp_ip}=${TOOLS_SYSTEM_IP} ${connected}=${True}
77 ${peer_check_url}= BuiltIn.Set_Variable ${REST_API}/bgp-rib:bgp-rib/rib=example-bgp-rib/peer=bgp:%2F%2F
78 ${exp_status_code}= BuiltIn.Set_Variable_If ${connected} ${200} ${404}
79 ${rsp}= RequestsLibrary.GET On Session
81 ... url=${peer_check_url}${exabgp_ip}?content=nonconfig
82 BuiltIn.Log ${rsp.content}
83 BuiltIn.Should_Be_Equal_As_Numbers ${exp_status_code} ${rsp.status_code}
85 Upload_ExaBgp_Cluster_Config_Files
86 [Documentation] Uploads exabgp config files.
87 [Arguments] ${bgp_var_folder} ${cfg_file}
88 SSHLibrary.Put_File ${bgp_var_folder}/${cfg_file} .
89 @{cfgfiles}= SSHLibrary.List_Files_In_Directory . *.cfg
90 FOR ${cfgfile} IN @{cfgfiles}
91 SSHLibrary.Execute_Command sed -i -e 's/EXABGPIP/${TOOLS_SYSTEM_IP}/g' ${cfgfile}
92 SSHLibrary.Execute_Command sed -i -e 's/ODLIP1/${ODL_SYSTEM_1_IP}/g' ${cfgfile}
93 SSHLibrary.Execute_Command sed -i -e 's/ODLIP2/${ODL_SYSTEM_2_IP}/g' ${cfgfile}
94 SSHLibrary.Execute_Command sed -i -e 's/ODLIP3/${ODL_SYSTEM_3_IP}/g' ${cfgfile}
95 SSHLibrary.Execute_Command sed -i -e 's/ROUTEREFRESH/disable/g' ${cfgfile}
96 SSHLibrary.Execute_Command sed -i -e 's/ADDPATH/disable/g' ${cfgfile}
97 ${stdout}= SSHLibrary.Execute_Command cat ${cfgfile}