Add option for loading serialized instances
authorMichele Tartara <mtartara@google.com>
Tue, 2 Jul 2013 19:08:38 +0000 (19:08 +0000)
committerMichele Tartara <mtartara@google.com>
Thu, 4 Jul 2013 17:03:46 +0000 (19:03 +0200)
Monitoring CLI tools might have to load serialized lists of instances
(mainly for testing reasons). This patch adds an option to allow that.

Signed-off-by: Michele Tartara <mtartara@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>

src/Ganeti/DataCollectors/CLI.hs

index db30441..d807d07 100644 (file)
@@ -40,6 +40,7 @@ module Ganeti.DataCollectors.CLI
   , oConfdAddr
   , oConfdPort
   , oInputFile
+  , oInstances
   , genericOptions
   ) where
 
@@ -67,6 +68,9 @@ data Options = Options
                                      -- connect to
   , optInputFile   :: Maybe FilePath -- ^ Path to the file containing the
                                      -- information to be parsed
+  , optInstances   :: Maybe FilePath -- ^ Path to the file contained a
+                                     -- serialized list of instances as in:
+                                     -- ([Primary], [Secondary])
   } deriving Show
 
 -- | Default values for the command line options.
@@ -81,6 +85,7 @@ defaultOptions  = Options
   , optConfdAddr   = Nothing
   , optConfdPort   = Nothing
   , optInputFile   = Nothing
+  , optInstances   = Nothing
   }
 
 -- | Abbreviation for the option type.
@@ -138,6 +143,13 @@ oInputFile =
       "the input FILE",
     OptComplFile)
 
+oInstances :: OptType
+oInstances =
+  ( Option "i" ["instances"]
+      (ReqArg (\ f o -> Ok o { optInstances = Just f}) "FILE")
+      "the FILE containing serialized instances",
+    OptComplFile)
+
 -- | Generic options.
 genericOptions :: [GenericOptType Options]
 genericOptions =  [ oShowVer