Be more explicit about the scope of gnt-cluster upgrade

Add an explicit statement to the documentation that gnt-cluster upgrade
only handles the switching between Ganeti versions, not the installation
or removal of the Ganeti binaries. Some users got confused about this.

Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Helga Velroyen <helgav@google.com>
Reviewed-by: Thomas Thrainer <thomasth@google.com>
Avoid assertIn

...as it is only present in python version 2.7 and higher.

Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Petr Pudlak <pudlak@google.com>
Merge branch 'stable-2.11' into stable-2.12

* stable-2.11
  Avoid assertIn
  Be more explicit about the scope of gnt-cluster upgrade

Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Hrvoje Ribicic <riba@google.com>
Merge branch 'stable-2.12' into master

* stable-2.12
  (no changes)

* stable-2.11
  Avoid assertIn
  Be more explicit about the scope of gnt-cluster upgrade

Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Hrvoje Ribicic <riba@google.com>
Add a module with utility functions for MonadPlus operations

In particular, functions for retrying a MonadPlus action:
It is repeated until it returns a valid result.

Signed-off-by: Petr Pudlak <pudlak@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>
Retry forking a new process several times

Apparently due to some library bug, forking sometimes fails: The new
process is running, but it doesn't start executing. Therefore we retry
the attempt several times.

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

We add templates for systemd service files and systemd targets under
doc/examples/systemd and flag them to be built. The generated files are
also added to .gitignore.

Signed-off-by: Apollon Oikonomopoulos <apoikos@gmail.com>
Reviewed-by: Jose A. Lopes <jabolopes@google.com>
daemon-util: use systemctl if applicable

daemon-util is used throughout the code for starting a daemon whenever
this is needed (e.g. during cluster bootstrapping or master failover).

In order not to confuse systemd and its service supervision code,
daemon-util needs to cooperate with it. Thus, we use systemctl for all
operations if both of these conditions hold:

 - systemd is running as PID 1, checked via the existence of
   /run/systemd/system, as per sd_booted(3).
 - systemd has the ganeti.target unit loaded, indicating that the
   relevant systemd unit files have been installed.

Signed-off-by: Apollon Oikonomopoulos <apoikos@gmail.com>
Reviewed-by: Jose A. Lopes <jabolopes@google.com>
daemon-util: do not restart failed systemd services

daemon-util's check-and-start function is only used by the watcher to
start failed services that should be running on the node. Systemd
supervises and restarts the services as needed; if a service is down, it
is so either because of an unrecoverable error, or because the
administrator manually stopped it. In any case, it should not be blindly
restarted.

Signed-off-by: Apollon Oikonomopoulos <apoikos@gmail.com>
Reviewed-by: Jose A. Lopes <jabolopes@google.com>
Add systemd unittests

Test the consistency between daemon-util and the systemd unit files:

  - Each service started/stopped by daemon-util must have a respective
    unit file.
  - The daemon user/group in the service file must be the same as the
    one reported by daemon-util.

Signed-off-by: Apollon Oikonomopoulos <apoikos@gmail.com>
Reviewed-by: Jose A. Lopes <jabolopes@google.com>
Add NEWS entry about systemd unit files

Signed-off-by: Apollon Oikonomopoulos <apoikos@gmail.com>
Reviewed-by: Jose A. Lopes <jabolopes@google.com>
Fix arrangement of items in the NEWS file

The improvements of the 'move-instance' tool were listed
below the improvements of OS installs, but should actually
be listed as separate item.

Signed-off-by: Helga Velroyen <helgav@google.com>
Reviewed-by: Petr Pudlak <pudlak@google.com>
Fix a list expression to conform to our style guide

This fixes an error occurring in 'make commit-check'.

Signed-off-by: Petr Pudlak <pudlak@google.com>
Reviewed-by: Jose A. Lopes <jabolopes@google.com>
Add disks entry to config.data

Add disks entry to config.data.

Signed-off-by: Ilias Tsitsimpis <iliastsi@grnet.gr>
Reviewed-by: Jose A. Lopes <jabolopes@google.com>
Add 'all_nodes' property to disk objects

This property returns the nodes covered by a disk.

Signed-off-by: Ilias Tsitsimpis <iliastsi@grnet.gr>
Reviewed-by: Jose A. Lopes <jabolopes@google.com>
Add timestamp/serial_no slot to disk objects

Now that disks are top level citizens in config,
they need a timestamp and a serial_no slot.

Signed-off-by: Ilias Tsitsimpis <iliastsi@grnet.gr>
Reviewed-by: Jose A. Lopes <jabolopes@google.com>
Add 'GetInstanceNodes' to config

Get all disk-related nodes for an instance.
Also use 'GetInstanceSecondaryNodes' to get the
list of secondary nodes.

Signed-off-by: Ilias Tsitsimpis <iliastsi@grnet.gr>
Reviewed-by: Jose A. Lopes <jabolopes@google.com>
Add 'GetInstanceLVsByNode' to config

Provide a mapping of node to LVs a given instance owns.

Signed-off-by: Ilias Tsitsimpis <iliastsi@grnet.gr>
Reviewed-by: Jose A. Lopes <jabolopes@google.com>
Fix '_create_instance' in config_unittest

Previously '_create_instance' would initialize the config object every
time it would be called. This causes '_WriteConfig' to fail with
ConfigurationError: The configuration file has been modified since the
last write. Fix this by passing the config object to '_create_instance'
method.

Signed-off-by: Ilias Tsitsimpis <iliastsi@grnet.gr>
Reviewed-by: Jose A. Lopes <jabolopes@google.com>
Change TestInstance in objects unittest

Now that 'all_nodes' and 'secondary_nodes' of an instance are computed
from the 'config' module, move the corresponding tests from
'objects_unittest' to 'config_unittest'.

Signed-off-by: Ilias Tsitsimpis <iliastsi@grnet.gr>
Reviewed-by: Jose A. Lopes <jabolopes@google.com>