Expose utils.DaemonPidFileName
authorIustin Pop <iustin@google.com>
Wed, 30 Jul 2008 08:34:55 +0000 (08:34 +0000)
committerIustin Pop <iustin@google.com>
Wed, 30 Jul 2008 08:34:55 +0000 (08:34 +0000)
Since we need to compute this from outside utils.py, we change this to a
public function.

Reviewed-by: ultrotter

lib/utils.py
test/ganeti.utils_unittest.py

index 6744358..143ca09 100644 (file)
@@ -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)
index 9a9eed9..405a241 100755 (executable)
@@ -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')