Merge "support nat_destination when attaching existing floating_ip to a server"

This commit is contained in:
Zuul 2022-10-19 11:57:36 +00:00 committed by Gerrit Code Review
commit 9eea61694e
2 changed files with 9 additions and 4 deletions

View File

@ -875,7 +875,7 @@ class FloatingIPCloudMixin(_normalize.Normalizer):
def add_ip_list(
self, server, ips, wait=False, timeout=60,
fixed_address=None):
fixed_address=None, nat_destination=None):
"""Attach a list of IPs to a server.
:param server: a server object
@ -886,6 +886,9 @@ class FloatingIPCloudMixin(_normalize.Normalizer):
See the ``wait`` parameter.
:param fixed_address: (optional) Fixed address of the server to
attach the IP to
:param nat_destination: (optional) Name or ID of the network that
the fixed IP to attach the
floating IP should be on
:returns: The updated server ``munch.Munch``
@ -900,7 +903,7 @@ class FloatingIPCloudMixin(_normalize.Normalizer):
id=None, filters={'floating_ip_address': ip})
server = self._attach_ip_to_server(
server=server, floating_ip=f_ip, wait=wait, timeout=timeout,
fixed_address=fixed_address)
fixed_address=fixed_address, nat_destination=nat_destination)
return server
def add_auto_ip(self, server, wait=False, timeout=60, reuse=True):
@ -988,7 +991,7 @@ class FloatingIPCloudMixin(_normalize.Normalizer):
elif ips:
server = self.add_ip_list(
server, ips, wait=wait, timeout=timeout,
fixed_address=fixed_address)
fixed_address=fixed_address, nat_destination=nat_destination)
elif auto_ip:
if self._needs_floating_ip(server, nat_destination):
server = self._add_auto_ip(

View File

@ -197,7 +197,9 @@ class TestFloatingIP(base.TestCase):
self.cloud.add_ips_to_server(server_dict, ips=ips)
mock_add_ip_list.assert_called_with(
server_dict, ips, wait=False, timeout=60, fixed_address=None)
server_dict, ips, wait=False, timeout=60,
fixed_address=None,
nat_destination=None)
@patch.object(connection.Connection, '_needs_floating_ip')
@patch.object(connection.Connection, '_add_auto_ip')