From f1aae7c87439eaadedaa7d9ea76315110210a889 Mon Sep 17 00:00:00 2001 From: Carl Baldwin Date: Mon, 17 Mar 2014 22:19:04 +0000 Subject: [PATCH] Don't use root to list namespaces A bit of low hanging fruit. I just noticed that this hadn't been fixed yet. Change-Id: Iea9210098b6acf4ab24a89287529ff82986faaad Closes-Bug: #1293818 --- neutron/agent/linux/ip_lib.py | 2 +- neutron/tests/unit/test_linux_ip_lib.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/neutron/agent/linux/ip_lib.py b/neutron/agent/linux/ip_lib.py index 297c566f8e..80302aea2d 100644 --- a/neutron/agent/linux/ip_lib.py +++ b/neutron/agent/linux/ip_lib.py @@ -466,7 +466,7 @@ class IpNetnsCommand(IpCommandBase): check_exit_code=check_exit_code) def exists(self, name): - output = self._as_root('list', options='o', use_root_namespace=True) + output = self._run('list', options='o') for line in output.split('\n'): if name == line.strip(): diff --git a/neutron/tests/unit/test_linux_ip_lib.py b/neutron/tests/unit/test_linux_ip_lib.py index 499153c3a3..74f47ccf67 100644 --- a/neutron/tests/unit/test_linux_ip_lib.py +++ b/neutron/tests/unit/test_linux_ip_lib.py @@ -713,17 +713,17 @@ class TestIpNetnsCommand(TestIPCmdBase): def test_namespace_exists(self): retval = '\n'.join(NETNS_SAMPLE) - self.parent._as_root.return_value = retval + self.parent._run.return_value = retval self.assertTrue( self.netns_cmd.exists('bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb')) - self._assert_sudo('o', ('list',), force_root_namespace=True) + self._assert_call('o', ('list',)) def test_namespace_doest_not_exist(self): retval = '\n'.join(NETNS_SAMPLE) - self.parent._as_root.return_value = retval + self.parent._run.return_value = retval self.assertFalse( self.netns_cmd.exists('bbbbbbbb-1111-2222-3333-bbbbbbbbbbbb')) - self._assert_sudo('o', ('list',), force_root_namespace=True) + self._assert_call('o', ('list',)) def test_execute(self): self.parent.namespace = 'ns'