Change IsPidFileAlive into ReadPidFile
authorIustin Pop <iustin@google.com>
Tue, 29 Jul 2008 08:49:34 +0000 (08:49 +0000)
committerIustin Pop <iustin@google.com>
Tue, 29 Jul 2008 08:49:34 +0000 (08:49 +0000)
commitd9f311d78e983c98343954c85e7415115fb22885
treee7b82262f22e8865c27687b855e91d6d1825e0ae
parentf71245a0add897939ded36cc66baac601b714233
Change IsPidFileAlive into ReadPidFile

We already have a function to test if a PID is alive, so it makes more
sense to use function composition that force calling (since we need to
read PIDs from files in other places too). Now IsProcessAlive returns
False for PIDs <= 0, since this is the error return from ReadPidFile.

The patch also adds a unittest for checking that WriteFile raises the
correct exception, and checks that an invalid or missing file causes
ReadPidFile to return zero. The unittest tearDown method will try to
cleanup the temp directory too (otherwise it leaves stuff after it).

Reviewed-by: ultrotter
lib/utils.py
test/ganeti.utils_unittest.py