1c39b72adb0caf047d37b99fd60e969967706fad
[integration/test.git] / csit / libraries / KarafKeywords.robot
1 *** Settings ***
2 Documentation     Karaf library. General utility keywords for interacting with the karaf environment, such as the
3 ...               karaf console, karaf.log, karaf features, and karaf config files.
4 ...
5 ...               This library is useful to deal with controller Karaf console for ssh sessions in cluster.
6 ...               Running Setup_Karaf_Keywords is necessary. If SetupUtils initialization is called, this gets initialized as well.
7 ...               If this gets initialized, ClusterManagement gets initialized as well.
8 Library           SSHLibrary
9 Library           OperatingSystem
10 Library           ${CURDIR}/netvirt/excepts.py
11 Resource          ${CURDIR}/ClusterManagement.robot
12 Resource          ${CURDIR}/SSHKeywords.robot
13 Variables         ${CURDIR}/../variables/Variables.py
14
15 *** Variables ***
16 ${WORKSPACE}      /tmp
17 ${connection_index_dict}    &{EMPTY}
18
19 *** Keywords ***
20 Setup_Karaf_Keywords
21     [Arguments]    ${http_timeout}=${DEFAULT_TIMEOUT_HTTP}
22     [Documentation]    Initialize ClusterManagement. Open ssh karaf connections to each ODL.
23     ClusterManagement.ClusterManagement_Setup    http_timeout=${http_timeout}
24     ClusterManagement.Run_Bash_Command_On_List_Or_All    iptables -I INPUT -p tcp --dport ${KARAF_SHELL_PORT} -j ACCEPT; iptables-save
25     BuiltIn.Comment    First connections to Karaf console may fail, so WUKS is used. TODO: Track as a Bug.
26     : FOR    ${index}    IN    @{ClusterManagement__member_index_list}
27     \    BuiltIn.Run_Keyword_And_Ignore_Error    BuiltIn.Wait_Until_Keyword_Succeeds    3s    1s    Open_Controller_Karaf_Console_On_Background    member_index=${index}
28
29 Verify_Feature_Is_Installed
30     [Arguments]    ${feature_name}    ${controller}=${ODL_SYSTEM_IP}    ${karaf_port}=${KARAF_SHELL_PORT}
31     [Documentation]    Will Succeed if the given ${feature_name} is found in the output of "feature:list -i"
32     ${output} =    Issue_Command_On_Karaf_Console    feature:list -i | grep ${feature_name}    ${controller}    ${karaf_port}
33     BuiltIn.Should_Contain    ${output}    ${feature_name}
34     [Return]    ${output}
35
36 Issue_Command_On_Karaf_Console
37     [Arguments]    ${cmd}    ${controller}=${ODL_SYSTEM_IP}    ${karaf_port}=${KARAF_SHELL_PORT}    ${timeout}=10    ${loglevel}=INFO
38     [Documentation]    Will execute the given ${cmd} by ssh'ing to the karaf console running on ${controller}
39     ...    Note that this keyword will open&close new SSH connection, without switching back to previously current session.
40     SSHLibrary.Open_Connection    ${controller}    port=${karaf_port}    prompt=${KARAF_PROMPT_LOGIN}    timeout=${timeout}
41     SSHLibrary.Login    ${KARAF_USER}    ${KARAF_PASSWORD}    loglevel=${loglevel}
42     SSHLibrary.Write    ${cmd}
43     ${output}    SSHLibrary.Read_Until_Regexp    ${KARAF_PROMPT}
44     SSHLibrary.Write    logout
45     SSHLibrary.Close_Connection
46     BuiltIn.Log    ${output}
47     [Return]    ${output}
48
49 Safe_Issue_Command_On_Karaf_Console
50     [Arguments]    ${cmd}    ${controller}=${ODL_SYSTEM_IP}    ${karaf_port}=${KARAF_SHELL_PORT}    ${timeout}=10    ${loglevel}=INFO
51     [Documentation]    Run Issue_Command_On_Karaf_Console but restore previous connection afterwards.
52     BuiltIn.Run_Keyword_And_Return    SSHKeywords.Run_Keyword_Preserve_Connection    Issue_Command_On_Karaf_Console    ${cmd}    ${controller}    ${karaf_port}    ${timeout}
53     ...    ${loglevel}
54
55 Check For Elements On Karaf Command Output Message
56     [Arguments]    ${cmd}    ${elements}    ${controller}=${ODL_SYSTEM_IP}    ${karaf_port}=${KARAF_SHELL_PORT}    ${timeout}=5
57     [Documentation]    Will execute the command using Issue Command On Karaf Console then check for the given elements
58     ...    in the command output message
59     ${output}    Issue_Command_On_Karaf_Console    ${cmd}    ${controller}    ${karaf_port}    ${timeout}
60     : FOR    ${i}    IN    @{elements}
61     \    BuiltIn.Should_Contain    ${output}    ${i}
62
63 Verify_Bundle_Is_Installed
64     [Arguments]    ${bundle_name}    ${controller}=${ODL_SYSTEM_IP}    ${karaf_port}=${KARAF_SHELL_PORT}
65     [Documentation]    Will succeed if the given ${bundle name} is present in the output of "bundle:list -s "
66     ${output} =    Issue_Command_On_Karaf_Console    bundle:list -s | grep ${bundle_name}    ${controller}    ${karaf_port}
67     BuiltIn.Should_Contain    ${output}    ${bundle_name}
68     [Return]    ${output}
69
70 Verify_Bundle_Is_Not_Installed
71     [Arguments]    ${bundle_name}    ${controller}=${ODL_SYSTEM_IP}    ${karaf_port}=${KARAF_SHELL_PORT}
72     [Documentation]    Will succeed if the given ${bundle_name} is NOT found in the output of "bundle:list -s"
73     ${output} =    Issue_Command_On_Karaf_Console    bundle:list -i | grep ${bundle_name}    ${controller}    ${karaf_port}
74     BuiltIn.Should_Not_Contain    ${output}    ${bundle_name}
75     [Return]    ${output}
76
77 Check_Karaf_Log_Has_Messages
78     [Arguments]    ${filter_string}    @{message_list}
79     [Documentation]    Will succeed if the @{messages} are found in \ the output of "log:display"
80     ${output} =    Issue_Command_On_Karaf_Console    log:display | grep ${filter_string}
81     : FOR    ${message}    IN    @{message_list}
82     \    BuiltIn.Should_Contain    ${output}    ${message}
83     [Return]    ${output}
84
85 Check_Karaf_Log_Message_Count
86     [Arguments]    ${message}    ${count}    ${use_console}=False
87     [Documentation]    Verifies that the ${message} exists specified number of times in
88     ...    karaf console log or Karaf Log Folder based on the arg ${use_console}.
89     Run Keyword If    ${use_console} == False    Check_Karaf_Log_File    ${message}    ${count}
90     ...    ELSE    Check_Karaf_Log_From_Console    ${message}    ${count}
91
92 Check_Karaf_Log_From_Console
93     [Arguments]    ${message}    ${count}
94     [Documentation]    Verifies that the ${message} exists in the Karaf Console log:display and checks
95     ...    that it appears ${count} number of times
96     ${output} =    Issue_Command_On_Karaf_Console    log:display | grep ${message} | wc -l
97     ${line} =    Get Line    ${output}    0
98     ${stripped} =    Strip String    ${line}
99     Should Be Equal As Strings    ${stripped}    ${count}
100
101 Check_Karaf_Log_File
102     [Arguments]    ${message}    ${count}
103     [Documentation]    Verifies that the ${message} exists in the Karaf Log Folder and checks
104     ...    that it appears ${count} number of times
105     ${output}    Run Command On Controller    ${ODL_SYSTEM_IP}    grep -o ${message} ${WORKSPACE}/${BUNDLEFOLDER}/data/log/* | wc -l
106     Should Be Equal As Strings    ${output}    ${count}
107
108 Install_A_Feature
109     [Arguments]    ${feature_name}    ${controller}=${ODL_SYSTEM_IP}    ${karaf_port}=${KARAF_SHELL_PORT}    ${timeout}=180
110     [Documentation]    Will Install the given ${feature_name}
111     BuiltIn.Log    ${timeout}
112     ${output} =    Issue_Command_On_Karaf_Console    feature:install ${feature_name}    ${controller}    ${karaf_port}    ${timeout}
113     BuiltIn.Log    ${output}
114     [Return]    ${output}
115
116 Install_A_Feature_Using_Active_Connection
117     [Arguments]    ${feature_name}
118     [Documentation]    Will Install the given ${feature_name} using active connection
119     ${cmd} =    BuiltIn.Set_Variable    feature:install ${feature_name}
120     SSHLibrary.Write    ${cmd}
121     ${output}    SSHLibrary.Read_Until_Regexp    ${KARAF_PROMPT}
122     BuiltIn.Log    ${output}
123     [Return]    ${output}
124
125 Uninstall_A_Feature
126     [Arguments]    ${feature_name}    ${controller}=${ODL_SYSTEM_IP}    ${karaf_port}=${KARAF_SHELL_PORT}    ${timeout}=180
127     [Documentation]    Will UnInstall the given ${feature_name}
128     ${output} =    Issue_Command_On_Karaf_Console    feature:uninstall ${feature_name}    ${controller}    ${karaf_port}    ${timeout}
129     BuiltIn.Log    ${output}
130     [Return]    ${output}
131
132 Open_Controller_Karaf_Console_On_Background
133     [Arguments]    ${member_index}=${1}    ${timeout}=10    ${loglevel}=INFO
134     [Documentation]    If there is a stored ssh connection index of connection to the controller's karaf console for ${member_index},
135     ...    close the previous connection. In any case create a new connection
136     ...    to karaf console for ${member_index}, set correct prompt set and login to karaf console.
137     ...    Store connection index for ${member_index} and restore the previous active connection.
138     ${current_ssh_connection_object}=    SSHLibrary.Get_Connection
139     BuiltIn.Log    ${connection_index_dict}
140     BuiltIn.Log    ${member_index}
141     ${status}    ${old_connection_index} =    BuiltIn.Run_Keyword_And_Ignore_Error    Get From Dictionary    ${connection_index_dict}    ${member_index}
142     BuiltIn.Run_Keyword_If    '${status}'=='PASS'    BuiltIn.Run_Keywords    SSHLibrary.Switch_Connection    ${old_connection_index}
143     ...    AND    SSHLibrary.Write    logout
144     ...    AND    SSHLibrary.Close_Connection
145     ${odl_ip} =    ClusterManagement.Resolve_IP_Address_For_Member    ${member_index}
146     SSHLibrary.Open_Connection    ${odl_ip}    port=${KARAF_SHELL_PORT}    prompt=${KARAF_PROMPT_LOGIN}    timeout=${timeout}
147     ${karaf_connection_object} =    SSHLibrary.Get_Connection
148     Collections.Set_To_Dictionary    ${connection_index_dict}    ${member_index}    ${karaf_connection_object.index}
149     SSHLibrary.Login    ${KARAF_USER}    ${KARAF_PASSWORD}    loglevel=${loglevel}
150     [Teardown]    SSHKeywords.Restore_Current_Ssh_Connection_From_Index    ${current_ssh_connection_object.index}
151
152 Open_Controller_Karaf_Console_With_Timeout
153     [Arguments]    ${member_index}=${1}    ${timeout}=3s
154     [Documentation]    Open new connection to karaf console for member index with specified timeout.
155     BuiltIn.Log    ${member_index}
156     ${odl_ip} =    ClusterManagement.Resolve_IP_Address_For_Member    ${member_index}
157     SSHLibrary.Open_Connection    ${odl_ip}    port=${KARAF_SHELL_PORT}    prompt=${KARAF_PROMPT_LOGIN}    timeout=${timeout}
158     SSHLibrary.Login    ${KARAF_USER}    ${KARAF_PASSWORD}
159
160 Configure_Timeout_For_Karaf_Console
161     [Arguments]    ${timeout}    ${member_index_list}=${EMPTY}
162     [Documentation]    Configure a different timeout for each Karaf console.
163     ${index_list} =    ClusterManagement.List_Indices_Or_All    given_list=${member_index_list}
164     ${current_connection_object} =    SSHLibrary.Get_Connection
165     : FOR    ${member_index}    IN    @{index_list}    # usually: 1, 2, 3
166     \    ${karaf_connection_index} =    Collections.Get_From_Dictionary    ${connection_index_dict}    ${member_index}
167     \    SSHLibrary.Switch_Connection    ${karaf_connection_index}
168     \    SSHLibrary.Set_Client_Configuration    timeout=${timeout}
169     [Teardown]    SSHKeywords.Restore_Current_Ssh_Connection_From_Index    ${current_connection_object.index}
170
171 Execute_Controller_Karaf_Command_On_Background
172     [Arguments]    ${command}    ${member_index}=${1}
173     [Documentation]    Send command to karaf without affecting current SSH connection. Read, log and return response.
174     ${karaf_connection_index} =    Collections.Get_From_Dictionary    ${connection_index_dict}    ${member_index}
175     ${current_connection_index} =    SSHLibrary.Switch_Connection    ${karaf_connection_index}
176     ${status_write}    ${message_write} =    BuiltIn.Run_Keyword_And_Ignore_Error    SSHLibrary.Write    ${command}
177     ${status_wait}    ${message_wait} =    BuiltIn.Run_Keyword_And_Ignore_Error    SSHLibrary.Read_Until_Regexp    ${KARAF_PROMPT}
178     BuiltIn.Run Keyword If    '${status_write}' != 'PASS'    BuiltIn.Fail    Failed to send the command: ${command}
179     BuiltIn.Log    ${message_wait}
180     BuiltIn.Run_Keyword_If    '${status_wait}' != 'PASS'    BuiltIn.Fail    Failed to see prompt after sending the command: ${command}
181     [Teardown]    SSHKeywords.Restore_Current_Ssh_Connection_From_Index    ${current_connection_index}
182     [Return]    ${message_wait}
183
184 Execute_Controller_Karaf_Command_With_Retry_On_Background
185     [Arguments]    ${command}    ${member_index}=${1}
186     [Documentation]    Attemp to send command to karaf for ${member_index}, if fail then open connection and try again.
187     ${status}    ${message} =    BuiltIn.Run_Keyword_And_Ignore_Error    Execute_Controller_Karaf_Command_On_Background    ${command}    ${member_index}
188     BuiltIn.Return_From_Keyword_If    '${status}' == 'PASS'    ${message}
189     # TODO: Verify this does not leak connections indices.
190     Open_Controller_Karaf_Console_On_Background    ${member_index}
191     ${message} =    Execute_Controller_Karaf_Command_On_Background    ${command}    ${member_index}
192     [Return]    ${message}
193
194 Log_Message_To_Controller_Karaf
195     [Arguments]    ${message}    ${member_index_list}=${EMPTY}    ${tolerate_failure}=True
196     [Documentation]    Make sure this resource is initialized. Send a message into the controller's karaf log file on every node listed (or all).
197     ...    By default, failure while processing a node is silently ignored, unless ${tolerate_failure} is False.
198     ${index_list} =    ClusterManagement.List_Indices_Or_All    given_list=${member_index_list}
199     : FOR    ${index}    IN    @{index_list}    # usually: 1, 2, 3.
200     \    ${status}    ${output} =    BuiltIn.Run_Keyword_And_Ignore_Error    Execute_Controller_Karaf_Command_With_Retry_On_Background    log:log "ROBOT MESSAGE: ${message}"    member_index=${index}
201     \    BuiltIn.Run_Keyword_Unless    ${tolerate_failure} or "${status}" == "PASS"    BuiltIn.Fail    ${output}
202
203 Log_Test_Suite_Start_To_Controller_Karaf
204     [Arguments]    ${member_index_list}=${EMPTY}
205     [Documentation]    Log suite name to karaf log, useful in suite setup.
206     Log_Message_To_Controller_Karaf    Starting suite ${SUITE_SOURCE}    ${member_index_list}
207
208 Log_Testcase_Start_To_Controller_Karaf
209     [Arguments]    ${member_index_list}=${EMPTY}
210     [Documentation]    Log test case name to karaf log, useful in test case setup.
211     Log_Message_To_Controller_Karaf    Starting test ${SUITE_NAME}.${TEST_NAME}    ${member_index_list}
212
213 Set_Bgpcep_Log_Levels
214     [Arguments]    ${bgpcep_level}=${DEFAULT_BGPCEP_LOG_LEVEL}    ${protocol_level}=${DEFAULT_PROTOCOL_LOG_LEVEL}    ${member_index_list}=${EMPTY}
215     [Documentation]    Assuming OCKCOB was used, set logging level on bgpcep and protocol loggers without affecting current SSH session.
216     # FIXME: Move to appropriate Resource
217     ${index_list} =    ClusterManagement.List_Indices_Or_All    given_list=${member_index_list}
218     : FOR    ${index}    IN    @{index_list}    # usually: 1, 2, 3.
219     \    Execute_Controller_Karaf_Command_On_Background    log:set ${bgpcep_level} org.opendaylight.bgpcep    member_index=${index}
220     \    Execute_Controller_Karaf_Command_On_Background    log:set ${protocol_level} org.opendaylight.protocol    member_index=${index}
221
222 Get Karaf Log Lines From Test Start
223     [Arguments]    ${ip}    ${test_name}    ${cmd}    ${user}=${ODL_SYSTEM_USER}    ${password}=${ODL_SYSTEM_PASSWORD}    ${prompt}=${ODL_SYSTEM_PROMPT}
224     ...    ${log_file}=${KARAF_LOG}
225     [Documentation]    Scrapes all log messages that match regexp ${type} which fall after a point given by a log message that
226     ...    contains ${test_name}. This is useful if your test cases are marking karaf.log with a message indicating when
227     ...    that test case has started; such that you can easily pull out any extra log messsages to parse/log/etc in the
228     ...    test logic itself. For example, you can grab all ERRORS that occur during your test case.
229     ${output} =    Run Command On Controller    ${ip}    ${cmd}    ${user}    ${password}    ${prompt}
230     @{log_lines} =    Split String    ${output}    ${\n}
231     [Return]    ${log_lines}
232
233 Fail If Exceptions Found During Test
234     [Arguments]    ${test_name}    ${log_file}=${KARAF_LOG}    ${fail}=False
235     [Documentation]    Create a failure if an Exception is found in the karaf.log that has not been whitelisted.
236     ...    Will work for single controller jobs as well as 3node cluster jobs
237     : FOR    ${i}    IN RANGE    1    ${NUM_ODL_SYSTEM} + 1
238     \    ${cmd} =    Set Variable    sed '1,/ROBOT MESSAGE: Starting test ${test_name}/d' ${log_file}
239     \    ${output} =    Get Karaf Log Lines From Test Start    ${ODL_SYSTEM_${i}_IP}    ${test_name}    ${cmd}
240     \    ${exlist}    ${matchlist} =    Verify Exceptions    ${output}
241     \    Write Exceptions Map To File    ${SUITE_NAME}.${TEST_NAME}    /tmp/odl${i}_exceptions.txt
242     \    ${listlength} =    BuiltIn.Get Length    ${exlist}
243     \    BuiltIn.Run Keyword If    "${fail}"=="True" and ${listlength} != 0    Log And Fail Exceptions    ${exlist}    ${listlength}
244     \    ...    ELSE    Collections.Log List    ${matchlist}
245
246 Log And Fail Exceptions
247     [Arguments]    ${exlist}    ${listlength}
248     [Documentation]    Print the list of failed exceptions and fail the test
249     Collections.Log List    ${exlist}
250     ${exstr} =    BuiltIn.Catenate    ${exlist}
251     BuiltIn.Fail    New exceptions found: ${listlength}\n${exstr}
252
253 Get Karaf Log Type From Test Start
254     [Arguments]    ${ip}    ${test_name}    ${type}    ${user}=${ODL_SYSTEM_USER}    ${password}=${ODL_SYSTEM_PASSWORD}    ${prompt}=${ODL_SYSTEM_PROMPT}
255     ...    ${log_file}=${KARAF_LOG}
256     [Documentation]    Scrapes all log messages that match regexp ${type} which fall after a point given by a log message that
257     ...    contains ${test_name}. This is useful if your test cases are marking karaf.log with a message indicating when
258     ...    that test case has started; such that you can easily pull out any extra log messsages to parse/log/etc in the
259     ...    test logic itself. For example, you can grab all ERRORS that occur during your test case.
260     ${cmd}    Set Variable    sed '1,/ROBOT MESSAGE: Starting test ${test_name}/d' ${log_file} | grep '${type}'
261     ${output}    Run Command On Controller    ${ip}    ${cmd}    ${user}    ${password}    ${prompt}
262     [Return]    ${output}
263
264 Get Karaf Log Types From Test Start
265     [Arguments]    ${ip}    ${test_name}    ${types}    ${user}=${ODL_SYSTEM_USER}    ${password}=${ODL_SYSTEM_PASSWORD}    ${prompt}=${ODL_SYSTEM_PROMPT}
266     ...    ${log_file}=${KARAF_LOG}
267     [Documentation]    A wrapper keyword for "Get Karaf Log Type From Test Start" so that we can parse for multiple types
268     ...    of log messages. For example, we can grab all messages of type WARN and ERROR
269     : FOR    ${type}    IN    @{types}
270     \    Get Karaf Log Type From Test Start    ${ip}    ${test_name}    ${type}    ${user}    ${password}
271     \    ...    ${prompt}    ${log_file}
272
273 Get Karaf Log Events From Test Start
274     [Arguments]    ${test_name}    ${user}=${ODL_SYSTEM_USER}    ${password}=${ODL_SYSTEM_PASSWORD}    ${prompt}=${ODL_SYSTEM_PROMPT}
275     [Documentation]    Wrapper for the wrapper "Get Karaf Log Types From Test Start" so that we can easily loop over
276     ...    any number of controllers to analyze karaf.log for ERROR, WARN and Exception log messages
277     ${log_types} =    Create List    ERROR    WARN    Exception
278     : FOR    ${i}    IN RANGE    1    ${NUM_ODL_SYSTEM} + 1
279     \    Get Karaf Log Types From Test Start    ${ODL_SYSTEM_${i}_IP}    ${test_name}    ${log_types}
280
281 Fail If Exceptions Found During Test Deprecated
282     [Arguments]    ${test_name}    ${exceptions_white_list}=${EMPTY}
283     [Documentation]    Create a failure if an Exception is found in the karaf.log. Will work for single controller jobs
284     ...    as well as 3node cluster jobs
285     : FOR    ${i}    IN RANGE    1    ${NUM_ODL_SYSTEM} + 1
286     \    Verify Exception Logging In Controller    ${ODL_SYSTEM_${i}_IP}    ${test_name}    ${exceptions_white_list}
287
288 Verify Exception Logging In Controller
289     [Arguments]    ${controller_ip}    ${test_name}    ${exceptions_white_list}
290     [Documentation]    Local keyword to make it easier to loop through N controllers to pull Exceptions from the
291     ...    karaf.log file and validate with "Check Against White List"
292     ${exceptions}=    Get Karaf Log Type From Test Start    ${controller_ip}    ${test_name}    Exception
293     @{log_lines}=    Split String    ${exceptions}    ${\n}
294     ${num_log_entries}    Get Length    ${log_lines}
295     Return From Keyword If    ${num_log_entries} == ${0}    No Exceptions found.
296     : FOR    ${log_message}    IN    @{log_lines}
297     \    Check Against White List    ${log_message}    ${exceptions_white_list}
298
299 Check Against White List
300     [Arguments]    ${exception_line}    ${exceptions_white_list}
301     [Documentation]    As soon as the ${exceptions_line} is found in one of the elements of ${exceptions_white_list}
302     ...    this keyword will exit and give a Pass to the caller. If there is no match, this keyword will end up
303     ...    marking a failure. In the case that no exceptions are found, the caller could end up passing a single
304     ...    empty line as that is what is returned when a grep on karaf.log has no match, so we can safely return
305     ...    in that case as well.
306     Return From Keyword If    "${exception_line}" == ""
307     : FOR    ${exception}    IN    @{exceptions_white_list}
308     \    Return From Keyword If    "${exception}" in "${exception_line}"    Exceptions found, but whitelisted: ${\n}${exception_line}${\n}
309     Fail    Exceptions Found: ${\n}${exception_line}${\n}
310
311 Wait_For_Karaf_Log
312     [Arguments]    ${message}    ${timeout}=60    ${member_index}=${1}
313     [Documentation]    Read karaf logs until message appear
314     # TODO: refactor this keyword to use the new workflow to account for multiple controllers.    Initial work was done
315     # in this patch https://git.opendaylight.org/gerrit/#/c/45596/
316     # however, the consumers of this keyword were breaking after that change.    Initial theory is that a previous
317     # keyword used before this "Wait For Karaf Log" keyword was closing the karaf console connection, so the
318     # "Flexible SSH Login" keyword from the patch above (45596) was failing.
319     BuiltIn.Log    Waiting for '${message}' in karaf log
320     SSHLibrary.Open_Connection    ${ODL_SYSTEM_IP}    port=${KARAF_SHELL_PORT}    prompt=${KARAF_PROMPT_LOGIN}    timeout=${timeout}
321     SSHLibrary.Login    ${KARAF_USER}    ${KARAF_PASSWORD}    loglevel=${loglevel}
322     SSHLibrary.Write    log:tail
323     SSHLibrary.Read_Until    ${message}
324     SSHLibrary.Write    logout
325     SSHLibrary.Close_Connection
326
327 Restart_Bundle
328     [Arguments]    ${bundle_id}
329     [Documentation]    Restarts bundle passed as argument. Note this operation is only for testing and not production environments
330     # TODO: prepare this for cluster environment and multiple controllers
331     Execute_Controller_Karaf_Command_With_Retry_On_Background    bundle:restart -f $(bundle:id '${bundle_id}')
332
333 Restart_Karaf
334     [Documentation]    Restarts Karaf and polls log to detect when Karaf is up and running again
335     # TODO: prepare this for cluster environment and multiple controllers
336     Execute_Controller_Karaf_Command_With_Retry_On_Background    log:clear
337     Execute_Controller_Karaf_Command_With_Retry_On_Background    shutdown -r -f
338     BuiltIn.Run_Keyword_And_Return_Status    BuiltIn.Wait_Until_Keyword_Succeeds    240s    60s    Wait_For_Karaf_Log    Karaf started in
339
340 Restart_Jetty
341     [Documentation]    Restarts jetty bundle (to reload certificates or key/truststore information)
342     Execute_Controller_Karaf_Command_With_Retry_On_Background    log:clear
343     Restart_Bundle    OPS4J Pax Web - Jetty
344     Wait_For_Karaf_Log    Instantiated the Application class org.opendaylight.restconf.RestconfApplication
345     Wait_For_Karaf_Log    Instantiated the Application class org.opendaylight.netconf.sal.rest.impl.RestconfApplication
346     Wait_For_Karaf_Log    Instantiated the Application class org.opendaylight.aaa.idm.IdmLightApplication