From 36434135152ab9dea0be088888dd20c7e0d94e4a Mon Sep 17 00:00:00 2001 From: deepak_mourya Date: Fri, 9 Feb 2018 11:00:05 +0530 Subject: [PATCH] Add subnet to addresses field According to the, https://developer.openstack.org/api-ref/application-container/#list-all-containers "addresses": { "2ede1821-1334-4e8b-b731-d3a82b41f42f": [{ "version": 4, "addr": "172.24.4.3", "port": "4b077255-9b4d-4068-b24f-b89594f870c2" }, { "version": 6, "addr": "2001:db8::9", "port": "4b077255-9b4d-4068-b24f-b89594f870c2" }] }, It would be useful to include 'subnet' for each address so that users can know this information. Change-Id: Ic6c041535bc6de2e264aeb9995a78a5a2ae4d2fd Closes-Bug: #1746643 --- zun/network/kuryr_network.py | 2 ++ zun/tests/unit/network/test_kuryr_network.py | 14 ++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/zun/network/kuryr_network.py b/zun/network/kuryr_network.py index 1144855a3..93b102d97 100644 --- a/zun/network/kuryr_network.py +++ b/zun/network/kuryr_network.py @@ -247,6 +247,7 @@ class KuryrNetwork(network.Network): 'addr': ip_address, 'version': 4, 'port': neutron_port['id'], + 'subnet_id': fixed_ip['subnet_id'], 'preserve_on_delete': preserve_on_delete }) else: @@ -254,6 +255,7 @@ class KuryrNetwork(network.Network): 'addr': ip_address, 'version': 6, 'port': neutron_port['id'], + 'subnet_id': fixed_ip['subnet_id'], 'preserve_on_delete': preserve_on_delete }) diff --git a/zun/tests/unit/network/test_kuryr_network.py b/zun/tests/unit/network/test_kuryr_network.py index de643414a..88c9686b1 100644 --- a/zun/tests/unit/network/test_kuryr_network.py +++ b/zun/tests/unit/network/test_kuryr_network.py @@ -32,7 +32,8 @@ class FakeNeutronClient(object): 'id': '12345678'}]} def create_port(self, port_id): - return {'port': {'fixed_ips': [{'ip_address': '192.168.2.22'}], + return {'port': {'fixed_ips': [{'ip_address': '192.168.2.22', + 'subnet_id': '85adb169-d151-41cd-8c76-157bfdb4345d'}], 'id': '1234567'}} def update_port(self, port_id, port): @@ -45,7 +46,8 @@ class FakeNeutronClient(object): pass def get_neutron_port(self, port_id): - return {'fixed_ips': [{'ip_address': '192.168.2.22'}], + return {'fixed_ips': [{'ip_address': '192.168.2.22', + 'subnet_id': '85adb169-d151-41cd-8c76-157bfdb4345d'}], 'id': '1234567', 'security_groups': []} @@ -154,9 +156,13 @@ class KuryrNetworkTestCase(base.TestCase): container = Container(self.context, **utils.get_test_container()) network_name = 'c02afe4e-8350-4263-8078' kwargs = {'ip_version': 4, 'ipv4_address': '192.168.2.22', - 'port': '1234567', 'preserve_on_delete': True} + 'port': '1234567', 'subnet_id': + '85adb169-d151-41cd-8c76-157bfdb4345d', + 'preserve_on_delete': True} expected = [{'version': 4, 'addr': '192.168.2.22', - 'port': '1234567', 'preserve_on_delete': True}] + 'port': '1234567', 'subnet_id': + '85adb169-d151-41cd-8c76-157bfdb4345d', + 'preserve_on_delete': True}] address = self.network_api.connect_container_to_network(container, network_name, kwargs)