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