Instance DictObject for objects with forthcoming variant

As dictionaries are the main form of communication, all our objects
are instances of DictObject. Also create such an instance for objects
that have a forthcoming variant, by dispatching on which of the two is
the case.

Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Niklas Hambuechen <niklash@google.com>
Instance ArrayObject objects with forthcoming variant

Note that, at the moment, Dict and Array instances of
Instances and Disks are only used in tests. So, when
adding those instances, we do not have to worry
about backwards compatibility. We add the "forthcoming"
field in front of the Array representation; in this way,
if new fields will be added later, the old representation
will be a prefix of the then new one.

Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Niklas Hambuechen <niklash@google.com>
Move Disk definition to a separate module

Move the definition of Disk from Ganeti.Objects to
a separate module. This allows convenient exportation of
all generated acessor functions when we start supporting
forthcoming disks. This module gets reexported from
Ganeti.Objects so that other modules are not affected.

Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Niklas Hambuechen <niklash@google.com>
Use Template Haskell to generate Disk Objects

...instead of the manual creation. Having a single declaration
not only is easier to read, but it also improves maintainability
as changes have to be carried out in one place only.

Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Niklas Hambuechen <niklash@google.com>
Support forthcoming disks

...as per our resource-reservation design.

Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Niklas Hambuechen <niklash@google.com>
Fix a typo in the gnt-filter man page

Signed-off-by: Niklas Hambuechen <niklash@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>
Retry thrice if a qa times out

Since the qa can take a lot of connection, it might happen that one of
them times out for reasons unrelated to ganeti. This patch allows the qa
to retry the command in that case.

Signed-off-by: Aaron Karper <akarper@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>
Remove spurious comment

In Ganeti, we only support downgrade from one version to the previous one.
So, all downgrade code is specific for that version and is reset after
the current version is forked off on a stable branch.

Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Petr Pudlak <pudlak@google.com>
Cabal: Don't try to use the user's ~/.cabal

When there's no ~/.cabal or ~/.cabal/config, cabal tries to create it.

We don't want (or need) that for our `ghc -M` based build;
an empty (default) cabal config does fine.

Signed-off-by: Niklas Hambuechen <niklash@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>
Cabal: Add snap-core dependency

It turns out that metad depends directly on it.

Signed-off-by: Niklas Hambuechen <niklash@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>
Cabal: Fix ganeti version (we're now at 2.14)

Signed-off-by: Niklas Hambuechen <niklash@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>
Makefile: Make TAGS use -package-id and macro flags

Makes sure that generating TAGS uses the same library versions
as the build itself.

Signed-off-by: Niklas Hambuechen <niklash@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>
Makefile: Refactor -package-id and macro flags to HFLAGS

All places HFLAGS is used also included these flags, and they make
sense for all GHC invocations in our build.

Signed-off-by: Niklas Hambuechen <niklash@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>
Makefile: Remove spurious HS_REGEX_PCRE flags

They were removed from configure.ac and replaced by the MIN_VERSION_*
flags which are now passed by default via HFLAGS.

Signed-off-by: Niklas Hambuechen <niklash@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>
Makefile: Pass -hide-all-packages to GHC

We already pass GHC all `-package-id`s that it should use.

This change makes sure that it *only* uses those.

Signed-off-by: Niklas Hambuechen <niklash@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>
.gitignore automatically generated files and directories

These files and directories recently have been added to the
build process. They are already cleaned up on make clean. So
make git ignore them.

Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Niklas Hambuechen <niklash@google.com>
Fix hlint warnings found by hlint 1.9.11

Our current hlint version cannot find them yet.

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

Cherry-picked-from: d05f1c86fcca10d2a52cfdcf538e8bfaf517f655
Signed-off-by: Niklas Hambuechen <niklash@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>
Adapt instance existence check to new locking

With the change to the new locking system, there is no
need any more to create locks at run time. As a consequence
of this, no check happens at "lock addition" that the lock
doesn't exist already. Fix the old comment still claiming this
and repeat the instance existence check at CheckPrereq.

Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Petr Pudlak <pudlak@google.com>
Also mention --yes-do-it in gnt-job cancel help string

Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Petr Pudlak <pudlak@google.com>
Make watcher identify itself on disk activation

For most jobs submitted by the watcher, it identifies
itself correctly in the reason trail. However, one
instance of an OpInstanceActivateDisk job was missed.
Fix this.

Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Petr Pudlak <pudlak@google.com>