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
20 ${CMD} env exabgp.tcp.port=1790 exabgp --debug
21 ${PEER_CHECK_URL} /restconf/operational/bgp-rib:bgp-rib/rib/example-bgp-rib/peer/bgp:%2F%2F
25 [Arguments] ${cfg_file}
26 [Documentation] Dump the start command into prompt. It assumes that no exabgp is running. For verified
27 ... start use Start_ExaBgp_And_Verify_Connected keyword.
28 ${start_cmd} BuiltIn.Set_Variable ${CMD} ${cfg_file}
29 BuiltIn.Log ${start_cmd}
30 SSHKeywords.Virtual_Env_Activate_On_Current_Session log_output=${True}
31 ${output}= SSHLibrary.Write ${start_cmd}
35 [Documentation] Stops the ExaBgp by sending ctrl+c
36 ${output}= SSHLibrary.Read
38 RemoteBash.Write_Bare_Ctrl_C
39 ${output}= SSHLibrary.Read_Until_Prompt
41 SSHKeywords.Virtual_Env_Deactivate_On_Current_Session log_output=${True}
43 Start_ExaBgp_And_Verify_Connected
44 [Arguments] ${cfg_file} ${session} ${exabgp_ip} ${connection_retries}=${3}
45 [Documentation] Starts the ExaBgp and verifies its connection. The verification is done by checking the presence
46 ... of the peer in the bgp rib.
47 : FOR ${idx} IN RANGE ${connection_retries}
48 \ Start_ExaBgp ${cfg_file}
49 \ ${status} ${value}= BuiltIn.Run_Keyword_And_Ignore_Error BuiltIn.Wait_Until_Keyword_Succeeds 3x 3s
50 \ ... Verify_ExaBgps_Connection ${session} ${exabgp_ip} connected=${True}
51 \ BuiltIn.Run_Keyword_Unless "${status}" == "PASS" Stop_ExaBgp
52 \ BuiltIn.Return_From_Keyword_If "${status}" == "PASS"
53 BuiltIn.Fail Unable to connect ExaBgp to ODL
55 Verify_ExaBgps_Connection
56 [Arguments] ${session} ${exabgp_ip} ${connected}=${True}
57 [Documentation] Checks peer presence in operational datastore
58 ${exp_status_code}= BuiltIn.Set_Variable_If ${connected} ${200} ${404}
59 ${rsp}= RequestsLibrary.Get Request ${session} ${PEER_CHECK_URL}${exabgp_ip}
60 BuiltIn.Log ${rsp.content}
61 BuiltIn.Should_Be_Equal_As_Numbers ${exp_status_code} ${rsp.status_code}