Clean-up L3 constant TODOs
Since the refactor is complete, let's clean these up and use neutron-lib constants instead. Trivialfix Change-Id: Ic69d59d53ee78a4c6eb0104583755c4145fb8e46
This commit is contained in:
parent
55bda46c47
commit
3fec181772
@ -38,7 +38,6 @@ from neutron.agent.l3 import l3_agent_extension_api as l3_ext_api
|
||||
from neutron.agent.l3 import l3_agent_extensions_manager as l3_ext_manager
|
||||
from neutron.agent.l3 import legacy_router
|
||||
from neutron.agent.l3 import namespace_manager
|
||||
from neutron.agent.l3 import namespaces
|
||||
from neutron.agent.l3 import router_processing_queue as queue
|
||||
from neutron.agent.linux import external_process
|
||||
from neutron.agent.linux import ip_lib
|
||||
@ -58,10 +57,6 @@ from neutron import context as n_context
|
||||
from neutron import manager
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
# TODO(Carl) Following constants retained to increase SNR during refactoring
|
||||
NS_PREFIX = namespaces.NS_PREFIX
|
||||
INTERNAL_DEV_PREFIX = namespaces.INTERNAL_DEV_PREFIX
|
||||
EXTERNAL_DEV_PREFIX = namespaces.EXTERNAL_DEV_PREFIX
|
||||
|
||||
# Number of routers to fetch from server at a time on resync.
|
||||
# Needed to reduce load on server side and to speed up resync on agent side.
|
||||
|
@ -15,12 +15,6 @@
|
||||
import weakref
|
||||
|
||||
from neutron.agent.l3 import dvr_fip_ns
|
||||
from neutron.agent.l3 import dvr_snat_ns
|
||||
|
||||
|
||||
# TODO(Carl) Following constants retained to increase SNR during refactoring
|
||||
SNAT_INT_DEV_PREFIX = dvr_snat_ns.SNAT_INT_DEV_PREFIX
|
||||
SNAT_NS_PREFIX = dvr_snat_ns.SNAT_NS_PREFIX
|
||||
|
||||
|
||||
class AgentMixin(object):
|
||||
|
@ -16,7 +16,6 @@
|
||||
from neutron_lib import constants
|
||||
|
||||
from neutron.agent.l3 import dvr_edge_router
|
||||
from neutron.agent.l3 import dvr_snat_ns
|
||||
from neutron.agent.l3 import ha_router
|
||||
from neutron.agent.l3 import router_info
|
||||
|
||||
@ -56,7 +55,7 @@ class DvrEdgeHaRouter(dvr_edge_router.DvrEdgeRouter,
|
||||
self._plug_ha_router_port(
|
||||
sn_port,
|
||||
self._get_snat_int_device_name,
|
||||
dvr_snat_ns.SNAT_INT_DEV_PREFIX)
|
||||
constants.SNAT_INT_DEV_PREFIX)
|
||||
|
||||
def external_gateway_added(self, ex_gw_port, interface_name):
|
||||
super(DvrEdgeHaRouter, self).external_gateway_added(
|
||||
@ -114,5 +113,5 @@ class DvrEdgeHaRouter(dvr_edge_router.DvrEdgeRouter,
|
||||
self.driver.plug(port['network_id'], port['id'],
|
||||
interface_name, port['mac_address'],
|
||||
namespace=self.snat_namespace.name,
|
||||
prefix=dvr_snat_ns.SNAT_INT_DEV_PREFIX,
|
||||
prefix=constants.SNAT_INT_DEV_PREFIX,
|
||||
mtu=port.get('mtu'))
|
||||
|
@ -112,7 +112,7 @@ class DvrEdgeRouter(dvr_local_router.DvrLocalRouter):
|
||||
sn_port['fixed_ips'],
|
||||
sn_port['mac_address'],
|
||||
interface_name,
|
||||
dvr_snat_ns.SNAT_INT_DEV_PREFIX,
|
||||
lib_constants.SNAT_INT_DEV_PREFIX,
|
||||
mtu=sn_port.get('mtu'))
|
||||
|
||||
def _dvr_internal_network_removed(self, port):
|
||||
@ -130,7 +130,7 @@ class DvrEdgeRouter(dvr_local_router.DvrLocalRouter):
|
||||
|
||||
snat_interface = self._get_snat_int_device_name(sn_port['id'])
|
||||
ns_name = self.snat_namespace.name
|
||||
prefix = dvr_snat_ns.SNAT_INT_DEV_PREFIX
|
||||
prefix = lib_constants.SNAT_INT_DEV_PREFIX
|
||||
if ip_lib.device_exists(snat_interface, namespace=ns_name):
|
||||
self.driver.unplug(snat_interface, namespace=ns_name,
|
||||
prefix=prefix)
|
||||
@ -141,7 +141,7 @@ class DvrEdgeRouter(dvr_local_router.DvrLocalRouter):
|
||||
self.snat_namespace.name, port['network_id'],
|
||||
port['id'], port['fixed_ips'],
|
||||
port['mac_address'], interface_name,
|
||||
dvr_snat_ns.SNAT_INT_DEV_PREFIX,
|
||||
lib_constants.SNAT_INT_DEV_PREFIX,
|
||||
mtu=port.get('mtu'))
|
||||
|
||||
def _create_dvr_gateway(self, ex_gw_port, gw_interface_name):
|
||||
@ -166,7 +166,7 @@ class DvrEdgeRouter(dvr_local_router.DvrLocalRouter):
|
||||
return self.snat_namespace
|
||||
|
||||
def _get_snat_int_device_name(self, port_id):
|
||||
long_name = dvr_snat_ns.SNAT_INT_DEV_PREFIX + port_id
|
||||
long_name = lib_constants.SNAT_INT_DEV_PREFIX + port_id
|
||||
return long_name[:self.driver.DEV_NAME_LEN]
|
||||
|
||||
def _is_this_snat_host(self):
|
||||
|
@ -18,7 +18,6 @@ from neutron.agent.linux import ip_lib
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
SNAT_NS_PREFIX = 'snat-'
|
||||
SNAT_INT_DEV_PREFIX = constants.SNAT_INT_DEV_PREFIX
|
||||
|
||||
|
||||
class SnatNamespace(namespaces.Namespace):
|
||||
@ -43,10 +42,10 @@ class SnatNamespace(namespaces.Namespace):
|
||||
def delete(self):
|
||||
ns_ip = ip_lib.IPWrapper(namespace=self.name)
|
||||
for d in ns_ip.get_devices(exclude_loopback=True):
|
||||
if d.name.startswith(SNAT_INT_DEV_PREFIX):
|
||||
if d.name.startswith(constants.SNAT_INT_DEV_PREFIX):
|
||||
LOG.debug('Unplugging DVR device %s', d.name)
|
||||
self.driver.unplug(d.name, namespace=self.name,
|
||||
prefix=SNAT_INT_DEV_PREFIX)
|
||||
prefix=constants.SNAT_INT_DEV_PREFIX)
|
||||
elif d.name.startswith(namespaces.EXTERNAL_DEV_PREFIX):
|
||||
self.driver.unplug(
|
||||
d.name,
|
||||
|
@ -25,9 +25,9 @@ from oslo_utils import importutils
|
||||
from neutron._i18n import _LE
|
||||
from neutron.agent.common import config as agent_config
|
||||
from neutron.agent.common import ovs_lib
|
||||
from neutron.agent.l3 import agent as l3_agent
|
||||
from neutron.agent.l3 import dvr
|
||||
from neutron.agent.l3 import dvr_fip_ns
|
||||
from neutron.agent.l3 import dvr_snat_ns
|
||||
from neutron.agent.l3 import namespaces
|
||||
from neutron.agent.linux import dhcp
|
||||
from neutron.agent.linux import external_process
|
||||
from neutron.agent.linux import interface
|
||||
@ -41,7 +41,8 @@ LOG = logging.getLogger(__name__)
|
||||
LB_NS_PREFIX = 'qlbaas-'
|
||||
NS_PREFIXES = {
|
||||
'dhcp': [dhcp.NS_PREFIX],
|
||||
'l3': [l3_agent.NS_PREFIX, dvr.SNAT_NS_PREFIX, dvr_fip_ns.FIP_NS_PREFIX],
|
||||
'l3': [namespaces.NS_PREFIX, dvr_snat_ns.SNAT_NS_PREFIX,
|
||||
dvr_fip_ns.FIP_NS_PREFIX],
|
||||
'lbaas': [LB_NS_PREFIX],
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,6 @@ import netaddr
|
||||
from neutron_lib import constants
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from neutron.agent.l3 import agent as l3_agent
|
||||
from neutron.agent.l3 import namespaces
|
||||
from neutron.agent.linux import ip_lib
|
||||
from neutron.common import utils as common_utils
|
||||
@ -85,7 +84,7 @@ class TestLegacyL3Agent(TestL3Agent):
|
||||
super(TestLegacyL3Agent, self).setUp(env)
|
||||
|
||||
def _get_namespace(self, router_id):
|
||||
return namespaces.build_ns_name(l3_agent.NS_PREFIX, router_id)
|
||||
return namespaces.build_ns_name(namespaces.NS_PREFIX, router_id)
|
||||
|
||||
def _assert_namespace_exists(self, ns_name):
|
||||
ip = ip_lib.IPWrapper(ns_name)
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
import mock
|
||||
|
||||
from neutron.agent.l3 import agent as l3_agent
|
||||
from neutron.agent.l3 import namespaces
|
||||
from neutron.agent.linux import dhcp
|
||||
from neutron.agent.linux import ip_lib
|
||||
from neutron.cmd import netns_cleanup
|
||||
@ -50,7 +50,7 @@ class NetnsCleanupTest(base.BaseSudoTestCase):
|
||||
dhcp_namespace = self.useFixture(
|
||||
net_helpers.NamespaceFixture(dhcp.NS_PREFIX)).name
|
||||
l3_namespace = self.useFixture(
|
||||
net_helpers.NamespaceFixture(l3_agent.NS_PREFIX)).name
|
||||
net_helpers.NamespaceFixture(namespaces.NS_PREFIX)).name
|
||||
bridge = self.useFixture(
|
||||
net_helpers.VethPortFixture(namespace=dhcp_namespace)).bridge
|
||||
self.useFixture(
|
||||
|
@ -398,7 +398,7 @@ class TestBasicRouterOperations(BasicRouterOperationsFramework):
|
||||
sn_port['fixed_ips'],
|
||||
sn_port['mac_address'],
|
||||
ri._get_snat_int_device_name(sn_port['id']),
|
||||
dvr_snat_ns.SNAT_INT_DEV_PREFIX,
|
||||
lib_constants.SNAT_INT_DEV_PREFIX,
|
||||
mtu=None)
|
||||
elif action == 'remove':
|
||||
self.device_exists.return_value = False
|
||||
@ -717,7 +717,7 @@ class TestBasicRouterOperations(BasicRouterOperationsFramework):
|
||||
interface_name,
|
||||
bridge=self.conf.external_network_bridge,
|
||||
namespace=snat_ns_name,
|
||||
prefix=l3_agent.EXTERNAL_DEV_PREFIX)
|
||||
prefix=namespaces.EXTERNAL_DEV_PREFIX)
|
||||
else:
|
||||
if not snat_hosted_before:
|
||||
self.assertIsNotNone(ri.snat_namespace)
|
||||
@ -1860,7 +1860,7 @@ class TestBasicRouterOperations(BasicRouterOperationsFramework):
|
||||
self.mock_driver.unplug.call_count)
|
||||
calls = [mock.call(stale_devname,
|
||||
namespace=ri.ns_name,
|
||||
prefix=l3_agent.INTERNAL_DEV_PREFIX)
|
||||
prefix=namespaces.INTERNAL_DEV_PREFIX)
|
||||
for stale_devname in stale_devnames]
|
||||
self.mock_driver.unplug.assert_has_calls(calls, any_order=True)
|
||||
|
||||
@ -1882,7 +1882,7 @@ class TestBasicRouterOperations(BasicRouterOperationsFramework):
|
||||
stale_devnames[0],
|
||||
bridge="",
|
||||
namespace=ri.ns_name,
|
||||
prefix=l3_agent.EXTERNAL_DEV_PREFIX)
|
||||
prefix=namespaces.EXTERNAL_DEV_PREFIX)
|
||||
|
||||
def test_router_deleted(self):
|
||||
agent = l3_agent.L3NATAgent(HOSTNAME, self.conf)
|
||||
@ -1955,10 +1955,10 @@ class TestBasicRouterOperations(BasicRouterOperationsFramework):
|
||||
calls = [mock.call('qg-aaaa',
|
||||
bridge=agent.conf.external_network_bridge,
|
||||
namespace=namespace,
|
||||
prefix=l3_agent.EXTERNAL_DEV_PREFIX),
|
||||
prefix=namespaces.EXTERNAL_DEV_PREFIX),
|
||||
mock.call('sg-aaaa',
|
||||
namespace=namespace,
|
||||
prefix=dvr_snat_ns.SNAT_INT_DEV_PREFIX)]
|
||||
prefix=lib_constants.SNAT_INT_DEV_PREFIX)]
|
||||
self.mock_driver.unplug.assert_has_calls(calls, any_order=True)
|
||||
|
||||
def _configure_metadata_proxy(self, enableflag=True):
|
||||
|
Loading…
Reference in New Issue
Block a user