Use neutron-lib provider net api-def
This patch refactors vmware-nsx to use provider net from neutron-lib. For more details see [1]. Also note that vmware-nsx code uses the private API _raise_if_updates_provider_attributes(). While it's a bad practice to use private APIs, I've submitted a patch to try and get it into lib [2]. NeutronLibImpact [1] https://review.openstack.org/421562/ [2] https://review.openstack.org/421961/ Change-Id: I340550a5564c5bbff2e20745f21a8c97a64b7395
This commit is contained in:
parent
fa2ac151fc
commit
96188c66a5
@ -14,7 +14,7 @@
|
||||
# under the License.
|
||||
|
||||
from neutron.extensions import multiprovidernet as mpnet
|
||||
from neutron.extensions import providernet as pnet
|
||||
from neutron_lib.api.definitions import provider_net as pnet
|
||||
from neutron_lib.api import validators
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import exceptions as n_exc
|
||||
|
@ -34,11 +34,12 @@ from neutron.extensions import allowedaddresspairs as addr_pair
|
||||
from neutron.extensions import multiprovidernet as mpnet
|
||||
from neutron.extensions import portbindings as pbin
|
||||
from neutron.extensions import portsecurity as psec
|
||||
from neutron.extensions import providernet as pnet
|
||||
from neutron.extensions import providernet
|
||||
from neutron.extensions import securitygroup as ext_sg
|
||||
from neutron.plugins.common import constants
|
||||
from neutron.plugins.common import utils
|
||||
from neutron.quota import resource_registry
|
||||
from neutron_lib.api.definitions import provider_net as pnet
|
||||
from neutron_lib.api import validators
|
||||
from neutron_lib import exceptions as n_exc
|
||||
|
||||
@ -282,7 +283,7 @@ class NsxDvsV2(addr_pair_db.AllowedAddressPairsMixin,
|
||||
|
||||
def update_network(self, context, id, network):
|
||||
net_attrs = network['network']
|
||||
pnet._raise_if_updates_provider_attributes(net_attrs)
|
||||
providernet._raise_if_updates_provider_attributes(net_attrs)
|
||||
|
||||
with context.session.begin(subtransactions=True):
|
||||
net_res = super(NsxDvsV2, self).update_network(context, id,
|
||||
|
@ -59,11 +59,12 @@ from neutron.extensions import l3
|
||||
from neutron.extensions import multiprovidernet as mpnet
|
||||
from neutron.extensions import portbindings as pbin
|
||||
from neutron.extensions import portsecurity as psec
|
||||
from neutron.extensions import providernet as pnet
|
||||
from neutron.extensions import providernet
|
||||
from neutron.extensions import securitygroup as ext_sg
|
||||
from neutron.plugins.common import constants as plugin_const
|
||||
from neutron.plugins.common import utils
|
||||
from neutron.quota import resource_registry
|
||||
from neutron_lib.api.definitions import provider_net as pnet
|
||||
|
||||
import vmware_nsx
|
||||
from vmware_nsx._i18n import _, _LE, _LI, _LW
|
||||
@ -1063,7 +1064,7 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
|
||||
fields) for network in networks])
|
||||
|
||||
def update_network(self, context, id, network):
|
||||
pnet._raise_if_updates_provider_attributes(network['network'])
|
||||
providernet._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."))
|
||||
|
@ -69,13 +69,14 @@ from neutron.extensions import l3
|
||||
from neutron.extensions import multiprovidernet as mpnet
|
||||
from neutron.extensions import portbindings as pbin
|
||||
from neutron.extensions import portsecurity as psec
|
||||
from neutron.extensions import providernet as pnet
|
||||
from neutron.extensions import providernet
|
||||
from neutron.extensions import securitygroup as ext_sg
|
||||
from neutron.plugins.common import constants as plugin_const
|
||||
from neutron.plugins.common import utils
|
||||
from neutron.quota import resource_registry
|
||||
from neutron.services.flavors import flavors_plugin
|
||||
from neutron.services.qos import qos_consts
|
||||
from neutron_lib.api.definitions import provider_net as pnet
|
||||
from vmware_nsx.dvs import dvs
|
||||
from vmware_nsx.services.qos.common import utils as qos_com_utils
|
||||
from vmware_nsx.services.qos.nsx_v import utils as qos_utils
|
||||
@ -1307,7 +1308,7 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
|
||||
net_attrs = network['network']
|
||||
original_network = self.get_network(context, id)
|
||||
|
||||
pnet._raise_if_updates_provider_attributes(net_attrs)
|
||||
providernet._raise_if_updates_provider_attributes(net_attrs)
|
||||
if net_attrs.get("admin_state_up") is False:
|
||||
raise NotImplementedError(_("admin_state_up=False networks "
|
||||
"are not supported."))
|
||||
|
@ -56,12 +56,13 @@ from neutron.extensions import extra_dhcp_opt as ext_edo
|
||||
from neutron.extensions import l3
|
||||
from neutron.extensions import portbindings as pbin
|
||||
from neutron.extensions import portsecurity as psec
|
||||
from neutron.extensions import providernet as pnet
|
||||
from neutron.extensions import providernet
|
||||
from neutron.extensions import securitygroup as ext_sg
|
||||
from neutron.plugins.common import constants as plugin_const
|
||||
from neutron.plugins.common import utils as n_utils
|
||||
from neutron.quota import resource_registry
|
||||
from neutron.services.qos import qos_consts
|
||||
from neutron_lib.api.definitions import provider_net as pnet
|
||||
from neutron_lib.api import validators
|
||||
from neutron_lib import constants as const
|
||||
from neutron_lib import exceptions as n_exc
|
||||
@ -918,7 +919,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
|
||||
pnet._raise_if_updates_provider_attributes(net_data)
|
||||
providernet._raise_if_updates_provider_attributes(net_data)
|
||||
extern_net = self._network_is_external(context, id)
|
||||
if extern_net:
|
||||
self._assert_on_external_net_with_qos(net_data)
|
||||
|
@ -21,9 +21,9 @@ from oslo_log import log as logging
|
||||
|
||||
from neutron.extensions import external_net as ext_net_extn
|
||||
from neutron.extensions import multiprovidernet as mpnet
|
||||
from neutron.extensions import providernet as pnet
|
||||
from neutron.ipam import exceptions as ipam_exc
|
||||
from neutron.ipam import requests as ipam_req
|
||||
from neutron_lib.api.definitions import provider_net as pnet
|
||||
from neutron_lib.api import validators
|
||||
|
||||
from vmware_nsx._i18n import _, _LE
|
||||
|
@ -27,8 +27,8 @@ from neutron.callbacks import events
|
||||
from neutron.callbacks import registry
|
||||
from neutron.callbacks import resources
|
||||
from neutron import context
|
||||
from neutron.extensions import providernet
|
||||
from neutron.plugins.common import utils as n_utils
|
||||
from neutron_lib.api.definitions import provider_net as providernet
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from neutron_lib.plugins import directory
|
||||
|
@ -17,7 +17,7 @@ from oslo_config import cfg
|
||||
import webob.exc
|
||||
|
||||
from neutron.extensions import multiprovidernet as mpnet
|
||||
from neutron.extensions import providernet as pnet
|
||||
from neutron_lib.api.definitions import provider_net as pnet
|
||||
from vmware_nsx.tests import unit as vmware
|
||||
from vmware_nsx.tests.unit.nsx_mh import test_plugin as test_nsx_plugin
|
||||
|
||||
|
@ -23,7 +23,6 @@ from neutron.extensions import external_net
|
||||
from neutron.extensions import l3
|
||||
from neutron.extensions import l3_ext_gw_mode
|
||||
from neutron.extensions import portbindings
|
||||
from neutron.extensions import providernet as pnet
|
||||
from neutron.extensions import securitygroup as secgrp
|
||||
from neutron.tests.unit import _test_extension_portbindings as test_bindings
|
||||
import neutron.tests.unit.db.test_db_base_plugin_v2 as test_plugin
|
||||
@ -32,6 +31,7 @@ import neutron.tests.unit.extensions.test_l3 as test_l3_plugin
|
||||
import neutron.tests.unit.extensions.test_l3_ext_gw_mode as test_ext_gw_mode
|
||||
import neutron.tests.unit.extensions.test_securitygroup as ext_sg
|
||||
from neutron.tests.unit import testlib_api
|
||||
from neutron_lib.api.definitions import provider_net as pnet
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import exceptions as ntn_exc
|
||||
from neutron_lib.plugins import directory
|
||||
|
@ -16,8 +16,8 @@
|
||||
import mock
|
||||
from neutron.db import api as db_api
|
||||
from neutron.extensions import multiprovidernet as mpnet
|
||||
from neutron.extensions import providernet as pnet
|
||||
from neutron.tests import base
|
||||
from neutron_lib.api.definitions import provider_net as pnet
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from vmware_nsx.api_client import exception as api_exc
|
||||
|
@ -28,7 +28,6 @@ from neutron.extensions import l3
|
||||
from neutron.extensions import l3_ext_gw_mode
|
||||
from neutron.extensions import l3_flavors
|
||||
from neutron.extensions import portbindings
|
||||
from neutron.extensions import providernet as pnet
|
||||
from neutron.extensions import router_availability_zone
|
||||
from neutron.extensions import securitygroup as secgrp
|
||||
from neutron.objects.qos import policy as qos_pol
|
||||
@ -43,6 +42,7 @@ import neutron.tests.unit.extensions.test_l3_ext_gw_mode as test_ext_gw_mode
|
||||
import neutron.tests.unit.extensions.test_portsecurity as test_psec
|
||||
import neutron.tests.unit.extensions.test_securitygroup as ext_sg
|
||||
from neutron.tests.unit import testlib_api
|
||||
from neutron_lib.api.definitions import provider_net as pnet
|
||||
from neutron_lib.api import validators
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import exceptions as n_exc
|
||||
|
@ -17,9 +17,9 @@ import mock
|
||||
import netaddr
|
||||
|
||||
from neutron import context
|
||||
from neutron.extensions import providernet as pnet
|
||||
from neutron.extensions import securitygroup as secgrp
|
||||
|
||||
from neutron_lib.api.definitions import provider_net as pnet
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from oslo_config import cfg
|
||||
|
@ -25,7 +25,6 @@ from neutron.extensions import extraroute
|
||||
from neutron.extensions import l3
|
||||
from neutron.extensions import l3_ext_gw_mode
|
||||
from neutron.extensions import portbindings
|
||||
from neutron.extensions import providernet as pnet
|
||||
from neutron.extensions import securitygroup as secgrp
|
||||
from neutron.tests.unit import _test_extension_portbindings as test_bindings
|
||||
from neutron.tests.unit.db import test_db_base_plugin_v2 as test_plugin
|
||||
@ -37,6 +36,7 @@ from neutron.tests.unit.extensions \
|
||||
from neutron.tests.unit.scheduler \
|
||||
import test_dhcp_agent_scheduler as test_dhcpagent
|
||||
|
||||
from neutron_lib.api.definitions import provider_net as pnet
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from neutron_lib.plugins import directory
|
||||
|
@ -16,7 +16,7 @@ from oslo_config import cfg
|
||||
|
||||
from vmware_nsx.tests.unit.nsx_v import test_plugin
|
||||
|
||||
from neutron.extensions import providernet as pnet
|
||||
from neutron_lib.api.definitions import provider_net as pnet
|
||||
|
||||
|
||||
class TestNsxvIpamSubnets(test_plugin.TestSubnetsV2):
|
||||
|
Loading…
Reference in New Issue
Block a user