IPv6: support ping6 in Check Ping keyword
[integration/test.git] / csit / libraries / OpenStackOperations.robot
index 5fc83b9a3680abf922a4ec4ee2b57313ad6925f4..8005a9331a102d290c56a865bcd9ba8dfe410647 100644 (file)
@@ -38,6 +38,26 @@ Create Network
     Log    ${output}
     [Return]    ${output}
 
+Update Network
+    [Arguments]    ${network_name}    ${additional_args}=${EMPTY}
+    [Documentation]    Update Network with neutron request.
+    ${devstack_conn_id}=    Get ControlNode Connection
+    Switch Connection    ${devstack_conn_id}
+    ${output}=    Write Commands Until Prompt    neutron -v net-update ${network_name} ${additional_args}    30s
+    Log    ${output}
+    Close Connection
+    [Return]    ${output}
+
+Show Network
+    [Arguments]    ${network_name}
+    [Documentation]    Show Network with neutron request.
+    ${devstack_conn_id}=    Get ControlNode Connection
+    Switch Connection    ${devstack_conn_id}
+    ${output}=    Write Commands Until Prompt    neutron -v net-show ${network_name}    30s
+    Log    ${output}
+    Close Connection
+    [Return]    ${output}
+
 List Networks
     [Documentation]    List networks and return output with neutron client.
     ${devstack_conn_id}=    Get ControlNode Connection
@@ -76,6 +96,26 @@ Create SubNet
     Log    ${output}
     Should Contain    ${output}    Created a new subnet
 
+Update SubNet
+    [Arguments]    ${subnet_name}    ${additional_args}=${EMPTY}
+    [Documentation]    Update subnet with neutron request.
+    ${devstack_conn_id}=    Get ControlNode Connection
+    Switch Connection    ${devstack_conn_id}
+    ${output}=    Write Commands Until Prompt    neutron -v subnet-update ${subnet_name} ${additional_args}    30s
+    Log    ${output}
+    Close Connection
+    [Return]    ${output}
+
+Show SubNet
+    [Arguments]    ${subnet_name}
+    [Documentation]    Show subnet with neutron request.
+    ${devstack_conn_id}=    Get ControlNode Connection
+    Switch Connection    ${devstack_conn_id}
+    ${output}=    Write Commands Until Prompt    neutron -v subnet-show ${subnet_name}    30s
+    Log    ${output}
+    Close Connection
+    [Return]    ${output}
+
 Create Port
     [Arguments]    ${network_name}    ${port_name}    ${sg}=default    ${additional_args}=${EMPTY}
     [Documentation]    Create Port with neutron request.
@@ -86,6 +126,26 @@ Create Port
     Log    ${output}
     Should Contain    ${output}    Created a new port
 
+Update Port
+    [Arguments]    ${port_name}    ${additional_args}=${EMPTY}
+    [Documentation]    Update port with neutron request.
+    ${devstack_conn_id}=    Get ControlNode Connection
+    Switch Connection    ${devstack_conn_id}
+    ${output}=    Write Commands Until Prompt    neutron -v port-update ${port_name} ${additional_args}    30s
+    Log    ${output}
+    Close Connection
+    [Return]    ${output}
+
+Show Port
+    [Arguments]    ${port_name}
+    [Documentation]    Show port with neutron request.
+    ${devstack_conn_id}=    Get ControlNode Connection
+    Switch Connection    ${devstack_conn_id}
+    ${output}=    Write Commands Until Prompt    neutron -v port-show ${port_name}    30s
+    Log    ${output}
+    Close Connection
+    [Return]    ${output}
+
 Delete Port
     [Arguments]    ${port_name}
     [Documentation]    Delete Port with neutron request.
@@ -299,6 +359,26 @@ Collect VM IP Addresses
     Return From Keyword If    ${dhcp_length}==0    ${ip_list}    ${EMPTY}
     [Return]    ${ip_list}    ${dhcp_ip}
 
+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
+    ...    correlates to the instance generated IPv6 address, based on the ${prefix} received from ODL (SLAAC mode).
+    ${devstack_conn_id}=    Get ControlNode Connection
+    Switch Connection    ${devstack_conn_id}
+    ${ip_list}    Create List    @{EMPTY}
+    : FOR    ${vm}    IN    @{vm_list}
+    \    Log    ${vm}
+    \    ${vm_ip_line}=    Write Commands Until Prompt    nova console-log ${vm} | grep -i "inet6"    30s
+    \    Log    ${vm_ip_line}
+    \    @{vm_ip_list}    Get Regexp Matches    ${vm_ip_line}    ${prefix}
+    \    ${vm_ip_length}    Get Length    ${vm_ip_list}
+    \    Run Keyword If    ${vm_ip_length}>0    Append To List    ${ip_list}    @{vm_ip_list}[0]
+    \    ...    ELSE    Append To List    ${ip_list}    None
+    \    Log    ${ip_list}
+    Run Keyword If    '${fail_on_none}' == 'true'    Should Not Contain    ${ip_list}    None
+    Log    ${ip_list}
+    [Return]    ${ip_list}
+
 View Vm Console
     [Arguments]    ${vm_instance_names}
     [Documentation]    View Console log of the created vm instances using nova show.
@@ -377,7 +457,9 @@ Exit From Vm Console
 Check Ping
     [Arguments]    ${ip_address}    ${ttl}=64
     [Documentation]    Run Ping command on the IP available as argument
-    ${output}=    Write Commands Until Expected Prompt    ping -t ${ttl} -c 3 ${ip_address}    ${OS_SYSTEM_PROMPT}
+    ${ethertype}=    Get Regexp Matches    ${ip_address}    ${IP_REGEX}
+    ${output}=    Run Keyword If    ${ethertype}    Write Commands Until Expected Prompt    ping -t ${ttl} -c 3 ${ip_address}    ${OS_SYSTEM_PROMPT}
+    ...    ELSE    Write Commands Until Expected Prompt    ping6 -t ${ttl} -c 3 ${ip_address}    ${OS_SYSTEM_PROMPT}
     Should Contain    ${output}    64 bytes
 
 Check Metadata Access
@@ -415,6 +497,7 @@ Test Operations From Vm Instance
     ${rcode}=    Run Keyword And Return Status    Check If Console Is VmInstance
     Run Keyword If    ${rcode}    Write Commands Until Expected Prompt    ifconfig    ${OS_SYSTEM_PROMPT}
     Run Keyword If    ${rcode}    Write Commands Until Expected Prompt    route    ${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}
     : FOR    ${dest_ip}    IN    @{dest_ips}
     \    Log    ${dest_ip}