Move assertions to beginning of ExecBlock

Usually we aim for operations to succeed or not do
anything at all. Do the same when failing for internal
errors (like bugs in the locks requesting code).

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

...by adding a "forthcoming" slot to the disk objects.

Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Niklas Hambuechen <niklash@google.com>
Allow instances to be forthcoming

...by adding an appropriate slot to the instance objects.

Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Niklas Hambuechen <niklash@google.com>
Remove forthcoming instances on downgrade

Forthcoming instances were newly introduced in Ganeti 2.14, hence
remove them on downgrade. Note that nothing has to be changed in
the physical world, as forthcoming instances are not created yet.

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

Forthcoming disks were newly introduced in Ganeti 2.14, hence
remove them on downgrade. Also remove them from the disks entry
of all (not forthcoming, and hence not removed anyway) instances.
Note that nothing has to be changed in the physical world, as
forthcoming disks are not yet created.

Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Niklas Hambuechen <niklash@google.com>
Make handling of forthcoming instances opt-in

Change all logical units to reject handling forthcoming
instances. We will later, one by one, add support for
forthcoming instances as needed. As most logical units
handling instances start with _ExpandAndLockInstance, we
have a central place to set the default.

Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Niklas Hambuechen <niklash@google.com>
For an instance report only the real LVs

When getting the logical volumes an instance owns (grouped
by node) only report the non-forthcoming ones. Only those
will be observable on the node.

Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Niklas Hambuechen <niklash@google.com>
Add an OpParam for forthcoming objects

We will add this parameter to opcodes creating objects
that might have a forthcoming variant. If present and
set to true, create the object as forthcoming, i.e.,
only reserve the resources.

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

...allowing to specify that the instance is to be
created as forthcoming, i.e., only resources to
be reserved.

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

...by just passing through that bit to the disk objects.

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

If a forthcoming instance is requested, we just reserve the resources,
but don't create the instance itself.

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

This option will be used by gnt-instance add to allow creation of
forthcoming instances.

Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Niklas Hambuechen <niklash@google.com>
Make GenericInstanceCreate honor forthcoming option

...and generate the opcode accordingly in this case.

Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Niklas Hambuechen <niklash@google.com>
Add --forthcoming to gnt-instance add

...and pass the flag through to LUInstanceCreate.

Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Niklas Hambuechen <niklash@google.com>
Document --forthcoming in the man page

...stating that it can be used to only reserve the
resources without creating the actual instance.

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

...by restricting all physical operations to real
objects, ignoring all operations that would have to
be carried out on a forthcoming object. So, for the
typical case (all forthcoming) it would mean only
removing the entry from the configuration.

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