summaryrefslogtreecommitdiffstats
path: root/build/neutron/agent/l3/namespaces.py
diff options
context:
space:
mode:
authorFeng Pan <fpan@redhat.com>2017-02-08 13:42:42 -0500
committerFeng Pan <fpan@redhat.com>2017-02-18 01:38:25 +0000
commitc7e6d15b4d2570c7f9d2bc8dcfc57d8a68fede71 (patch)
tree81dcdb87979d37fa4bf061e92db79d88dd7c6f82 /build/neutron/agent/l3/namespaces.py
parent89f0410672d80015c419f77e69a5bb155cac2bfe (diff)
Add support for odl-fdio scenario
Changes: - Kernel parameters are now set through first-boot.yaml during deployment. No custom images will be built. Note that all nodes will be configured the same way, we only use compute's kernel parameter settings currently (from deploy settings file) - Add support for VPP interface type in network settings file, it is now possible to specify vpp_interface type and uio_driver for tenant nic in network settings file. A new example config, network_settings_vpp.yaml is added. - Add support for odl_l2-fdio scenario. Limitations: - Physical NIC names must be specified in network settings file, numbered nic names such as nic1 are not supported for fdio scenarios. - The same kernel parameters will be configured for all nodes. The paramters will be taken from compute kernel parameter section in deploy settings file. opnfv-tht-pr: 104 opnfv-puppet-tripleo-pr: 12 os-net-config-pr: 3 Change-Id: Ie9d6151e6e58d11da3c66fbcabe4a0886c3fa152 Signed-off-by: Feng Pan <fpan@redhat.com>
Diffstat (limited to 'build/neutron/agent/l3/namespaces.py')
-rw-r--r--build/neutron/agent/l3/namespaces.py142
1 files changed, 0 insertions, 142 deletions
diff --git a/build/neutron/agent/l3/namespaces.py b/build/neutron/agent/l3/namespaces.py
deleted file mode 100644
index aa282052..00000000
--- a/build/neutron/agent/l3/namespaces.py
+++ /dev/null
@@ -1,142 +0,0 @@
-# Copyright 2015 Hewlett-Packard Development Company, L.P.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-#
-
-import functools
-
-from oslo_log import log as logging
-from oslo_utils import excutils
-
-from neutron.agent.linux.interface import OVSInterfaceDriver
-from neutron._i18n import _LE, _LW
-from neutron.agent.linux import ip_lib
-
-LOG = logging.getLogger(__name__)
-
-NS_PREFIX = 'qrouter-'
-INTERNAL_DEV_PREFIX = 'qr-'
-EXTERNAL_DEV_PREFIX = 'qg-'
-# TODO(Carl) It is odd that this file needs this. It is a dvr detail.
-ROUTER_2_FIP_DEV_PREFIX = 'rfp-'
-
-
-def build_ns_name(prefix, identifier):
- """Builds a namespace name from the given prefix and identifier
-
- :param prefix: The prefix which must end with '-' for legacy reasons
- :param identifier: The id associated with the namespace
- """
- return prefix + identifier
-
-
-def get_prefix_from_ns_name(ns_name):
- """Parses prefix from prefix-identifier
-
- :param ns_name: The name of a namespace
- :returns: The prefix ending with a '-' or None if there is no '-'
- """
- dash_index = ns_name.find('-')
- if 0 <= dash_index:
- return ns_name[:dash_index + 1]
-
-
-def get_id_from_ns_name(ns_name):
- """Parses identifier from prefix-identifier
-
- :param ns_name: The name of a namespace
- :returns: Identifier or None if there is no - to end the prefix
- """
- dash_index = ns_name.find('-')
- if 0 <= dash_index:
- return ns_name[dash_index + 1:]
-
-
-def check_ns_existence(f):
- @functools.wraps(f)
- def wrapped(self, *args, **kwargs):
- if not self.exists():
- LOG.warning(_LW('Namespace %(name)s does not exists. Skipping '
- '%(func)s'),
- {'name': self.name, 'func': f.__name__})
- return
- try:
- return f(self, *args, **kwargs)
- except RuntimeError:
- with excutils.save_and_reraise_exception() as ctx:
- if not self.exists():
- LOG.debug('Namespace %(name)s was concurrently deleted',
- self.name)
- ctx.reraise = False
- return wrapped
-
-
-class Namespace(object):
-
- def __init__(self, name, agent_conf, driver, use_ipv6):
- self.name = name
- self.ip_wrapper_root = ip_lib.IPWrapper()
- self.agent_conf = agent_conf
- self.driver = driver
- self.use_ipv6 = use_ipv6
-
- def create(self):
- ip_wrapper = self.ip_wrapper_root.ensure_namespace(self.name)
- cmd = ['sysctl', '-w', 'net.ipv4.ip_forward=1']
- ip_wrapper.netns.execute(cmd)
- if self.use_ipv6:
- cmd = ['sysctl', '-w', 'net.ipv6.conf.all.forwarding=1']
- ip_wrapper.netns.execute(cmd)
-
- def delete(self):
- try:
- self.ip_wrapper_root.netns.delete(self.name)
- except RuntimeError:
- msg = _LE('Failed trying to delete namespace: %s')
- LOG.exception(msg, self.name)
-
- def exists(self):
- return self.ip_wrapper_root.netns.exists(self.name)
-
-
-class RouterNamespace(Namespace):
-
- def __init__(self, router_id, agent_conf, driver, use_ipv6, ovs_driver):
- self.router_id = router_id
- self.ovs_driver = ovs_driver
- name = self._get_ns_name(router_id)
- super(RouterNamespace, self).__init__(
- name, agent_conf, driver, use_ipv6)
-
- @classmethod
- def _get_ns_name(cls, router_id):
- return build_ns_name(NS_PREFIX, router_id)
-
- @check_ns_existence
- 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(INTERNAL_DEV_PREFIX):
- # device is on default bridge
- self.driver.unplug(d.name, namespace=self.name,
- prefix=INTERNAL_DEV_PREFIX)
- elif d.name.startswith(ROUTER_2_FIP_DEV_PREFIX):
- ns_ip.del_veth(d.name)
- elif d.name.startswith(EXTERNAL_DEV_PREFIX):
- self.ovs_driver.unplug(
- d.name,
- bridge=self.agent_conf.external_network_bridge,
- namespace=self.name,
- prefix=EXTERNAL_DEV_PREFIX)
-
- super(RouterNamespace, self).delete()