LGTM Thanks, Guido
On Mon, Dec 23, 2013 at 6:25 PM, Klaus Aehlig <[email protected]> wrote: > Make luxid also handle queries to drain the job queue. > > Signed-off-by: Klaus Aehlig <[email protected]> > --- > src/Ganeti/Query/Server.hs | 12 +++++++++++- > 1 file changed, 11 insertions(+), 1 deletion(-) > > diff --git a/src/Ganeti/Query/Server.hs b/src/Ganeti/Query/Server.hs > index db363a8..1a24362 100644 > --- a/src/Ganeti/Query/Server.hs > +++ b/src/Ganeti/Query/Server.hs > @@ -40,6 +40,7 @@ import Data.Maybe (fromMaybe) > import qualified Text.JSON as J > import Text.JSON (encode, showJSON, JSValue(..)) > import System.Info (arch) > +import System.Directory > > import qualified Ganeti.Constants as C > import qualified Ganeti.ConstantUtils as ConstantUtils (unFrozenSet) > @@ -56,7 +57,7 @@ import Ganeti.Logging > import Ganeti.Luxi > import qualified Ganeti.Query.Language as Qlang > import qualified Ganeti.Query.Cluster as QCluster > -import Ganeti.Path (queueDir, jobQueueLockFile) > +import Ganeti.Path (queueDir, jobQueueLockFile, jobQueueDrainFile) > import Ganeti.Rpc > import Ganeti.Query.Query > import Ganeti.Query.Filter (makeSimpleFilter) > @@ -293,6 +294,15 @@ handleCall _ _ cfg (SetWatcherPause time) = do > _ <- executeRpcCall (masters ++ mcs) $ RpcCallSetWatcherPause time > return . Ok . maybe JSNull showJSON $ time > > +handleCall _ _ cfg (SetDrainFlag value) = do > + let mcs = Config.getMasterCandidates cfg > + fpath <- jobQueueDrainFile > + if value > + then writeFile fpath "" > + else removeFile fpath > + _ <- executeRpcCall mcs $ RpcCallSetDrainFlag value > + return . Ok . showJSON $ True > + > handleCall _ _ _ op = > return . Bad $ > GenericError ("Luxi call '" ++ strOfOp op ++ "' not implemented") > -- > 1.8.5.1 > -- Guido Trotter Ganeti Engineering Google Germany GmbH Dienerstr. 12, 80331, München Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg Geschäftsführer: Graham Law, Christine Elizabeth Flores Steuernummer: 48/725/00206 Umsatzsteueridentifikationsnummer: DE813741370
