Merge "Don't use root to list namespaces"

This commit is contained in:
Jenkins 2014-03-20 05:20:19 +00:00 committed by Gerrit Code Review
commit 4e1a15c436
2 changed files with 5 additions and 5 deletions

View File

@ -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():

View File

@ -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'