Specifies the appropriate ip address in case of multi-networking
When connecting a storage_network to VMs, the tests may try to associate a FloatingIP to the storage network instead of the project network. Note: This failure has been caused since [1] was merged [1] https://review.opendev.org/#/c/668597/ Change-Id: Ife32cb2616701a285cb16d5b267bdf6a78d74c3c
This commit is contained in:
parent
ce66f004c8
commit
7636a1fce4
@ -734,14 +734,15 @@ class NetworkScenarioTest(ScenarioTest):
|
||||
return self.os_admin.networks_client.list_networks()['networks']
|
||||
|
||||
def create_floating_ip(self, thing, external_network_id=None,
|
||||
port_id=None, client=None):
|
||||
port_id=None, ip_addr=None, client=None):
|
||||
"""Create a floating IP and associates to a resource/port on Neutron"""
|
||||
if not external_network_id:
|
||||
external_network_id = CONF.network.public_network_id
|
||||
if not client:
|
||||
client = self.floating_ips_client
|
||||
if not port_id:
|
||||
port_id, ip4 = self._get_server_port_id_and_ip4(thing)
|
||||
port_id, ip4 = self._get_server_port_id_and_ip4(thing,
|
||||
ip_addr=ip_addr)
|
||||
else:
|
||||
ip4 = None
|
||||
result = client.create_floatingip(
|
||||
|
@ -158,10 +158,11 @@ class ShareScenarioTest(manager.NetworkScenarioTest):
|
||||
def init_remote_client(self, instance):
|
||||
server_ip = None
|
||||
if self.ipv6_enabled:
|
||||
server_ip = self._get_ipv6_server_ip(instance)
|
||||
server_ip = self._get_ip_server_ip(instance, ip_version=6)
|
||||
if not server_ip:
|
||||
ip_addr = self._get_ip_server_ip(instance)
|
||||
# Obtain a floating IP
|
||||
floating_ip = self.create_floating_ip(instance)
|
||||
floating_ip = self.create_floating_ip(instance, ip_addr=ip_addr)
|
||||
self.floating_ips[instance['id']] = floating_ip
|
||||
server_ip = floating_ip['floating_ip_address']
|
||||
|
||||
@ -328,7 +329,7 @@ class ShareScenarioTest(manager.NetworkScenarioTest):
|
||||
client = client or self.shares_v2_client
|
||||
if not CONF.share.multitenancy_enabled:
|
||||
if self.ipv6_enabled and not self.storage_network:
|
||||
server_ip = self._get_ipv6_server_ip(instance)
|
||||
server_ip = self._get_ip_server_ip(instance, ip_version=6)
|
||||
else:
|
||||
server_ip = (
|
||||
CONF.share.override_ip_for_nfs_access
|
||||
@ -379,15 +380,15 @@ class ShareScenarioTest(manager.NetworkScenarioTest):
|
||||
|
||||
return locations
|
||||
|
||||
def _get_ipv6_server_ip(self, instance):
|
||||
ipv6_addrs = []
|
||||
def _get_ip_server_ip(self, instance, ip_version=4):
|
||||
ip_addrs = []
|
||||
for network_name, nic_list in instance['addresses'].items():
|
||||
if network_name == self.storage_network_name:
|
||||
continue
|
||||
for nic_data in nic_list:
|
||||
if nic_data['version'] == 6:
|
||||
ipv6_addrs.append(nic_data['addr'])
|
||||
return ipv6_addrs[0] if ipv6_addrs else None
|
||||
if nic_data['version'] == ip_version:
|
||||
ip_addrs.append(nic_data['addr'])
|
||||
return ip_addrs[0] if ip_addrs else None
|
||||
|
||||
def _create_share(self, share_protocol=None, size=None, name=None,
|
||||
snapshot_id=None, description=None, metadata=None,
|
||||
|
Loading…
Reference in New Issue
Block a user