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 Resource ${CURDIR}/SSHKeywords.robot
17 Resource ${CURDIR}/RemoteBash.robot
18 Resource ${CURDIR}/BGPcliKeywords.robot
21 ${EXABGP_KILL_COMMAND} ps axf | grep exabgp | grep -v grep | awk '{print \"kill -9 \" $1}' | sh
22 ${CMD} env exabgp.tcp.port=1790 exabgp --debug
23 ${PEER_CHECK_URL} /restconf/operational/bgp-rib:bgp-rib/rib/example-bgp-rib/peer/bgp:%2F%2F
27 [Arguments] ${cfg_file}
28 [Documentation] Dump the start command into prompt. It assumes that no exabgp is running. For verified
29 ... start use Start_ExaBgp_And_Verify_Connected keyword.
30 ${start_cmd} BuiltIn.Set_Variable ${CMD} ${cfg_file}
31 BuiltIn.Log ${start_cmd}
32 SSHKeywords.Virtual_Env_Activate_On_Current_Session log_output=${True}
33 ${output}= SSHLibrary.Write ${start_cmd}
37 [Documentation] Stops the ExaBgp by sending ctrl+c
38 ${output}= SSHLibrary.Read
40 RemoteBash.Write_Bare_Ctrl_C
41 ${output}= SSHLibrary.Read_Until_Prompt
43 SSHKeywords.Virtual_Env_Deactivate_On_Current_Session log_output=${True}
46 [Documentation] Sends kill command to stop all exabgps running
47 ${output} SSHLibrary.Read
49 ${output} SSHLibrary.Write ${EXABGP_KILL_COMMAND}
52 Start_ExaBgp_And_Verify_Connected
53 [Arguments] ${cfg_file} ${session} ${exabgp_ip} ${connection_retries}=${3}
54 [Documentation] Starts the ExaBgp and verifies its connection. The verification is done by checking the presence
55 ... of the peer in the bgp rib.
56 : FOR ${idx} IN RANGE ${connection_retries}
57 \ Start_ExaBgp ${cfg_file}
58 \ ${status} ${value}= BuiltIn.Run_Keyword_And_Ignore_Error BuiltIn.Wait_Until_Keyword_Succeeds 3x 3s
59 \ ... Verify_ExaBgps_Connection ${session} ${exabgp_ip} connected=${True}
60 \ BuiltIn.Run_Keyword_Unless "${status}" == "PASS" Stop_ExaBgp
61 \ BuiltIn.Return_From_Keyword_If "${status}" == "PASS"
62 BuiltIn.Fail Unable to connect ExaBgp to ODL
64 Verify_ExaBgps_Connection
65 [Arguments] ${session} ${exabgp_ip}=${TOOLS_SYSTEM_IP} ${connected}=${True}
66 [Documentation] Checks peer presence in operational datastore
67 ${exp_status_code}= BuiltIn.Set_Variable_If ${connected} ${200} ${404}
68 ${rsp}= RequestsLibrary.Get Request ${session} ${PEER_CHECK_URL}${exabgp_ip}
69 BuiltIn.Log ${rsp.content}
70 BuiltIn.Should_Be_Equal_As_Numbers ${exp_status_code} ${rsp.status_code}
72 Upload_ExaBgp_Cluster_Config_Files
73 [Arguments] ${bgp_var_folder} ${cfg_file}
74 [Documentation] Uploads exabgp config files.
75 SSHLibrary.Put_File ${bgp_var_folder}/${cfg_file} .
76 @{cfgfiles}= SSHLibrary.List_Files_In_Directory . *.cfg
77 : FOR ${cfgfile} IN @{cfgfiles}
78 \ SSHLibrary.Execute_Command sed -i -e 's/EXABGPIP/${TOOLS_SYSTEM_IP}/g' ${cfgfile}
79 \ SSHLibrary.Execute_Command sed -i -e 's/ODLIP1/${ODL_SYSTEM_1_IP}/g' ${cfgfile}
80 \ SSHLibrary.Execute_Command sed -i -e 's/ODLIP2/${ODL_SYSTEM_2_IP}/g' ${cfgfile}
81 \ SSHLibrary.Execute_Command sed -i -e 's/ODLIP3/${ODL_SYSTEM_3_IP}/g' ${cfgfile}
82 \ SSHLibrary.Execute_Command sed -i -e 's/ROUTEREFRESH/disable/g' ${cfgfile}
83 \ SSHLibrary.Execute_Command sed -i -e 's/ADDPATH/disable/g' ${cfgfile}
84 \ ${stdout}= SSHLibrary.Execute_Command cat ${cfgfile}