]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commit
Improve performance of ensure_namespace
authorJohn Kasperski <jckasper@us.ibm.com>
Thu, 24 Sep 2015 23:16:18 +0000 (18:16 -0500)
committerJohn Kasperski <jckasper@linux.vnet.ibm.com>
Tue, 13 Oct 2015 20:29:59 +0000 (20:29 +0000)
commit81823e86328e62850a89aef9f0b609bfc0a6dacd
tree9bf04f556c60f7ed9a8676ecf523c2636bb49c64
parentbadb221bb0c0290d61dea73f62e73059defc493c
Improve performance of ensure_namespace

The ensure_namespace method calls IpNetnsCommand.exists to
determine if the specified namespace exists or not.  This is
accomplished by listing all namespaces with "ip netns list"
and then looping through the output to determine if the specified
namespace was included in the output.

Research of various Linux operating systems has indicated that
namespaces are represented as files in /var/run/netns and root
authority is "typically" not required in order to look at the
files in this subdirectory.

The existing configuration option "use_helper_for_ns_read"
will be used to determine if the root-helper should be used to
to retrieve the list of namespaces.  If this configuraton option
is set to False, the native python os.listdir(/var/run/netns)
will be used.

Related-Bug: #1311804
Closes-Bug: #1497396
Change-Id: I9da627d07d6cbb6e5ef1a921a5f22963317a04e2
neutron/agent/linux/ip_lib.py
neutron/tests/functional/agent/linux/test_ip_lib.py
neutron/tests/unit/agent/linux/test_ip_lib.py