2 Documentation Robot keyword library (Resource) for handling the BGP speaker CLI tools
4 ... Copyright (c) 2015 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
10 ... This library contains keywords to handle command line tools in BGP Application
11 ... for handling shell connections
12 Library SSHLibrary timeout=10s
13 Library RequestsLibrary
14 Variables ${CURDIR}/../variables/Variables.py
15 Resource ${CURDIR}/Utils.robot
19 [Arguments] ${command} ${tool_opt}
20 [Documentation] Start the tool ${command} ${tool_opt}
21 BuiltIn.Log ${command}
22 ${output}= SSHLibrary.Write ${command} ${tool_opt}
25 Wait_Until_Console_Tool_Finish
26 [Arguments] ${timeout}
27 [Documentation] Wait ${timeout} for the tool exit.
28 BuiltIn.Wait Until Keyword Succeeds ${timeout} 1s SSHLibrary.Read Until Prompt
31 [Documentation] Stop the tool if still running.
32 Utils.Write_Bare_Ctrl_C
33 ${output}= SSHLibrary.Read delay=1s
36 Read_And_Fail_If_Prompt_Is_Seen
37 [Documentation] Try to read SSH to see prompt, but expect to see no prompt within SSHLibrary's timeout.
38 ${passed}= BuiltIn.Run_Keyword_And_Return_Status BuiltIn.Run_Keyword_And_Expect_Error No match found for '${ODL_SYSTEM_PROMPT}' in *. Read_Text_Before_Prompt
39 BuiltIn.Return_From_Keyword_If ${passed}
40 BGPSpeaker.Dump_BGP_Speaker_Logs
41 Builtin.Fail The prompt was seen but it was not expected yet
43 Read_Text_Before_Prompt
44 [Documentation] Log text gathered by SSHLibrary.Read_Until_Prompt.
45 ... This needs to be a separate keyword just because how Read_And_Fail_If_Prompt_Is_Seen is implemented.
46 ${text}= SSHLibrary.Read_Until_Prompt
49 Store_File_To_Workspace
50 [Arguments] ${source_file_name} ${target_file_name}
51 [Documentation] Store the ${source_file_name} to the workspace as ${target_file_name}.
52 ${output_log}= SSHLibrary.Execute_Command cat ${source_file_name}
53 BuiltIn.Log ${output_log}
54 Create File ${target_file_name} ${output_log}
56 Check_File_For_Word_Count
57 [Arguments] ${file_name} ${word} ${expected_count}
58 [Documentation] Count ${word} in ${file_name}. Expect ${expected_count} occurence(s)
59 ${output_log}= SSHLibrary.Execute_Command grep -o '${word}' ${file_name} | wc -l
60 BuiltIn.Log ${output_log}
61 BuiltIn.Should_Be_Equal_As_Strings ${output_log} ${expected_count}
64 [Arguments] ${file_name} ${keyword} ${value}=''
65 [Documentation] Check file for ${keyword} or ${keyword} ${value} pair and returns number of occurences
66 ${output_log}= SSHLibrary.Execute_Command grep '${keyword}' ${file_name} | grep -c ${value}
67 ${count}= Convert To Integer ${output_log}
70 Check_File_For_Occurence
71 [Arguments] ${file_name} ${keyword} ${value}=''
72 [Documentation] Check file for ${keyword} or ${keyword} ${value} pair and returns number of occurences
73 ${output_log}= SSHLibrary.Execute_Command grep '${keyword}' ${file_name} | grep -c ${value}
74 ${count}= Convert To Integer ${output_log}