Commit 53beffbb authored by Iustin Pop's avatar Iustin Pop
Browse files

Expose utils.DaemonPidFileName

Since we need to compute this from outside utils.py, we change this to a
public function.

Reviewed-by: ultrotter
parent 5675cd1f
......@@ -1056,7 +1056,7 @@ def Daemonize(logfile, noclose_fds=None):
return 0
def _DaemonPidFileName(name):
def DaemonPidFileName(name):
"""Compute a ganeti pid file absolute path, given the daemon name.
"""
......@@ -1070,7 +1070,7 @@ def WritePidFile(name):
"""
pid = os.getpid()
pidfilename = _DaemonPidFileName(name)
pidfilename = DaemonPidFileName(name)
if IsProcessAlive(ReadPidFile(pidfilename)):
raise errors.GenericError("%s contains a live process" % pidfilename)
......@@ -1084,7 +1084,7 @@ def RemovePidFile(name):
"""
pid = os.getpid()
pidfilename = _DaemonPidFileName(name)
pidfilename = DaemonPidFileName(name)
# TODO: we could check here that the file contains our pid
try:
RemoveFile(pidfilename)
......
......@@ -108,7 +108,7 @@ class TestPidFileFunctions(unittest.TestCase):
def setUp(self):
self.dir = tempfile.mkdtemp()
self.f_dpn = lambda name: os.path.join(self.dir, "%s.pid" % name)
utils._DaemonPidFileName = self.f_dpn
utils.DaemonPidFileName = self.f_dpn
def testPidFileFunctions(self):
pid_file = self.f_dpn('test')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment