CA-136790: Move utility function refreshDev from B_util to scsiutil

So it can be used throughout SM.

Signed-off-by: Robert Breker <robert.breker@citrix.com>
Reviewed-by: Keith Petley <keith.petley@citrix.com>

(cherry picked from commit de31a37)
Imported-by: Robert Breker <robert.breker@citrix.com>
CA-136790: Add utility function for calling python functions with a timeout

Signed-off-by: Robert Breker <robert.breker@citrix.com>
Reviewed-by: Keith Petley <keith.petley@citrix.com>

(cherry picked from commit b42dbf1)
Imported-by: Robert Breker <robert.breker@citrix.com>
CA-136790: Add utility functions for refreshing LUN sizes to scsiutil, on_slave

This commit implements means to effectively refresh LUN sizes for a provided
SCSIid. It provides functionality to refresh the current host, with and w/o
multipath, as well as all slaves in a pool.

Signed-off-by: Robert Breker <robert.breker@citrix.com>
Reviewed-by: Keith Petley <keith.petley@citrix.com>

(cherry picked from commit b50f692)
Imported-by: Robert Breker <robert.breker@citrix.com>
CA-136790: Enable online expansion of LVHDxSRs

Attempt to expand the size of LVHDxSRs by growing into additional available
space, if extra space exists on the backing device during sr-attach of the
master or sr-scan.

If the master detects that the LUN has been resized, it will synchronize
with the slaves. If all nodes succeed to refresh the size of the LUN, the
master will go ahead and resize the PV.

This commit supersedes the limited undocumented functionality to expand
LVHDxSRs that we had before. The master used to do the resize after a reboot
during sr-attach. Pool members needed to be rebooted after the master as there
was no synchronization between pool nodes.

Signed-off-by: Robert Breker <robert.breker@citrix.com>
Reviewed-by: Keith Petley <keith.petley@citrix.com>

(cherry picked from commit 0999405)
Imported-by: Robert Breker <robert.breker@citrix.com>
CA-136790: Ensure consistent behaviour of get_devices_by_SCSIid

Dependant on the udev rules there may be a mapper device in by-scsid. This
commit ensures that that get_devices_by_SCSIid never returns the mapper-device.

Signed-off-by: Robert Breker <robert.breker@citrix.com>
Reviewed-by: Keith Petley <keith.petley@citrix.com>
CA-136790: scsiutil.getdev should return dm-x instead of individual paths

when handling mapper devices.

Signed-off-by: Robert Breker <robert.breker@citrix.com>
Reviewed-by: Keith Petley <keith.petley@citrix.com>
Merge branch 'CA-136790' into xs64bit

GitHub: closes #150 on xapi-project/sm
CP-8514: Add xapi-plugin 'trim' to facilitate trim

The xapi plugin 'trim' could be used to enable trim on LVM based
SRs to free up storage space from Storage arrays. The plugin creates
a LV using all of the free space in the VG, and then issue a lvremove
setting the issue_discards to 1. lvremove should trigger a trim / unmap
by lvm that should result in freeing up the storage space in the array

Signed-off-by: Vineeth Thampi Raveendran <vineeth.thampi@citrix.com>
Reviewed-by: Chandrika Srinivasan <chandrika.srinivasan@citrix.com>

GitHub: closes #156 on xapi-project/sm
CP-8679: fake makedirs and file, add errorcodes

Enhance the testing library by faking out os.makedirs and file. This
will enable to test further components, which try to use these
functions.

Also create a setup_error_codes method that will pretend that the error
codes file required by XenError are there.

Also increase the existing testlib's coverage to 100%.

Signed-off-by: Mate Lakat <mate.lakat@citrix.com>
Fix XenError

If the XML error description does not exist in the filesystem, XenError
tried to call Exception.__init__(self, ''), which is invalid, as self is
not inheriting from Exception.

Github: fixes xapi-project/sm#158

Signed-off-by: Mate Lakat <mate.lakat@citrix.com>
CP-8629: Do not build snapwatchd for unit testing

It is no longer required to compile snapwatchd and put the bindings on
the pythonpath, so removing it.

Signed-off-by: Mate Lakat <mate.lakat@citrix.com>
Testlib enhancements

GitHub: closes #157 on xapi-project/sm
CP-6336: Removal of dm-multipath-conf

Migration of dm-multipath-conf.patch content from dm-multipath to sm
with basic conf file.
Previously we patched device-mapper-multipath to use a different
configuration file.

Those changes are now integrated into our own configuration file
that is installed using "update-alternatives" with a backup copy
if the original file is a regular file.

Signed-off-by: Germano Percossi <germano.percossi@citrix.com>
Reviewed-by: Vineeth Thampi Raveendran <vineeth.thampi@citrix.com>
[Robert Breker cherry picked and imported for CA-132062 from commit b0892d4]
Signed-off-by: Robert Breker <robert.breker@citrix.com>
CP-7343: Enable conversion for whitespaces

Enable CentOS 6.5 flag to fix problem with devices with padded IDs.
Use same name mangling as udev rules.

Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com>
Reviewed-by: Chandrika Srinivasan <chandrika.srinivasan@citrix.com>

(cherry picked from commit ebf16b3)
Imported-by: Robert Breker <robert.breker@citrix.com>
CA-125486: Don't use commas in /etc/multipath.conf

The syntax of some of the custom entries in /etc/multipath.conf is wrong. It is
not valid to separate parameter declarations using commas.

The DM multipath parser misreads and does not apply the erroneous custom
configuration entries.

Signed-off-by: Robert Breker <robert.breker@citrix.com>
Acked-by: Germano Percossi <germano.percossi@citrix.com>

(cherry picked from commit cede3cc)
Imported-by: Robert Breker <robert.breker@citrix.com>
CP-8203: Add multipath.conf entry for EQLOGIC

Signed-off-by: Robert Breker <robert.breker@citrix.com>

(cherry picked from commit 3455114)
Imported-by: Robert Breker <robert.breker@citrix.com>
CA-125717: Reinstate default dev_loss_tmo in /etc/multipath.conf

Since implementing CA-108915 we need to specify dev_loss_tmo in
/etc/multipath.conf to properly handle lost devices.
It seems that the setting accidentaly got lost when porting the configuration
file from guest-packages.hg to dm-multipath.git. This commit reinstates the
dev_loss_tmo setting that we had before.

Why we need dev_loss_tmo:
   The way in which explicit path mapping is currently implemented requires
   dev_loss_tmo to be a finite value as close to 0 as possible.

   This is because multipathd will only monitor devices that are:
     a) accessible (scsi_id works) when a new map is initially added
     b) devices that appear after new map is added.
   In case of  dev_loss_tmo infinity, it is far more likely that devices
   linger around, are not accessible when a map is initially added (violate a),
   and multipathd does not receive an event for when they become accessible
   (like when they newly appear in case b). This leads to cases in which a
   SRs are backed by less paths then available.

   The use of dev_loss_tmo 30 generally minimises this problem.

Signed-off-by: Robert Breker <robert.breker@citrix.com>

(cherry picked from commit 4670646)
Imported-by: Robert Breker <robert.breker@citrix.com>
CA-125717: Make NETAPP LUN.* default to dev_loss_tmo 30 as a workaround

As the inbox device specific entry specifies dev_loss_tmo infinity, we need to
customise it in multipath.conf until we overcome the limitations when combining
explicit path mapping with larger values for dev_loss_tmo as outlined in
CA-135899.

Signed-off-by: Robert Breker <robert.breker@citrix.com>

(cherry picked from commit f386c21)
Imported-by: Robert Breker <robert.breker@citrix.com>
Order device specific entries in multipath.conf alphabetically

No functional change.

Signed-off-by: Robert Breker <robert.breker@citrix.com>

(cherry picked from commit 154fae0)
Imported-by: Robert Breker <robert.breker@citrix.com>
Improve the comments in multipath.conf to better guide users

No functional change.

Signed-off-by: Robert Breker <robert.breker@citrix.com>

(cherry picked from commit 214c82f)
Imported-by: Robert Breker <robert.breker@citrix.com>