Fix floatingip allocation
- Use neutron's floating IP provisioning APIs instead of the
compute APIs that will proxy the request to neutron anyway.
Another advantage of doing this is because we'll be using the
external network to create a floating IP upon, and don't need
to configure yet another "floating_pool_name" config opt to
get things to work. When used, in most environments, the
external network is the same as the floating pool.
- Fix usage of the GET /ports API where an incorrect filter
parameter ("fixed_ip") was being used (and subsequently ignored
by older versions of neutron, see bug #1749820 [1])
- Refactor the check for ironic (we don't use baremetal nodes in
our testing) to match that in tempest's own implementation of the
port resolution [2]
- replace assertNotEqual(0, len(somelist)) with
assertNotEmpty(somelist)
[1] https://launchpad.net/bugs/1749820
[2] https://opendev.org/openstack/tempest/src/commit/5c191faae78f52f876edba72484ea644d3df04fd/tempest/scenario/manager.py#L958-L994
Change-Id: I48b0f21fe75fae623e7e513cf2890f2c10a80317
Co-Authored-by: Goutham Pacha Ravi <gouthampravi@gmail.com>
Co-Authored-by: Shi Yan <yanshi.403@gmail.com>
Signed-off-by: Goutham Pacha Ravi <gouthampravi@gmail.com>
diff --git a/manila_tempest_tests/tests/scenario/manager.py b/manila_tempest_tests/tests/scenario/manager.py
index 6e8a2f6..dede47a 100644
--- a/manila_tempest_tests/tests/scenario/manager.py
+++ b/manila_tempest_tests/tests/scenario/manager.py
@@ -681,28 +681,36 @@
return subnet
def _get_server_port_id_and_ip4(self, server, ip_addr=None):
- ports = self.os_admin.ports_client.list_ports(
- device_id=server['id'], fixed_ip=ip_addr)['ports']
+ if ip_addr:
+ ports = self.os_admin.ports_client.list_ports(
+ device_id=server['id'],
+ fixed_ips='ip_address=%s' % ip_addr)['ports']
+ else:
+ ports = self.os_admin.ports_client.list_ports(
+ device_id=server['id'])['ports']
# A port can have more than one IP address in some cases.
# If the network is dual-stack (IPv4 + IPv6), this port is associated
# with 2 subnets
- p_status = ['ACTIVE']
- # NOTE(vsaienko) With Ironic, instances live on separate hardware
- # servers. Neutron does not bind ports for Ironic instances, as a
- # result the port remains in the DOWN state.
- # TODO(vsaienko) remove once bug: #1599836 is resolved.
- if getattr(CONF.service_available, 'ironic', False):
- p_status.append('DOWN')
+
+ def _is_active(port):
+ # NOTE(vsaienko) With Ironic, instances live on separate hardware
+ # servers. Neutron does not bind ports for Ironic instances, as a
+ # result the port remains in the DOWN state. This has been fixed
+ # with the introduction of the networking-baremetal plugin but
+ # it's not mandatory (and is not used on all stable branches).
+ return (port['status'] == 'ACTIVE' or
+ port.get('binding:vnic_type') == 'baremetal')
+
port_map = [(p["id"], fxip["ip_address"])
for p in ports
for fxip in p["fixed_ips"]
- if netutils.is_valid_ipv4(fxip["ip_address"])
- and p['status'] in p_status]
+ if (netutils.is_valid_ipv4(fxip["ip_address"]) and
+ _is_active(p))]
inactive = [p for p in ports if p['status'] != 'ACTIVE']
if inactive:
LOG.warning("Instance has ports that are not ACTIVE: %s", inactive)
- self.assertNotEqual(0, len(port_map),
+ self.assertNotEmpty(port_map,
"No IPv4 addresses found in: %s" % ports)
self.assertEqual(len(port_map), 1,
"Found multiple IPv4 addresses: %s. "
diff --git a/manila_tempest_tests/tests/scenario/manager_share.py b/manila_tempest_tests/tests/scenario/manager_share.py
index 1ae1b4a..eaffa35 100644
--- a/manila_tempest_tests/tests/scenario/manager_share.py
+++ b/manila_tempest_tests/tests/scenario/manager_share.py
@@ -26,7 +26,6 @@
from tempest.common import waiters
from tempest import config
from tempest.lib.common.utils import data_utils
-from tempest.lib.common.utils import test_utils
from tempest.lib import exceptions
from tempfile import mkstemp
@@ -162,10 +161,9 @@
server_ip = self._get_ipv6_server_ip(instance)
if not server_ip:
# Obtain a floating IP
- floating_ip = (
- self.compute_floating_ips_client.create_floating_ip()
- ['floating_ip'])
+ floating_ip = self.create_floating_ip(instance)
self.floating_ips[instance['id']] = floating_ip
+ server_ip = floating_ip['floating_ip_address']
if self.storage_network:
storage_net_nic = instance['addresses'].get(
@@ -174,15 +172,10 @@
self.storage_network_nic_ips[instance['id']] = (
storage_net_nic[0]['addr']
)
-
- self.addCleanup(
- test_utils.call_and_ignore_notfound_exc,
- self.compute_floating_ips_client.delete_floating_ip,
- floating_ip['id'])
# Attach a floating IP
self.compute_floating_ips_client.associate_floating_ip_to_server(
- floating_ip['ip'], instance['id'])
- server_ip = floating_ip['ip']
+ floating_ip['floating_ip_address'], instance['id'])
+
self.assertIsNotNone(server_ip)
# Check ssh
remote_client = self.get_remote_client(
@@ -337,10 +330,12 @@
if self.ipv6_enabled and not self.storage_network:
server_ip = self._get_ipv6_server_ip(instance)
else:
- server_ip = (CONF.share.override_ip_for_nfs_access or
- self.storage_network_nic_ips.get(
- instance['id']) or
- self.floating_ips[instance['id']]['ip'])
+ server_ip = (
+ CONF.share.override_ip_for_nfs_access
+ or self.storage_network_nic_ips.get(instance['id'])
+ or self.floating_ips[instance['id']]['floating_ip_address']
+ )
+
self.assertIsNotNone(server_ip)
return self.allow_access_ip(
share['id'], ip=server_ip,