Merge "Fix IpNetnsCommand to execute without root_wrapper when no netns"
This commit is contained in:
commit
15e3406fc1
@ -524,10 +524,10 @@ class IpNetnsCommand(IpCommandBase):
|
||||
self._as_root('delete', name, use_root_namespace=True)
|
||||
|
||||
def execute(self, cmds, addl_env={}, check_exit_code=True):
|
||||
if not self._parent.root_helper:
|
||||
raise exceptions.SudoRequired()
|
||||
ns_params = []
|
||||
if self._parent.namespace:
|
||||
if not self._parent.root_helper:
|
||||
raise exceptions.SudoRequired()
|
||||
ns_params = ['ip', 'netns', 'exec', self._parent.namespace]
|
||||
|
||||
env_params = []
|
||||
|
@ -827,6 +827,15 @@ class TestIpNetnsCommand(TestIPCmdBase):
|
||||
['ip', 'link', 'list'],
|
||||
root_helper='sudo', check_exit_code=True)
|
||||
|
||||
def test_execute_nosudo_with_no_namespace(self):
|
||||
with mock.patch('neutron.agent.linux.utils.execute') as execute:
|
||||
self.parent.namespace = None
|
||||
self.parent.root_helper = None
|
||||
self.netns_cmd.execute(['test'])
|
||||
execute.assert_called_once_with(['test'],
|
||||
root_helper=None,
|
||||
check_exit_code=True)
|
||||
|
||||
|
||||
class TestDeviceExists(base.BaseTestCase):
|
||||
def test_device_exists(self):
|
||||
|
Loading…
Reference in New Issue
Block a user