vdsm-tool: remove 'vdsm/tool/*.pyc' files on uninstallation

It's found that 'vdsm/tool/*.pyc' files are not removed on uninstallation.
It could cause a break after installing a different version vdsm. That's
because vdsm-tool tries to load all python modules under vdsm.tool. If the
requirements of these old modules can't be sytisfied by the new installed
packages, vdsm-tool will abort.

This problem is caused by a wrong target type for python files in
lib/vdsm/tool. They're not compiled during 'make install' and therefore
complied python files are not tracked by rpm.

This patch also fixes a wrong target name in CLEANFILES.

Change-Id: I5fd67f3fbcbf4c8f72180ba0129b0bc09b20def0
Signed-off-by: Mark Wu <wudxw@linux.vnet.ibm.com>
Reviewed-on: http://gerrit.ovirt.org/16761
Reviewed-by: Yaniv Bronhaim <ybronhei@redhat.com>
Reviewed-by: Dan Kenigsberg <danken@redhat.com>
gluster: verbs for managing services

Verbs to manage or get status of gluster/system services.

glusterServicesGet: To get the status of given system services
Output structure:
{'services': [{'name': SERVICE_NAME,
               'status': STATUS,
               'message': MESSAGE},..]}

glusterServicesAction: To start/stop/restart system services like
glusterd, memcached, gluster-swift-account, smb, gluster-swift-container..
Output structure:
{'services': [{'name': SERVICE_NAME,
               'status': STATUS,
               'message': MESSAGE},..]}

Change-Id: I8a16bf566d17e186a66503391dfd04b2f2bb4bb4
Signed-off-by: Aravinda VK <avishwan@redhat.com>
Signed-off-by: Timothy Asir <tjeyasin@redhat.com>
Reviewed-on: http://gerrit.ovirt.org/11094
Reviewed-by: Zhou Zheng Sheng <zhshzhou@linux.vnet.ibm.com>
Reviewed-by: Adam Litke <agl@us.ibm.com>
Reviewed-by: Dan Kenigsberg <danken@redhat.com>
Multiple Gateways[3/2]: Re-did comms between dhclient and vdsm

SElinux disallows dhclient to change routing table information directly,
and so we needed a different way for dhclient to communicate with vdsm.
We did it via files and inotify.
dhclient writes to /var/run/vdsm/sourceRoutes with all of the info
of the DHCP response. supervdsm checks that folder upon startup
(in case dhclient operated while supervdsm was down) and registers
an inotify event handler on that folder on a separate thread.

Patch Set 3:
* Re-added libvirt check when configuring a network
* Added sourceRouteThread.py, /var/run/vdsm/sourceRoutes dir to
  spec and make files
* Capitalized DHClientEventHandler, removed os.path.join usage
* Files created in /var/run/vdsm/sourceRoutes are now named $timeStamp
  and we now read the folder in alphabetical order during vdsm start up
  so that we handle dhcp responses by their received order

Patch Set 4:
* Removed argparse from spec file
* Changed from file created to file closed to fix possible race
* Answered Giuseppe's and Dan's reviews

Patch Set 5:
* Fixed pep8 issue
* Fixed bug with signature of the event handler. It needed two
  versions: One I call manually, and one inotify calls

Change-Id: Ib7a47a680bfbfe285f708290de97e8f08714695a
Signed-off-by: Assaf Muller <amuller@redhat.com>
Reviewed-on: http://gerrit.ovirt.org/16461
Reviewed-by: Dan Kenigsberg <danken@redhat.com>
Multiple Gateways[4/2]: Fixed ifdown bug for DHCP interfaces

If the admin manually ifdown'd an interface of ours following
patch 3 in the series, we failed to remove the routes and rules
we created during ifup. The reason is that since patch 3 we
are working with files. The dhclient hook created a file during
ifdown and finished the ifdown operation before VDSM got the
notification that the file was created. By the time VDSM got
the notification the interface was already down and thus could
not find any information about the interface.

This patch fixes that bug by adding the device to the rule
while adding the rule, so that we may use the device name
to look up all rules created for that device.

Patch Set 2:
* Renamed Rule.inDevice to Rule.srcDevice
* Removed sourceRoute.py:_getNetwork

Change-Id: If1ed9efc548ec0342db9ea0ae4692d2c0aec93df
Signed-off-by: Assaf Muller <amuller@redhat.com>
Reviewed-on: http://gerrit.ovirt.org/16552
Reviewed-by: Dan Kenigsberg <danken@redhat.com>
fileSD: fix set update for getAllImages

Change-Id: I3afc389fcd02bd7b08d7b194c2e130d7541e2b9a
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=982617
Signed-off-by: Yeela Kaplan <ykaplan@redhat.com>
Reviewed-on: http://gerrit.ovirt.org/16830
Reviewed-by: Eduardo <ewarszaw@redhat.com>
Multiple Gateways[5/2]: sourceRoute handles exceptions

sourceRoute.configure and remove now handle IPRoute2Error
exceptions that can be thrown if using DynamicSourceRoute
and the Iproute2 configurator. The Iproute2 configurator
calls 'ip rule add/remove, ip route add/remove' that can
throw exceptions if the configuration fails.

For example:
  1) If we try to add routes if the interface is down
     (Which might happen during host bootup)
  2) If we try to configure routes that already exist
  3) If we try to remove rules that don't exist

Patch Sets 2-4:
* Rebases

Patch Set 5:
* Moved exception handling to sourceRoute.py

Patch Set 6:
* Removed unused imports

Patch Set 7:
* Updated commit message

Change-Id: Ib550a63257de28df1c44a92aeb0dc078f2edd906
Signed-off-by: Assaf Muller <amuller@redhat.com>
Reviewed-on: http://gerrit.ovirt.org/16629
Reviewed-by: Dan Kenigsberg <danken@redhat.com>
lvm: Enhance lvm performance by altering filter

Change-Id: If92940f132238d90e91c1e9ddfecb68df453e1d8
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=981055
Signed-off-by: Yeela Kaplan <ykaplan@redhat.com>
Reviewed-on: http://gerrit.ovirt.org/16730
Reviewed-by: Marina Kalinin <marinamku@gmail.com>
Tested-by: Marina Kalinin <marinamku@gmail.com>
Reviewed-by: Saggi Mizrahi <smizrahi@redhat.com>
Multiple Gateways[6/2]: Swapped libvirt network & netEnt creation

During source routing configuraton for DHCP interfaces we wanted
to know if we're dealing with an interface that's 'owned' by
VDSM. Because of that we swapped the order in which we ifup
or ifdown an interface and create its libvirt network,
so that first we create the libvirt network and then the
top level device, that way when we ifupifdown and get a DHCP
response we can check if the interface is known to libvirt.
That introduced a bug when deleting a network that was on top
of a bridgeless-bond. Additionally, because of patches 3+4
in the Multiple Gateways series the original swap created a
race condition.

This patch reverses the libvirt network creation / deletion
and net entitiy creation / deletion to the original order,
and uses an alternative / additional method to check if an
interface is owned by VDSM.

Patch Set 3:
* Added /var/run/vdsm/trackedInterfaces to spec/make files

Patch Set 4:
* Added comment so that future generations know why we must
  first remove the libvirt network and then the network entity
  during delNetwork
* Moved interface tracking files add/delete to
  DynamicSourceRoute. Moved libvirt/vdsm interface checks
  from static to dynamic as well
* Added a helper method to get a tracking file path, using
  os.path.join

Patch Set 5:
* Fixed pep8 issue

Patch Set 6:
* Removed debugging log output

Patch Set 7:
* Use util.rmFile to remove tracking files
* Open and then close files instead of using the touch binary
  for creating tracking files

Change-Id: Ic5af431909427dc7488875f0cb14fe4361657a83
Signed-off-by: Assaf Muller <amuller@redhat.com>
Reviewed-on: http://gerrit.ovirt.org/16692
Reviewed-by: Dan Kenigsberg <danken@redhat.com>
spec: restart systemd-modules-load.service on post installation

It's observed that the needed modules are not loaded after vdsm is
installed without rebooting system. That's because we reply on
systemd-modules-load.service to load the modules required by vdsm,
but systemd-modules-load.service can't detect the new config
file added by vdsm. It should not be a problem if the vdsm host
is added to ovirt engine. So this change only make it more friendly
for people who run vdsm in standalone mode.

Change-Id: I7786a6d73307369f72ea83f27c3a128ba9d99159
Signed-off-by: Mark Wu <wudxw@linux.vnet.ibm.com>
Reviewed-on: http://gerrit.ovirt.org/16610
Reviewed-by: Zhou Zheng Sheng <zhshzhou@linux.vnet.ibm.com>
Reviewed-by: Douglas Schilling Landgraf <dougsland@redhat.com>
Reviewed-by: Dan Kenigsberg <danken@redhat.com>
trival change for skip mom test logic

    using wrapper of runtime vdsm caps to judge mom module existence
instead of trying to load, make it usable for other testcases outside
this module.

Change-Id: Iee2adb63d61f708d74ef84ee68f220994247eea3
Signed-off-by: Royce Lv<lvroyce@linux.vnet.ibm.com>
Reviewed-on: http://gerrit.ovirt.org/12550
Tested-by: Mei Liu <liumbj@linux.vnet.ibm.com>
Reviewed-by: Dan Kenigsberg <danken@redhat.com>
volume: add the extendVolumeSize method

This patch adds the extendVolumeSize SPM method to implement the volume
size extension (disk resize).

 extendVolumeSize(spUUID, sdUUID, imgUUID, volUUID, newSize)

The argument spUUID, sdUUID, imgUUID, volUUID indentify the volume to
extend, newSize is the new size of the volume in bytes.

Change-Id: I817be851d7fbe080adf4da297b526837e244cec6
Signed-off-by: Federico Simoncelli <fsimonce@redhat.com>
Reviewed-on: http://gerrit.ovirt.org/14590
Reviewed-by: Sergey Gotliv <sgotliv@redhat.com>
Tested-by: Sergey Gotliv <sgotliv@redhat.com>
Reviewed-by: Allon Mureinik <amureini@redhat.com>
Reviewed-by: Ayal Baron <abaron@redhat.com>
init: restart sanlock groups are missing

If sanlock was started before the *first* installation of vdsm
then it is probably missing the supplementary groups and it needs
to be restarted.

Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=977926
Change-Id: Idd3f8ffe10f771a09d0a779b148bb2ebaf95fecc
Signed-off-by: Federico Simoncelli <fsimonce@redhat.com>
Reviewed-on: http://gerrit.ovirt.org/16742
Reviewed-by: Allon Mureinik <amureini@redhat.com>
Reviewed-by: Ayal Baron <abaron@redhat.com>
deploy: add rpcbind to the needed services

Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=977940
Change-Id: I5ff0b85d5a7c439fbd8d6946f0861c5f27d0042e
Signed-off-by: Federico Simoncelli <fsimonce@redhat.com>
Reviewed-on: http://gerrit.ovirt.org/16741
Reviewed-by: Allon Mureinik <amureini@redhat.com>
Reviewed-by: Ayal Baron <abaron@redhat.com>
vm: add the live diskSizeExtend method

This patch adds the diskSizeExtend HSM method to implement the live disk
extension.

 returnCode = diskSizeExtend(vmUUID, driveSpecs, newSize)

 driveSpecs =  {
   'poolID':   '<spUUID>',
   'domainID': '<sdUUID>',
   'imageID':  '<imgUUID>',
   'volumeID': '<volUUID>',
 }

 returnCode = {
   'status': {'code': 0, 'message': 'Done'},
   'size': '<newSize>',
 }

The driveSpecs (usually poolID, domainID, imageID, volumeID) indentify
the disk to extend. The driveSpecs as GUID is not supported.
The returnCode also returns the newSize of the disk seen by the guest
(might be different from the requested one, e.g. rounded by QEMU).

The returnCode might also return the following specific errors:

- noVM(1): Virtual machine does not exist
- resizeErr(58): Wrong resize disk parameter
- updateDevice(56): Failed to update device

Change-Id: I326f0e71d53382a49eb3b43cdf0bc0472f71abdc
Signed-off-by: Federico Simoncelli <fsimonce@redhat.com>
Reviewed-on: http://gerrit.ovirt.org/15614
Reviewed-by: Ayal Baron <abaron@redhat.com>
vdsm.spec: glusterfs 3.4

Glusterfs 3.4 package now available at Koji, updating the spec.

Change-Id: I16bf2f5bbc606b55440cf04e7d5e08bcdc7729a5
Signed-off-by: Douglas Schilling Landgraf <dougsland@redhat.com>
Reviewed-on: http://gerrit.ovirt.org/16894
Reviewed-by: Dan Kenigsberg <danken@redhat.com>
vdsm: /usr/lib/tmpfiles.d/vdsm.conf

tmpfiles.d is a service in Fedora 15 and later for managing temporary files and
runtime directories for daemons. Directories /var/run and /var/lock are symlinks
into the /run tmpfs filesystem. As such, they are created empty on every reboot.
For files intended to be placed into those directories, this should normally
not pose any problems. For directories, however, we often need to create the
directories ahead of time. This is best done using the tmpfiles.d mechanism.

Change-Id: Iea9ec4b7ba1e362c1141c4e0cb734d2b1520dbfd
Signed-off-by: Douglas Schilling Landgraf <dougsland@redhat.com>
Reviewed-on: http://gerrit.ovirt.org/15707
Reviewed-by: Yaniv Bronhaim <ybronhei@redhat.com>
Reviewed-by: Dan Kenigsberg <danken@redhat.com>
Remove mac address from host interface statistics

It's unnecessary to report mac address in host interface statistics
since it's unchanged. And it's not used by engine side. So it's safe
to remove it.

Change-Id: If5c2b455387f30bfb386662fa040a82b051f153d
Signed-off-by: Mark Wu <wudxw@linux.vnet.ibm.com>
Reviewed-on: http://gerrit.ovirt.org/13840
Reviewed-by: Petr Šebek <psebek@redhat.com>
Reviewed-by: Dan Kenigsberg <danken@redhat.com>
destroyStoragePool: release host id lease correctly

In hsm.py destroyStoragePool, it calls pool.domainMonitor.close() before
pool.detachAllDomains(). domainMonitor.close() assumes SPM is stopped
and releases the host id lease for all domains, however this is not true,
because the master storage domain is not detached and the cluster lock
is still ative. This causes domainMonitor fail to release host id lease
of the master domain but the monitor thread is stopped. In log file we
can see this exception traceback. When we call formatStorageDomain,
sanlock is still active on the id lease file so the domain can not be
cleaned, and it raises an exception
"MiscDirCleanupFailure: Directory cleanup failure" for fileSD,
"VolumeGroupRemoveError: Volume Group remove error" for blockSD.

Since pool.detachAllDomains() detaches master storage domain and
releases cluster lock, pool.domainMonitor.close() should be called after
pool.detachAllDomains(). Actually self._disconnectPool() indirectly
calls pool.domainMonitor.close() at last, so there is no need to call it
directly in destroyStoragePool().

This patch deletes the line calling pool.domainMonitor.close() in
destroyStoragePool(), so that the cluster lock and host id lease of
master storage domain are released in the correct order, and
formatStorageDomain would succeed in cleaning the domain.

Change-Id: Ie3b4eb587ddb4fc61b389f592d7a3e1ae239c1a3
Signed-off-by: Zhou Zheng Sheng <zhshzhou@linux.vnet.ibm.com>
Reviewed-on: http://gerrit.ovirt.org/16895
Reviewed-by: Saggi Mizrahi <smizrahi@redhat.com>
Add setMOMPolicyParameters

This adds setMOMPolicyParameters to the API and a configuration
option mom/tuning_policy to the configuration file.

It is intended to be used for fine tuning a MoM policy.

Change-Id: Ie2c2fce24a8a499976ef845ce1e7e40bdd439949
Signed-off-by: Martin Sivak <msivak@redhat.com>
Reviewed-on: http://gerrit.ovirt.org/16659
Reviewed-by: Dan Kenigsberg <danken@redhat.com>
Enable balloon and use the MoM multiple policies feature

This moves mom policy configuration to /etc/vdsm/mom.d and
splits the policy files to:

00-python.policy
01-parameters.policy
02-balloon.policy
03-ksm.policy

It also uses the 01 file as the destination for updates
received using the setMOMPolicyParameters API call.

Change-Id: I3fa80990bdbcd88f8ec83f5c664047c75c2e7a73
Signed-off-by: Martin Sivak <msivak@redhat.com>
Reviewed-on: http://gerrit.ovirt.org/16728
Reviewed-by: Dan Kenigsberg <danken@redhat.com>