xenapi: reduce impact of errors during SR.scan

There are some race conditions in SR.scan leading to errors similar to:
* The SR scan failed [opterr=['MAP_DUPLICATE_KEY', 'VDI', 'sm_config',
  '$UUID', 'vhd-blocks']]
* The SR scan failed [opterr=['UUID_INVALID', 'VDI', '$UUID']]

This seems to be happening because an SR.scan is happening when a xenapi
plugin is modifying the SR at the same time.

To reduce the likely-hood of this error, I have added a mutex around
calls to SR.scan to ensure nova-compute never makes more than one call
at once, because XenServer will join any extra SR.scan requests to
listen to the result of any current SR.scan that may be running.

In addition, when and error occurs during an SR scan, I have added a
retry loop, to attempt to stop these races from impacting users.

Fixes bug 1221293
Change-Id: Ib83e6e0f4f7fab2058fe137e32934606c4fe8f7e
VMWare: Disabling linked clone doesn't cache images

This fixes an issue when use_linked_clone is false and the image is
already in the cache.  The problem was that the image would be
copied from glance into the instance directory even if it was already
in the cache.  This change checks if the file is in the cache, only
copies from glance if it is not, and copies the image from the cache
into the instance directory if use_linked_clone is false.

Fixes: bug #1207064
Change-Id: Idfa59eb0eb26cce52ff59f97e433deeab6510215
Merge "xenapi: reduce impact of errors during SR.scan"
Merge "VMWare: Disabling linked clone doesn't cache images"
xenapi: make _migrate_disk_resizing_up use @step

Make use of the step decorator into _migrate_disk_resizing_up to make it
more consistent with _migrate_disk_resizing_up.

Also add some extra unit tests to help lock down this process with unit
tests.

Change-Id: I395b8e27380649c667bb8d891802532ee3ab746b
xenapi: revert on _migrate_disk_resizing_up error

_migrate_disk_resizing_up now follows similar pattern to
_migrate_disk_resizing_down, and rolls back if there is an error.

Change-Id: I2557357a4f3502f991a5d187c2ecf7ffeb22286e
xenapi: simplify _migrate_disk_resizing_up

Previously it called get_vdi_for_vm_safely but it already had all the
information it needed from snapshot_attached_here.

Change-Id: I4e0dd1a875ee7e194d38016ff49296a360627aea
xenapi: migrate multiple ephemeral disks

Current migrate does not move ephemeral disks. This change allows those
disks to be moved. Note there could be several ephemeral disks in the
case where there are ephemeral disks that would be too big for a single
VHD file, or split up to improve performance.

This change disables the ability to resize ephemeral disks. A later
patch will look at enabling resize-up for ephemeral disks. Currently,
during resize, the ephemeral disks are just dropped and re-recreated.

Change-Id: I8d7d84b54d2a876a510c442bb11a1c64c35feb00