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
This commit is contained in:
deepak_mourya 2018-02-09 11:00:05 +05:30 committed by Deepak Mourya
parent f3e0e67c40
commit 3643413515
2 changed files with 12 additions and 4 deletions

View File

@ -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
})

View File

@ -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)