X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=csit%2Flibraries%2FOpenStackOperations.robot;h=f685829206132c393c09b8cf40698c99bcf160ec;hb=5d2dd411302134b434ee34b924ca376357b1f968;hp=44732b36871ead8cbc2cfd927f63241c5894a4aa;hpb=3fbb0e18faa83c3adc4316b6410943bc28351ab9;p=integration%2Ftest.git diff --git a/csit/libraries/OpenStackOperations.robot b/csit/libraries/OpenStackOperations.robot index 44732b3687..f685829206 100644 --- a/csit/libraries/OpenStackOperations.robot +++ b/csit/libraries/OpenStackOperations.robot @@ -7,6 +7,7 @@ Library SSHLibrary Resource DataModels.robot Resource DevstackUtils.robot Resource L2GatewayOperations.robot +Resource OVSDB.robot Resource SetupUtils.robot Resource SSHKeywords.robot Resource Utils.robot @@ -144,9 +145,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 --all-projects - Log ${output} - Should Be True '${rc}' == '0' + ${output}= OpenStack CLI openstack server list --all-projects [Return] ${output} Create And Associate Floating IPs @@ -161,9 +160,7 @@ Create And Associate Floating IPs \ ${ip_length} Get Length ${ip} \ Run Keyword If ${ip_length}>0 Append To List ${ip_list} @{ip}[0] \ ... ELSE Append To List ${ip_list} None - \ ${rc} ${output}= Run And Return Rc And Output openstack server add floating ip ${vm} @{ip}[0] - \ Log ${output} - \ Should Be True '${rc}' == '0' + \ OpenStack CLI openstack server add floating ip ${vm} @{ip}[0] [Return] ${ip_list} Delete Floating IP @@ -207,8 +204,7 @@ Verify No Gateway Ips Delete Vm Instance [Arguments] ${vm_name} [Documentation] Delete Vm instances using instance names. - ${rc} ${output}= Run And Return Rc And Output openstack server delete ${vm_name} - Log ${output} + OpenStack CLI openstack server delete ${vm_name} Get Net Id [Arguments] ${network_name} @@ -253,17 +249,21 @@ Create Vm Instances ${image} Set Variable If "${image}"=="${EMPTY}" ${CIRROS_${OPENSTACK_BRANCH}} ${image} ${net_id}= Get Net Id ${net_name} : 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} --min ${min} --max ${max} - \ Should Be True '${rc}' == '0' - \ Log ${output} + \ OpenStack CLI openstack server create --image ${image} --flavor ${flavor} --nic net-id=${net_id} ${VmElement} --security-group ${sg} --min ${min} --max ${max} + +Create Vm Instance On Compute Node + [Arguments] ${net_name} ${vm_name} ${node_hostname} ${image}=${EMPTY} ${flavor}=m1.nano ${sg}=default + [Documentation] Create a VM instance on a specific compute node. + ${image} = Set Variable If "${image}"=="${EMPTY}" ${CIRROS_${OPENSTACK_BRANCH}} ${image} + ${net_id} = Get Net Id ${net_name} + OpenStack CLI openstack server create ${vm_name} --image ${image} --flavor ${flavor} --nic net-id=${net_id} --security-group ${sg} --availability-zone nova:${node_hostname} Create Vm Instance With Port [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} - ${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} + OpenStack CLI openstack server create --image ${image} --flavor ${flavor} --nic port-id=${port_id} ${vm_instance_name} --security-group ${sg} Create Vm Instance With Ports [Arguments] ${port_name} ${port2_name} ${vm_instance_name} ${image}=${EMPTY} ${flavor}=m1.nano ${sg}=default @@ -271,19 +271,14 @@ Create Vm Instance With Ports ${image} Set Variable If "${image}"=="${EMPTY}" ${CIRROS_${OPENSTACK_BRANCH}} ${image} ${port_id}= Get Port Id ${port_name} ${port2_id}= Get Port Id ${port2_name} - ${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} - Log ${output} - Should Be True '${rc}' == '0' + OpenStack CLI openstack server create --image ${image} --flavor ${flavor} --nic port-id=${port_id} --nic port-id=${port2_id} ${vm_instance_name} --security-group ${sg} Create Vm Instance With Port On Compute Node - [Arguments] ${port_name} ${vm_instance_name} ${compute_node} ${image}=${EMPTY} ${flavor}=m1.nano ${sg}=default + [Arguments] ${port_name} ${vm_instance_name} ${node_hostname} ${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} - ${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 Be True '${rc}' == '0' + OpenStack CLI openstack server create --image ${image} --flavor ${flavor} --nic port-id=${port_id} --security-group ${sg} --availability-zone nova:${node_hostname} ${vm_instance_name} Get Hypervisor Hostname From IP [Arguments] ${hypervisor_ip} @@ -291,7 +286,7 @@ Get Hypervisor Hostname From IP ... 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 + ${rc} ${hostname}= Run And Return Rc And Output openstack hypervisor list -f value | grep "${hypervisor_ip} " | cut -d" " -f 2 Log ${hostname} Should Be True '${rc}' == '0' [Return] ${hostname} @@ -305,8 +300,7 @@ Create Nano Flavor 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 - Should Be True '${rc}' == '0' + ${output}= OpenStack CLI openstack server show ${vm_name} | grep OS-EXT-STS:vm_state Should Contain ${output} active Poll VM Is ACTIVE @@ -390,31 +384,31 @@ Get VM IPs [Return] @{vm_ips} ${ips_and_console_log[1]} Collect VM IPv6 SLAAC Addresses - [Arguments] ${fail_on_none} ${prefix} @{vm_list} - [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} + [Arguments] ${fail_on_none} ${vm_list} ${network} ${subnet} + [Documentation] For each VM parse output of "openstack server show" to get its IPv6 address from Neutron DB. + ... Then try to connect to each VM by SSH and execute there "ip -6 a" command. This double-check allows to + ... obtain and compare IP info (Neutron DB vs dnsmasque/ODL DHCP) and to test L2 connectivity as well. + ... Returns an empty list if no IPv6 addresses found or if SSH connection fails. + ... Otherwise, returns a list of IPv6 addresses. + ${ipv6_list} Create List @{EMPTY} : FOR ${vm} IN @{vm_list} - \ Log ${vm} - \ ${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} - \ ${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} + \ ${output}= OpenStack CLI openstack server show ${vm} -f shell + \ ${pattern}= Replace String ${subnet} ::/64 (:[a-f0-9]{,4}){,4} + \ @{vm_ipv6}= Get Regexp Matches ${output} ${pattern} + \ ${vm_ip_length} Get Length ${vm_ipv6}[0] + \ ${ipv6_data_from_vm}= Run Keyword If ${vm_ip_length}>0 Execute Command on VM Instance ${network} ${vm_ipv6[0]} + \ ... ip -6 a + \ @{ipv6}= Get Regexp Matches ${ipv6_data_from_vm} ${pattern} + \ ${ipv6_addr_list_length} Get Length @{ipv6} + \ Run Keyword If ${ipv6_addr_list_length}>0 Append To List ${ipv6_list} ${ipv6[0]} + \ ... ELSE Append To List ${ipv6_list} None + [Return] ${ipv6_list} 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 openstack server show ${VmElement} - \ Log ${output} - \ Should Be True '${rc}' == '0' + \ OpenStack CLI openstack server show ${VmElement} \ ${rc} ${output}= Run And Return Rc And Output openstack console log show ${VmElement} \ Log ${output} \ Should Be True '${rc}' == '0' @@ -959,15 +953,13 @@ Create And Configure Security Group Add Security Group To VM [Arguments] ${vm} ${sg} [Documentation] Add the security group provided to the given VM. - ${rc} ${output}= Run And Return Rc And Output openstack server add security group ${vm} ${sg} - Log ${output} - Should Be True '${rc}' == '0' + ${output}= OpenStack CLI openstack server add security group ${vm} ${sg} Remove Security Group From VM [Arguments] ${vm} ${sg} [Documentation] Remove the security group provided to the given VM. Get ControlNode Connection - ${output}= Write Commands Until Prompt And Log openstack server remove security group ${vm} ${sg} + OpenStack CLI openstack server remove security group ${vm} ${sg} Create SFC Flow Classifier [Arguments] ${name} ${src_ip} ${dest_ip} ${protocol} ${dest_port} ${neutron_src_port} @@ -1052,9 +1044,7 @@ Delete SFC Port Chain Reboot Nova VM [Arguments] ${vm_name} [Documentation] Reboot NOVA VM - ${rc} ${output}= Run And Return Rc And Output openstack server reboot --wait ${vm_name} - Log ${output} - Should Be True '${rc}' == '0' + OpenStack CLI openstack server reboot --wait ${vm_name} Wait Until Keyword Succeeds 35s 10s Verify VM Is ACTIVE ${vm_name} Remove RSA Key From KnownHosts @@ -1150,7 +1140,9 @@ Cleanup Router OpenStack Suite Setup [Documentation] Wrapper teardown keyword that can be used in any suite running in an openstack environement SetupUtils.Setup_Utils_For_Setup_And_Teardown + Run Keyword If "${PRE_CLEAN_OPENSTACK_ALL}"=="True" OpenStack Cleanup All DevstackUtils.Devstack Suite Setup + Add OVS Logging On All OpenStack Nodes OpenStack Suite Teardown [Documentation] Wrapper teardown keyword that can be used in any suite running in an openstack environement @@ -1175,3 +1167,15 @@ Is Feature Installed \ ${status} ${output} Run Keyword And Ignore Error Builtin.Should Contain ${CONTROLLERFEATURES} ${feature} \ Return From Keyword If "${status}" == "PASS" True [Return] False + +Add OVS Logging On All OpenStack Nodes + [Documentation] Add higher levels of OVS logging to all the OpenStack nodes + Run Keyword If 0 < ${NUM_OS_SYSTEM} OVSDB.Add OVS Logging ${OS_CNTL_CONN_ID} + Run Keyword If 1 < ${NUM_OS_SYSTEM} OVSDB.Add OVS Logging ${OS_CMP1_CONN_ID} + Run Keyword If 2 < ${NUM_OS_SYSTEM} OVSDB.Add OVS Logging ${OS_CMP2_CONN_ID} + +Reset OVS Logging On All OpenStack Nodes + [Documentation] Reset the OVS logging to all the OpenStack nodes + Run Keyword If 0 < ${NUM_OS_SYSTEM} OVSDB.Reset OVS Logging ${OS_CNTL_CONN_ID} + Run Keyword If 1 < ${NUM_OS_SYSTEM} OVSDB.Reset OVS Logging ${OS_CMP1_CONN_ID} + Run Keyword If 2 < ${NUM_OS_SYSTEM} OVSDB.Reset OVS Logging ${OS_CMP2_CONN_ID}