From a71db08bc71308bb54ba7a715048767242434d0f Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Mon, 9 Nov 2015 10:36:31 -0500 Subject: [PATCH] Plumb fixed_address through add_ips_to_server Specifying a fixed_address if you know it is somethig that the lower level functions understand, but was left out of the argument list for add_ips_to_server. Plumb it through. Change-Id: Iba3456f0f45e5b0230c752a50fc3d3b29e8ade54 --- shade/openstackcloud.py | 18 +++++++++++++----- shade/tests/unit/test_floating_ip_common.py | 5 +++-- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/shade/openstackcloud.py b/shade/openstackcloud.py index 4eb810fee..0dc62435b 100644 --- a/shade/openstackcloud.py +++ b/shade/openstackcloud.py @@ -3024,7 +3024,9 @@ class OpenStackCloud(object): server=server, floating_ip=f_ip, fixed_address=fixed_address, wait=wait, timeout=timeout) - def add_ip_list(self, server, ips, wait=False, timeout=60): + def add_ip_list( + self, server, ips, wait=False, timeout=60, + fixed_address=None): """Attach a list of IPs to a server. :param server: a server object @@ -3033,6 +3035,8 @@ class OpenStackCloud(object): to the server in Nova. Defaults to False. :param timeout: (optional) Seconds to wait, defaults to 60. See the ``wait`` parameter. + :param fixed_address: (optional) Fixed address of the server to + attach the IP to :returns: The updated server dict @@ -3045,7 +3049,8 @@ class OpenStackCloud(object): f_ip = self.get_floating_ip( id=None, filters={'floating_ip_address': ip}) return self._attach_ip_to_server( - server=server, floating_ip=f_ip, wait=wait, timeout=timeout) + server=server, floating_ip=f_ip, wait=wait, timeout=timeout, + fixed_address=fixed_address) def add_auto_ip(self, server, wait=False, timeout=60, reuse=True): """Add a floating IP to a server. @@ -3090,12 +3095,15 @@ class OpenStackCloud(object): def add_ips_to_server( self, server, auto_ip=True, ips=None, ip_pool=None, - wait=False, timeout=60, reuse=True): + wait=False, timeout=60, reuse=True, fixed_address=None): if ip_pool: server = self._add_ip_from_pool( - server, ip_pool, reuse=reuse, wait=wait, timeout=timeout) + server, ip_pool, reuse=reuse, wait=wait, timeout=timeout, + fixed_address=fixed_address) elif ips: - server = self.add_ip_list(server, ips, wait=wait, timeout=timeout) + server = self.add_ip_list( + server, ips, wait=wait, timeout=timeout, + fixed_address=fixed_address) elif auto_ip: if not self.get_server_public_ip(server): server = self._add_auto_ip( diff --git a/shade/tests/unit/test_floating_ip_common.py b/shade/tests/unit/test_floating_ip_common.py index 4a49b5caa..f54493171 100644 --- a/shade/tests/unit/test_floating_ip_common.py +++ b/shade/tests/unit/test_floating_ip_common.py @@ -76,7 +76,8 @@ class TestFloatingIP(base.TestCase): self.client.add_ips_to_server(server_dict, ip_pool=pool) mock_add_ip_from_pool.assert_called_with( - server_dict, pool, reuse=True, wait=False, timeout=60) + server_dict, pool, reuse=True, wait=False, timeout=60, + fixed_address=None) @patch.object(OpenStackCloud, 'nova_client') @patch.object(OpenStackCloud, 'add_ip_list') @@ -92,7 +93,7 @@ class TestFloatingIP(base.TestCase): self.client.add_ips_to_server(server_dict, ips=ips) mock_add_ip_list.assert_called_with( - server_dict, ips, wait=False, timeout=60) + server_dict, ips, wait=False, timeout=60, fixed_address=None) @patch.object(OpenStackCloud, 'nova_client') @patch.object(OpenStackCloud, '_add_auto_ip')