Commit 7bca53e4 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

ganeti-watcher: Replace custom exceptions with ganeti.error.*

Reviewed-by: iustinp
parent 2fb96d39
......@@ -53,11 +53,7 @@ KEY_RESTART_WHEN = "restart_when"
KEY_BOOT_ID = "bootid"
class Error(Exception):
"""Generic custom error class."""
class NotMasterError(Error):
class NotMasterError(errors.GenericError):
"""Exception raised when this host is not the master."""
......@@ -84,11 +80,12 @@ def DoCmd(cmd):
res = utils.RunCmd(cmd)
if res.failed:
raise Error("Command %s failed:\n%s\nstdout:\n%sstderr:\n%s" %
msg = ("Command %s failed:\n%s\nstdout:\n%sstderr:\n%s" %
raise errors.CommandError(msg)
return res
......@@ -101,7 +98,7 @@ def LockFile(fd):
fcntl.flock(fd, fcntl.LOCK_EX | fcntl.LOCK_NB)
except IOError, err:
if err.errno == errno.EAGAIN:
raise StandardError("File already locked")
raise errors.LockError("File already locked")
......@@ -112,7 +109,7 @@ class WatcherState(object):
def __init__(self):
"""Open, lock, read and parse the file.
Raises StandardError on lock contention.
Raises exception on lock contention.
# The two-step dance below is necessary to allow both opening existing
......@@ -210,3 +210,9 @@ class TagError(GenericError):
The argument to this exception will show the exact error.
class CommandError(GenericError):
"""External command error.
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