CP-8657: Remove iSL references from storage manager.

- Removed all code references
- Removed all CSLG error codes
- Replaced CSLGXMLParse to XMLParse

Signed-off-by: Siddharth Vinothkumar <siddharth.vinothkumar@citrix.com>
Reviewed-by: Chandrika Srinivasan <chandrika.srinivasan@citrix.com>
Imported-by: Thanos Makatos <thanos.makatos@citrix.com>

(cherry picked from commit 0b1e794152b8a97746985776edc5388e1b841ee4)

Methods util.get_isl_scsiids, util.get_scsiid_from_svid, and
util.getCslDevPath have been kept back as they are used by OCFS.

Conflicts:

	drivers/mpathcount.py
CP-8657: Fix XE_SR_ERRORCODES.xml

Signed-off-by: Chandrika Srinivasan <chandrika.srinivasan@citrix.com>
Reviewed-by: Mate Lakat <mate.lakat@citrix.com>
Imported-by: Thanos Makatos <thanos.makatos@citrix.com>

(cherry picked from commit 004465eb3d9506d0c0707414ef693abe76f0ad92)
CA-134784: [UnitTest] Mimic rmdir, open('w')

Mimic the behavior of rmdir, and also raise the appropriate exceptions
if client wants to open a file in a non-existing directory. Enable the
client to open files with 'w' flag.

Signed-off-by: Mate Lakat <mate.lakat@citrix.com>
Reviewed-by: Chandrika Srinivasan <chandrika.srinivasan@citrix.com>
Imported-by: Thanos Makatos <thanos.makatos@citrix.com>

(cherry picked from commit 3090c20534f6a900cea1489f72ba1e3d729d1374)
CA-134784: [UnitTest] cover refcounter

Signed-off-by: Mate Lakat <mate.lakat@citrix.com>
Reviewed-by: Chandrika Srinivasan <chandrika.srinivasan@citrix.com>
Imported-by: Thanos Makatos <thanos.makatos@citrix.com>

(cherry picked from commit 019f1404e60f21ff632af14c386428b1449c88e3)
CA-134784: Fix race conditions in refcounter

Concurrent refcounter operations on two different refcounters sharing
the same namespace can lead to race conditions:
 A.) By the time the refcounter file is written, the namespace directory
     has already been removed
 B.) Removing a namespace directory fails, because a a new refcounter file
     has been created within the same directory

_writeCount now returns False if the file was not found

A is solved by spinning on _writeCount until it succeeds.
B is solved by ignoring the errors

Signed-off-by: Mate Lakat <mate.lakat@citrix.com>
Reviewed-by: Thanos Makatos <thanos.makatos@cirix.com>
Imported-by: Thanos Makatos <thanos.makatos@citrix.com>

(cherry picked from commit 63491d7b74e864436715e2a77d921be495445cbe)

Conflicts:

	drivers/refcounter.py
CA-134784: [UnitTest] Tests for refcounter

Signed-off-by: Mate Lakat <mate.lakat@citrix.com>
Reviewed-by: Chandrika Srinivasan <chandrika.srinivasan@citrix.com>
Imported-by: Thanos Makatos <thanos.makatos@citrix.com>

(cherry picked from commit f5693a167e271e90b09f34b10f68c571171e186a)
CA-135017: notify toolstack about tapdisk unpause errors in coalesce

Coalesce is an asynchronous operation so if a tapdisk refresh fails the
VM will lose the disk but the administrator will realise that when the
VM hangs. This patch notifies the toolstack as soon as the failure
occurs.

Signed-off-by: Thanos Makatos <thanos.makatos@citrix.com>
Acked-by: Germano Percossi <germano.percossi@citrix.com>
Imported-by: Thanos Makatos <thanos.makatos@tcitrix.com>

(cherry picked from commit 5d3a649127036e0c2ceeeb169d55e451e22cdd91)
CA-139484: introduce TapdiskFailed exception type

Signed-off-by: Thanos Makatos <thanos.makatos@citrix.com>
Reviewed-by: Siddharth Vinothkumar <siddharth.vinothkumar@citrix.com>
Imported-by: Thanos Makatos <thanos.makatos@citrix.com>

(cherry picked from commit 4b999e1e2848e4cbc48d7a7f25ae5ede5e4d19b1)

Conflicts:

	drivers/XE_SR_ERRORCODES.xml
CA-139739: encode NFS shares

Signed-off-by: Thanos Makatos <thanos.makatos@citrix.com>
Reviewed-by: Chandrika Srinivasan <chandrika.srinivasan@citrix.com>
Imported-by: Thanos Makatos <thanos.makatos@citrix.com>

(cherry picked from commit 2508b267a717391c92a2caecc6d826f600564b15)
CA-119888: Fix logical volume deletion error.

Signed-off-by: Siddharth Vinothkumar <siddharth.vinothkumar@citrix.com>
Reviewed-by: Chandrika Srinivasan <chandrika.srinivasan@citrix.com>
Imported-by: Thanos Makatos <thanos.makatos@citrix.com>

(cherry picked from commit 51d1ff4f18e0371aff4a4300c95a21bca32a729a)
UnitTest: log to stdout

By printing the log messages to stdout, they will be captured by nose,
thus not disturbing the user. Should a test fail, the messages will
still be displayed.

Signed-off-by: Mate Lakat <mate.lakat@citrix.com>
Acked-by: Germano Percossi <germano.percossi@citrix.com>
Imported-by: Thanos Makatos <thanos.makatos@citrix.com>

(cherry picked from commit 9a19651f8212c96a751e282025284882653e2212)
UnitTest: Enable custom context

Should the user want to use a custom context implementation, he can use
the with_custom_context decorator to do that. It enables users to
inherit from TestContext, extend its functionality, and use the extended
version in a test. This could be useful if someone wanted to use a
custom implementation for `open`.

Signed-off-by: Mate Lakat <mate.lakat@citrix.com>
Acked-by: Germano Percossi <germano.percossi@citrix.com>
Imported-by: Thanos Makatos <thanos.makatos@citrix.com>

(cherry picked from commit 422896397367f7832cba94e4269c9371bd835921)
CA-140596: [UnitTest] Test to reproduce gc error

This test will reproduce the issue that was seen in the referenced
ticket. Whenever a new Lock instance is created, and the file() call
fails, the instance's lockfile attribute remained uninitialised. As the
instance has a custom destructor, that will be called by the garbage
collector. That function assumes that the instance has a lockfile
attribute, and thus prints a message.

Signed-off-by: Mate Lakat <mate.lakat@citrix.com>
Acked-by: Germano Percossi <germano.percossi@citrix.com>
Imported-by: Thanos Makatos <thanos.makatos@citrix.com>

(cherry picked from commit 9c077a91c338cda683111c9bbc6490c4867fda97)
CA-140596: Fix lockfile attribute in Lock

As Lock's destructor was assuming that lockfile attribute exists, it
printed out an AttributeError on stdout while the GC was cleaning it up.
This fix initialises the lockfile field in the constructor.

Signed-off-by: Mate Lakat <mate.lakat@citrix.com>
Reviewed-by: Germano Percossi <germano.percossi@citrix.com>
Imported-by: Thanos Makatos <thanos.makatos@citrix.com>

(cherry picked from commit 22d7e9b62ecb196cdd382776b4567b959a4336a8)
CA-140596: Add seam for file call

Extract the file call to a separate method, so that the extracted method
could be used in tests as a seam, emulating situations like: what would
happen if the file call failed.

Signed-off-by: Mate Lakat <mate.lakat@citrix.com>
Reviewed-by: Germano Percossi <germano.percossi@citrix.com>
Imported-by: Thanos Makatos <thanos.makatos@citrix.com>

(cherry picked from commit 1d2d9084bf6b041ce639effd75b2e7aa7342fad8)
CA-140596: [UnitTest] Test file not found in Lock

These are test cases covering the lock module, and also testing what
happens if file() raises an IOError. This can happen as a race
condition, if two locks - A and B are created in the same namespace and
by the time A gets to open the lockfile, B already cleaned up the
namespace.

Signed-off-by: Mate Lakat <mate.lakat@citrix.com>
Acked-by: Germano Percossi <germano.percossi@citrix.com>
Imported-by: Thanos Makatos <thanos.makatos@citrix.com>

(cherry picked from commit d10e3b034486a852483c22822e16b6249aeefdca)
CA-140596: Fix file creation error

If creating the lockfile failed with IOError having ENOENT error code,
that means that another lock within the same namespace already cleaned
up the namespace. With this change, should IOError happen with ENOENT,
the lock will re-create the namespace, and the file 10 times, and only
bubble up the exception if it failed all those retries.

Signed-off-by: Mate Lakat <mate.lakat@citrix.com>
Reviewed-by: Germano Percossi <germano.percossi@citrix.com>
Imported-by: Thanos Makatos <thanos.makatos@citrix.com>

(cherry picked from commit 3021503ce0275f4c293df1785e1c95111034c6c9)
UnitTest: tests for NFSSR.py, ISOSR.py and nfs.py

Test mount calls.

Signed-off-by: Robert Breker <robert.breker@citrix.com>
Signed-off-by: Mate Lakat <mate.lakat@citrix.com>
Acked-by: Germano Percossi <germano.percossi@citrix.com>
Imported-by: Thanos Makatos <thanos.makatos@citrix.com>

(cherry picked from commit 27fbd54c9cd97a9b3a18a55f33aec0c9dc010b20)
CA-135612: Add experimental support for NFSv4

This enables the specification of the NFS version (3,4) in the
device-config of ISOSRs(type=nfs) and NFSSRs.

For example:

    device-config:nfsversion=4

Signed-off-by: Robert Breker <robert.breker@citrix.com>
Signed-off-by: Mate Lakat <mate.lakat@citrix.com>
Reviewed-by: Germano Percossi <germano.percossi@citrix.com>
Imported-by: Thanos Makatos <thanos.makatos@citrix.com>

(cherry picked from commit 7fa6b8c65d0a8fc72d14f39ab7f56a87aacbf3c9)
CA-135612: [UnitTest] Tests for nfsversions

Test NFSSR, ISOSR and nfs

Signed-off-by: Robert Breker <robert.breker@citrix.com>
Reviewed-by: Mate Lakat <mate.lakat@citrix.com>
Acked-by: Germano Percossi <germano.percossi@citrix.com>
Imported-by: Thanos Makatos <thanos.makatos@citrix.com>

(cherry picked from commit 7c13c87c8f14d0ff24f4b8b27cdbceef0e4ea6dc)