Test: Rename genCount to genSlotCount

Describes better what it does.

Signed-off-by: Niklas Hambuechen <niklash@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>
Test: Generate sensible rate limits instead of plain Ints

Huge rate limits are not very useful for testing.

Signed-off-by: Niklas Hambuechen <niklash@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>
SlotMap: Clarify adding to empty SlotMap

This points out an important case when `hasSlotsFor` returns False.

Signed-off-by: Niklas Hambuechen <niklash@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>
Test.JQScheduler: Refactor enqueued jobs

Makes the test easier to read.

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

It is useful for defining properties of `filter` like functions
(in fact, it is the only property that can be said about filter
if the filter predicate is not known).

Signed-off-by: Niklas Hambuechen <niklash@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>
Test.JQScheduler: Make test more precise

The output of a filter operation should be exactly a subsequence.

Signed-off-by: Niklas Hambuechen <niklash@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>
Add cabal file
Objects: Add filterRuleOrder / Ord instance for FilterRule

This is necessary to process filters in this order, as required
by the filtering spec.
Query.Filter: Add `evaluateFilterJSON`

We will need it to evaluate filters on OpCodes for job filtering.
JSON: Add `nestedAccessByKey` and `nestedAccessByKeyDotted`

We will need them for job filters, where we want to access OpCodes
as a JSON structure.
Implement job filtering

This implements the operational part of the design doc
  "Filtering of jobs for the Ganeti job queue"
(design-optables.rst).

It includes
- respecting filter rules when jobs are scheduled
- cancelling running jobs rejected by filters
- re-running the scheduler when filter rules are changed
- handling of the filter actions ACCEPT, CONTINUE, PAUSE, REJECT
  and RATE_LIMIT
- implementation of the "jobid", "opcode" and "reason" predicates
Tests: Add test for filterRuleOrder

Property mirrors the implementation, but is tested still since it
is an important part of the specification.
qa_utils: Make AssertCommand return stdout/stderr as well

This is usefull if the run commands output something that's needed afterwards.
qa_utils: Allow passing fail=None to AssertCommand

This is for cases where we don't care about the exit code.
WIP: Add filter qa