Browse Source

Move raise_if_updates_provider_attributes in plugin

Do not leverage anymore the code from neutron extensions package.

Change-Id: Ifc5e19e8eb7276f4b24d26c30b0c5300c59c7463
changes/73/766573/5
Salvatore Orlando 4 months ago
committed by asarfaty
parent
commit
ef6cb79f46
5 changed files with 25 additions and 8 deletions
  1. +11
    -0
      vmware_nsx/plugins/common/plugin.py
  2. +1
    -2
      vmware_nsx/plugins/dvs/plugin.py
  3. +11
    -2
      vmware_nsx/plugins/nsx_mh/plugin.py
  4. +1
    -2
      vmware_nsx/plugins/nsx_v/plugin.py
  5. +1
    -2
      vmware_nsx/plugins/nsx_v3/plugin.py

+ 11
- 0
vmware_nsx/plugins/common/plugin.py View File

@ -27,6 +27,7 @@ from neutron_lib.api.definitions import address_scope as ext_address_scope
from neutron_lib.api.definitions import availability_zone as az_def
from neutron_lib.api.definitions import network as net_def
from neutron_lib.api.definitions import port as port_def
from neutron_lib.api.definitions import provider_net as pnet
from neutron_lib.api.definitions import subnet as subnet_def
from neutron_lib.api import validators
from neutron_lib.api.validators import availability_zone as az_validator
@ -382,6 +383,16 @@ class NsxPluginBase(db_base_plugin_v2.NeutronDbPluginV2,
"Default security group already created", tenant_id)
return self._get_default_sg_id(context, tenant_id)
def _raise_if_updates_provider_attributes(self, attrs):
"""Raise exception if provider attributes are present.
This method is used for plugins that do not support
updating provider networks.
"""
if any(validators.is_attr_set(attrs.get(a)) for a in pnet.ATTRIBUTES):
msg = _("Plugin does not support updating provider attributes")
raise n_exc.InvalidInput(error_message=msg)
# Register the callback
def _validate_network_has_subnet(resource, event, trigger, **kwargs):


+ 1
- 2
vmware_nsx/plugins/dvs/plugin.py View File

@ -38,7 +38,6 @@ from neutron.db import portbindings_db
from neutron.db import portsecurity_db
from neutron.db import securitygroups_db
from neutron.db import vlantransparent_db as vlan_ext_db
from neutron.extensions import providernet
from neutron.extensions import securitygroup as ext_sg
from neutron.plugins.common import utils
from neutron.quota import resource_registry
@ -339,7 +338,7 @@ class NsxDvsV2(addr_pair_db.AllowedAddressPairsMixin,
def update_network(self, context, id, network):
net_attrs = network['network']
providernet._raise_if_updates_provider_attributes(net_attrs)
self._raise_if_updates_provider_attributes(net_attrs)
with db_api.context_manager.writer.using(context):
net_res = super(NsxDvsV2, self).update_network(context, id,


+ 11
- 2
vmware_nsx/plugins/nsx_mh/plugin.py View File

@ -60,7 +60,6 @@ from neutron.db import portbindings_db
from neutron.db import portsecurity_db
from neutron.db import quota_db # noqa
from neutron.db import securitygroups_db
from neutron.extensions import providernet
from neutron.extensions import securitygroup as ext_sg
from neutron.plugins.common import utils
from neutron.quota import resource_registry
@ -1068,8 +1067,18 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
[db_utils.resource_fields(network,
fields) for network in networks])
def _raise_if_updates_provider_attributes(self, attrs):
"""Raise exception if provider attributes are present.
This method is used for plugins that do not support
updating provider networks.
"""
if any(validators.is_attr_set(attrs.get(a)) for a in pnet.ATTRIBUTES):
msg = _("Plugin does not support updating provider attributes")
raise n_exc.InvalidInput(error_message=msg)
def update_network(self, context, id, network):
providernet._raise_if_updates_provider_attributes(network['network'])
self._raise_if_updates_provider_attributes(network['network'])
if network["network"].get("admin_state_up") is False:
raise NotImplementedError(_("admin_state_up=False networks "
"are not supported."))


+ 1
- 2
vmware_nsx/plugins/nsx_v/plugin.py View File

@ -83,7 +83,6 @@ from neutron.db import portsecurity_db
from neutron.db import quota_db # noqa
from neutron.db import securitygroups_db
from neutron.db import vlantransparent_db
from neutron.extensions import providernet
from neutron.extensions import securitygroup as ext_sg
from neutron.objects import securitygroup
from neutron.plugins.common import utils
@ -1609,7 +1608,7 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
and not validators.is_attr_set(
attrs.get(pnet.SEGMENTATION_ID))):
return
providernet._raise_if_updates_provider_attributes(attrs)
super(NsxVPluginV2, self)._raise_if_updates_provider_attributes(attrs)
def _update_vlan_network_dvs_ids(self, context, network,
new_physical_network, az_dvs):


+ 1
- 2
vmware_nsx/plugins/nsx_v3/plugin.py View File

@ -59,7 +59,6 @@ from neutron.db import portbindings_db
from neutron.db import portsecurity_db
from neutron.db import securitygroups_db
from neutron.db import vlantransparent_db
from neutron.extensions import providernet
from neutron.extensions import securitygroup as ext_sg
from neutron.plugins.common import utils as n_utils
from neutron.plugins.ml2 import models as pbin_model
@ -1440,7 +1439,7 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
original_net = super(NsxV3Plugin, self).get_network(context, id)
net_data = network['network']
# Neutron does not support changing provider network values
providernet._raise_if_updates_provider_attributes(net_data)
self._raise_if_updates_provider_attributes(net_data)
self._validate_qos_policy_id(
context, net_data.get(qos_consts.QOS_POLICY_ID))
extern_net = self._network_is_external(context, id)


Loading…
Cancel
Save