Use psqueue library

This change will be used to implement the scheduling of the data
collectors.

Signed-off-by: Aaron Karper <akarper@google.com>
Signed-off-by: Michele Tartara <mtartara@google.com>
Reviewed-by: Michele Tartara <mtartara@google.com>
Add design goal for multiple disk templates per instance

The original design document for the disks didn't mentioned that there
is also the assumption that all disks for a single instance are of the
same template.

Signed-off-by: Aaron Karper <akarper@google.com>
Signed-off-by: Michele Tartara <mtartara@google.com>
Reviewed-by: Michele Tartara <mtartara@google.com>
Add design doc: sync rate throttling

Lays out a functionality that sets the drbd sync rate depending on the
number of devices syncing. Later versions would also adapt to
inter-group syncs and handle flow more effectively.

Relates to issue 935.

Signed-off-by: Aaron Karper <akarper@google.com>
Signed-off-by: Michele Tartara <mtartara@google.com>
Reviewed-by: Michele Tartara <mtartara@google.com>
Remove unused code

Not sure why -Werror didn't catch these.

Signed-off-by: Niklas Hambuechen <niklash@google.com>
Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>
Types: Add `instance Applicative Private`

Fixes warning with GHC 7.8 (Applicative will be a base class of Monad).

Signed-off-by: Niklas Hambuechen <niklash@google.com>
Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>
Rename Ganeti.Utils.MonadPlus to Ganeti.Utils.Monad

It contains only one MonadPlus-specific function and we would like
to add more Monad-specific functions.

Signed-off-by: Niklas Hambuechen <niklash@google.com>
Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>
Auto-derive instances where possible

Removes a lot of unnecessary code.

Signed-off-by: Niklas Hambuechen <niklash@google.com>
Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>
Utils.Monad: Add anyM and allM

Useful for short-circuiting computations.

Signed-off-by: Niklas Hambuechen <niklash@google.com>
Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>
Query.Filter: Simplify `evaluateFilter` recursion

We can remove the explicit recursion and special-casing using
`anyM` and `allM`.

Signed-off-by: Niklas Hambuechen <niklash@google.com>
Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>
Query.Filter: Simplify `wrapGetter`

No need to pass the unmodified QffMode `qff` supplied by the caller
unmodified to a function supplied by the caller.

Signed-off-by: Niklas Hambuechen <niklash@google.com>
Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>
Query.Filter: Add evaluateFilterM

This is a more general version of evaluateFilter, which can be
used for general evaluations of the Ganeti filter language that
do not involve ConfigData, live data and other specialties.

To make this function general enough for expressing very specific
evaluations (such as expressing `evaluateFilter`, which has various
short-cuts, in terms of `evaluateFilterM`), a GADT is introduced
that captures the operations we can perform on the leaves of the
query language.

This lack of separation between the recursive structure and the leaf
structure is what made it hard to write generic functions on `Filter`.

However, we currently need this separation only for filter evaluation
functions and not in the type of `Filter` itself, so
Ganeti.Query.Language remains unchanged.

Signed-off-by: Niklas Hambuechen <niklash@google.com>
Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>
Query.Filter: Simplify `evaluateFilter`

We can now express it in terms of `evaluateFilterM`.

Signed-off-by: Niklas Hambuechen <niklash@google.com>
Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>
Query.Filter: `evaluateFilter` -> `evaluateQueryFilter`

This captures better what it does, and doesn't give the impression
that it is a pure version of `evaluateFilterM`.

Signed-off-by: Niklas Hambuechen <niklash@google.com>
Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>
Remove random word from gnt-instance man for kernel_args

Signed-off-by: Chris Schrier <schrierc@google.com>
Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>
Add cabal file
Query.Language: Add Ord instances

We need them for putting things into Sets and Maps.
Add MonadBaseControl instance for RpcClientMonad

So that exceptions can be caught in the `RpcClientMonad`.
Utils: Add `isUUID`

We have an existing uuidRegex with which UUIDs can be checked,
but it is conditionally compiled if Ganeti is configured with
regex-pcre support, and we don't want to make the dependency on that
unconditional.

This implements `isUUID` with an Attoparsec parser that is equivalent
to the `uuidRegex`.
WConfd.Client: Add `withLockedConfig` helper function

Blocks until a a lock on the config is obtained.
Query.Server: Extract `handleQuery` from `handleClassicQuery`