Add tcpdump filter 37/67037/9
authorSam Hague <shague@redhat.com>
Wed, 10 Jan 2018 21:56:21 +0000 (16:56 -0500)
committerJamo Luhrsen <jluhrsen@redhat.com>
Thu, 11 Jan 2018 04:23:45 +0000 (04:23 +0000)
Change-Id: I8d5c31098d9b31a42642a45d44cd5b15c10f20a5
Signed-off-by: Sam Hague <shague@redhat.com>
csit/libraries/Tcpdump.robot

index 748a8714d727688d839f05d268e3ff7e96cf96dd..b72e28b2d361705b7fd24c7b7a0c73c5189cbe84 100644 (file)
@@ -42,12 +42,12 @@ Stop Tcpdumping And Download
 
 Start Packet Capture On Node
     [Arguments]    ${node_ip}    ${file_Name}=${dump_default_name}    ${network_Adapter}=eth0    ${user}=${DEFAULT_USER}    ${password}=${EMPTY}    ${prompt}=${DEFAULT_LINUX_PROMPT}
-    ...    ${prompt_timeout}=${DEFAULT_TIMEOUT}
+    ...    ${prompt_timeout}=${DEFAULT_TIMEOUT}    ${filter}=${EMPTY}
     [Documentation]    Connects to the remote machine and starts tcpdump
     ${current_ssh_connection}=    SSHLibrary.Get Connection
     ${conn_id}=    SSHLibrary.Open Connection    ${node_ip}    prompt=${prompt}    timeout=${prompt_timeout}
     SSHKeywords.Flexible SSH Login    ${user}    ${password}
-    ${cmd} =    Set Variable    sudo /usr/sbin/tcpdump -vvv -ni ${networkAdapter} -w /tmp/${file_Name}.pcap
+    ${cmd} =    Set Variable    sudo /usr/sbin/tcpdump -vvv -ni ${networkAdapter} ${filter} -w /tmp/${file_Name}.pcap
     ${stdout}    ${stderr} =    SSHLibrary.Start Command    ${cmd}
     Log    ${stderr}
     Log    ${stdout}
@@ -68,3 +68,20 @@ Stop Packet Capture on Node
     ${stdout} =    SSHLibrary.Execute Command    sudo ls -ls /tmp
     Log    ${stdout}
     SSHLibrary. Close Connection
+
+Start Packet Capture on Nodes
+    [Arguments]    ${tag}=${EMPTY}    ${filter}=${EMPTY}    ${ips}=@{EMPTY}
+    [Documentation]    Start packet captures on the given list of node ips.
+    ...    The captures will be named with the tag and ip.
+    @{conn_ids} =    BuiltIn.Create List    @{EMPTY}
+    : FOR    ${ip}    IN    @{ips}
+    \    ${fname} =    BuiltIn.Catenate    SEPARATOR=__    ${tag}    ${ip}
+    \    ${conn_id} =    Tcpdump.Start Packet Capture on Node    ${ip}    file_Name=${fname}    filter=${filter}
+    \    Collections.Append To List    ${conn_ids}    ${conn_id}
+    [Return]    @{conn_ids}
+
+Stop Packet Capture on Nodes
+    [Arguments]    @{conn_ids}=@{EMPTY}
+    [Documentation]    Stop the packet captures on the given list of node connection ids
+    : FOR    ${conn_id}    IN    @{conn_ids}
+    \    Stop Packet Capture on Node    ${conn_id}