Merge "dhcp: rename get_process_uuid as private"

This commit is contained in:
Zuul 2024-01-31 20:16:40 +00:00 committed by Gerrit Code Review
commit b85b19e384
2 changed files with 15 additions and 2 deletions

View File

@ -296,7 +296,7 @@ class DhcpLocalProcess(DhcpBase, metaclass=abc.ABCMeta):
"""Returns the file name for a given kind of config file."""
return os.path.join(self.network_conf_dir, kind)
def get_process_uuid(self):
def _get_process_uuid(self):
if self.segment:
# NOTE(sahid): Keep the order to match directory path. This is used
# by external_process.ProcessManager to check whether the process
@ -349,7 +349,7 @@ class DhcpLocalProcess(DhcpBase, metaclass=abc.ABCMeta):
def _get_process_manager(self, cmd_callback=None):
return external_process.ProcessManager(
conf=self.conf,
uuid=self.get_process_uuid(),
uuid=self._get_process_uuid(),
namespace=self.network.namespace,
service=DNSMASQ_SERVICE_NAME,
default_cmd_callback=cmd_callback,

View File

@ -1222,6 +1222,19 @@ class TestDhcpLocalProcess(TestBase):
self.assertEqual(lp.called, ['spawn'])
self.assertTrue(self.mock_mgr.return_value.setup.called)
def test_get_process_uuid(self):
net = FakeV4Network()
lp = LocalChild(self.conf, net)
self.assertEqual(
"aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa",
lp._get_process_uuid())
lp.segment = FakeSegment()
self.assertEqual(
"1212/aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa",
lp._get_process_uuid())
@mock.patch.object(fileutils, 'ensure_tree')
def test_enable(self, ensure_dir):
attrs_to_mock = dict(