Use consistent naming in elan suite
[integration/test.git] / csit / libraries / OpenStackOperations.robot
index c0cc9938aa713550b6a7af152d2c1ecf11bb84b2..f52d11cea962972c4e446fddc75160a473ca4e65 100644 (file)
@@ -15,7 +15,6 @@ Variables         ../variables/netvirt/Modules.py
 Get Tenant ID From Security Group
     [Documentation]    Returns tenant ID by reading it from existing default security-group.
     ${rc}    ${output}=    Run And Return Rc And Output    openstack security group show default | grep "| tenant_id" | awk '{print $4}'
-    Log    ${output}
     Should Not Be True    ${rc}
     [Return]    ${output}
 
@@ -142,7 +141,7 @@ List Ports
 
 List Nova VMs
     [Documentation]    List VMs and return output with nova client.
-    ${rc}    ${output}=    Run And Return Rc And Output    openstack server list
+    ${rc}    ${output}=    Run And Return Rc And Output    openstack server list --all-projects
     Log    ${output}
     Should Not Be True    ${rc}
     [Return]    ${output}
@@ -166,22 +165,19 @@ Create And Associate Floating IPs
 
 Verify Gateway Ips
     [Documentation]    Verifies the Gateway Ips with dump flow.
-    ${output}=    Write Commands Until Prompt    sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
-    Log    ${output}
+    ${output}=    Write Commands Until Prompt And Log    sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
     : FOR    ${GatewayIpElement}    IN    @{GATEWAY_IPS}
     \    Should Contain    ${output}    ${GatewayIpElement}
 
 Verify Dhcp Ips
     [Documentation]    Verifies the Dhcp Ips with dump flow.
-    ${output}=    Write Commands Until Prompt    sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
-    Log    ${output}
+    ${output}=    Write Commands Until Prompt And Log    sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
     : FOR    ${DhcpIpElement}    IN    @{DHCP_IPS}
     \    Should Contain    ${output}    ${DhcpIpElement}
 
 Verify No Dhcp Ips
     [Documentation]    Verifies the Dhcp Ips with dump flow.
-    ${output}=    Write Commands Until Prompt    sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
-    Log    ${output}
+    ${output}=    Write Commands Until Prompt And Log    sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
     : FOR    ${DhcpIpElement}    IN    @{DHCP_IPS}
     \    Should Not Contain    ${output}    ${DhcpIpElement}
 
@@ -190,13 +186,11 @@ Delete SubNet
     [Documentation]    Delete SubNet for the Network with neutron request.
     Log    ${subnet}
     ${rc}    ${output}=    Run And Return Rc And Output    openstack subnet delete ${subnet}
-    Log    ${output}
     Should Not Be True    ${rc}
 
 Verify No Gateway Ips
     [Documentation]    Verifies the Gateway Ips removed with dump flow.
-    ${output}=    Write Commands Until Prompt    sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
-    Log    ${output}
+    ${output}=    Write Commands Until Prompt And Log    sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
     : FOR    ${GatewayIpElement}    IN    @{GATEWAY_IPS}
     \    Should Not Contain    ${output}    ${GatewayIpElement}
 
@@ -205,71 +199,66 @@ Delete Vm Instance
     [Documentation]    Delete Vm instances using instance names.
     ${rc}    ${output}=    Run And Return Rc And Output    openstack server delete ${vm_name}
     Log    ${output}
-    Log    ${rc}
 
 Get Net Id
     [Arguments]    ${network_name}    ${devstack_conn_id}
     [Documentation]    Retrieve the net id for the given network name to create specific vm instance
     ${rc}    ${output}=    Run And Return Rc And Output    openstack network list | grep "${network_name}" | awk '{print $2}'
-    Log    ${output}
     Should Not Be True    ${rc}
     ${splitted_output}=    Split String    ${output}    ${EMPTY}
     ${net_id}=    Get from List    ${splitted_output}    0
-    Log    ${net_id}
     [Return]    ${net_id}
 
 Get Subnet Id
     [Arguments]    ${subnet_name}    ${devstack_conn_id}
     [Documentation]    Retrieve the subnet id for the given subnet name
     ${rc}    ${output}=    Run And Return Rc And Output    openstack subnet show "${subnet_name}" | grep " id " | awk '{print $4}'
-    Log    ${output}
     Should Not Be True    ${rc}
     ${splitted_output}=    Split String    ${output}    ${EMPTY}
     ${subnet_id}=    Get from List    ${splitted_output}    0
-    Log    ${subnet_id}
     [Return]    ${subnet_id}
 
 Get Port Id
     [Arguments]    ${port_name}    ${devstack_conn_id}
     [Documentation]    Retrieve the port id for the given port name to attach specific vm instance to a particular port
     ${rc}    ${output}=    Run And Return Rc And Output    openstack port list | grep "${port_name}" | awk '{print $2}'
-    Log    ${output}
     Should Not Be True    ${rc}
     ${splitted_output}=    Split String    ${output}    ${EMPTY}
     ${port_id}=    Get from List    ${splitted_output}    0
-    Log    ${port_id}
     [Return]    ${port_id}
 
 Get Router Id
     [Arguments]    ${router1}    ${devstack_conn_id}
     [Documentation]    Retrieve the router id for the given router name
     ${rc}    ${output}=    Run And Return Rc And Output    openstack router list -f table | grep "${router1}" | awk '{print $2}'
-    Log    ${output}
     Should Not Be True    ${rc}
     ${splitted_output}=    Split String    ${output}    ${EMPTY}
     ${router_id}=    Get from List    ${splitted_output}    0
-    Log    ${router_id}
     [Return]    ${router_id}
 
 Create Vm Instances
-    [Arguments]    ${net_name}    ${vm_instance_names}    ${image}=cirros-0.3.4-x86_64-uec    ${flavor}=m1.nano    ${sg}=default
+    [Arguments]    ${net_name}    ${vm_instance_names}    ${image}=${EMPTY}    ${flavor}=m1.nano    ${sg}=default    ${min}=1
+    ...    ${max}=1
     [Documentation]    Create X Vm Instance with the net id of the Netowrk.
+    ${image}    Set Variable If    "${image}"=="${EMPTY}"    ${CIRROS_${OPENSTACK_BRANCH}}    ${image}
     ${net_id}=    Get Net Id    ${net_name}    ${devstack_conn_id}
     : FOR    ${VmElement}    IN    @{vm_instance_names}
-    \    ${rc}    ${output}=    Run And Return Rc And Output    openstack server create --image ${image} --flavor ${flavor} --nic net-id=${net_id} ${VmElement} --security-group ${sg}
+    \    ${rc}    ${output}=    Run And Return Rc And Output    openstack server create --image ${image} --flavor ${flavor} --nic net-id=${net_id} ${VmElement} --security-group ${sg} --min ${min} --max ${max}
     \    Should Not Be True    ${rc}
     \    Log    ${output}
 
 Create Vm Instance With Port
-    [Arguments]    ${port_name}    ${vm_instance_name}    ${image}=cirros-0.3.4-x86_64-uec    ${flavor}=m1.nano    ${sg}=default
+    [Arguments]    ${port_name}    ${vm_instance_name}    ${image}=${EMPTY}    ${flavor}=m1.nano    ${sg}=default
     [Documentation]    Create One VM instance using given ${port_name} and for given ${compute_node}
+    ${image}    Set Variable If    "${image}"=="${EMPTY}"    ${CIRROS_${OPENSTACK_BRANCH}}    ${image}
     ${port_id}=    Get Port Id    ${port_name}    ${devstack_conn_id}
-    ${rc}    ${output}=    Run And Return Rc And Output    openstack server create --image ${image} --flavor ${flavor} --nic port-id=${port_id} ${vm_instance_name} --security-groups ${sg}
+    ${rc}    ${output}=    Run And Return Rc And Output    openstack server create --image ${image} --flavor ${flavor} --nic port-id=${port_id} ${vm_instance_name} --security-group ${sg}
     Log    ${output}
 
 Create Vm Instance With Ports
-    [Arguments]    ${port_name}    ${port2_name}    ${vm_instance_name}    ${image}=cirros-0.3.4-x86_64-uec    ${flavor}=m1.nano    ${sg}=default
+    [Arguments]    ${port_name}    ${port2_name}    ${vm_instance_name}    ${image}=${EMPTY}    ${flavor}=m1.nano    ${sg}=default
     [Documentation]    Create One VM instance using given ${port_name} and for given ${compute_node}
+    ${image}    Set Variable If    "${image}"=="${EMPTY}"    ${CIRROS_${OPENSTACK_BRANCH}}    ${image}
     ${port_id}=    Get Port Id    ${port_name}    ${devstack_conn_id}
     ${port2_id}=    Get Port Id    ${port2_name}    ${devstack_conn_id}
     ${rc}    ${output}=    Run And Return Rc And Output    openstack server create --image ${image} --flavor ${flavor} --nic port-id=${port_id} --nic port-id=${port2_id} ${vm_instance_name} --security-group ${sg}
@@ -277,44 +266,61 @@ Create Vm Instance With Ports
     Should Not Be True    ${rc}
 
 Create Vm Instance With Port On Compute Node
-    [Arguments]    ${port_name}    ${vm_instance_name}    ${compute_node}    ${image}=cirros-0.3.4-x86_64-uec    ${flavor}=m1.nano    ${sg}=default
+    [Arguments]    ${port_name}    ${vm_instance_name}    ${compute_node}    ${image}=${EMPTY}    ${flavor}=m1.nano    ${sg}=default
     [Documentation]    Create One VM instance using given ${port_name} and for given ${compute_node}
+    ${image}    Set Variable If    "${image}"=="${EMPTY}"    ${CIRROS_${OPENSTACK_BRANCH}}    ${image}
     ${port_id}=    Get Port Id    ${port_name}    ${devstack_conn_id}
-    ${hostname_compute_node}=    Run Command On Remote System    ${compute_node}    hostname
+    ${hostname_compute_node}=    Get Hypervisor Hostname From IP    ${compute_node}
     ${rc}    ${output}=    Run And Return Rc And Output    openstack server create --image ${image} --flavor ${flavor} --nic port-id=${port_id} --security-group ${sg} --availability-zone nova:${hostname_compute_node} ${vm_instance_name}
     Log    ${output}
     Should Not Be True    ${rc}
 
+Get Hypervisor Hostname From IP
+    [Arguments]    ${hypervisor_ip}
+    [Documentation]    Returns the hostname found for the given IP address if it's listed in hypervisor list. For debuggability
+    ...    the full listing is logged first, then followed by a grep | cut to focus on the actual hostname to return
+    ${rc}    ${output}    Run And Return Rc And Output    openstack hypervisor list
+    Log    ${output}
+    ${rc}    ${hostname}=    Run And Return Rc And Output    openstack hypervisor list -f value | grep ${hypervisor_ip} | cut -d" " -f 2
+    Log    ${hostname}
+    Should Not Be True    ${rc}
+    [Return]    ${hostname}
+
+Create Nano Flavor
+    [Documentation]    Create a nano flavor
+    ${rc}    ${output}=    Run And Return Rc And Output    openstack flavor create m1.nano --id auto --ram 64 --disk 0 --vcpus 1
+    Log    ${output}
+    Should Not Be True    ${rc}
+
 Verify VM Is ACTIVE
     [Arguments]    ${vm_name}
     [Documentation]    Run these commands to check whether the created vm instance is active or not.
     ${rc}    ${output}=    Run And Return Rc And Output    openstack server show ${vm_name} | grep OS-EXT-STS:vm_state
-    Log    ${output}
-    Should Not Be True    ${rc}
+    Should Be True    '${rc}' == '0'
     Should Contain    ${output}    active
 
+Poll VM Is ACTIVE
+    [Arguments]    ${vm_name}    ${retry}=600s    ${retry_interval}=30s
+    [Documentation]    Run these commands to check whether the created vm instance is active or not.
+    Wait Until Keyword Succeeds    ${retry}    ${retry_interval}    Verify VM Is ACTIVE    ${vm_name}
+
 Collect VM IP Addresses
     [Arguments]    ${fail_on_none}    @{vm_list}
-    [Documentation]    Using nova console-log on the provided ${vm_list} to search for the string "obtained" which
+    [Documentation]    Using the console-log on the provided ${vm_list} to search for the string "obtained" which
     ...    correlates to the instance receiving it's IP address via DHCP. Also retrieved is the ip of the nameserver
     ...    if available in the console-log output. The keyword will also return a list of the learned ips as it
     ...    finds them in the console log output, and will have "None" for Vms that no ip was found.
     ${ip_list}    Create List    @{EMPTY}
     : FOR    ${vm}    IN    @{vm_list}
     \    ${rc}    ${vm_ip_line}=    Run And Return Rc And Output    openstack console log show ${vm} | grep -i "obtained"
-    \    Log    ${vm_ip_line}
-    \    Log    ${rc}
     \    @{vm_ip}    Get Regexp Matches    ${vm_ip_line}    [0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}
     \    ${vm_ip_length}    Get Length    ${vm_ip}
     \    Run Keyword If    ${vm_ip_length}>0    Append To List    ${ip_list}    @{vm_ip}[0]
     \    ...    ELSE    Append To List    ${ip_list}    None
     \    ${rc}    ${dhcp_ip_line}=    Run And Return Rc And Output    openstack console log show ${vm} | grep "^nameserver"
-    \    Log    ${dhcp_ip_line}
-    \    Log    ${rc}
     \    ${dhcp_ip}    Get Regexp Matches    ${dhcp_ip_line}    [0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}
     \    ${dhcp_ip_length}    Get Length    ${dhcp_ip}
     \    Run Keyword If    ${dhcp_ip_length}<=0    Append To List    ${dhcp_ip}    None
-    \    Log    ${dhcp_ip}
     \    ${vm_console_output}=    Run    openstack console log show ${vm}
     \    Log    ${vm_console_output}
     ${dhcp_length}    Get Length    ${dhcp_ip}
@@ -324,14 +330,62 @@ Collect VM IP Addresses
     Return From Keyword If    ${dhcp_length}==0    ${ip_list}    ${EMPTY}
     [Return]    ${ip_list}    ${dhcp_ip}
 
+Get Match
+    [Arguments]    ${text}    ${regexp}    ${index}=0
+    [Documentation]    Wrapper around Get Regexp Matches to return None if not found or the first match if found.
+    @{matches} =    String.Get Regexp Matches    ${text}    ${regexp}
+    ${matches_length} =    Get Length    ${matches}
+    BuiltIn.Set Test Variable    ${match}    None
+    BuiltIn.Run Keyword If    ${matches_length} > ${index}    BuiltIn.Set Test Variable    ${match}    @{matches}[${index}]
+    [Return]    ${match}
+
+Get VM IP
+    [Arguments]    ${fail_on_none}    ${vm}
+    [Documentation]    Get the vm ip address and nameserver by scraping the vm's console log.
+    ...    Get VM IP returns three values: [0] the vm IP, [1] the DHCP IP and [2] the vm console log.
+    ${rc}    ${vm_console_output}=    Run And Return Rc And Output    openstack console log show ${vm}
+    ${vm_ip} =    Set Variable    None
+    ${dhcp_ip} =    Set Variable    None
+    ${match} =    Get Match    ${vm_console_output}    ${REGEX_OBTAINED}
+    ${vm_ip} =    Get Match    ${match}    ${REGEX_IPV4}    0
+    ${match} =    Get Match    ${vm_console_output}    ${REGEX_IPROUTE}
+    ${dhcp_ip} =    Get Match    ${match}    ${REGEX_IPV4}    1
+    BuiltIn.Run Keyword If    '${fail_on_none}' == 'true'    Should Not Contain    ${vm_ip}    None
+    BuiltIn.Run Keyword If    '${fail_on_none}' == 'true'    Should Not Contain    ${dhcp_ip}    None
+    [Return]    ${vm_ip}    ${dhcp_ip}    ${vm_console_output}
+
+Get VM IPs
+    [Arguments]    @{vms}
+    [Documentation]    Get the instance IP addresses and nameserver address for the list of given vms.
+    ...    First poll for the vm instance to be in the active state, then poll for the vm ip address and nameserver.
+    ...    Get VM IPs returns two things: [0] a list of the ips for the vms passed to this keyword (may contain values
+    ...    of None) and [1] the dhcp ip address found in the last vm checked.
+    ...    TODO: there is a potential issue for a caller that passes in VMs belonging to different networks that
+    ...    may have different dhcp server addresses. Not sure what TODO about that, but noting it here for reference.
+    @{vm_ips}    BuiltIn.Create List    @{EMPTY}
+    : FOR    ${vm}    IN    @{vms}
+    \    Poll VM Is ACTIVE    ${vm}
+    \    ${status}    ${ips_and_console_log}    Run Keyword And Ignore Error    Wait Until Keyword Succeeds    120s    15s
+    \    ...    Get VM IP    true    ${vm}
+    \    # If there is trouble with Get VM IP, the status will be FAIL and the return value will be a string of what went
+    \    # wrong. We need to handle both the PASS and FAIL cases. In the FAIL case we know we wont have access to the
+    \    # console log, as it would not be returned; so we need to grab it again to log it. We also can append 'None' to
+    \    # the vm ip list if status is FAIL.
+    \    Run Keyword If    "${status}" == "PASS"    BuiltIn.Log    ${ips_and_console_log[2]}
+    \    BuiltIn.Run Keyword If    "${status}" == "PASS"    Collections.Append To List    ${vm_ips}    ${ips_and_console_log[0]}
+    \    BuiltIn.Run Keyword If    "${status}" == "FAIL"    Collections.Append To List    ${vm_ips}    None
+    \    ${rc}    ${vm_console_output}=    BuiltIn.Run Keyword If    "${status}" == "FAIL"    Run And Return Rc And Output    openstack console log show ${vm}
+    \    BuiltIn.Run Keyword If    "${status}" == "FAIL"    BuiltIn.Log    ${vm_console_output}
+    [Return]    @{vm_ips}    ${ips_and_console_log[1]}
+
 Collect VM IPv6 SLAAC Addresses
     [Arguments]    ${fail_on_none}    ${prefix}    @{vm_list}
-    [Documentation]    Using nova console-log on the provided ${vm_list} to search for the string "inet6" which
+    [Documentation]    Using the console-log on the provided ${vm_list} to search for the string "inet6" which
     ...    correlates to the instance generated IPv6 address, based on the ${prefix} received from ODL (SLAAC mode).
     ${ip_list}    Create List    @{EMPTY}
     : FOR    ${vm}    IN    @{vm_list}
     \    Log    ${vm}
-    \    ${rc}    ${vm_ip_line}=    Run And Return Rc And Output    nova console-log ${vm} | grep -i "inet6"
+    \    ${rc}    ${vm_ip_line}=    Run And Return Rc And Output    openstack console log show ${vm} | grep -i "inet6"
     \    Log    ${vm_ip_line}
     \    Log    ${rc}
     \    @{vm_ip_list}    Get Regexp Matches    ${vm_ip_line}    ${prefix}
@@ -347,7 +401,7 @@ View Vm Console
     [Arguments]    ${vm_instance_names}
     [Documentation]    View Console log of the created vm instances using nova show.
     : FOR    ${VmElement}    IN    @{vm_instance_names}
-    \    ${rc}    ${output}=    Run And Return Rc And Output    nova show ${VmElement}
+    \    ${rc}    ${output}=    Run And Return Rc And Output    openstack server show ${VmElement}
     \    Log    ${output}
     \    Should Not Be True    ${rc}
     \    ${rc}    ${output}=    Run And Return Rc And Output    openstack console log show ${VmElement}
@@ -362,8 +416,7 @@ Ping Vm From DHCP Namespace
     Switch Connection    ${devstack_conn_id}
     ${net_id}=    Get Net Id    ${net_name}    ${devstack_conn_id}
     Log    ${net_id}
-    ${output}=    Write Commands Until Prompt    sudo ip netns exec qdhcp-${net_id} ping -c 3 ${vm_ip}    20s
-    Log    ${output}
+    ${output}=    Write Commands Until Prompt And Log    sudo ip netns exec qdhcp-${net_id} ping -c 3 ${vm_ip}    20s
     Close Connection
     Should Contain    ${output}    64 bytes
 
@@ -387,8 +440,7 @@ Ping Vm From Control Node
     Log    ${vm_floating_ip}
     ${devstack_conn_id}=    Get ControlNode Connection
     Switch Connection    ${devstack_conn_id}
-    ${output}=    Write Commands Until Prompt    ping ${additional_args} -c 3 ${vm_floating_ip}    20s
-    Log    ${output}
+    ${output}=    Write Commands Until Prompt And Log    ping ${additional_args} -c 3 ${vm_floating_ip}    20s
     Close Connection
     Should Contain    ${output}    64 bytes
 
@@ -407,8 +459,7 @@ Curl Metadata Server
 
 Close Vm Instance
     [Documentation]    Exit the vm instance.
-    ${output}=    Write Commands Until Prompt    exit
-    Log    ${output}
+    ${output}=    Write Commands Until Prompt And Log    exit
 
 Check If Console Is VmInstance
     [Arguments]    ${console}=cirros
@@ -474,7 +525,7 @@ Test Operations From Vm Instance
     Run Keyword If    ${rcode}    Write Commands Until Expected Prompt    route -n    ${OS_SYSTEM_PROMPT}
     Run Keyword If    ${rcode}    Write Commands Until Expected Prompt    route -A inet6    ${OS_SYSTEM_PROMPT}
     Run Keyword If    ${rcode}    Write Commands Until Expected Prompt    arp -an    ${OS_SYSTEM_PROMPT}
-    Run Keyword If    ${rcode}    Write Commands Until Expected Prompt    ip -6 neigh    ${OS_SYSTEM_PROMPT}
+    Run Keyword If    ${rcode}    Write Commands Until Expected Prompt    ip -f inet6 neigh show    ${OS_SYSTEM_PROMPT}
     : FOR    ${dest_ip}    IN    @{dest_ips}
     \    Log    ${dest_ip}
     \    ${string_empty}=    Run Keyword And Return Status    Should Be Empty    ${dest_ip}
@@ -494,10 +545,8 @@ Test Netcat Operations From Vm Instance
     ${devstack_conn_id}=    Get ControlNode Connection
     Switch Connection    ${devstack_conn_id}
     Log    ${vm_ip}
-    ${output}=    Write Commands Until Prompt    ( ( echo "${server_data}" | sudo timeout 60 nc -l ${additional_args} ${port} ) & )
-    Log    ${output}
-    ${output}=    Write Commands Until Prompt    sudo netstat -nlap | grep ${port}
-    Log    ${output}
+    ${output}=    Write Commands Until Prompt And Log    ( ( echo "${server_data}" | sudo timeout 60 nc -l ${additional_args} ${port} ) & )
+    ${output}=    Write Commands Until Prompt And Log    sudo netstat -nlap | grep ${port}
     ${nc_output}=    Execute Command on VM Instance    ${net_name}    ${vm_ip}    sudo echo "${client_data}" | nc -v -w 5 ${additional_args} ${dest_ip} ${port}
     Log    ${nc_output}
     ${output}=    Execute Command on VM Instance    ${net_name}    ${vm_ip}    sudo route -n
@@ -520,8 +569,8 @@ Create Router
     ${rc}    ${output}=    Run And Return Rc And Output    openstack router create ${router_name}
     Should Not Be True    ${rc}
 
-List Router
-    [Documentation]    List Router and return output with neutron client.
+List Routers
+    [Documentation]    List Routers and return output with neutron client.
     ${rc}    ${output}=    Run And Return Rc And Output    openstack router list -f value
     Log    ${output}
     Should Not Be True    ${rc}
@@ -534,9 +583,8 @@ Add Router Interface
 
 Show Router Interface
     [Arguments]    ${router_name}
-    [Documentation]    List Router interface associated with given Router and return output with neutron client.
+    [Documentation]    List Routers interface associated with given Router and return output with neutron client.
     ${rc}    ${output}=    Run And Return Rc And Output    openstack port list --router ${router_name} -f value
-    Log    ${output}
     Should Not Be True    ${rc}
     [Return]    ${output}
 
@@ -582,7 +630,7 @@ Get DumpFlows And Ovsconfig
     Write Commands Until Expected Prompt    ip route    ${DEFAULT_LINUX_PROMPT_STRICT}
     Write Commands Until Expected Prompt    arp -an    ${DEFAULT_LINUX_PROMPT_STRICT}
     ${nslist}=    Write Commands Until Expected Prompt    ip netns list | awk '{print $1}'    ${DEFAULT_LINUX_PROMPT_STRICT}
-    @{lines}    Split To Lines    ${nslist}
+    @{lines}    Split To Lines    ${nslist}    end=-1
     : FOR    ${line}    IN    @{lines}
     \    Write Commands Until Expected Prompt    sudo ip netns exec ${line} ip -o link    ${DEFAULT_LINUX_PROMPT_STRICT}
     \    Write Commands Until Expected Prompt    sudo ip netns exec ${line} ip -o addr    ${DEFAULT_LINUX_PROMPT_STRICT}
@@ -599,7 +647,7 @@ Get Karaf Log Type From Test Start
     ...    ${log_file}=${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log
     ${cmd}    Set Variable    sed '1,/ROBOT MESSAGE: Starting test ${test_name}/d' ${log_file} | grep '${type}'
     ${output}    Run Command On Controller    ${ip}    ${cmd}    ${user}    ${password}    ${prompt}
-    Log    ${output}
+    [Return]    ${output}
 
 Get Karaf Log Types From Test Start
     [Arguments]    ${ip}    ${test_name}    ${types}    ${user}=${ODL_SYSTEM_USER}    ${password}=${ODL_SYSTEM_PASSWORD}    ${prompt}=${ODL_SYSTEM_PROMPT}
@@ -633,33 +681,39 @@ Get Test Teardown Debugs
     Run Keyword And Ignore Error    Get Model Dump    ${HA_PROXY_IP}    ${netvirt_data_models}
     Get Karaf Log Events From Test Start    ${test_name}
 
-Get Suite Teardown Debugs
-    Get OvsDebugInfo
-    Get Model Dump    ${HA_PROXY_IP}    ${netvirt_data_models}
+Get Test Teardown Debugs For SFC
+    [Arguments]    ${test_name}=${TEST_NAME}
+    Run Keyword And Ignore Error    Get Model Dump    ${HA_PROXY_IP}    ${netvirt_sfc_data_models}
 
 Show Debugs
     [Arguments]    @{vm_indices}
     [Documentation]    Run these commands for debugging, it can list state of VM instances and ip information in control node
     ${devstack_conn_id}=    Get ControlNode Connection
     Switch Connection    ${devstack_conn_id}
-    ${output}=    Write Commands Until Prompt    sudo ip netns list
-    Log    ${output}
+    ${output}=    Write Commands Until Prompt And Log    sudo ip netns list
     Close Connection
     : FOR    ${index}    IN    @{vm_indices}
     \    ${rc}    ${output}=    Run And Return Rc And Output    nova show ${index}
     \    Log    ${output}
-    \    Log    ${rc}
     List Nova VMs
+    List Routers
     List Networks
     List Subnets
     List Ports
+    List Security Groups
+
+List Security Groups
+    [Documentation]    Logging keyword to display all security groups using the openstack cli. Assumes openstack
+    ...    credentials are already sourced
+    ${rc}    ${output}=    Run And Return Rc And Output    openstack security group list
+    Log    ${output}
+    Should Not Be True    ${rc}
+    [Return]    ${output}
 
 Neutron Security Group Show
     [Arguments]    ${SecurityGroupRuleName}
     [Documentation]    Displays the neutron security group configurations that belongs to a given neutron security group name
-    ${cmd}=    Set Variable    openstack security group show ${SecurityGroupRuleName}
-    Log    ${cmd}
-    ${rc}    ${output}=    Run And Return Rc And Output    ${cmd}
+    ${rc}    ${output}=    Run And Return Rc And Output    openstack security group show ${SecurityGroupRuleName}
     Log    ${output}
     Should Not Be True    ${rc}
     [Return]    ${output}
@@ -667,9 +721,7 @@ Neutron Security Group Show
 Neutron Port Show
     [Arguments]    ${PortName}
     [Documentation]    Display the port configuration that belong to a given neutron port
-    ${cmd}=    Set Variable    openstack port show ${PortName}
-    Log    ${cmd}
-    ${rc}    ${output}=    Run And Return Rc And Output    ${cmd}
+    ${rc}    ${output}=    Run And Return Rc And Output    openstack port show ${PortName}
     Log    ${output}
     Should Not Be True    ${rc}
     [Return]    ${output}
@@ -679,9 +731,7 @@ Neutron Security Group Create
     [Documentation]    Create a security group with specified name ,description & protocol value according to security group template
     ${devstack_conn_id}=    Get ControlNode Connection
     Switch Connection    ${devstack_conn_id}
-    ${cmd}=    Set Variable    openstack security group create ${SecurityGroupName} ${additional_args}
-    Log    ${cmd}
-    ${rc}    ${output}=    Run And Return Rc And Output    ${cmd}
+    ${rc}    ${output}=    Run And Return Rc And Output    openstack security group create ${SecurityGroupName} ${additional_args}
     Log    ${output}
     Should Not Be True    ${rc}
     ${sgp_id}=    Should Match Regexp    ${output}    [0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}
@@ -691,9 +741,7 @@ Neutron Security Group Create
 Neutron Security Group Update
     [Arguments]    ${SecurityGroupName}    ${additional_args}=${EMPTY}
     [Documentation]    Updating security groups
-    ${cmd}=    Set Variable    openstack security group set ${SecurityGroupName} ${additional_args}
-    Log    ${cmd}
-    ${rc}    ${output}=    Run And Return Rc And Output    ${cmd}
+    ${rc}    ${output}=    Run And Return Rc And Output    openstack security group set ${SecurityGroupName} ${additional_args}
     Log    ${output}
     Should Not Be True    ${rc}
     [Return]    ${output}
@@ -793,12 +841,21 @@ Delete All Security Group Rules
     \    Log    ${output}
     \    Should Not Be True    ${rc}
 
+Create Allow All SecurityGroup
+    [Arguments]    ${sg_name}    ${ether_type}=IPv4
+    [Documentation]    Allow all TCP/UDP/ICMP packets for this suite
+    Neutron Security Group Create    ${sg_name}
+    Neutron Security Group Rule Create    ${sg_name}    direction=ingress    ethertype=${ether_type}    port_range_max=65535    port_range_min=1    protocol=tcp
+    Neutron Security Group Rule Create    ${sg_name}    direction=egress    ethertype=${ether_type}    port_range_max=65535    port_range_min=1    protocol=tcp
+    Neutron Security Group Rule Create    ${sg_name}    direction=ingress    ethertype=${ether_type}    protocol=icmp
+    Neutron Security Group Rule Create    ${sg_name}    direction=egress    ethertype=${ether_type}    protocol=icmp
+    Neutron Security Group Rule Create    ${sg_name}    direction=ingress    ethertype=${ether_type}    port_range_max=65535    port_range_min=1    protocol=udp
+    Neutron Security Group Rule Create    ${sg_name}    direction=egress    ethertype=${ether_type}    port_range_max=65535    port_range_min=1    protocol=udp
+
 Create Neutron Port With Additional Params
     [Arguments]    ${network_name}    ${port_name}    ${additional_args}=${EMPTY}
     [Documentation]    Create Port With given additional parameters
-    ${cmd}=    Set Variable    neutron -v port-create ${network_name} --name ${port_name} ${additional_args}
-    Log    ${cmd}
-    ${rc}    ${output}=    Run And Return Rc And Output    ${cmd}
+    ${rc}    ${output}=    Run And Return Rc And Output    neutron -v port-create ${network_name} --name ${port_name} ${additional_args}
     Log    ${output}
     Should Not Be True    ${rc}
     ${port_id}=    Should Match Regexp    ${OUTPUT}    [0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}
@@ -818,10 +875,8 @@ Get Port Ip
     [Arguments]    ${port_name}
     [Documentation]    Keyword would return the IP of the ${port_name} received.
     ${rc}    ${output}=    Run And Return Rc And Output    openstack port list | grep "${port_name}" | awk -F\\' '{print $2}'
-    Log    ${output}
     ${splitted_output}=    Split String    ${output}    ${EMPTY}
     ${port_ip}=    Get from List    ${splitted_output}    0
-    Log    ${port_ip}
     Should Not Be True    ${rc}
     [Return]    ${port_ip}
 
@@ -829,10 +884,8 @@ Get Port Mac
     [Arguments]    ${port_name}    ${conn_id}=${devstack_conn_id}
     [Documentation]    Keyword would return the MAC ID of the ${port_name} received.
     ${rc}    ${output}=    Run And Return Rc And Output    openstack port show ${port_name} | grep mac_address | awk '{print $4}'
-    Log    ${output}
     ${splitted_output}=    Split String    ${output}    ${EMPTY}
     ${port_mac}=    Get from List    ${splitted_output}    0
-    Log    ${port_mac}
     Should Not Be True    ${rc}
     [Return]    ${port_mac}
 
@@ -879,7 +932,6 @@ Get L2gw Id
     Should Not Be True    ${rc}
     ${splitted_output}=    Split String    ${output}    ${EMPTY}
     ${l2gw_id}=    Get from List    ${splitted_output}    0
-    Log    ${l2gw_id}
     [Return]    ${l2gw_id}
 
 Get L2gw Connection Id
@@ -887,12 +939,10 @@ Get L2gw Connection Id
     [Documentation]    Keyword to retrieve the L2 Gateway Connection ID for the ${l2gw_name} (Using Neutron CLI).
     ${l2gw_id}=    OpenStackOperations.Get L2gw Id    ${l2gw_name}
     ${rc}    ${output}=    Run And Return Rc And Output    ${L2GW_GET_CONN} | grep "${l2gw_id}" | awk '{print $2}'
-    Log    ${output}
     Should Not Be True    ${rc}
     ${splitted_output}=    Split String    ${output}    ${EMPTY}
     ${splitted_output}=    Split String    ${output}    ${EMPTY}
     ${l2gw_conn_id}=    Get from List    ${splitted_output}    0
-    Log    ${l2gw_conn_id}
     [Return]    ${l2gw_conn_id}
 
 Neutron Port List Rest
@@ -942,19 +992,16 @@ Remove Security Group From VM
     [Documentation]    Remove the security group provided to the given VM.
     ${devstack_conn_id}=    Get ControlNode Connection
     Switch Connection    ${devstack_conn_id}
-    ${output}=    Write Commands Until Prompt    openstack server remove security group ${vm} ${sg}
-    Log    ${output}
+    ${output}=    Write Commands Until Prompt And Log    openstack server remove security group ${vm} ${sg}
     Close Connection
 
 Create SFC Flow Classifier
     [Arguments]    ${name}    ${src_ip}    ${dest_ip}    ${protocol}    ${dest_port}    ${neutron_src_port}
     [Documentation]    Create a flow classifier for SFC
-    ${cmd}=    Set Variable    neutron flow-classifier-create --ethertype IPv4 --source-ip-prefix ${src_ip}/32 --destination-ip-prefix ${dest_ip}/32 --protocol ${protocol} --destination-port ${dest_port}:${dest_port} --logical-source-port ${neutron_src_port} ${name}
-    Log    ${cmd}
-    ${rc}    ${output}=    Run And Return Rc And Output    ${cmd}
+    ${rc}    ${output}=    Run And Return Rc And Output    openstack sfc flow classifier create --ethertype IPv4 --source-ip-prefix ${src_ip}/32 --destination-ip-prefix ${dest_ip}/32 --protocol ${protocol} --destination-port ${dest_port}:${dest_port} --logical-source-port ${neutron_src_port} ${name}
     Log    ${output}
     Should Not Be True    ${rc}
-    Should Contain    ${output}    Created a new flow_classifier
+    Should Contain    ${output}    ${name}
     [Return]    ${output}
 
 Delete SFC Flow Classifier
@@ -962,12 +1009,9 @@ Delete SFC Flow Classifier
     [Documentation]    Delete a SFC flow classifier
     ${devstack_conn_id}=    Get ControlNode Connection
     Switch Connection    ${devstack_conn_id}
-    ${cmd}=    Set Variable    neutron flow-classifier-delete ${name}
-    Log    ${cmd}
-    ${rc}    ${output}=    Run And Return Rc And Output    ${cmd}
+    ${rc}    ${output}=    Run And Return Rc And Output    openstack sfc flow classifier delete ${name}
     Log    ${output}
     Should Not Be True    ${rc}
-    Should Contain    ${output}    Deleted flow_classifier
     [Return]    ${output}
 
 Create SFC Port Pair
@@ -975,79 +1019,62 @@ Create SFC Port Pair
     [Documentation]    Creates a neutron port pair for SFC
     ${devstack_conn_id}=    Get ControlNode Connection
     Switch Connection    ${devstack_conn_id}
-    ${cmd}=    Set Variable    neutron port-pair-create --ingress=${port_in} --egress=${port_out} ${name}
-    Log    ${cmd}
-    ${rc}    ${output}=    Run And Return Rc And Output    ${cmd}
+    ${rc}    ${output}=    Run And Return Rc And Output    openstack sfc port pair create --ingress=${port_in} --egress=${port_out} ${name}
     Log    ${output}
     Should Not Be True    ${rc}
-    Should Contain    ${output}    Created a new port_pair
+    Should Contain    ${output}    ${name}
     [Return]    ${output}
 
 Delete SFC Port Pair
     [Arguments]    ${name}
     [Documentation]    Delete a SFC port pair
-    ${cmd}=    Set Variable    neutron port-pair-delete ${name}
-    Log    ${cmd}
-    ${rc}    ${output}=    Run And Return Rc And Output    ${cmd}
+    ${rc}    ${output}=    Run And Return Rc And Output    openstack sfc port pair delete ${name}
     Log    ${output}
     Should Not Be True    ${rc}
-    Should Contain    ${output}    Deleted port_pair
     [Return]    ${output}
 
 Create SFC Port Pair Group
     [Arguments]    ${name}    ${port_pair}
     [Documentation]    Creates a port pair group with a single port pair for SFC
-    ${cmd}=    Set Variable    neutron port-pair-group-create --port-pair ${port_pair} ${name}
-    Log    ${cmd}
-    ${rc}    ${output}=    Run And Return Rc And Output    ${cmd}
+    ${rc}    ${output}=    Run And Return Rc And Output    openstack sfc port pair group create --port-pair ${port_pair} ${name}
     Log    ${output}
     Should Not Be True    ${rc}
-    Should Contain    ${output}    Created a new port_pair_group
+    Should Contain    ${output}    ${name}
     [Return]    ${output}
 
 Create SFC Port Pair Group With Two Pairs
     [Arguments]    ${name}    ${port_pair1}    ${port_pair2}
     [Documentation]    Creates a port pair group with two port pairs for SFC
-    ${cmd}=    Set Variable    neutron port-pair-group-create --port-pair ${port_pair1} --port-pair ${port_pair2} ${name}
-    Log    ${cmd}
-    ${rc}    ${output}=    Run And Return Rc And Output    ${cmd}
+    ${rc}    ${output}=    Run And Return Rc And Output    openstack sfc port pair group create --port-pair ${port_pair1} --port-pair ${port_pair2} ${name}
     Log    ${output}
     Should Not Be True    ${rc}
-    Should Contain    ${output}    Created a new port_pair_group
+    Should Contain    ${output}    ${name}
     [Return]    ${output}
 
 Delete SFC Port Pair Group
     [Arguments]    ${name}
     [Documentation]    Delete a SFC port pair group
     ${devstack_conn_id}=    Get ControlNode Connection
-    ${cmd}=    Set Variable    neutron port-pair-group-delete ${name}
-    Log    ${cmd}
-    ${rc}    ${output}=    Run And Return Rc And Output    ${cmd}
+    ${rc}    ${output}=    Run And Return Rc And Output    openstack sfc port pair group delete ${name}
     Log    ${output}
     Should Not Be True    ${rc}
-    Should Contain    ${output}    Deleted port_pair_group
     [Return]    ${output}
 
 Create SFC Port Chain
     [Arguments]    ${name}    ${pg1}    ${pg2}    ${fc}
     [Documentation]    Creates a port pair chain with two port groups and a singel classifier.
-    ${cmd}=    Set Variable    neutron port-chain-create --port-pair-group ${pg1} --port-pair-group ${pg2} --flow-classifier ${fc} ${name}
-    Log    ${cmd}
-    ${rc}    ${output}=    Run And Return Rc And Output    ${cmd}
+    ${rc}    ${output}=    Run And Return Rc And Output    openstack sfc port chain create --port-pair-group ${pg1} --port-pair-group ${pg2} --flow-classifier ${fc} ${name}
     Log    ${output}
     Should Not Be True    ${rc}
-    Should Contain    ${output}    Created a new port_chain
+    Should Contain    ${output}    ${name}
     [Return]    ${output}
 
 Delete SFC Port Chain
     [Arguments]    ${name}
     [Documentation]    Delete a SFC port chain
-    ${cmd}=    Set Variable    neutron port-chain-delete ${name}
-    Log    ${cmd}
-    ${rc}    ${output}=    Run And Return Rc And Output    ${cmd}
+    ${rc}    ${output}=    Run And Return Rc And Output    openstack sfc port chain delete ${name}
     Log    ${output}
     Should Not Be True    ${rc}
-    Should Contain    ${output}    Deleted port_chain
     [Return]    ${output}
 
 Reboot Nova VM
@@ -1058,15 +1085,13 @@ Reboot Nova VM
     Should Not Be True    ${rc}
     Wait Until Keyword Succeeds    35s    10s    Verify VM Is ACTIVE    ${vm_name}
 
-Remove RSA Key From KnowHosts
+Remove RSA Key From KnownHosts
     [Arguments]    ${vm_ip}
     [Documentation]    Remove RSA
     ${devstack_conn_id}=    Get ControlNode Connection
     Switch Connection    ${devstack_conn_id}
-    ${output}=    Write Commands Until Prompt    sudo cat /root/.ssh/known_hosts    30s
-    Log    ${output}
-    ${output}=    Write Commands Until Prompt    sudo ssh-keygen -f "/root/.ssh/known_hosts" -R ${vm_ip}    30s
-    Log    ${output}
+    ${output}=    Write Commands Until Prompt And Log    sudo cat /root/.ssh/known_hosts    30s
+    ${output}=    Write Commands Until Prompt And Log    sudo ssh-keygen -f "/root/.ssh/known_hosts" -R ${vm_ip}    30s
     ${output}=    Write Commands Until Prompt    sudo cat "/root/.ssh/known_hosts"    30s
 
 Wait For Routes To Propogate