Fix RAPI custom parameter support for recreate-disks

The recreate-disks RAPI call previously ignored almost all parameters
passed to it, and this patch fixes the issue and adds tests.

Signed-off-by: Chris Schrier <schrierc@google.com>
Reviewed-by: Hrvoje Ribicic <riba@google.com>

Cherry-picked from [d59dd394774a]

Signed-off-by: Petr Pudlak <pudlak@google.com>
Reviewed-by: Helga Velroyen <helgav@google.com>
Add iallocator arg to RAPI client RecreateInstanceDisks

This allows to change the iallocator when calling the function over
the RAPI interface.

Signed-off-by: Chris Schrier <schrierc@google.com>
Signed-off-by: Petr Pudlak <pudlak@google.com>
Reviewed-by: Petr Pudlak <pudlak@google.com>
Reviewed-by: Helga Velroyen <helgav@google.com>
Revert "Ganeti Filter Language: Delete `qlangOpNotEqual`"

This reverts commit 97e7ea3fa918369c9dd6163fa021b8ca5e93891d.

The "!=" operation never worked on the command line, but it did work
in 2.10 via RAPI.

Thus we decided to not remove "!=", but instead try to make it work
as a proper alias of "not (... == ...)".

Signed-off-by: Niklas Hambuechen <niklash@google.com>
Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>
Remove Mond Server compilation for test if Mond is disabled

The autogenerated TestImports.hs depends on all HS_LIB_SRCS files and
thus the build process breaks if the dependencies of Mond are not
fulfilled, even if it is disabled.

Signed-off-by: Aaron Karper <akarper@google.com>
Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>
Compile htest only if HTEST is set

test/hs/htest needs only be compiled if the tests are supposed to be
run.

Signed-off-by: Aaron Karper <akarper@google.com>
Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>
Refactor functions for building the developent schroot

We want to avoid passing bash functions through the environment,
therefore refactor the functions to be run outside the schroot and
let them invoke commands in the schroot instead.

Signed-off-by: Petr Pudlak <pudlak@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>
ReasonRateLimiting: Generalize `slotMapFromJob` a bit

This function doesn't need to take a `JobWithStat`, the `QueuedJob`
inside it is sufficient.

Signed-off-by: Niklas Hambuechen <niklash@google.com>
Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>
ReasonRateLimiting: Refactor: Extract `queueSlotMap`

Makes `reasonRateLimit` easier to read.

Signed-off-by: Niklas Hambuechen <niklash@google.com>
Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>
Generalize SlotMap

This turns the existing `SlotMap` from the structure

  Map (label :: String, limit :: Int) (occupied :: Int)

into

  Map (label :: a) (occupied :: Int, limit :: Int)

and extracts it into its own module; this makes it possible to use
`SlotMap`s for cases outside of reason rate limiting.

There is also a semantic clean-up (not affecting how reason rate limiting
works): `joinSlotMap` (now `occupySlots`) no longer takes a `SlotMap`
as second argument, removing the need to decide how the limits of the
second `SlotMap` affect the return value.

Before `c = joinSlotMap a b`  allowed to have keys in `b` that don't appear
in `a`, and those would appear in `c` with the limits from `b` (so `a` does
not constrain them).
In the new `occupySlots`, such keys have a limit of 0 instead.

Signed-off-by: Niklas Hambuechen <niklash@google.com>
Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>
Always distribute src/Ganeti/Monitoring/Server.hs

Depending on the value of ENABLE_MOND it is part of the
haskell library base or not; however, in any case it should
end up in the distribution tar ball. Also, do not have whitespace
in front of Make-variable assignments.

Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Petr Pudlak <pudlak@google.com>
adapting tools/users-setup to be used also on Gentoo

Signed-off-by: Guido Serra <guido@gaikai.com>
Reviewed-by: Hrvoje Ribicic <riba@google.com>
Query.Language: Add "==", make "=" legacy

`man 7 ganeti` specifies that "==" is the comparison operator
for the Ganeti Query Language.

"==" has always been used in the CLI tools, but RAPI for some reason
used "=".

We switch to "==" as the default, and keep "=" as supported legacy.

Signed-off-by: Niklas Hambuechen <niklash@google.com>
Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>
Query.Language: Support "!="

It is specified in `man 7 ganeti`.

Ideally we would drop support for it and keep only "not (==)",
but Ganeti 2.10 supported "!=", so we keep it as supported legacy.

This only affects parsing "!="; the internal representation is "not (==)".

Signed-off-by: Niklas Hambuechen <niklash@google.com>
Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>
Tests: Add `case_filterParsing`

This also makes clear how legacy filter are supposed to be treated.

Signed-off-by: Niklas Hambuechen <niklash@google.com>
Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>
Merge branch 'stable-2.12' into master

* stable-2.12
  Refactor functions for building the developent schroot
  Add iallocator arg to RAPI client RecreateInstanceDisks
  Fix RAPI custom parameter support for recreate-disks

Signed-off-by: Petr Pudlak <pudlak@google.com>
Reviewed-by: Helga Velroyen <helgav@google.com>
Reviewed-by: Hrvoje Ribicic <riba@google.com>
Enable haskell tests for distcheck

The full test suite also includes the haskell tests.
Hence enable them when running distcheck.

Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Helga Velroyen <helgav@google.com>
Always distribute test/hs/htest.hs

If in the original configure, haskell-tests are disabled,
test/hs/htest.hs will not be a needed dependency, hence it
will not automatically end up in the distribution tar ball.
Add the file to EXTRA_DIST in this case.

Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Petr Pudlak <pudlak@google.com>
Tests: Ignore lint error for "case_" tests

This is the same we do for all tests starting with "case_".

Signed-off-by: Niklas Hambuechen <niklash@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>
query: Support legacy "=" filter also in Python

We already did this for the Haskell part; this fixes the Python
query implementation and tests.

Signed-off-by: Niklas Hambuechen <niklash@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>
Change the default chroot distribution

We are moving away from squeeze on all fronts, and we should do the
same in the build_chroot script.

Signed-off-by: Hrvoje Ribicic <riba@google.com>
Reviewed-by: Helga Velroyen <helgav@google.com>