Merge "Allow provider net attr in update if no change"
This commit is contained in:
commit
a36e2dd797
|
@ -842,16 +842,19 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
|
|||
This function will raise an exception if the provider network attribute
|
||||
update is not supported.
|
||||
"""
|
||||
if net_data.get(provider_net.SEGMENTATION_ID):
|
||||
self._update_segmentation_id(context, network, net_data)
|
||||
|
||||
provider_net_attrs = (set(provider_net.ATTRIBUTES) -
|
||||
{provider_net.SEGMENTATION_ID})
|
||||
if any(validators.is_attr_set(net_data.get(a))
|
||||
for a in provider_net_attrs):
|
||||
msg = (_('Plugin does not support updating the following provider '
|
||||
'network attributes: %s') % ', '.join(provider_net_attrs))
|
||||
raise exc.InvalidInput(error_message=msg)
|
||||
requested_provider_net_attrs = set(net_data) & provider_net_attrs
|
||||
for attr in requested_provider_net_attrs:
|
||||
if (validators.is_attr_set(net_data.get(attr)) and
|
||||
net_data.get(attr) != network[attr]):
|
||||
msg = (_('Plugin does not support updating the following '
|
||||
'provider network attributes: %s') %
|
||||
', '.join(provider_net_attrs))
|
||||
raise exc.InvalidInput(error_message=msg)
|
||||
|
||||
if net_data.get(provider_net.SEGMENTATION_ID):
|
||||
self._update_segmentation_id(context, network, net_data)
|
||||
|
||||
def _delete_objects(self, context, resource, objects):
|
||||
delete_op = getattr(self, 'delete_%s' % resource)
|
||||
|
|
|
@ -421,11 +421,18 @@ class TestMl2NetworksV2(test_plugin.TestNetworksV2,
|
|||
self.assertEqual(3, f.call_count)
|
||||
retry_fixture.cleanUp()
|
||||
|
||||
def test__update_provider_network_attributes_no_segmentation_id(self):
|
||||
def test__update_provider_network_attributes_update_attrs(self):
|
||||
plugin = directory.get_plugin()
|
||||
with self.network() as net:
|
||||
kwargs = {'arg_list': (pnet.NETWORK_TYPE, ),
|
||||
pnet.NETWORK_TYPE: 'vlan'}
|
||||
with self.network(**kwargs) as net:
|
||||
for attribute in set(pnet.ATTRIBUTES) - {pnet.SEGMENTATION_ID}:
|
||||
net_data = {attribute: 'attribute_value'}
|
||||
net_data = {attribute: net['network'][attribute]}
|
||||
self.assertIsNone(
|
||||
plugin._update_provider_network_attributes(
|
||||
self.context, net['network'], net_data))
|
||||
|
||||
net_data = {attribute: 'other_value'}
|
||||
self.assertRaises(
|
||||
exc.InvalidInput,
|
||||
plugin._update_provider_network_attributes,
|
||||
|
|
Loading…
Reference in New Issue