Implement providernet._raise_if_updates_provider_attributes internally
Function [1] is a private function in Neutron and should not be imported in other projects. Also this function is removed in [2], while implementing the related bug. Related-Bug: #1806052 [1] https://github.com/openstack/neutron/blob/stable/stein/neutron/extensions/providernet.py#L24 [2] https://review.openstack.org/#/c/633165/ Change-Id: Ic6260fbe944062c8db7c888b77c3725b2f44c68c
This commit is contained in:
parent
8b48578f69
commit
33212a66eb
@ -26,9 +26,12 @@ import six
|
|||||||
import tenacity
|
import tenacity
|
||||||
from tenacity import _utils as tenacity_utils
|
from tenacity import _utils as tenacity_utils
|
||||||
|
|
||||||
|
from neutron._i18n import _
|
||||||
from neutron import version as n_version
|
from neutron import version as n_version
|
||||||
|
from neutron_lib.api.definitions import provider_net
|
||||||
from neutron_lib.api import validators
|
from neutron_lib.api import validators
|
||||||
from neutron_lib import constants
|
from neutron_lib import constants
|
||||||
|
from neutron_lib import exceptions as n_exc
|
||||||
from oslo_context import context as common_context
|
from oslo_context import context as common_context
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
|
|
||||||
@ -295,3 +298,15 @@ def spawn_n(func, *args, **kwargs):
|
|||||||
func(*args, **kwargs)
|
func(*args, **kwargs)
|
||||||
|
|
||||||
eventlet.spawn_n(context_wrapper, *args, **kwargs)
|
eventlet.spawn_n(context_wrapper, *args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
def raise_if_updates_provider_attributes(attrs):
|
||||||
|
"""Raise exception if provider attributes are present.
|
||||||
|
|
||||||
|
This method is used for plugins that do not support updating provider
|
||||||
|
network attributes.
|
||||||
|
"""
|
||||||
|
if any(validators.is_attr_set(attrs.get(a))
|
||||||
|
for a in provider_net.ATTRIBUTES):
|
||||||
|
msg = _("Plugin does not support updating provider attributes")
|
||||||
|
raise n_exc.InvalidInput(error_message=msg)
|
||||||
|
@ -47,7 +47,6 @@ from neutron.db import portbindings_db
|
|||||||
from neutron.db import portsecurity_db
|
from neutron.db import portsecurity_db
|
||||||
from neutron.db import securitygroups_db
|
from neutron.db import securitygroups_db
|
||||||
from neutron.db import vlantransparent_db as vlan_ext_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.extensions import securitygroup as ext_sg
|
||||||
from neutron.quota import resource_registry
|
from neutron.quota import resource_registry
|
||||||
|
|
||||||
@ -377,7 +376,7 @@ class NsxDvsV2(addr_pair_db.AllowedAddressPairsMixin,
|
|||||||
|
|
||||||
def update_network(self, context, id, network):
|
def update_network(self, context, id, network):
|
||||||
net_attrs = network['network']
|
net_attrs = network['network']
|
||||||
providernet._raise_if_updates_provider_attributes(net_attrs)
|
c_utils.raise_if_updates_provider_attributes(net_attrs)
|
||||||
|
|
||||||
with db_api.CONTEXT_WRITER.using(context):
|
with db_api.CONTEXT_WRITER.using(context):
|
||||||
net_res = super(NsxDvsV2, self).update_network(context, id,
|
net_res = super(NsxDvsV2, self).update_network(context, id,
|
||||||
|
@ -69,7 +69,6 @@ from neutron.db import models_v2
|
|||||||
from neutron.db import portbindings_db
|
from neutron.db import portbindings_db
|
||||||
from neutron.db import portsecurity_db
|
from neutron.db import portsecurity_db
|
||||||
from neutron.db import securitygroups_db
|
from neutron.db import securitygroups_db
|
||||||
from neutron.extensions import providernet
|
|
||||||
from neutron.extensions import securitygroup as ext_sg
|
from neutron.extensions import securitygroup as ext_sg
|
||||||
from neutron.quota import resource_registry
|
from neutron.quota import resource_registry
|
||||||
|
|
||||||
@ -1070,7 +1069,7 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
|
|||||||
fields) for network in networks])
|
fields) for network in networks])
|
||||||
|
|
||||||
def update_network(self, context, id, network):
|
def update_network(self, context, id, network):
|
||||||
providernet._raise_if_updates_provider_attributes(network['network'])
|
c_utils.raise_if_updates_provider_attributes(network['network'])
|
||||||
if network["network"].get("admin_state_up") is False:
|
if network["network"].get("admin_state_up") is False:
|
||||||
raise NotImplementedError(_("admin_state_up=False networks "
|
raise NotImplementedError(_("admin_state_up=False networks "
|
||||||
"are not supported."))
|
"are not supported."))
|
||||||
|
@ -26,7 +26,6 @@ from neutron.db import l3_db
|
|||||||
from neutron.db.models import l3 as l3_db_models
|
from neutron.db.models import l3 as l3_db_models
|
||||||
from neutron.db.models import securitygroup as securitygroup_model # noqa
|
from neutron.db.models import securitygroup as securitygroup_model # noqa
|
||||||
from neutron.db import models_v2
|
from neutron.db import models_v2
|
||||||
from neutron.extensions import providernet
|
|
||||||
from neutron.extensions import securitygroup as ext_sg
|
from neutron.extensions import securitygroup as ext_sg
|
||||||
from neutron.quota import resource_registry
|
from neutron.quota import resource_registry
|
||||||
from neutron_lib.api.definitions import address_scope
|
from neutron_lib.api.definitions import address_scope
|
||||||
@ -675,7 +674,7 @@ class NsxPolicyPlugin(nsx_plugin_common.NsxPluginV3Base):
|
|||||||
self._assert_on_resource_admin_state_down(net_data)
|
self._assert_on_resource_admin_state_down(net_data)
|
||||||
|
|
||||||
# Neutron does not support changing provider network values
|
# Neutron does not support changing provider network values
|
||||||
providernet._raise_if_updates_provider_attributes(net_data)
|
utils.raise_if_updates_provider_attributes(net_data)
|
||||||
extern_net = self._network_is_external(context, network_id)
|
extern_net = self._network_is_external(context, network_id)
|
||||||
is_nsx_net = self._network_is_nsx_net(context, network_id)
|
is_nsx_net = self._network_is_nsx_net(context, network_id)
|
||||||
|
|
||||||
|
@ -91,7 +91,6 @@ from neutron.db import models_v2
|
|||||||
from neutron.db import portsecurity_db
|
from neutron.db import portsecurity_db
|
||||||
from neutron.db import securitygroups_db
|
from neutron.db import securitygroups_db
|
||||||
from neutron.db import vlantransparent_db
|
from neutron.db import vlantransparent_db
|
||||||
from neutron.extensions import providernet
|
|
||||||
from neutron.extensions import securitygroup as ext_sg
|
from neutron.extensions import securitygroup as ext_sg
|
||||||
from neutron.quota import resource_registry
|
from neutron.quota import resource_registry
|
||||||
from neutron.services.flavors import flavors_plugin
|
from neutron.services.flavors import flavors_plugin
|
||||||
@ -1676,7 +1675,7 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
|
|||||||
not validators.is_attr_set(
|
not validators.is_attr_set(
|
||||||
attrs.get(pnet.SEGMENTATION_ID))):
|
attrs.get(pnet.SEGMENTATION_ID))):
|
||||||
return
|
return
|
||||||
providernet._raise_if_updates_provider_attributes(attrs)
|
c_utils.raise_if_updates_provider_attributes(attrs)
|
||||||
|
|
||||||
def _update_vlan_network_dvs_ids(self, context, network,
|
def _update_vlan_network_dvs_ids(self, context, network,
|
||||||
new_physical_network, az_dvs):
|
new_physical_network, az_dvs):
|
||||||
|
@ -58,7 +58,6 @@ from neutron.db import l3_db
|
|||||||
from neutron.db.models import l3 as l3_db_models
|
from neutron.db.models import l3 as l3_db_models
|
||||||
from neutron.db.models import securitygroup as securitygroup_model # noqa
|
from neutron.db.models import securitygroup as securitygroup_model # noqa
|
||||||
from neutron.db import models_v2
|
from neutron.db import models_v2
|
||||||
from neutron.extensions import providernet
|
|
||||||
from neutron.extensions import securitygroup as ext_sg
|
from neutron.extensions import securitygroup as ext_sg
|
||||||
from neutron.quota import resource_registry
|
from neutron.quota import resource_registry
|
||||||
|
|
||||||
@ -1075,7 +1074,7 @@ class NsxV3Plugin(nsx_plugin_common.NsxPluginV3Base,
|
|||||||
original_net = super(NsxV3Plugin, self).get_network(context, id)
|
original_net = super(NsxV3Plugin, self).get_network(context, id)
|
||||||
net_data = network['network']
|
net_data = network['network']
|
||||||
# Neutron does not support changing provider network values
|
# Neutron does not support changing provider network values
|
||||||
providernet._raise_if_updates_provider_attributes(net_data)
|
utils.raise_if_updates_provider_attributes(net_data)
|
||||||
extern_net = self._network_is_external(context, id)
|
extern_net = self._network_is_external(context, id)
|
||||||
is_nsx_net = self._network_is_nsx_net(context, id)
|
is_nsx_net = self._network_is_nsx_net(context, id)
|
||||||
is_ens_net = self._is_ens_tz_net(context, id)
|
is_ens_net = self._is_ens_tz_net(context, id)
|
||||||
|
Loading…
Reference in New Issue
Block a user