Migrate "ovs-ofctl" to oslo.privsep

Story: #2007686
Task: #42184

Change-Id: Ifc7ec227d4084331948c42cd99d96ad10c09a6f1
This commit is contained in:
Rodolfo Alonso Hernandez 2021-03-31 07:11:51 +00:00
parent 493286511d
commit becb42b92e
4 changed files with 8 additions and 6 deletions

View File

@ -373,7 +373,8 @@ class OVSBridge(BaseOVS):
for i in range(1, 11):
try:
return utils.execute(full_args, run_as_root=True,
process_input=process_input)
process_input=process_input,
privsep_exec=True)
except Exception as e:
if "failed to connect to socket" in str(e):
LOG.debug("Failed to connect to OVS. Retrying "

View File

@ -113,7 +113,8 @@ def ofctl_arg_supported(cmd, **kwargs):
ovs_lib._build_flow_expr_str(kwargs, cmd.split('-')[0],
False)]
try:
agent_utils.execute(full_args, run_as_root=True)
agent_utils.execute(full_args, run_as_root=True,
privsep_exec=True)
except RuntimeError as e:
LOG.debug("Exception while checking supported feature via "
"command %s. Exception: %s", full_args, e)

View File

@ -200,12 +200,12 @@ class OVS_Lib_Test(base.BaseTestCase):
def _ofctl_mock(self, cmd, *args, **kwargs):
cmd = self._ofctl_args(cmd, *args)
return mock.call(cmd, run_as_root=True, **kwargs)
return mock.call(cmd, run_as_root=True, privsep_exec=True, **kwargs)
def _verify_ofctl_mock(self, cmd, *args, **kwargs):
cmd = self._ofctl_args(cmd, *args)
return self.execute.assert_called_once_with(cmd, run_as_root=True,
**kwargs)
return self.execute.assert_called_once_with(
cmd, run_as_root=True, privsep_exec=True, **kwargs)
def test_add_flow_timeout_set(self):
flow_dict = collections.OrderedDict([

View File

@ -1168,7 +1168,7 @@ class TestCookieContext(base.BaseTestCase):
mock.ANY,
process_input='hard_timeout=0,idle_timeout=0,priority=1,'
'cookie=%d,actions=drop' % cookie,
run_as_root=mock.ANY,
run_as_root=True, privsep_exec=True
) for cookie in (update_cookie, default_cookie)
]