net models: simplify error condition

An attempt to add a bonding device with no nics ends with a different
error, depending whether the bond is already define in the kernel or
not. This surprising behaviour means that the functional test
testFailWithBadParam fails if BONDING_NAME is removed from the kernel.

This patch unifies the error code, returning ERR_BAD_PARAMS in both
cases.

Change-Id: I557ba2dcecbfa40f9268e8c3da0562f491a32c3c
Signed-off-by: Dan Kenigsberg <danken@redhat.com>
Reviewed-on: http://gerrit.ovirt.org/28497
Reviewed-by: Antoni Segura Puimedon <asegurap@redhat.com>
virt: Specify snapshot type

Libvirt 1.2.2 introduced the 'type' attribute to the source element in a
domainsnapshot XML document.  This attribute allows you to specify
'block' as the type (which we should be doing on block domains).
Leaving this out creates a snapshot of type 'file' which has some
troubling side effects.  For one, it changes the disk type from block to
file.  This interferes with libvirt's write watermark detection causing
the wrong value to be returned.  In turn, vdsm will extend the drive
until it consumes the entire block storage domain.  See bug 1091094 [1].

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1091094

Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1091094
Change-Id: I940ef0fb702708bf2158739eeed7be43ccce78d6
Signed-off-by: Adam Litke <alitke@redhat.com>
Reviewed-on: http://gerrit.ovirt.org/28531
Reviewed-by: Federico Simoncelli <fsimonce@redhat.com>
virt: Filter internal data for getVMList API

Filter out all keys that begin with '_' when returning detailed VM
information via the getVMList API.  This is needed by live merge which
will persist block job information in a '_blockJobs' key.  We don't want
that data to be made public

Change-Id: I39ac6935e5b95912eed42f16871566722316515a
Signed-off-by: Adam Litke <alitke@redhat.com>
Reviewed-on: http://gerrit.ovirt.org/28532
Reviewed-by: Federico Simoncelli <fsimonce@redhat.com>
jsonrpc: Removal of not needed reactors

Json over tcp reactor is not needed at all and proton reactor won't be
released in 3.5.

Change-Id: I2beed9ae4adac94312681f919f9b72a692617d43
Signed-off-by: pkliczewski <piotr.kliczewski@gmail.com>
Reviewed-on: http://gerrit.ovirt.org/28503
Reviewed-by: Dan Kenigsberg <danken@redhat.com>
jsonrpc: vsam-api removal

vdsm-api was removed and all rpc related code was moved to rpc package
within vdsm. The code is packaged as part of vdsm-jsonrpc rpm.

Removed package was design to hold jsonrpc schema and its parsing code.
Jsonrpc related code was packaged already in jsonrpc. Together with
jsonrpc being required we do not need vdsm-api anymore.

Change-Id: Ib8a6bc4a064952e1c3a14b27b8db6011767a9d80
Signed-off-by: pkliczewski <piotr.kliczewski@gmail.com>
Reviewed-on: http://gerrit.ovirt.org/28527
Reviewed-by: Dan Kenigsberg <danken@redhat.com>
Reviewed-by: Nir Soffer <nsoffer@redhat.com>
jsonrpc: Moving xml rpc related modules in to rpc package

In order to keep all the modules in single place we move xml rpc module
into the package where old vdsm-api code already resides.

Change-Id: I83246098e084fe15f45d7fe50df6e4ec33d2aaa1
Signed-off-by: pkliczewski <piotr.kliczewski@gmail.com>
Reviewed-on: http://gerrit.ovirt.org/28504
Reviewed-by: Dan Kenigsberg <danken@redhat.com>
Reviewed-by: Nir Soffer <nsoffer@redhat.com>
jsonrpc: Json processing issues fixed

Number of issues fixed:
- Default value was missing in SP.disconnect
- Host.setupNetworks and Image.download was returning True where as it
should return information according to schema
- Bridge.py did not processed order of optional parameters properly.
For fencing flow second optional parameter is ued which caused the
issue. Fix provide default value for any optional parameters in between.

Change-Id: I33094f3e761c616141f60c190f7deaec08fe1f08
Signed-off-by: pkliczewski <piotr.kliczewski@gmail.com>
Reviewed-on: http://gerrit.ovirt.org/28505
Reviewed-by: Dan Kenigsberg <danken@redhat.com>
jsonrpc: ssl related code moved to single module

New sslutils module was created to keep all ssl related code.
Unit tests will be added later.

Change-Id: If941d90edc08e37e6c0707f3f3bc30f517f9e8eb
Signed-off-by: pkliczewski <piotr.kliczewski@gmail.com>
Reviewed-on: http://gerrit.ovirt.org/28506
Reviewed-by: Dan Kenigsberg <danken@redhat.com>
Reviewed-by: Nir Soffer <nsoffer@redhat.com>
logging: Use 'Storage' log handler for logging storage reports

This patch enables 23 storage loggers by making them child loggers of the
Storage logger. Before that change all those logs were used the root
handler.

Change-Id: I1dd8cd29377b12dc290f90b7c6bf314d5624a830
Signed-off-by: Nir Soffer <nsoffer@redhat.com>
Signed-off-by: Yaniv Bronhaim <ybronhei@redhat.com>
Reviewed-on: http://gerrit.ovirt.org/23924
Reviewed-by: Dan Kenigsberg <danken@redhat.com>
netinfo: Hacked InfiniBand speed.

Currently, the kernel errors out with EINVAL when
reading the speed of ib* devices. Report a speed
of 10000 for them.

Handle dummy devices' IOError gracefully.

Change-Id: I55089558d59d33da7f44a2f6d7059d291c064f8a
Bug-Url: https://bugzilla.redhat.com/1103469
Signed-off-by: Ondřej Svoboda <osvoboda@redhat.com>
Reviewed-on: http://gerrit.ovirt.org/28502
Reviewed-by: Antoni Segura Puimedon <asegurap@redhat.com>
Reviewed-by: Dan Kenigsberg <danken@redhat.com>
iproute2: raise ConfigNetworkError when dhcp fails and blockingdhcp is set

It is important that a ConfigNetworkError exception is raised when
doing the addressing synchronously, otherwise it fails silently.

Change-Id: I6bbcd0ccee2371413e228c9709cc1df984329348
Signed-off-by: Antoni S. Puimedon <asegurap@redhat.com>
Reviewed-on: http://gerrit.ovirt.org/28559
Reviewed-by: Ondřej Svoboda <osvoboda@redhat.com>
Reviewed-by: Dan Kenigsberg <danken@redhat.com>
jsonrpc: xmlrpc protocol detection

Protocol detection added which only recognize xmlrpc and there is still
additional socket to handle jsonrpc related communication.

Change-Id: I72819cc0ab5bde0150456263ab7dd1a5e99abfeb
Signed-off-by: pkliczewski <piotr.kliczewski@gmail.com>
Reviewed-on: http://gerrit.ovirt.org/28507
Reviewed-by: Nir Soffer <nsoffer@redhat.com>
Reviewed-by: Dan Kenigsberg <danken@redhat.com>
jsonrpc: json over stomp available on the same socket

Changes required to have both supported protocols detected on the same
socket opened by vdsm.

Change-Id: Idc4eb04bf6115fafa4652453f26a771f389478a1
Signed-off-by: pkliczewski <piotr.kliczewski@gmail.com>
Reviewed-on: http://gerrit.ovirt.org/28508
Reviewed-by: Yaniv Bronhaim <ybronhei@redhat.com>
Reviewed-by: Dan Kenigsberg <danken@redhat.com>
virt: Lookup conf and device by path

Live merge requires the ability to lookup a VmDevice and its associated
conf entry given a disk path.  Provide these helper methods.

Change-Id: Ib5f63715cd5142ffaf21ae9ba8d451175ae09be0
Signed-off-by: Adam Litke <alitke@redhat.com>
Reviewed-on: http://gerrit.ovirt.org/27951
Reviewed-by: Federico Simoncelli <fsimonce@redhat.com>
Reviewed-by: Francesco Romani <fromani@redhat.com>
LiveMerge: Add support for deleting merged volumes

Once a live merge has completed the merged volumes that have previously
been unlinked from the chain need to be deleted.  We can use the
existing deleteVolume verb with one minor change for block volumes.
When deleting a live-merged volume, its former child may have a stale LV
tag pointing back to this volume.  This occurs because an HSM host
resolves the block job completion event and can only update the parent
UUID in the storage domain's metadata LV (not in the LV Tags).  In this
special case, we sync the LV tag of the child to match the metadata LV
prior to validating the delete operation.

Also, don't validate deletes in hsm.py since we already perform
validation in the volume-specific implementations.

Change-Id: Icf43f65f984d7f76622454dc8877d56ef8dedb8f
Signed-off-by: Adam Litke <alitke@redhat.com>
Reviewed-on: http://gerrit.ovirt.org/26768
Reviewed-by: Federico Simoncelli <fsimonce@redhat.com>
netlink: Do not truncate InfiniBand HW addresses anymore

Change-Id: Ib53e6518d0f2f8ea573451d04ae8cb0464142a17
Signed-off-by: Ondřej Svoboda <osvoboda@redhat.com>
Reviewed-on: http://gerrit.ovirt.org/28554
Reviewed-by: Dan Kenigsberg <danken@redhat.com>
Remove usage print on vdsm-tool.UsageError and use it on ExtraArgsError

This print add usage explanation of vdsm-tool command on error. There is
no need for such print Unless UsageError refers actually to the verb
usage, but currently we use it for any usage error.
On ExtraArgsError catch we add this usage print

Change-Id: I6df376664ffcda66ea19f66e28edc0521566c091
Signed-off-by: Yaniv Bronhaim <ybronhei@redhat.com>
Reviewed-on: http://gerrit.ovirt.org/28406
Reviewed-by: Dima Kuznetsov <dkuznets@redhat.com>
Reviewed-by: Dan Kenigsberg <danken@redhat.com>
Refactoring reportError func

Extracting the error function from inner function to class level function.

Change-Id: I041a662f4fe02f671a7335d7eca84704443f5bee
Signed-off-by: Kobi Ianko <kianku@redhat.com>
Reviewed-on: http://gerrit.ovirt.org/28482
Reviewed-by: Francesco Romani <fromani@redhat.com>
Reviewed-by: Dan Kenigsberg <danken@redhat.com>
Tested-by: Kobi Ianko <kobi@redhat.com>
vdsmapi-schema: fix typo in tpm device

Small typo in documentation, VmTpmDeviceType is in no way related
to smartcard.

Change-Id: I38c616af488f0861e9357249c00c47271e033832
Signed-off-by: Martin Polednik <mpoledni@redhat.com>
Reviewed-on: http://gerrit.ovirt.org/28393
Reviewed-by: Dan Kenigsberg <danken@redhat.com>
Tested-by: Dan Kenigsberg <danken@redhat.com>
virt: stats: get rid of _getStatsInternal

it was used on just one place anyway.

Change-Id: I469759b86115d80bad62c3449fe9084d5f2e550b
Signed-off-by: Francesco Romani <fromani@redhat.com>