Assemble Xen NIC parameters into a dictionary

... instead of a string. This reduces the chance of programmer errors
and also eliminates the need to include comma separators everywhere.

Signed-off-by: Petr Pudlak <pudlak@google.com>
Reviewed-by: Helga Velroyen <helgav@google.com>
Add a script for setting up the metad NIC for Xen

The script does the bare minimum required to set up the interface during
instance creation. The rest of the process is carried out by the ifup-os
script.

Signed-off-by: Petr Pudlak <pudlak@google.com>
Reviewed-by: Helga Velroyen <helgav@google.com>
Use tools/vif-ganeti-metad when setting up Xen metad NIC

... and skip the setup used for regular NICs.

Signed-off-by: Petr Pudlak <pudlak@google.com>
Reviewed-by: Helga Velroyen <helgav@google.com>
Check for all NICs when looking for a free metad NIC name

With Xen, the interfaces aren't set in 'tuntap' mode so 'ip tuntap list'
doesn't show them.

Signed-off-by: Petr Pudlak <pudlak@google.com>
Reviewed-by: Helga Velroyen <helgav@google.com>
Let drbd disks resync during cluster verify

Commit 9b0e86e issues an error during cluster verify if the status
of DRBD is degraded and if the local disk is not UpToDate.

Still in case of a newly created instance or a newly attached disk with
--no-wait-for-sync, if a cluster verify runs it will report errors
for the instance's disks that are syncing.

This patch does the following:

  - Adds a new local disk state namely LDS_SYNC.

  - Thinks of a drbd device that is syncing as degraded.

  - During cluster verify, if the device is degraded, the local disk
    status is checked and if it is ok or syncing it prints a warning
    instead of an error.

  - Updates the order of lds to: ok < syncing < unknown < faulty

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Signed-off-by: Petr Pudlak <pudlak@google.com>
Reviewed-by: Petr Pudlak <pudlak@google.com>
Do not hard-code python path

...in our automatically generated top-level python files.
Instead use the automatically detected python path.

Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Petr Pudlak <pudlak@google.com>
Fix python shebang line in tools as well

While most of our top-level python scripts used to be generated
in the Makefile already, the scripts under tools used to be
"ready to use". However, in our current situation where the
python 2 interpreter is called different on different platforms
we still need to fix the shebang line. This patch achieves this
without moving source files around.

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

* stable-2.10
  Fix python shebang line in tools as well
  Do not hard-code python path

Conflicts:
	Makefile.am (trivial)

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

Keyword arguments should not be passed positionally.

Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Petr Pudlak <pudlak@google.com>
Support forcing a config lock

As reads from WConfD are consistent anyway, the need for
dynamically acquiring the config lock is mostly gone;
that's why requests for shared config locks are ignored
by default. However, still support forcing shared config
locks for the cases still remaining, in particular
ClusterVerify.

Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Petr Pudlak <pudlak@google.com>
Force config lock in cluster verification

...as we compare our copy of the configuration with that
on the other master candidates. So consistency only for
within the job process is not enough.

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
  (no changes)

* stable-2.10
  Fix python shebang line in tools as well
  Do not hard-code python path

Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Petr Pudlak <pudlak@google.com>
Move helpers of LUInstanceCreate and LUInstanceSetParams

This is preparatory for moving both of them into their own files.

Signed-off-by: Aaron Karper <akarper@google.com>
Reviewed-by: Michele Tartara <mtartara@google.com>
Move LUInstanceSetParams to own file

The class has grown to 1700 lines and deserves its own file.

Signed-off-by: Aaron Karper <akarper@google.com>
Reviewed-by: Michele Tartara <mtartara@google.com>
Moving cmdlib.instance.LUInstanceCreate to separate module

The class is 1500 lines long and deserves it's own file. This includes
moving some utilities to the instance_utils module and mocking them out
in the unittests separately.

Signed-off-by: Aaron Karper <akarper@google.com>
Reviewed-by: Michele Tartara <mtartara@google.com>
Fixing handling of diskless instances

There were several checks that `all(...)` disks were of a certain type.
This leads to (often) wrong behaviour: `all([])` is true, so diskless
instances are all kinds of types. This fixes the issue by introducing
the helper functions AllDisksOfType and AnyDisksOfType.

Signed-off-by: Aaron Karper <akarper@google.com>
Signed-off-by: Michele Tartara <mtartara@google.com>
Reviewed-by: Michele Tartara <mtartara@google.com>
Merge branch 'stable-2.12' into stable-2.13

* stable-2.12
  Check for all NICs when looking for a free metad NIC name
  Use tools/vif-ganeti-metad when setting up Xen metad NIC
  Add a script for setting up the metad NIC for Xen
  Assemble Xen NIC parameters into a dictionary

* stable-2.10
  Fix python shebang line in tools as well
  Do not hard-code python path

Conflicts:
	Makefile.am - take additions from both versions

Signed-off-by: Petr Pudlak <pudlak@google.com>
Reviewed-by: Helga Velroyen <helgav@google.com>
Merge branch 'stable-2.13' into master

* stable-2.13
  Let drbd disks resync during cluster verify

* stable-2.12
  Check for all NICs when looking for a free metad NIC name
  Use tools/vif-ganeti-metad when setting up Xen metad NIC
  Add a script for setting up the metad NIC for Xen
  Assemble Xen NIC parameters into a dictionary

* stable-2.10
  Fix python shebang line in tools as well
  Do not hard-code python path

No conflicts.

Signed-off-by: Petr Pudlak <pudlak@google.com>
Reviewed-by: Helga Velroyen <helgav@google.com>
Fix outdated comment

Ganeti.WConfD.Core has nothing to do with HTools.

Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Petr Pudlak <pudlak@google.com>
THH: Remove unused varNameE function

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