Added four new hook points for device migrations

Continued effort on device custom properties. Added four new
hook points: before/after_device_migrate_source, and
before/after_device_migrate_destination. The new hooks are called
for every device that has custom properties.

Patch Set 2:
* Added destination hooks, but they aren't called yet
* Modified installation files, man page to reflect new hook points.

Patch Set 3:
* We now call the before/after_device_migrate_destination hooks.
* Since the device._deviceXML cache is not sent when migrating
  a VM, I had to re-populate that cache at the destination host,
  via a search by device alias.

Patch Set 4:
* Fixed wording in man page
* Added more verbose error reporting in _updateDevicesCache
* Updated copyright for libvirtvm.py file

Patch Set 5:
* We now crash horribly if an alias was not found for a device
  when updating devices domxml cache after migrating
* _updateDevicesCache has been changed from O(n^2) to O(n)

Patch Set 6:
* Removed orphaned function
* Semantic changes

Change-Id: I12278b91102f9bc0f031c4605ebf8b43fcb1bd6f
Signed-off-by: Assaf Muller <amuller@redhat.com>
Reviewed-on: http://gerrit.ovirt.org/13876
Reviewed-by: Dan Kenigsberg <danken@redhat.com>
Tested-by: Dan Kenigsberg <danken@redhat.com>
cleanup: inline STRG_*SCSI_* macros

They are used only once; their name is less clear than their content.

Change-Id: I80c54e1c398ea46badb1e57b3c446fefa9122581
Signed-off-by: Dan Kenigsberg <danken@redhat.com>
Reviewed-on: http://gerrit.ovirt.org/14256
fix pep8 err

Change-Id: Ib502fd06e46ae9f754f2f0247a64140624eac2af
Signed-off-by: Yaniv Bronhaim <ybronhei@redhat.com>
Reviewed-on: http://gerrit.ovirt.org/14340
Reviewed-by: Kiril Nesenko <knesenko@redhat.com>
Reviewed-by: Dan Kenigsberg <danken@redhat.com>
Adding utils package to outOfProcess and remoteFileHandler

As part of http://gerrit.ovirt.org/11423 we added utils package to
outOfProcess modules. oop uses remoteFileHandler to run external
processes, each external process expose modules and functions. To allow
running function from utils package with outOfProcess, we need to
register utils module to crabRPCServer that handles the requests.

The utils.py module name is vdsm.utils (as its under vdsm package).
To avoid register all vdsm module to the crabRPCServer we use custom
name and it allows an access by oop.utils.func

Change-Id: I59d258b58a18aa187eb2b723aa018e22432d61d3
Signed-off-by: Yaniv Bronhaim <ybronhei@redhat.com>
Reviewed-on: http://gerrit.ovirt.org/14325
Reviewed-by: Dan Kenigsberg <danken@redhat.com>
stats: report the domain version

Given that some features are available only since a specific domain
version (e.g. live snapshots require at least V3) and the upgrade
is asynchronous for the non-master domains (see upgradeStoragePool)
VDSM should provide to the engine a way to determine if a domain
(other than the master) has been upgraded or not.

Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=951057
Change-Id: I88884356eefcd5040deccbf34eab271be8dbc522
Signed-off-by: Federico Simoncelli <fsimonce@redhat.com>
Reviewed-on: http://gerrit.ovirt.org/13620
Reviewed-by: Allon Mureinik <amureini@redhat.com>
Reviewed-by: Dan Kenigsberg <danken@redhat.com>
vm: update volume apparentsize after snapshot

After a live snapshot succeeded we need to force the update of the
volume apparentsize to avoid races in the extension requests.

Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=923964
Change-Id: I472c2931551643914e6a09b54d3d96f371f34864
Signed-off-by: Federico Simoncelli <fsimonce@redhat.com>
Reviewed-on: http://gerrit.ovirt.org/13346
Reviewed-by: Vered Volansky <vvolansk@redhat.com>
Reviewed-by: Ayal Baron <abaron@redhat.com>
Update device hooks: Added before and after update device hooks.

Bug-Url:https://bugzilla.redhat.com/show_bug.cgi?id=893576
Change-Id: I8fe7f5e6d8291cc227a323b324c977bcd5bc8295
Signed-off-by: Giuseppe Vallarelli <gvallare@redhat.com>
Reviewed-on: http://gerrit.ovirt.org/13972
Reviewed-by: Dan Kenigsberg <danken@redhat.com>
storage.misc: Move execCmd and its dependencies to vdsm.utils

The original vdsm.utils.execCmd actually imports and invokes
storage.misc.execCmd, which means if a process does not have
/usr/share/vdsm in its PYTHONPATH and want to use vdsm.utils.execCmd, it
will fail. Furthermore, lib/vdsm/utils.py should not use anything that
is not present in the python standard library or in a dependency of the
vdsm-python package.

execCmd is very useful for modules in vdsm-tool, currently these modules
use ad-hoc execCmd implementation. This patch moves storage.misc.execCmd
and its dependencies to vdsm.utils, so that other modules can import the
'official' execCmd implementation without adding /usr/share/vdsm to
PYTHONPATH.

Change-Id: Id8fb42035b24bc915aaa700ab128580bdb609d9e
Signed-off-by: Zhou Zheng Sheng <zhshzhou@linux.vnet.ibm.com>
Reviewed-on: http://gerrit.ovirt.org/14221
Reviewed-by: Yaniv Bronhaim <ybronhei@redhat.com>
Reviewed-by: Dan Kenigsberg <danken@redhat.com>
vdsm-tool: unify ad-hoc execCmd implementations

There are various ad-hoc execCmd implementations in the modules of
vdsm-tool. Before the parent of this patch, execCmd is in storage.misc,
we can not import storage.misc.execCmd without modifying PYTHONPATH. The
parent of this patch moved execCmd to vdsm.utils, so this patch makes
use of the 'official' execCmd implementation in vdsm.utils for all the
modules of vdsm-tool.

Change-Id: I8ca64ec5dbfebe5c5090ec8fac46785a538b79d3
Signed-off-by: Zhou Zheng Sheng <zhshzhou@linux.vnet.ibm.com>
Reviewed-on: http://gerrit.ovirt.org/13917
Reviewed-by: Dan Kenigsberg <danken@redhat.com>
vdsm-tool: add service management utilities

Change-Id: Idd1cbcf5fd00bb1ec73c5970be012e294b3b4c55
Signed-off-by: Zhou Zheng Sheng <zhshzhou@linux.vnet.ibm.com>
Reviewed-on: http://gerrit.ovirt.org/13701
Reviewed-by: Federico Simoncelli <fsimonce@redhat.com>
Reviewed-by: Yaniv Bronhaim <ybronhei@redhat.com>
Reviewed-by: Ewoud Kohl van Wijngaarden <ewoud@kohlvanwijngaarden.nl>
Reviewed-by: Vered Volansky <vvolansk@redhat.com>
Reviewed-by: Dan Kenigsberg <danken@redhat.com>
vdsmd.init.in: simplify system services management by using vdsm-tool

In vdsm-tool there is a module implemented the service management
utilities that covers systemd, upstart and sysv.

Change-Id: I57a89d969b8ff4eba57daa893dc29840358c30e7
Signed-off-by: Zhou Zheng Sheng <zhshzhou@linux.vnet.ibm.com>
Reviewed-on: http://gerrit.ovirt.org/13702
Reviewed-by: Yaniv Bronhaim <ybronhei@redhat.com>
Reviewed-by: Dan Kenigsberg <danken@redhat.com>
vdsm.spec.in: update raw_version_revision

The raw_version_revision from dsaversion.py should be updated with the
version/release of RPM removing the git stuff.

Change-Id: I8dc1e514ef8fd626018167e1dd13bc58100d5d7b
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=893193
Signed-off-by: Douglas Schilling Landgraf <dougsland@redhat.com>
Reviewed-on: http://gerrit.ovirt.org/14011
Reviewed-by: Dan Kenigsberg <danken@redhat.com>
vdsmapi: vdsmapi support for gluster vdsm verbs

Reads vdsmapi-gluster-schema.json from gluster directory if
vdsm-gluster is installed.

Change-Id: Id10b51a41d103afcf81cb76c460f3b9821238317
Signed-off-by: Aravinda VK <avishwan@redhat.com>
Reviewed-on: http://gerrit.ovirt.org/13921
Reviewed-by: Timothy Asir <tjeyasin@redhat.com>
Tested-by: Timothy Asir <tjeyasin@redhat.com>
Reviewed-by: Adam Litke <agl@us.ibm.com>
trivial: Improve the ways to get bonding devices and their slaves

Compared with using glob, it could make the code simple and clean.
And it could be a little faster in the case of finding bonding device.

Change-Id: I87d25636685f75b8c429860a041494698febead0
Signed-off-by: Mark Wu <wudxw@linux.vnet.ibm.com>
Reviewed-on: http://gerrit.ovirt.org/13506
Reviewed-by: Dan Kenigsberg <danken@redhat.com>
gluster: move exportToSupervdsm at module level as makePublic

The scope of exportToSuperVdsm decorator is limited to cli.py.
It's moved to module level which enables the usage widely.
And the function name exportToSupervdsm changed into makePublic.

Change-Id: I5b8217899a637a10c7bc47a13e8afdddc1b0fefe
Signed-off-by: Timothy Asir <tjeyasin@redhat.com>
Reviewed-on: http://gerrit.ovirt.org/13051
Reviewed-by: Dan Kenigsberg <danken@redhat.com>
vdsm-reg: move OK message to caller.

Due bz#890572 engine.py now calls setVdsConf() to write into vdsm_reg.conf.
However, setVdsConf() prints an 'OK' message used in the old bootstrap and
it's showing in oVirt TUI. This patch will move this OK message to the
caller.

Change-Id: Ifaea56ca3f9f9a4f5e60c684dae9ae1f17f63a1e
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=925967
Signed-off-by: Douglas Schilling Landgraf <dougsland@redhat.com>
Reviewed-on: http://gerrit.ovirt.org/14393
Reviewed-by: Dan Kenigsberg <danken@redhat.com>
vdsm now reports pid when starting up.

When vdsm starts it now outputs to the vdsm log:
"MainThread::INFO::2013-05-05 11:57:38,609::vdsm::89::vds::(run)
(PID: 14576) I am the actual vdsm..."

Change-Id: I029581f4ab1cc5005a55c0f7ecec8672d08da49e
Bug-Url: https://bugzilla.redhat.com/952089
Signed-off-by: Assaf Muller <amuller@redhat.com>
Reviewed-on: http://gerrit.ovirt.org/14430
Reviewed-by: Giuseppe Vallarelli <gvallare@redhat.com>
Reviewed-by: Dan Kenigsberg <danken@redhat.com>
vdsm: Don't log irrelevant errors with level ERROR

libvirtconnection.get() wrapMethod logs unhandled libvirtErrors
as ERROR. However it's irrelevant at that point, therefore it
should log it only as DEBUG message.

Change-Id: I62c395734173a996bc8237d24b85f1bb32a0be35
Bug-Url: https://bugzilla.redhat.com/955593
Signed-off-by: Vinzenz Feenstra <vfeenstr@redhat.com>
Reviewed-on: http://gerrit.ovirt.org/14226
Reviewed-by: Antoni Segura Puimedon <asegurap@redhat.com>
Reviewed-by: Dan Kenigsberg <danken@redhat.com>
gluster: Added gluster hooks support

Gluster hooks enable users to run scripts on pre or post level of
gluster command execution. Pre scripts are executed before gluster
command execution and post scripts are executed after gluster
command execution.

Below new verbs are added to perform to list, enable and disable hooks.

New verbs:
* glusterHookEnable
* glusterHookDisable
* glusterHooksList
    Output structure:
        [{'name': HOOK-NAME,
          'status': STATUS,
          'type': MIME_TYPE,
          'command': GLUSTERCOMMAND,
          'level': HOOK-LEVEL,
          'md5sum': MD5SUM}]

Change-Id: I3918aa035d90967f1297dc7fadcf14b6a9385c45
Signed-off-by: Timothy Asir <tjeyasin@redhat.com>
Reviewed-on: http://gerrit.ovirt.org/9671
Reviewed-by: Aravinda VK <avishwan@redhat.com>
Reviewed-by: Adam Litke <agl@us.ibm.com>
Reviewed-by: Dan Kenigsberg <danken@redhat.com>
libvirtvm: avoid concurrent VM changes during saveState

When multiple changes of the VM configuration are applied at the
same time there's an high chance of saveState failing during a
deepcopy for a RuntimeError exception (e.g. dictionary changed size
during iteration). To avoid this problem the configuration changes
and the saveState requests are now serialized.

Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=948940
Change-Id: Ic08b4073f5e3f5184baa5f1c7dd3ec5a148ff60b
Signed-off-by: Federico Simoncelli <fsimonce@redhat.com>
Reviewed-on: http://gerrit.ovirt.org/13624
Tested-by: Daniel Paikov <paikov@gmail.com>
Reviewed-by: Ayal Baron <abaron@redhat.com>