Merge "NeutronBindNetworkPlugin: fix multi segment neutron data save."
This commit is contained in:
commit
47d83342a2
@ -442,7 +442,7 @@ class NeutronBindNetworkPlugin(NeutronNetworkPlugin):
|
|||||||
"local_link_information": local_links}
|
"local_link_information": local_links}
|
||||||
return arguments
|
return arguments
|
||||||
|
|
||||||
def _store_neutron_net_info(self, context, share_network):
|
def _save_neutron_network_data(self, context, share_network):
|
||||||
"""Store the Neutron network info.
|
"""Store the Neutron network info.
|
||||||
|
|
||||||
In case of dynamic multi segments the segment is determined while
|
In case of dynamic multi segments the segment is determined while
|
||||||
@ -456,7 +456,7 @@ class NeutronBindNetworkPlugin(NeutronNetworkPlugin):
|
|||||||
# In case of dynamic multi segment the segment is determined while
|
# In case of dynamic multi segment the segment is determined while
|
||||||
# binding the port
|
# binding the port
|
||||||
return
|
return
|
||||||
super(NeutronBindNetworkPlugin, self)._store_neutron_net_info(
|
super(NeutronBindNetworkPlugin, self)._save_neutron_network_data(
|
||||||
context, share_network)
|
context, share_network)
|
||||||
|
|
||||||
def allocate_network(self, context, share_server, share_network=None,
|
def allocate_network(self, context, share_server, share_network=None,
|
||||||
@ -473,8 +473,8 @@ class NeutronBindNetworkPlugin(NeutronNetworkPlugin):
|
|||||||
self._wait_for_ports_bind(ports, share_server)
|
self._wait_for_ports_bind(ports, share_server)
|
||||||
if self._is_neutron_multi_segment(share_network):
|
if self._is_neutron_multi_segment(share_network):
|
||||||
# update segment information after port bind
|
# update segment information after port bind
|
||||||
super(NeutronBindNetworkPlugin, self)._store_neutron_net_info(
|
super(NeutronBindNetworkPlugin,
|
||||||
context, share_network)
|
self)._save_neutron_network_data(context, share_network)
|
||||||
for num, port in enumerate(ports):
|
for num, port in enumerate(ports):
|
||||||
port_info = {
|
port_info = {
|
||||||
'network_type': share_network['network_type'],
|
'network_type': share_network['network_type'],
|
||||||
|
@ -71,6 +71,14 @@ fake_neutron_network = {
|
|||||||
'fake subnet id 2'],
|
'fake subnet id 2'],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fake_ip_version = 4
|
||||||
|
|
||||||
|
fake_neutron_subnet = {
|
||||||
|
'cidr': '10.0.0.0/24',
|
||||||
|
'ip_version': fake_ip_version,
|
||||||
|
'gateway_ip': '10.0.0.1',
|
||||||
|
}
|
||||||
|
|
||||||
fake_share_network = {
|
fake_share_network = {
|
||||||
'id': 'fake nw info id',
|
'id': 'fake nw info id',
|
||||||
'neutron_subnet_id': fake_neutron_network['subnets'][0],
|
'neutron_subnet_id': fake_neutron_network['subnets'][0],
|
||||||
@ -155,7 +163,7 @@ fake_share_network_multi = {
|
|||||||
'name': 'fake name',
|
'name': 'fake name',
|
||||||
'description': 'fake description',
|
'description': 'fake description',
|
||||||
'security_services': [],
|
'security_services': [],
|
||||||
'ip_version': 4,
|
'ip_version': None,
|
||||||
'cidr': 'fake_cidr',
|
'cidr': 'fake_cidr',
|
||||||
'gateway': 'fake_gateway',
|
'gateway': 'fake_gateway',
|
||||||
'mtu': fake_neutron_network_multi['mtu'],
|
'mtu': fake_neutron_network_multi['mtu'],
|
||||||
@ -170,9 +178,9 @@ fake_network_allocation_multi = {
|
|||||||
'label': 'user',
|
'label': 'user',
|
||||||
'network_type': None,
|
'network_type': None,
|
||||||
'segmentation_id': None,
|
'segmentation_id': None,
|
||||||
'ip_version': fake_share_network_multi['ip_version'],
|
'ip_version': fake_neutron_subnet['ip_version'],
|
||||||
'cidr': fake_share_network_multi['cidr'],
|
'cidr': fake_neutron_subnet['cidr'],
|
||||||
'gateway': 'fake_gateway',
|
'gateway': fake_neutron_subnet['gateway_ip'],
|
||||||
'mtu': fake_share_network_multi['mtu'],
|
'mtu': fake_share_network_multi['mtu'],
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -435,11 +443,7 @@ class NeutronNetworkPluginTest(test.TestCase):
|
|||||||
|
|
||||||
@mock.patch.object(db_api, 'share_network_update', mock.Mock())
|
@mock.patch.object(db_api, 'share_network_update', mock.Mock())
|
||||||
def test_save_neutron_subnet_data(self):
|
def test_save_neutron_subnet_data(self):
|
||||||
neutron_subnet_info = {
|
neutron_subnet_info = fake_neutron_subnet
|
||||||
'cidr': '10.0.0.0/24',
|
|
||||||
'ip_version': 4,
|
|
||||||
'gateway_ip': '10.0.0.1',
|
|
||||||
}
|
|
||||||
subnet_value = {
|
subnet_value = {
|
||||||
'cidr': '10.0.0.0/24',
|
'cidr': '10.0.0.0/24',
|
||||||
'ip_version': 4,
|
'ip_version': 4,
|
||||||
@ -770,6 +774,7 @@ class NeutronBindNetworkPluginTest(test.TestCase):
|
|||||||
network_allocation_update_data)
|
network_allocation_update_data)
|
||||||
fake_share_network_multi_updated = dict(fake_share_network_multi)
|
fake_share_network_multi_updated = dict(fake_share_network_multi)
|
||||||
fake_share_network_multi_updated.update(network_update_data)
|
fake_share_network_multi_updated.update(network_update_data)
|
||||||
|
fake_share_network_multi_updated.update(fake_neutron_subnet)
|
||||||
config_data = {
|
config_data = {
|
||||||
'DEFAULT': {
|
'DEFAULT': {
|
||||||
'neutron_net_id': 'fake net id',
|
'neutron_net_id': 'fake net id',
|
||||||
@ -783,8 +788,6 @@ class NeutronBindNetworkPluginTest(test.TestCase):
|
|||||||
|
|
||||||
self.mock_object(self.bind_plugin, '_has_provider_network_extension')
|
self.mock_object(self.bind_plugin, '_has_provider_network_extension')
|
||||||
self.bind_plugin._has_provider_network_extension.return_value = True
|
self.bind_plugin._has_provider_network_extension.return_value = True
|
||||||
save_subnet_data = self.mock_object(self.bind_plugin,
|
|
||||||
'_save_neutron_subnet_data')
|
|
||||||
self.mock_object(self.bind_plugin, '_wait_for_ports_bind')
|
self.mock_object(self.bind_plugin, '_wait_for_ports_bind')
|
||||||
neutron_host_id_opts = plugin.neutron_bind_network_plugin_opts[1]
|
neutron_host_id_opts = plugin.neutron_bind_network_plugin_opts[1]
|
||||||
self.mock_object(neutron_host_id_opts, 'default')
|
self.mock_object(neutron_host_id_opts, 'default')
|
||||||
@ -799,6 +802,9 @@ class NeutronBindNetworkPluginTest(test.TestCase):
|
|||||||
self.mock_object(self.bind_plugin.neutron_api, 'get_network')
|
self.mock_object(self.bind_plugin.neutron_api, 'get_network')
|
||||||
self.bind_plugin.neutron_api.get_network.return_value = (
|
self.bind_plugin.neutron_api.get_network.return_value = (
|
||||||
fake_neutron_network_multi)
|
fake_neutron_network_multi)
|
||||||
|
self.mock_object(self.bind_plugin.neutron_api, 'get_subnet')
|
||||||
|
self.bind_plugin.neutron_api.get_subnet.return_value = (
|
||||||
|
fake_neutron_subnet)
|
||||||
self.mock_object(db_api, 'share_network_update')
|
self.mock_object(db_api, 'share_network_update')
|
||||||
|
|
||||||
with mock.patch.object(self.bind_plugin.neutron_api, 'create_port',
|
with mock.patch.object(self.bind_plugin.neutron_api, 'create_port',
|
||||||
@ -810,9 +816,6 @@ class NeutronBindNetworkPluginTest(test.TestCase):
|
|||||||
allocation_info={'count': 1})
|
allocation_info={'count': 1})
|
||||||
|
|
||||||
self.bind_plugin._has_provider_network_extension.assert_any_call()
|
self.bind_plugin._has_provider_network_extension.assert_any_call()
|
||||||
save_subnet_data.assert_called_once_with(
|
|
||||||
self.fake_context,
|
|
||||||
fake_share_network_multi_updated)
|
|
||||||
expected_kwargs = {
|
expected_kwargs = {
|
||||||
'binding:vnic_type': 'baremetal',
|
'binding:vnic_type': 'baremetal',
|
||||||
'host_id': 'foohost1',
|
'host_id': 'foohost1',
|
||||||
@ -826,14 +829,14 @@ class NeutronBindNetworkPluginTest(test.TestCase):
|
|||||||
db_api.network_allocation_create.assert_called_once_with(
|
db_api.network_allocation_create.assert_called_once_with(
|
||||||
self.fake_context,
|
self.fake_context,
|
||||||
fake_network_allocation_multi)
|
fake_network_allocation_multi)
|
||||||
db_api.share_network_update.assert_called_once_with(
|
db_api.share_network_update.assert_called_with(
|
||||||
self.fake_context,
|
self.fake_context,
|
||||||
fake_share_network_multi['id'],
|
fake_share_network_multi['id'],
|
||||||
network_update_data)
|
network_update_data)
|
||||||
network_allocation_update_data['cidr'] = (
|
network_allocation_update_data['cidr'] = (
|
||||||
fake_share_network_multi['cidr'])
|
fake_neutron_subnet['cidr'])
|
||||||
network_allocation_update_data['ip_version'] = (
|
network_allocation_update_data['ip_version'] = (
|
||||||
fake_share_network_multi['ip_version'])
|
fake_neutron_subnet['ip_version'])
|
||||||
db_api.network_allocation_update.assert_called_once_with(
|
db_api.network_allocation_update.assert_called_once_with(
|
||||||
self.fake_context,
|
self.fake_context,
|
||||||
fake_neutron_port['id'],
|
fake_neutron_port['id'],
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
Fixed multi segment neutron data save in NeutronBindNetworkPlugin to
|
||||||
|
provide IP version for neutron port creation.
|
Loading…
Reference in New Issue
Block a user