ganeti-local
10 years ago(2.10) KVM: reserve a PCI slot for the SCSI controller
Apollon Oikonomopoulos [Fri, 28 Mar 2014 18:29:17 +0000 (20:29 +0200)]
(2.10) KVM: reserve a PCI slot for the SCSI controller

Currently instances with disk_type=scsi are broken, because the SCSI
controller uses a PCI slot not accounted for in the PCI assignment
logic. We reserve a throw-away slot just for that.

This is a temporary workaround and will be reverted during the upcoming
refactoring.

Signed-off-by: Apollon Oikonomopoulos <apoikos@gmail.com>
Signed-off-by: Thomas Thrainer <thomasth@google.com>
Reviewed-by: Thomas Thrainer <thomasth@google.com>

10 years ago(2.13) kvm: Add migration capabilities as an hvparam
Dimitris Aragiorgis [Tue, 3 Dec 2013 13:42:28 +0000 (15:42 +0200)]
(2.13) kvm: Add migration capabilities as an hvparam

Latest QEMU versions support various migration capabilities.  Each
can be enabled/disabled with 'migrate_set_capability' monitor
command.

Version 1.7.0 defines x-rdma-pin-all, auto-converge, zero-blocks,
and xbzrle migration capabilities.

Since migration capabilities are more than one, and because hvparams
accept only strings/integers and not dicts we decide to provide the
capabilities that should be on via a ":" separated string.

In other words one can use the following to enable xbzrle and
auto-converge:

-H kvm:migration_caps=xbzrle:auto-converge

IMPORTANT: xbzrle may result to BSOD for instances running Windows
2008r8 on drbd.

Update man page of gnt-instance to include the new hvparam.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>

10 years ago(2.10) Fix conflict between virtio + spice or soundhw
Dimitris Aragiorgis [Mon, 17 Mar 2014 12:00:19 +0000 (14:00 +0200)]
(2.10) Fix conflict between virtio + spice or soundhw

With regard to PCI slot occupied by a KVM instance we have
observed the following:

1) Slot 0 will always be Host bridge.
2) Slot 1 will always be ISA bridge.
3) Slot 2 will always be VGA controller (even with -display none).
4) If soundhw=hda|ac97|es1370 an extra PCI slot is occupied.
   This slot *MUST* be the No. 3.

5) Option '-balloon virtio' gets an extra PCI slot.
   Still it can take id, bus, and addr args and be placed anywhere

6) If spice is used instead of vnc we have:
   * No extra PCI slot gets occupied without vdagent
   * Otherwise we have the following extra optionsa [1]
     a) -device virtio-serial-pci
        (this can take id, bus, and addr args too)
     b) -device virtserialport,chardev=spicechannel0,...
     c) -chardev spicevmc,id=spicechannel0

This patch does the following:

1) Change _DEFAULT_PCI_RESERVATIONS to "1110...."
2) Move soundhw option early in the command line and if hda etc.
   reserve slot 3.
3) Add id, bus, and addr in balloon option and reserve next slot.
4) Add id, bus, and addr in -device virtio-serial-pci option and if
   passed reserve next slot.

[1] http://www.linux-kvm.org/page/SPICE

Fixes issue 757.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Reviewed-by: Jose A. Lopes <jabolopes@google.com>

10 years ago(2.10) Fix bitarray ops wrt PCI slots
Dimitris Aragiorgis [Mon, 17 Mar 2014 12:00:18 +0000 (14:00 +0200)]
(2.10) Fix bitarray ops wrt PCI slots

Introduce new method `_GetFreeSlot()` responsible only for bitarray
operations. It fixes search in case of bitarray is either '0000..'
or '1111..'.

Use it instead of `_UpdatePCISlots()` and in `_GetFreePCISlot()`.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Reviewed-by: Jose A. Lopes <jabolopes@google.com>

10 years ago(2.11) Make BlockDev subclasses adhere the interface for Create
Dimitris Aragiorgis [Thu, 13 Mar 2014 13:52:37 +0000 (15:52 +0200)]
(2.11) Make BlockDev subclasses adhere the interface for Create

In commit 702c3270 two new parameters were added to the
Create function of BlockDev. Make subclasses also adhere
this specification.

Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Petr Pudlak <pudlak@google.com>
Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>

10 years ago(2.11) Make BlockDev subclasses adhere to new interface
Dimitris Aragiorgis [Thu, 13 Mar 2014 13:49:11 +0000 (15:49 +0200)]
(2.11) Make BlockDev subclasses adhere to new interface

In commit 702c3270 two new parameters were added to the
constructor of BlockDev. Make the subclassess accept these
additional parameters as well.

Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Petr Pudlak <pudlak@google.com>
Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>

10 years ago(2.11) Make disk.name and disk.uuid available in bdev
Dimitris Aragiorgis [Mon, 10 Mar 2014 10:19:17 +0000 (12:19 +0200)]
(2.11) Make disk.name and disk.uuid available in bdev

Until now Disk name and uuid was not available on bdev level.
In case of ExtStorage, this info is useful, and may be for other
templates in the future too.

This patch treats the name and uuid object slots just like the size
one and passes them to BlockDev.__init__() and to BlockDev.Create().

The ExtStrorage interface exports these options to scripts via the
VOL_CNAME and VOL_UUID environment variables.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>

This should be backported since in stable-2.11 bdev.py is split
in lib/storage/*.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>

10 years agoifdown: Use new methods to unconfigure NICs
Dimitris Aragiorgis [Tue, 4 Feb 2014 13:47:24 +0000 (15:47 +0200)]
ifdown: Use new methods to unconfigure NICs

We unconfigure a NIC (invoke ifdown script) during:

* instance cleanup
* finalizing successful migration on source node
* hot-unplugging a NIC

In case of migration we do only a local cleanup.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>

10 years agoifdown: Use new methods to create NIC files
Dimitris Aragiorgis [Tue, 4 Feb 2014 13:40:46 +0000 (15:40 +0200)]
ifdown: Use new methods to create NIC files

NIC files containing corresponding tap name are created during:

* instance startup
* NIC hot-add

For compatibility we continue creating indexed based NIC files along
with uuid based ones.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>

10 years agoifdown: Introduce _UnconfigureNIC() helper method
Dimitris Aragiorgis [Tue, 4 Feb 2014 13:33:09 +0000 (15:33 +0200)]
ifdown: Introduce _UnconfigureNIC() helper method

This method takes a NIC object, creates the proper invironment
and invokes ifdown script.

It takes an extra boolean argument only_local which is passed
to ifdown script as the second positional argument. It states
if the external script should wipe out every configuration
related to the NIC or should only clean up local thinks, e.g.
during a successful migration we are going to invoke ifdown
on the source node but we do not want to purge any DDNS
configuration related to instance's NICs.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>

10 years agoifdown: Make Read/LoadKVMRuntime classmethods
Dimitris Aragiorgis [Tue, 4 Feb 2014 13:01:58 +0000 (15:01 +0200)]
ifdown: Make Read/LoadKVMRuntime classmethods

.. and make LoadKVMRuntime() take instance_name rather than the
whole instance object as first argument. This will be needed during
instance cleanup where we the instance object is not available.

We are going to retrieve current NIC configuration from the runtime
file in order to invoke the corresponding ifdown scripts.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>

10 years agoifdown: Extract env creation from ConfigureNic()
Dimitris Aragiorgis [Tue, 4 Feb 2014 12:49:00 +0000 (14:49 +0200)]
ifdown: Extract env creation from ConfigureNic()

Introduce new helper method that creates the environment passed
to ifup/ifdown scripts. Instance tags and NIC index will be passed
only during ifup script since only then are available and
valid. Both can change until a NIC gets removed and thus will not
be passed to ifdown script.

Note that TAP name may be not available during ifdown script for
old instances without UUID indexed NIC files. That's why it gets
included in env only if it exists.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>

10 years agoifdown: Introduce helper methods
Dimitris Aragiorgis [Tue, 4 Feb 2014 12:21:34 +0000 (14:21 +0200)]
ifdown: Introduce helper methods

Until now Ganeti upon TAP creation, a NIC file was created
under $RUNDIR/kvm-hypervisor/nic/<instance_name>/<nic_index>

Since NICs have obtained a UUID, we are going to create another
file named after its UUID. This will be needed during ifdown
script in order to retrieve the tap name related to the
corresponding NIC. Index of a NIC may change but UUID will not;
When a NIC is getting hot-plugged may be the third one from
the master perspective but after removing the second, its index
will change.

In the following patches we are going to refer to NIC files
named after NIC's uuid. Here we add helper methods that
add/remove those kind of files. For retrieving NIC's tap name
we search *only* for a NIC file named after its UUID. If not
found (e.g. in case of already existing instances) we fail
silently. External ifdown script must deal with this corner case.

To keep compatibility we still create NIC files based on their
*current* index.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>

10 years agoifdown: Change kvm-if* scripts
Dimitris Aragiorgis [Thu, 30 Jan 2014 15:16:41 +0000 (17:16 +0200)]
ifdown: Change kvm-if* scripts

* Rename kvm-vif-bridge to kvm-ifup-custom
* Search if /etc/ganeti/kvm-if*-custom is available
  and execute it instead
* Pass positional argument to custom script

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>

10 years agoifdown: Add example kvm-ifdown script
Dimitris Aragiorgis [Fri, 24 Jan 2014 16:45:02 +0000 (18:45 +0200)]
ifdown: Add example kvm-ifdown script

This script currently does nothing more that calling user the
user provided one if it exists.

User provided script should be placed under /etc/ganeti/
and named `ganeti-kvm-ifdown`.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>

10 years ago(2.9) Make gnt-debug locks display fake job locks properly
Hrvoje Ribicic [Tue, 25 Feb 2014 16:28:59 +0000 (16:28 +0000)]
(2.9) Make gnt-debug locks display fake job locks properly

When a job is dependent on other jobs, a fake lock is created whose
pending entry contains a list of job ids waiting on the job. gnt-debug
locks did not expect the job ids to be ints, crashing when encountering
them. This patch fixes the situation by forcing a string cast.

Signed-off-by: Hrvoje Ribicic <riba@google.com>
Reviewed-by: Jose A. Lopes <jabolopes@google.com>

10 years ago(2.9) Make NiceSort treat integers well
Hrvoje Ribicic [Tue, 25 Feb 2014 16:25:29 +0000 (16:25 +0000)]
(2.9) Make NiceSort treat integers well

NiceSort is invoked on arrays that may contain strings, but in other
situations can contain ints as well. As this surprisingly makes sense,
add a tiny modification to make NiceSort work in these conditions.

Signed-off-by: Hrvoje Ribicic <riba@google.com>
Reviewed-by: Jose A. Lopes <jabolopes@google.com>

10 years ago(2.10) Workaround for monitor bug related to greeting msg
Dimitris Aragiorgis [Sat, 25 Jan 2014 18:13:14 +0000 (20:13 +0200)]
(2.10) Workaround for monitor bug related to greeting msg

QMP may return multiple greeting messages upon connection.
This is reported on qemu-devel. The fix is one-liner but
until it get's released this is a quick and dirty workaround
that flushes the client's buffer after getting the first
greeting message.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>

10 years ago(2.10) hotplug: Verify if a command succeeded or not
Dimitris Aragiorgis [Mon, 3 Feb 2014 20:19:27 +0000 (22:19 +0200)]
(2.10) hotplug: Verify if a command succeeded or not

Just after issuing _CallHoplugCommands() we invoke
_VerifyHotplugCommand() which parses `info pci` result
and searches for given PCI slot and device id.

If we previously had removed a device but it is still there
abort. Do the same if we had add a device but it is not found.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>

10 years ago(2.10) hotplug: Each hotplug qemu commmand with a separate socat
Dimitris Aragiorgis [Tue, 14 Jan 2014 09:18:18 +0000 (11:18 +0200)]
(2.10) hotplug: Each hotplug qemu commmand with a separate socat

Previously we issued one socat command with two "\n" separated
actions (e.g. netdev_add ...\ndevice_add...)

After having observed a strange monitor behavior [1] splitting
those commands and introducing a sleep time in between, may reduce
any race possibilities. Additionally it will be a step forward
parsing monitor output of each command and decide whether to
modify runtime files or raise a HotplugError.

This patch we simply changes _CallHotplugCommand() to take a
list of commands and issue them separately. Introduces one second
sleep after each command and removes sleep from HotModDevice().

[1] https://groups.google.com/d/msg/ganeti-devel/hCQnmuqKtU0/UWGnw251cskJ

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>

10 years ago(2.9) Gracefully handle degraded instances in verification
Klaus Aehlig [Thu, 30 Jan 2014 15:30:00 +0000 (16:30 +0100)]
(2.9) Gracefully handle degraded instances in verification

The current code assumes that every instance either is of type
diskless or has at least one disk. However, with the option to
remove individual disk degraded 0-disk non-diskless instances
can occur. While such instances usually are not useful, Ganeti
still should be operational in their presence.

Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Hrvoje Ribicic <riba@google.com>
Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>

10 years ago(2.9) Be aware of the degraded case when cleaning up an instance
Klaus Aehlig [Thu, 30 Jan 2014 15:08:06 +0000 (16:08 +0100)]
(2.9) Be aware of the degraded case when cleaning up an instance

In the case of a degraded file-based instance, the file storage directory
for that instance cannot be obtained by looking at the first disk. Use
the standard location, computed from first principles, in this case.

Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Hrvoje Ribicic <riba@google.com>
Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>

10 years ago(2.9) Preserve disk basename on instance rename
Klaus Aehlig [Thu, 30 Jan 2014 11:46:03 +0000 (12:46 +0100)]
(2.9) Preserve disk basename on instance rename

For file-based instances, upon rename, the directory containing
the instance disks is moved. Therefore, the basename needs to
be preserved in this case. Fix this. Note that so far, this
worked by accident as before 94e252a3 file names used to be
"disk" followed by the index.

Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Hrvoje Ribicic <riba@google.com>
Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>

10 years ago(2.9) Assign unique filenames to filebased disks
Ilias Tsitsimpis [Tue, 28 Jan 2014 15:23:46 +0000 (17:23 +0200)]
(2.9) Assign unique filenames to filebased disks

With the new format for cmdline arguments, the user is able to add a
disk to an instance at a specific index. But filebased disks' filenames
have the form "{0}/disk{1}" where '{0}' is the file_storage_dir and
'{1}' is the index of the disk. So if an instance has 3 disks and we
try to create a new one at index 1, the operation will fail because the
filename "{0}/disk1" already exists.

This patch fixes the above problem and also makes the naming of file and
shared disks uniform with other templates.

Signed-off-by: Ilias Tsitsimpis <iliastsi@grnet.gr>
Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>

10 years ago(2.9) Remove deprecated _ERROR_DATA_KEY in QMP
Dimitris Aragiorgis [Sat, 11 Jan 2014 16:14:03 +0000 (18:14 +0200)]
(2.9) Remove deprecated _ERROR_DATA_KEY in QMP

Commit de253f14 of QEMU repo "BREAKS QMP's compatibility for
the error response" as it removes "data" key from qmp error
response messages.  To this end we only log "class" and "desc"
values of the message.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Signed-off-by: Stratos Psomadakis <psomas@grnet.gr>

10 years ago(2.10) Include target node in hooks nodes for migration
Dimitris Aragiorgis [Wed, 8 Jan 2014 04:36:07 +0000 (06:36 +0200)]
(2.10) Include target node in hooks nodes for migration

In case of DRBD, hooks run on both primary (source) and secondary
(target) nodes. To get the same behavior for DTS_EXT_MIRROR, where we
do not have secondary node, we should explicitly add target node to
hooks nodes during instance migration/failover.

CheckPrereq() of TLMigrateInstance runs before BuildHooksManager(),
thus target_node calculated by Iallocator is available under
self._migrater.target_node. Use this value instead of
self.op.target_node which can be None.

Update related doc entries.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>

10 years ago(ipfix) Allow NICs with mode=routed and ip=none
Dimitris Aragiorgis [Mon, 16 Dec 2013 01:13:48 +0000 (03:13 +0200)]
(ipfix) Allow NICs with mode=routed and ip=none

This allows us to define an IPv6 only network (currently with a
dummy IPv4 network) with connectivity mode 'routed' and let
the NICs inside this network have only IPv6 address (auto-generated
from their MAC and the network's prefix).

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>

10 years ago(ext) Do not remove disks if --keep-disks and DT_EXT
Dimitris Aragiorgis [Thu, 17 Oct 2013 15:47:18 +0000 (18:47 +0300)]
(ext) Do not remove disks if --keep-disks and DT_EXT

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>

10 years ago(ext) Override disk_cache hvp with disk param in ext
Dimitris Aragiorgis [Tue, 3 Dec 2013 09:41:30 +0000 (11:41 +0200)]
(ext) Override disk_cache hvp with disk  param in ext

This is a hack that brings disk_cache hypervisor param
at disk level. This is supported only for disks of ext
template that allow arbitrary params. The corresponding
param that should be used is 'cache'.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>

10 years ago(ext) Pass disk geometry in kvm command
Dimitris Aragiorgis [Tue, 3 Dec 2013 09:32:21 +0000 (11:32 +0200)]
(ext) Pass disk geometry in kvm command

Currently we allow this feature only for ext templates that
allow arbitrary params per disk. If both 'heads' and 'secs'
params are given then 'cyls' is calculated from the disk size.

TODO: export these params in IDISK_PARAMS since the can be
useful for every disk.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>

10 years ago(ext) Export logical_id info to hooks env
Dimitris Aragiorgis [Mon, 2 Dec 2013 10:26:58 +0000 (12:26 +0200)]
(ext) Export logical_id info to hooks env

DISK_ID as the second part of logical_id

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>

10 years ago(b64) Use base64 encoding in networks' bitarrays
Dimitris Aragiorgis [Wed, 2 Oct 2013 19:36:54 +0000 (22:36 +0300)]
(b64) Use base64 encoding in networks' bitarrays

This is needed for GRNET'S production environment.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>

10 years ago(snap) Snapshot support for ExtStorage
Dimitris Aragiorgis [Wed, 16 Oct 2013 18:46:25 +0000 (21:46 +0300)]
(snap) Snapshot support for ExtStorage

Extend existing RPC params with the snapshot name and
add allow snapshot not only for LVM but also for EXT.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>

10 years ago(grnet) Remove deprecated idx slot from NIC/Disk objects
Dimitris Aragiorgis [Thu, 28 Nov 2013 09:39:00 +0000 (11:39 +0200)]
(grnet) Remove deprecated idx slot from NIC/Disk objects

This code will run when reading old kvm runtime files created
by hot-plugging related code back in Ganeti 2.6.2

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>

10 years ago(grnet) Enable -device option for old disks upon migration
Dimitris Aragiorgis [Thu, 28 Nov 2013 07:04:09 +0000 (09:04 +0200)]
(grnet) Enable -device option for old disks upon migration

Change _GenerateDeviceKVMId() to take device index as an
extra argument. In case device has uuid and pci info
we return proper device id. In case idx is given we return
a dummy id (e.g. hotdisk-0). Otherwise we raise an Exception.

This is used only by GenerateKVMBlockDevicesOptions() for
block_devices found in runtime files that have not uuid or
pci info (Ganeti 2.6.2 hotplug implementation). By returning
a dummy id we enable -device option in for paravirtual disk types.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>

10 years ago(grnet) Move disk options before nic ones in kvm command
Dimitris Aragiorgis [Thu, 28 Nov 2013 06:25:59 +0000 (08:25 +0200)]
(grnet) Move disk options before nic ones in kvm command

Older versions of Ganeti did ensure that during startup
disk devices will be inserted before nic devices in PCI
configuration space. KVM inserts devices to PCI slots
depending on the order of command line options.

Upon migration kvm command options are re-generated based
on runtime files info. To be able to migrate instances
with old format runtime files put disk options before
NIC ones so that disk occupy the first pci slots available
and not the other way around.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>

10 years ago(grnet) Hotplug: cfgupgrade for deprecated fields
Dimitris Aragiorgis [Fri, 12 Jul 2013 12:34:07 +0000 (15:34 +0300)]
(grnet) Hotplug: cfgupgrade for deprecated fields

Add cfgupgrade so that we remove any deprecated fields hotplug
implementation used in the past.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>

10 years ago(2.10) Introduce _UpgradeSerializedRuntime() method
Dimitris Aragiorgis [Fri, 29 Nov 2013 19:14:19 +0000 (21:14 +0200)]
(2.10) Introduce _UpgradeSerializedRuntime() method

This method is invoked during _AnalizeSerializedRuntime() and is
meant to modify runtime files in the way cfgupgrade does for
config.data.  This could remove deprecated fields, change the
format of the file, add/remove sections, etc.

There is a possibility data included inside runtime
files to cause migration failures after a Ganeti upgrade.
Use this method to avoid such cases.

Commit cc6fd3d exports NICs' UUIDs to configuration scripts.
It assumes UUIDs as an non optional slot in NIC object.
This is true for latest Ganeti versions. Still there might
be instances created back in Ganeti 2.7 missing that slot.

Ganeti 2.10 supports hot-plugging of devices. A prerequisite
for this feature was to change the format of runtime files and
add another entry containing block devices. This was done in
_AnalizeSerializedRuntime(). Move this logic in the new method.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Signed-off-by: Thomas Thrainer <thomasth@google.com>
Reviewed-by: Thomas Thrainer <thomasth@google.com>

10 years ago(2.10) Export NIC's UUID and name to network scripts
Dimitris Aragiorgis [Fri, 22 Nov 2013 19:59:45 +0000 (21:59 +0200)]
(2.10) Export NIC's UUID and name to network scripts

In case of kvm None values are not allowed in env dict
so we have to add name only if not None.

In case of Xen since we are writing on a file that
is going to be sourced we should not add INTERFACE_NAME=None.

Fix IP=None case.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Signed-off-by: Thomas Thrainer <thomasth@google.com>
Reviewed-by: Thomas Thrainer <thomasth@google.com>

10 years ago(2.10) Use HooksDict() to export network options in Xen
Dimitris Aragiorgis [Fri, 22 Nov 2013 19:59:44 +0000 (21:59 +0200)]
(2.10) Use HooksDict() to export network options in Xen

Remove duplicate code that exports network options to environment
variables.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Signed-off-by: Thomas Thrainer <thomasth@google.com>
Reviewed-by: Thomas Thrainer <thomasth@google.com>

Conflicts:
lib/hypervisor/hv_xen.py

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>

10 years ago(2.10) Export tags via GetTags() to network scripts
Dimitris Aragiorgis [Fri, 22 Nov 2013 19:59:43 +0000 (21:59 +0200)]
(2.10) Export tags via GetTags() to network scripts

Use GetTags() instance method in order to export instance tags
to NIC configuration scripts and files of kvm and xen hypervisors.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Signed-off-by: Thomas Thrainer <thomasth@google.com>
Reviewed-by: Thomas Thrainer <thomasth@google.com>

10 years ago(2.10) Fix net-common script in case of routed mode
Dimitris Aragiorgis [Fri, 22 Nov 2013 19:59:42 +0000 (21:59 +0200)]
(2.10) Fix net-common script in case of routed mode

setup_route should run in case or routed mode and not
openvswitch.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Signed-off-by: Thomas Thrainer <thomasth@google.com>
Reviewed-by: Thomas Thrainer <thomasth@google.com>

10 years ago(2.10) Introduce --hotplug-if-possible option
Dimitris Aragiorgis [Thu, 21 Nov 2013 12:27:10 +0000 (14:27 +0200)]
(2.10) Introduce --hotplug-if-possible option

This will be useful for an external entity using RAPI that
wants to modify devices of instances.

The common use case for that is:
"I want to add a NIC/disk to an instance. If it is running
then try to hotplug the device. If not, then just add it to config."

Another use case is that if we are unaware of the instance's
hypervisor: "I want do add a NIC/disk to an instance and if
its hypervisor is KVM try to hotplug it."

For all those cases just print a warning in CheckPrereq() and
disable any further hotplug related actions (and let
modifications take place after reboot).

Add NoHoplugSupport and HotplugIfPossible unittests an modify
existing by explicitly creating successful RPC results for
call_hotplug_supported.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Signed-off-by: Thomas Thrainer <thomasth@google.com>
Reviewed-by: Thomas Thrainer <thomasth@google.com>

Add pylint disable in CheckPrereq() of LUInstanceSetParams
(too many local variables)

Conflicts:
lib/cmdlib/instance.py
src/Ganeti/OpCodes.hs
src/Ganeti/OpParams.hs
test/py/cmdlib/instance_unittest.py

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>

10 years ago(2.10) RAPI: Make use of request_body in Reboot/Remove
Dimitris Aragiorgis [Thu, 14 Nov 2013 12:10:53 +0000 (14:10 +0200)]
(2.10) RAPI: Make use of request_body in Reboot/Remove

Until now, the shutdown_timeout parameter could only be passed to
ShutdownInstance() inside kwargs, causing it to be included in the
request body. Based on that, extend RebootInstance() and
RemoveInstance() so that they can take extra arguments (e.g.
shutdown_timeout) and pass them eventually to the corresponding opcode.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Reviewed-by: Hrvoje Ribicic <riba@google.com>

10 years ago(2.10) RAPI: Pass depends body arg (if any) to opcode
Dimitris Aragiorgis [Thu, 14 Nov 2013 12:10:52 +0000 (14:10 +0200)]
(2.10) RAPI: Pass depends body arg (if any) to opcode

Most rlib2 classes override the default _GetDefaultData() method with
custom methods that parse a request's body and query args and return a
(body, specific_static) tuple eventually passed to FillOpCode().
Job dependencies are defined in the `depends` body argument that might
get lost because most of those methods return {} as the body. In order
not to modify every custom method we update the returned body with
the `depends` argument of the original request body for all RAPI calls
inside OpcodeResource._GenericHandler(). It's up to the client to
include the `depends` argument with the job dependencies if desired.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Reviewed-by: Hrvoje Ribicic <riba@google.com>

10 years ago(2.10) Allow instances to obtain externally reserved IPs
Dimitris Aragiorgis [Fri, 1 Nov 2013 14:24:38 +0000 (16:24 +0200)]
(2.10) Allow instances to obtain externally reserved IPs

The administrator should be able to assign an externally reserved IP
to a Ganeti instance manually, if desired. Currently this is not
supported. External reservations should act as holes in the pool and
not just as IPs already used by someone outside of Ganeti.
Automatic allocation with ip=pool will continue to exclude those IPs
as happens now.

To allow such functionality the administrator needs to pass explicitly
the desired IP along with the ``--no-conflicts-check`` option, or else
an error will be produced as happens now.

The aforementioned require the following changes:

 - Make IsReserved() to look either in reservations or external ones.
 - Make Reserve() and Release() to use IsReserved() with external
   argument True or False.
 - Pass extra option to ReserveIp() to bypass checking of external reservations
 - Update man pages and design doc for this change.

Furthermore, a side effect of this patch is that it fixes the
following problem:
Currently, one could not mark an IP as external if it was already
reserved (i.e. belonged to an instance). The code would produce a warning
and fail silently.

Fix config_mock.py so that if network and ip is given then reserve it in
the pool.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Signed-off-by: Thomas Thrainer <thomasth@google.com>
Reviewed-by: Thomas Thrainer <thomasth@google.com>

Conflicts:
test/py/cmdlib/testsupport/config_mock.py

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>

10 years ago(2.10) Mark cluster's IPs as externally reserved
Dimitris Aragiorgis [Fri, 1 Nov 2013 14:24:37 +0000 (16:24 +0200)]
(2.10) Mark cluster's IPs as externally reserved

Currently, upon network creation, nodes' and master's IPs
are reserved in the pool.

This leads to pool reservations ('X' in map) that cannot be changed
afterwards, although they may need to (e.g. in case of node
removal/modification). Also, these IPs are not actually handled by
Ganeti in the sense that they are not assigned to the cluster's VMs.

Thus, we should mark the as externally reserved and not just reserved.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Signed-off-by: Thomas Thrainer <thomasth@google.com>
Reviewed-by: Thomas Thrainer <thomasth@google.com>

10 years ago(2.10) Check if hotplug is supported in CheckPrereq
Dimitris Aragiorgis [Wed, 30 Oct 2013 16:56:01 +0000 (18:56 +0200)]
(2.10) Check if hotplug is supported in CheckPrereq

Introduce new RPC hotplug_supported that invokes the corresponding
hypervisor's method which checks if hotplug is generally
supported. Call this RPC early in CheckPrereq() and abort if
hotplug is not supported. Currently only KVM hypervisor with
qemu versions > 1.0. Please note that this check is unaware of
target device and hotplug action. This latter check is still
done during hotplug_device() RPC.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>

Conflicts:
lib/cmdlib/instance.py
test/py/cmdlib/instance_unittest.py

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>

10 years ago(2.10) SimpleRetry on BlockDev.Remove()
Dimitris Aragiorgis [Fri, 25 Oct 2013 15:43:06 +0000 (18:43 +0300)]
(2.10) SimpleRetry on BlockDev.Remove()

Sometimes, upon disk removal, corresponding file descriptors
are kept briefly open by various processes (hypervisor, blkid, etc.).
With this patch, we retry several times before raising the appropriate
error, thus making disk removal more robust against those corner cases.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>

In stable-2.10 we have constants auto-generated from haskell

Conflicts:
lib/constants.py
src/Ganeti/HsConstants.hs

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>

10 years ago(2.10) drive_del after device_del in disk hot-remove
Dimitris Aragiorgis [Thu, 17 Oct 2013 12:25:12 +0000 (15:25 +0300)]
(2.10) drive_del after device_del in disk hot-remove

This is needed so that qemu process really releases the
corresponding file descriptor and thus we can dmsetup/lvremove
the device without errors.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Signed-off-by: Thomas Thrainer <thomasth@google.com>
Reviewed-by: Thomas Thrainer <thomasth@google.com>

10 years ago(2.10) Minor changes regarding hotplug support
Dimitris Aragiorgis [Sat, 12 Oct 2013 18:25:37 +0000 (21:25 +0300)]
(2.10) Minor changes regarding hotplug support

* Mention restrictions in NEWS
  - RBD userspace access mode
  - In case of a downgrade instances should suffer a reboot to be migrateable
* Bypass interactive verification in NIC modifications via --force option
  - Mention it in man page
* Print "modifications take place after restart" message no matter if
  --hotplug option is passed. Change cmdlib to append hotplug status info
  (if any) to the final result printed out to the user
* Change hotplug option description

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Signed-off-by: Thomas Thrainer <thomasth@google.com>
Reviewed-by: Thomas Thrainer <thomasth@google.com>

Conflicts:
NEWS

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>

10 years ago(2.10) Fix in RPC
Dimitris Aragiorgis [Fri, 11 Oct 2013 00:53:23 +0000 (03:53 +0300)]
(2.10) Fix in RPC

Use _SingleDiskDictDP() instead of _ObjectDict() for serializing
a disk.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Signed-off-by: Thomas Thrainer <thomasth@google.com>
Reviewed-by: Thomas Thrainer <thomasth@google.com>

In stable-2.10 rpc methods take node as first argument.

Conflicts:
lib/rpc.py

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>

10 years ago(2.10) block_devices -> kvm_disks renaming
Dimitris Aragiorgis [Fri, 11 Oct 2013 00:52:09 +0000 (03:52 +0300)]
(2.10) block_devices -> kvm_disks renaming

and a couple more styple fixes.
block_devices are misleading so rename them to kvm_disk (just like kvm_nics)

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Signed-off-by: Thomas Thrainer <thomasth@google.com>
Reviewed-by: Thomas Thrainer <thomasth@google.com>

Remove uri occurrences.

Conflicts:
lib/hypervisor/hv_kvm.py

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>

10 years ago(2.10) Make hotplug related method raise HotplugError
Dimitris Aragiorgis [Fri, 11 Oct 2013 00:50:56 +0000 (03:50 +0300)]
(2.10) Make hotplug related method raise HotplugError

Hotplug is not supported by default and thus we raise
HotplugError() for hotplug related methods.
If a hypervisor wants to support it, we must override VerifyHotplugSupport()
and implement the Hot* method.

Backend invokes VerifyHotplugSupport() and raises RPCFail if an
exception is raised.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Signed-off-by: Thomas Thrainer <thomasth@google.com>
Reviewed-by: Thomas Thrainer <thomasth@google.com>

10 years ago(2.10) Some fixes in _GenerateKVMBlockDevicesOptions()
Dimitris Aragiorgis [Thu, 10 Oct 2013 13:00:44 +0000 (16:00 +0300)]
(2.10) Some fixes in _GenerateKVMBlockDevicesOptions()

* Add docstring.
* fix missed usecase of boot_disk=False if kernel_path is given.
* Use devlist arg in GenerateKVMBlockDeviceOptions()
  This is previously calculated in _ExecuteKVMRuntime()
  so there is no need to rerun the same command.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Signed-off-by: Thomas Thrainer <thomasth@google.com>
Reviewed-by: Thomas Thrainer <thomasth@google.com>

10 years ago(2.10) Add unittests for Hotplug support
Dimitris Aragiorgis [Wed, 9 Oct 2013 14:45:40 +0000 (17:45 +0300)]
(2.10) Add unittests for Hotplug support

Try base InstanceSetParams tests that modify instance's
devices with hotplug=True.

Add some unittests for kvm hypervisor regarding runtime file
manipulation. Based on a sample runtime file search for
specific disk and nic entries based on their UUID.

Add unittest for kvm device id generation.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Signed-off-by: Thomas Thrainer <thomasth@google.com>
Reviewed-by: Thomas Thrainer <thomasth@google.com>

The test should not expect the uri entry in kvm_disks tuple

Conflicts:
Makefile.am
test/py/cmdlib/instance_unittest.py

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>

10 years ago(2.10) Extend qa to test hotplug support
Dimitris Aragiorgis [Wed, 9 Oct 2013 14:45:39 +0000 (17:45 +0300)]
(2.10) Extend qa to test hotplug support

Only if default hypervisor is KVM try all hotplug related actions.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Signed-off-by: Thomas Thrainer <thomasth@google.com>
Reviewed-by: Thomas Thrainer <thomasth@google.com>

10 years ago(2.10) Hotplug: Update manpages and NEWS
Dimitris Aragiorgis [Wed, 9 Oct 2013 14:45:37 +0000 (17:45 +0300)]
(2.10) Hotplug: Update manpages and NEWS

Add --hotplug entry in gnt-instance manpage.
Add NEWS entry for hotplug support.
In both cases mention that hotplug is only supported for
the KVM Hypervisor version >= 1.0.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Signed-off-by: Thomas Thrainer <thomasth@google.com>
Reviewed-by: Thomas Thrainer <thomasth@google.com>

Conflicts:
NEWS

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>

10 years ago(2.10) Hotplug: client support
Dimitris Aragiorgis [Wed, 9 Oct 2013 14:45:36 +0000 (17:45 +0300)]
(2.10) Hotplug: client support

Add --hotplug option. Only used in OpInstanceSetParams.
If this is omitted, modifications become effective after reboot.

Ask user confirmation in case NIC modify + hotplug because it will
be done via removing old NIC (and the corresponding tap) and adding
a new one in the same PCI slot.

Corresponding mods in haskell opcode definitions.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Signed-off-by: Thomas Thrainer <thomasth@google.com>
Reviewed-by: Thomas Thrainer <thomasth@google.com>

Conflicts:
src/Ganeti/OpCodes.hs
src/Ganeti/OpParams.hs

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>

10 years ago(fix) SetDiskID() before blockdev_assemble()
Dimitris Aragiorgis [Sun, 8 Dec 2013 05:43:33 +0000 (07:43 +0200)]
(fix) SetDiskID() before blockdev_assemble()

Before blockdev_assemble we call SetDiskID() in order to fill up
physical_id of disk needed by bdev.Assemble and eventually by
constructor of each BlockDev.

This is not needed in 2.10 since physical_id has become deprecated.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>

10 years ago(2.10) Hotplug: cmdlib support
Dimitris Aragiorgis [Wed, 9 Oct 2013 14:45:35 +0000 (17:45 +0300)]
(2.10) Hotplug: cmdlib support

Hotplugging is done by functions invoked by ApplyContainerMods(). In
order hotplugging to take place the --hotplug option must be passed
otherwise the modifications will take place after reboot.

NIC hotplug supports add, remove and modify. The modify is done by removing
the existing NIC and adding a new one in the same pci slot.

Disk hotplug supports add and remove.  Before hotplugging a Disk it
must be assembled. Use blockdev_assemble RPC, get the device link_name
and then call hotplug RPC command.

In order to remove a disk (with blockdev_remove) it must be shutdown. So
after unplugging the disk ShutdownDiskInstanceDisks() must be invoked.

For both device types we use the generic RPC call_hotplug_device.

Also adapt unit tests to follow the change.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Signed-off-by: Thomas Thrainer <thomasth@google.com>
Reviewed-by: Thomas Thrainer <thomasth@google.com>

cmdlib unittests do not exist in stable-2.8
The other were easy to resolve

Conflicts:
lib/cmdlib/instance.py
lib/cmdlib/instance_storage.py
test/py/cmdlib/backup_unittest.py

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>

10 years ago(2.10) Return link_name in blockdev_assemble rpc
Dimitris Aragiorgis [Wed, 9 Oct 2013 14:45:34 +0000 (17:45 +0300)]
(2.10) Return link_name in blockdev_assemble rpc

Until now this RPC returned only dev_path. Since we use it in
hotplug we have to know the simlink of the device so that we
pass it to the corresponding hypervisor command and include it
in block_devices entry in runtime files.

Fix unittest to be aware of changed rpc

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Signed-off-by: Thomas Thrainer <thomasth@google.com>
Reviewed-by: Thomas Thrainer <thomasth@google.com>

cmdlib unittest do not exist in stable-2.8

Conflicts:
test/py/cmdlib/instance_migration_unittest.py
test/py/cmdlib/instance_unittest.py

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>

10 years ago(2.10) Hotplug: rpc support
Dimitris Aragiorgis [Wed, 9 Oct 2013 14:45:33 +0000 (17:45 +0300)]
(2.10) Hotplug: rpc support

Introduce new RPC that eventually invoke hypervisor specific
hotplug functions. In order to be generic it has the following
arguments: device type, action, device, extra info, seq.
Device type can be NIC or DISK, action can be ADD, REMOVE,
device is the NIC or Disk object, extra info is used by Disk
hotplug to point the device path and seq is the device index
(from the master perspective)

Add HotplugSupported() in all Hypervisors

Only KVM hypervisor supports this method. The other hypervisors
raise HypervisorError.

Before trying hotplug in backend layer invoke hyper.HotplugSupported
and abort RPC in case it is not implemented or for some other reason
not supported (disk+chroot, nic without fdsend, etc).

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Signed-off-by: Thomas Thrainer <thomasth@google.com>
Reviewed-by: Thomas Thrainer <thomasth@google.com>

RPC methods in stable-2.10 take node as first argument

Conflicts:
lib/rpc.py
lib/rpc_defs.py

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>

10 years ago(2.10) Introduce hotplug methods (hypervisor inteface)
Dimitris Aragiorgis [Wed, 9 Oct 2013 14:45:32 +0000 (17:45 +0300)]
(2.10) Introduce hotplug methods (hypervisor inteface)

4 new methods: HotAddDevice, HotDelDevice, HotModDevice, HotplugSupported
All these are the hypervisor interface with the backend.
In general they read current runtime info, do the actual hotplug
and update the runtime file.

NIC hot-add:
 - open a tap and get its file descriptor.
 - pass fd with SCM rights (using python-fdsend) via monitor socket
 - create netdev and device with id=kvm_devid and proper pci info

Disk hot-add:
 - create drive with id=kvm_devid
 - create device with id=kvm_devid and corresponding pci info

Use MonitorSocket in _PassTapFd in order to connect to monitor socket
and pass the tap's file descriptor using fdsend.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Signed-off-by: Thomas Thrainer <thomasth@google.com>
Reviewed-by: Thomas Thrainer <thomasth@google.com>

10 years ago(2.10) Extract socket related code from QmpMonitor class
Dimitris Aragiorgis [Wed, 9 Oct 2013 14:45:31 +0000 (17:45 +0300)]
(2.10) Extract socket related code from QmpMonitor class

Separate unix socket related code from QmpMonitor class and
make the latter extend the newly introduced one: MonitorSocket

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Signed-off-by: Thomas Thrainer <thomasth@google.com>
Reviewed-by: Thomas Thrainer <thomasth@google.com>

10 years ago(2.10) Helper methods that check for hotplug support
Dimitris Aragiorgis [Wed, 9 Oct 2013 14:45:30 +0000 (17:45 +0300)]
(2.10) Helper methods that check for hotplug support

Hotplug is currently *not* supported for:

 - KVM < 1.0
 - existing devices in the cluster
 - python-fdsend module is not installed (NIC hotplug)
 - chroot (Disk hotplug)
 - security mode other than None (Disk hotplug)

For the above reasons raise HotplugError exception and
let masterd handle it.

TODO: modify CallHotplugCommand() so that it parses
monitor output and reports whether the command
succeeded or not.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Signed-off-by: Thomas Thrainer <thomasth@google.com>
Reviewed-by: Thomas Thrainer <thomasth@google.com>

10 years ago(2.10) Use -device with pci info if possible
Dimitris Aragiorgis [Wed, 9 Oct 2013 14:45:29 +0000 (17:45 +0300)]
(2.10) Use -device with pci info if possible

Extend kvm_cmd with -device option for the case of paravirual
Disks and NICs.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Signed-off-by: Thomas Thrainer <thomasth@google.com>
Reviewed-by: Thomas Thrainer <thomasth@google.com>

(fix) Remove uri from kvm_disks

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>

10 years ago(2.10) Helper methods for PCI slots and device ids
Dimitris Aragiorgis [Wed, 9 Oct 2013 14:45:28 +0000 (17:45 +0300)]
(2.10) Helper methods for PCI slots and device ids

Device naming:
QEMU monitor expects devices to be uniquely named. Device ids derive
from the following function:
kvm_devid = <device_type>-<part of uuid>-pci-<pci_slot>
Device ids must be reproduce-able when we want to remove them.
For that reason we store the pci slot inside the runtime file and
in case we want to remove a device we obtain its pci slot by
parsing the corresponding runtime enrty and matching the device
by its uuid.

Finding the PCI slot:
For newly added devices Hypervisor parses existing PCI allocations
(via _GetFreePCISlot() and eventually ``info pci`` monitor
command) and decides the PCI slot to plug in the device. During
instance startup hypervisor invokes _UpdatePCISlots() for every
device of the instance.  Initial PCI reservations derive from KVM
default setup, that allocates 4 slots for devices other than disks
and NICs.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Signed-off-by: Thomas Thrainer <thomasth@google.com>
Reviewed-by: Thomas Thrainer <thomasth@google.com>

10 years ago(fix) Remove uri slot from block_devices
Dimitris Aragiorgis [Sat, 7 Dec 2013 22:45:38 +0000 (00:45 +0200)]
(fix) Remove uri slot from block_devices

In stable-2.10 we have userspace access mode for rbd. Backend
calculates uri along with link and dev_path. Thus we have
three items in block_devices and kvm_disks tuples.

We this patch we remove the third value.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>

10 years ago(2.10) Prepare block_devices runtime entry
Dimitris Aragiorgis [Wed, 9 Oct 2013 14:45:27 +0000 (17:45 +0300)]
(2.10) Prepare block_devices runtime entry

With this patch we add another entry in runtime files along with
kvm_cmd, kvm_nics, and hvparams. block_devices that used to be
encapsulated inside kvm_cmd, live now separately just like nics do
but in tupples of (L{objects.Disk}, dev_path).

Introduce also _GetExistingDeviceInfo() helper function to search
for runtime entries. This is going to be useful later in hotplug
methods.

Define new exception: HotplugError.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Signed-off-by: Thomas Thrainer <thomasth@google.com>
Reviewed-by: Thomas Thrainer <thomasth@google.com>

10 years ago(2.10) Prepare kvm options to support -device for disks
Dimitris Aragiorgis [Wed, 9 Oct 2013 14:45:26 +0000 (17:45 +0300)]
(2.10) Prepare kvm options to support -device for disks

Newer kvm version support -device driver,... option where available
drivers can be found by running kvm -device ? command. Currently
ganeti uses `if` property of driver to define the disk type to use
which is also passed as hvparam. This patch prepares the use of
-device option only for paravirtual disks. To support other drivers
as well we must create a mapping between the values passed now as
disk_type hvparam and existing drivers. Note that if -device is used
`if` property of `drive` option should be `none`.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Signed-off-by: Thomas Thrainer <thomasth@google.com>
Reviewed-by: Thomas Thrainer <thomasth@google.com>

10 years ago(2.10) Introduce _GenerateKVMBlockDevicesOptions()
Dimitris Aragiorgis [Fri, 2 Aug 2013 16:37:02 +0000 (19:37 +0300)]
(2.10) Introduce _GenerateKVMBlockDevicesOptions()

Simply move logic that generates block device related
options out of _GenerateKVMRuntime().

NOTE: Back-port corresponding commit from stable-2.10

- 2.8 does not have user-space access support for rbd

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>

10 years ago(2.10) Hotplug: objects and constants additions
Dimitris Aragiorgis [Thu, 9 Aug 2012 10:54:18 +0000 (13:54 +0300)]
(2.10) Hotplug: objects and constants additions

Add pci slot in NIC/Disk objects. This slot will be used only
by hypervisor code. Currently only KVM will use it and store it
temporarily in runtime files.
Add HOTPLUG_* constants to define device types an hotplug actions.

(fix) Add missing opcode parameter

In stable-2.10 opcodes.py is auto-generated from haskell ones.
Add hotplug* params to OpInstanceSetParams.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>

10 years ago(2.9) Document vif-ganeti usage
Dimitris Aragiorgis [Wed, 26 Jun 2013 14:38:18 +0000 (17:38 +0300)]
(2.9) Document vif-ganeti usage

In order to be able to use it as vif-script one has to
create a symbolic link inside /etc/xen/scripts pointing
to /usr/lib/ganeti/vif-ganeti and then add is a hypervisor
parameter.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Signed-off-by: Thomas Thrainer <thomasth@google.com>
Reviewed-by: Thomas Thrainer <thomasth@google.com>

10 years ago(2.9) Refactor NIC configuration scripts
Dimitris Aragiorgis [Wed, 26 Jun 2013 14:38:16 +0000 (17:38 +0300)]
(2.9) Refactor NIC configuration scripts

Add new script vif-ganeti that could be used instead of
default vif-bridge in order NIC customization can be more
flexible.

Extract common code from kvm-ifup and insert it in a new
file net-common that is being sourced by kvm-ifup and
vif-ganeti and located under package lib dir (/usr/lib/ganeti/).

Install vif-ganeti properly with make under /usr/lib/ganeti too.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Signed-off-by: Thomas Thrainer <thomasth@google.com>
Reviewed-by: Thomas Thrainer <thomasth@google.com>

10 years ago(2.9) Make NIC setup more flexible in case of Xen
Dimitris Aragiorgis [Wed, 26 Jun 2013 14:38:15 +0000 (17:38 +0300)]
(2.9) Make NIC setup more flexible in case of Xen

For every NIC write down a file that contains NIC's
info (MAC, mode, link, network details), that can
be sourced by any vif script.  The file location is:
/var/run/ganeti/xen-hypervisor/nic/<domname>/<nicidx>.

This file is created upon cfg file creation and before
starting the instance and can be sourced by an external
script. Before file creation ensure that all parent dirs
exist.

Cleanup NIC dir when removing config files. Upon Xen
configuration file removal, remove NIC dir as well.

Add new hv param vif_script that allows execution of
user defined networking script and overrides the one
xend is configured with in xend-config.sxp

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Signed-off-by: Thomas Thrainer <thomasth@google.com>
Reviewed-by: Thomas Thrainer <thomasth@google.com>

10 years ago(2.8r) Workaround for Issue 621
Dimitris Aragiorgis [Mon, 25 Nov 2013 16:25:08 +0000 (18:25 +0200)]
(2.8r) Workaround for Issue 621

Upon LUNetworkDisconnect() and LUNetworkConnect() try to acquire
all cluster's instances.

By that _LS_ACQUIRE_ALL acquire mode is set and not
_LS_ACQUIRE_EXACT and thus the deleted lock does cause any problem.

NOTE: This workaround is not merged upstream. They prefer to have
one opcode fail and make the end user retry, rather than have a
greedy way that locks all instances to resolve this. Since synnefo
does not use nodegroups, locking all instances is the same with
locking instances on default nodegroup.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>

10 years agoAdd reason parameter to RAPI client functions
Michele Tartara [Wed, 26 Mar 2014 13:20:28 +0000 (14:20 +0100)]
Add reason parameter to RAPI client functions

Only the functions for starting, stopping and rebooting a VM had a reason
parameter. Now, all the RAPI client functions generating opcodes do.

Also, one test is expanded to verify that a RAPI request with both body and
query supports the reason parameter properly.

Fixes Issue 776.

Signed-off-by: Michele Tartara <mtartara@google.com>
Reviewed-by: Hrvoje Ribicic <riba@google.com>

10 years agoInclude qa/patch in Makefile
Thomas Thrainer [Thu, 20 Mar 2014 07:54:02 +0000 (08:54 +0100)]
Include qa/patch in Makefile

Fix the build by including the qa/patch directory in Makefile.am.

Signed-off-by: Thomas Thrainer <thomasth@google.com>
Reviewed-by: Helga Velroyen <helgav@google.com>

10 years agoHandle empty patches better
Hrvoje Ribicic [Wed, 19 Mar 2014 11:40:43 +0000 (11:40 +0000)]
Handle empty patches better

The previous patch loading utilities omitted empty patches, as they
were thought to be of no significance, and when no patches were used,
the import and therefore dependency should not be used. If a user has
added an empty patch file, and made an entry in the order file, the QA
would treat this as an error as it had no means of differentiating
between a patch not present and an empty patch.

This patch fixes the solution by better handling empty patches, and
logging warnings when they are encountered.

Signed-off-by: Hrvoje Ribicic <riba@google.com>
Reviewed-by: Michele Tartara <mtartara@google.com>

10 years agoMove message formatting functions to separate file
Hrvoje Ribicic [Wed, 19 Mar 2014 11:37:29 +0000 (11:37 +0000)]
Move message formatting functions to separate file

The formatting functions in qa_utils.py cannot be used by modules
imported there, such as qa_config. This patch factors the function
calls into a separate file. Also reorders imports in touched files.

Signed-off-by: Hrvoje Ribicic <riba@google.com>
Reviewed-by: Michele Tartara <mtartara@google.com>

10 years agoAdd optional ordering of QA patch files
Hrvoje Ribicic [Tue, 18 Mar 2014 20:46:06 +0000 (20:46 +0000)]
Add optional ordering of QA patch files

To explicitly specify the order of patches executed, the QA provides an
"order" file. It can contain names of patches that will be executed
first, and in the order listed, before all the other patches that still
follow an alphabetical order.

Signed-off-by: Hrvoje Ribicic <riba@google.com>
Reviewed-by: Michele Tartara <mtartara@google.com>

10 years agoAllow multiple QA patches
Hrvoje Ribicic [Tue, 18 Mar 2014 20:25:18 +0000 (20:25 +0000)]
Allow multiple QA patches

This patch allows support for multiple patches placed in the "patch"
directory, which are executed in alphabetical order.

Signed-off-by: Hrvoje Ribicic <riba@google.com>
Reviewed-by: Michele Tartara <mtartara@google.com>

10 years agoRefactor current patching code
Hrvoje Ribicic [Tue, 18 Mar 2014 19:57:46 +0000 (19:57 +0000)]
Refactor current patching code

* Refactors the current patch code to allow for multiple patches that
  can be applied, yet leaves only one for now.

* Rewords the message shown to the user in case the modules needed for
  patching are missing.

Signed-off-by: Hrvoje Ribicic <riba@google.com>
Reviewed-by: Michele Tartara <mtartara@google.com>

10 years agoImprove RAPI detection of the watcher
Michele Tartara [Fri, 7 Mar 2014 13:59:49 +0000 (13:59 +0000)]
Improve RAPI detection of the watcher

If the watcher is not allowed to access RAPI, it doesn't mean that it is dead
and needs to be restarted.

Fixes Issue 752.

Signed-off-by: Michele Tartara <mtartara@google.com>
Reviewed-by: Hrvoje Ribicic <riba@google.com>

10 years agoAdd patching QA configuration files on buildbots
Petr Pudlak [Thu, 21 Nov 2013 14:06:41 +0000 (15:06 +0100)]
Add patching QA configuration files on buildbots

In order to work, it is necessary:
* Write a JSON Patch to file "qa/qa-patch.json" in a source repository.
  (And be careful not to commit it!) The file must conform to RFC6902
  and describes what changes should be done to the QA JSON
  configuration. This is simple as
   [
     { "op": "add",
       "path": "default",
       "value": false },
     { "op": "add",
       "path": "/tests/instance-add-file",
       "value": true }
   ]

* Install "jsonpatch" and "jsonpointer" modules on the machines QA is
  running on. Either using "easy_install" or as Debian packages using
  "pypi-install".

QA only loads the modules if the patch file is present and non-empty.
Therefore no changes to buildbots are needed, if the feature is not
used.

It's advisable to add a git pre-commit hook for the main repository to
prevent changes to "qa/patch.json", keeping it to "[]". Suggestion for
such a hook:

  # Exit code 1 if the patch file isn't just "[]":
  python -c 'import json, sys; \
    exit(0 if json.load(open("qa/qa-patch.json", "r")) == [] else 1)'

Locally it's possible to tell git not to track changes to the file at
all (see https://help.github.com/articles/ignoring-files):

  git update-index --assume-unchanged qa/qa-patch.json

Cherry-pick of e5398c3afde43e9165e96ab5cc8e0426519ad8ad from stable-2.11.

Signed-off-by: Petr Pudlak <pudlak@google.com>
Signed-off-by: Michele Tartara <mtartara@google.com>
Reviewed-by: Jose A. Lopes <jabolopes@google.com>

10 years agoEnable a timeout for instance shutdown
Michele Tartara [Fri, 7 Mar 2014 09:50:33 +0000 (10:50 +0100)]
Enable a timeout for instance shutdown

Add the timeout parameter to the StopInstance function of the hypervisor base
class and to all its implementations.

Also, change the tests as required by this change.

Signed-off-by: Michele Tartara <mtartara@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>

10 years agoAllow KVM commands to have a timeout
Michele Tartara [Fri, 7 Mar 2014 09:47:38 +0000 (10:47 +0100)]
Allow KVM commands to have a timeout

Modify the function that sends commands to the KVM monitor so that it is
possible to specify an optional timeout after which the command is killed.

Signed-off-by: Michele Tartara <mtartara@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>

10 years agoAllow xen commands to have a timeout
Michele Tartara [Fri, 7 Mar 2014 09:46:02 +0000 (10:46 +0100)]
Allow xen commands to have a timeout

Modify the function that runs Xen commands so that it is possible to specify an
optional timeout after which the command is killed.

Signed-off-by: Michele Tartara <mtartara@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>

10 years agoFix wrong docstring
Michele Tartara [Fri, 7 Mar 2014 09:22:29 +0000 (10:22 +0100)]
Fix wrong docstring

Fields must be the final elements in an epytext string.

Signed-off-by: Michele Tartara <mtartara@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>

10 years agoFix expression describing optional parameters
Klaus Aehlig [Mon, 24 Feb 2014 13:29:15 +0000 (14:29 +0100)]
Fix expression describing optional parameters

The NIC's network and vlan are also newly added, hence need to be
considered optional to remain backwards compatible.

Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Michele Tartara <mtartara@google.com>

10 years agoImprove job status assert affected by race condition
Hrvoje Ribicic [Thu, 20 Feb 2014 14:11:32 +0000 (15:11 +0100)]
Improve job status assert affected by race condition

In the sliver of time between choosing a waiting job to be executed and
trying to acquire locks for its execution, the status of the job can be
changed to canceling. An assert checking the job status neglected to
take this into account, and raised an error that managed to perpetually
lock the job in the canceling state. This patch resolves the issue by
making the assert accept the canceling state as well, and exiting if
the job was cancelled.

Signed-off-by: Hrvoje Ribicic <riba@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>

10 years agoExport and import Disk/NIC name
Dimitris Aragiorgis [Thu, 13 Feb 2014 14:47:01 +0000 (16:47 +0200)]
Export and import Disk/NIC name

Name of Disk/NIC were not exported during backup until now.
Use the exported info during gnt-backup import.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Signed-off-by: Michele Tartara <mtartara@google.com>
Reviewed-by: Michele Tartara <mtartara@google.com>

10 years agoFix backup import in case NIC is inside a network
Dimitris Aragiorgis [Thu, 13 Feb 2014 14:47:00 +0000 (16:47 +0200)]
Fix backup import in case NIC is inside a network

Network UUID is written in .ini file during backup export
but is not used by _ReadExportParams(). This patch fixes it.

Please note that in case a network is given, link and mode should
not be included in NIC options.

This fixes issue 716.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Signed-off-by: Michele Tartara <mtartara@google.com>
Reviewed-by: Michele Tartara <mtartara@google.com>

10 years agoOverride get() method of ConfigParser
Dimitris Aragiorgis [Thu, 13 Feb 2014 14:46:59 +0000 (16:46 +0200)]
Override get() method of ConfigParser

During backup import/export SafeConfigParser() is used to
save/restore instance's configuration. There is a possibility if an
export is done with a different Ganeti version, a specific value not
to be saved during export (e.g. the NIC/Disk name) but still
requested during import.

With this patch we override the get() method of SafeConfigParser()
and catch NoOptionError if raised and return None. Additionally we
translate "None" values read from .ini file into None.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Signed-off-by: Michele Tartara <mtartara@google.com>
Reviewed-by: Michele Tartara <mtartara@google.com>

10 years agoFix integer overflow problem in hbal
Michele Tartara [Thu, 13 Feb 2014 12:39:38 +0000 (13:39 +0100)]
Fix integer overflow problem in hbal

waitForJobs in src/Ganeti/Jobs.hs has an integer overflow that (at least on
amd64) causes it to break after waiting for ~10 minutes. This results in hbal
sleeping forever (when compiled with squeeze's ghc 6.12.1) or crashing (when
compiled with precise's ghc 7.4.1) whenever it has to wait ~10 minutes for a
jobset to complete.

Thanks to gjo@google.com for finding the bug and suggesting the fix.

Fixes Issue 717.

Signed-off-by: Michele Tartara <mtartara@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>

10 years agoAdd missing space
Michele Tartara [Thu, 13 Feb 2014 12:23:36 +0000 (12:23 +0000)]
Add missing space

Also, refactor the line to keep it under 80 chars.

Signed-off-by: Michele Tartara <mtartara@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>

10 years agoFix execution group of NodeD
Michele Tartara [Wed, 5 Feb 2014 17:46:32 +0000 (17:46 +0000)]
Fix execution group of NodeD

The Node deamon was executed with the wrong gid (gnt-daemons) instead of the one
assigned to it by configure.ac.

Fixes Issue 707.

Signed-off-by: Michele Tartara <mtartara@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>

10 years agoVersion bump for 2.8.4 and NEWS update
Michele Tartara [Thu, 23 Jan 2014 08:52:42 +0000 (08:52 +0000)]
Version bump for 2.8.4 and NEWS update

Update the version number to 2.8.4 and insert the final details for this
release in the NEWS file, including the release date.

Signed-off-by: Michele Tartara <mtartara@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>

10 years agoUpdate NEWS file with news about job cancellation bugfix
Hrvoje Ribicic [Mon, 20 Jan 2014 16:25:02 +0000 (17:25 +0100)]
Update NEWS file with news about job cancellation bugfix

Signed-off-by: Hrvoje Ribicic <riba@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>