CP-7292: add pylintrc 0.21.1 standard template

As pylintrc-0.13.1, this backup can helps us to identify our setup
customization when we upgrade to newer release of pylint in the future.

Signed-off-by: Zheng Li <zheng.li@eu.citrix.com>
Reviewed-by: Chandrika Srinivasan <chandrika.srinivasan@citrix.com>
CP-7292: port our customization onto the new pylintrc template

Get the customization we previously made by diffing the current
pylintrc and pylintrc 0.13.1 template we backed up, then ported
it onto the new pylintrc (based on pylintrc 0.21.1 template).

Signed-off-by: Zheng Li <zheng.li@eu.citrix.com>
Reviewed-by: Chandrika Srinivasan <chandrika.srinivasan@citrix.com>
CP-7292: remove the pylintrc 0.13.1 template backup

Signed-off-by: Zheng Li <zheng.li@eu.citrix.com>
Reviewed-by: Chandrika Srinivasan <chandrika.srinivasan@citrix.com>
CP-7292: E1201 is now deprecated

Putting it in the config would stop pylint from working.

Signed-off-by: Zheng Li <zheng.li@eu.citrix.com>
Reviewed-by: Chandrika Srinivasan <chandrika.srinivasan@citrix.com>
CP-7292: Inherit XenError from the Exception base class (E0710)

Let XenError inherit from the Exception base class, so that we can
get rid of the E0710 exemption. Otherwise pylint complains with

E0710: Raising a new style class which doesn't inherit from BaseException

Signed-off-by: Zheng Li <zheng.li@eu.citrix.com>
Reviewed-by: Chandrika Srinivasan <chandrika.srinivasan@citrix.com>
CP-7292: Remove E1101 from the exemption list

E1101: Used when a variable is accessed for a nonexistent member.

Some type magic in a small portion of blktap2.py is too advanced
for pylint to comprehend. So we explicitly tell pylint to ignore
that particular warning on that particular section.

By doing so, we can now enable E1101 for all the rest part of our
code to achieve better safety.

Signed-off-by: Zheng Li <zheng.li@eu.citrix.com>
Reviewed-by: Chandrika Srinivasan <chandrika.srinivasan@citrix.com>
CP-7292: remove the dependency on simplejson

The extra dependency on simplejson makes pylint to complain, because
the 3rd party module is not available in our building environment.

Replacing this single instance with python's standard json lib, we
can achieve equally good result for our simple object.

Signed-off-by: Zheng Li <zheng.li@eu.citrix.com>
Reviewed-by: Chandrika Srinivasan <chandrika.srinivasan@citrix.com>
CP-7292: remove dependency on iofi

iofi is a customize module which doesn't exist in either xenbuilder
chroot or a standard XenServer host. Hence pylint complains about
the reference to a non-existed module.

My understanding is that the module is for debugging purpose and can
be purposely copied onto the system when necessary. But in general
cases, it won't be on the system.

The change workaround the pylint complain by using dynamic loading
via module name. This also fits the conditional loading concept
in context, where loading which module could be calculated and
dynamically decided (though not necessary in this instance).

Signed-off-by: Zheng Li <zheng.li@eu.citrix.com>
Reviewed-by: Chandrika Srinivasan <chandrika.srinivasan@citrix.com>
CP-7292: Make use of the exit code of pylint

In the previous version of pylint we use, the exit code of a pylint
process is always zero (regardless there are issues found or not).
So we have to capture the output of pylint to make a judgement call
ourselves.

The newer vesion of pylint exit with non-zero code if any issue
has been found. So we can now interpreter the exit code rathe than
the output text, which makes things simpler.

Unfortunately, a bug in the exact version 0.21.1 [1] stops us from
passing all the python files to check to pylint all at once, so we
still have to iterate over all the files one by one and record the
existence of any errors. The code can become considerablly simpler
when we move to a even newer version of pylint with this bug fixed.

[1] http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=591670

Signed-off-by: Zheng Li <zheng.li@eu.citrix.com>
Reviewed-by: Chandrika Srinivasan <chandrika.srinivasan@citrix.com>
Merge CP-7292: Update pylint config for CentOS 6.4

Signed-off-by: Zheng Li <zheng.li@eu.citrix.com>
Reviewed-by: Chandrika Srinivasan <chandrika.srinivasan@citrix.com>

Github: closes #71 on xapi-project/sm
CA-123640: clarify use of LEAFCLSC_OFFLINE

Signed-off-by: Thanos Makatos <thanos.makatos@citrix.com>
Reviewed-by: Vineeth Thampi Raveendran <vineeth.thampi@citrix.com>

GitHub: closes #62 on xapi-project/sm
CA-124248: Resolve EEXIST errors.

When attempting to manually recreate the symlinks which possess valid
dev-mapper entries, ignore EEXIST errors.

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

GitHub: closes #73 on xapi-project/sm
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>

Github: closes #67 on xapi-project/sm
CP-5913: Move users of "xs.h" to "xenstore.h"

Signed-off-by: Zoltan Kiss <zoltan.kiss@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Thanos Makatos <thanos.makatos@citrix.com>

GitHub: closes #74 on xapi-project/sm
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>

GitHub: closes #72 on xapi-project/sm
CA-127209: Disk may not have enough space to do a parent inflate

In case when the clone operation failed for Out of Storage, disk may not
have enough space to do a inflate parent keeping the full sized child.
The order of operation should be to delete the children, and then go for
a parent inflate

Signed-off-by: Vineeth Thampi Raveendran <vineeth.thampi@citrix.com>
Reviewed-by: Thanos Makatos <thanos.makatos@citrix.com>

GitHub: closes #77 on xapi-project/sm
CP-7396: Ensure tapdisk reports metrics to rrdd.

- Register tapdisk with rrdd as a plugin when we open a new tapdisk.
- Deregister tapdisk with rrdd before we detach the tapdisk.

Signed-off-by: Siddharth Vinothkumar <siddharth.vinothkumar@citrix.com>
Reviewed-by: Vineeth Thampi Raveendran <vineeth.thampi@citrix.com>

GitHub: closes #75 on xapi-project/sm
CA-125230: Fix compilation for 64 bit

Support pack use fixed build architecture.
Change to detect architecture to fix building on 64 bit architecture and
stay compatible with 32 bit one.

Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com>
Acked-by: Germano Percossi <germano.percossi@citrix.com>

GitHub: closes #68 on xapi-project/sm
CA-117628: allow LVM metadata updates when running through plug-in

This patch uses the LVM configuration file that allows metadata updates when
running LVM commands on the master through the plug-in. In addition,
this patch introduces checks on the return value of a few functions.

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

GitHub: closes #70 on xapi-project/sm
XOP-591: Dump sm_config as part of NFSVDI.generate_config

This information is used by HA to attach heartbeat VDI when XAPI is
not around. It is necessary to preserve the sm_config information
because it now contains the nosubdir flag which is crucial for
deciding which path to mount.

Previously, we deliberately didn't change this to minimize code
churn, because we knew that Cloudstack didn't use XenServer's HA,
and even if they do, they should use the normal NFSSR with subdirectory.

However, the situation changed. Firstly, CloudStack will use XenServer's
HA; Secondly, a user could set heartbeat SR to CloudStack's primary NFSSR
storage by mistake (which has the nosubdir=true) and he/she will then
stuck in a situation can't easily recover. Therefore, we must fix this
problem properly.

Signed-off-by: Zheng Li <zheng.li@citrix.com>
Reviewed-by: Vineeth Thampi Raveendran <vineeth.thampi@citrix.com>

Github: closes #78 on xapi-project/sm