In addition to ConfigurationError it contains a list of messages
collected by the verification process.

It will be used to report any verification errors in WConfd to the
Python code.

Signed-off-by: Petr Pudlak <[email protected]>
---
 lib/errors.py        | 9 +++++++++
 src/Ganeti/Errors.hs | 7 ++++++-
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/lib/errors.py b/lib/errors.py
index 4cf35e1..faa9eb9 100644
--- a/lib/errors.py
+++ b/lib/errors.py
@@ -114,6 +114,15 @@ class ConfigVersionMismatch(ConfigurationError):
   """
 
 
+class ConfigVerifyError(ConfigurationError):
+  """Error reported by configuration verification
+
+  The error has two arguments: the main error message and a list of errors
+  found.
+
+  """
+
+
 class AddressPoolError(GenericError):
   """Errors related to IP address pools.
 
diff --git a/src/Ganeti/Errors.hs b/src/Ganeti/Errors.hs
index 900f49a..09780b3 100644
--- a/src/Ganeti/Errors.hs
+++ b/src/Ganeti/Errors.hs
@@ -71,6 +71,7 @@ $(genException "GanetiException"
   , ("ProgrammerError", [excErrMsg])
   , ("BlockDeviceError", [excErrMsg])
   , ("ConfigurationError", [excErrMsg])
+  , ("ConfigVerifyError", [excErrMsg, ("allErrors", [t| [String] |])])
   , ("ConfigVersionMismatch", [ ("expVer", [t| Int |])
                               , ("actVer", [t| Int |])])
   , ("ReservationError", [excErrMsg])
@@ -128,12 +129,16 @@ $(genStrOfOp ''GanetiException "excName")
 -- back an exception from masterd.
 errorExitCode :: GanetiException -> ExitCode
 errorExitCode (ConfigurationError {}) = ExitFailure 2
+errorExitCode (ConfigVerifyError {}) = ExitFailure 2
 errorExitCode _ = ExitFailure 1
 
 -- | Formats an exception.
 formatError :: GanetiException -> String
 formatError (ConfigurationError msg) =
-  "Corrup configuration file: " ++ msg ++ "\nAborting."
+  "Corrupt configuration file: " ++ msg ++ "\nAborting."
+formatError (ConfigVerifyError msg es) =
+  "Corrupt configuration file: " ++ msg ++ "\nAborting. Details:\n"
+  ++ unlines es
 formatError (HooksAbort errs) =
   unlines $
   "Failure: hooks execution failed:":
-- 
2.0.0.526.g5318336

Reply via email to