VMware: Fix memory leaks caused by caches

Using suds objects as keys for the DatastoreBrowser cache is incorrect
because they don't implement __eq__ and __hash__ for the VIM types.
This always results in cache miss and the cache grows with every spawn()
operation.

This patch fix this by using the 'value' property (which is string) of
the MoRef as key.

Closes-Bug: 1316433
(cherry picked from commit bceb3f96b06ff8a048598724494299cf111bcaf8)

Conflicts:

	nova/tests/virt/vmwareapi/test_imagecache.py
	nova/tests/virt/vmwareapi/test_vmops.py

Change-Id: I2bcaf87e733d51055566aee41bb0a7e254027ba9
VMware: Fix fake raising the wrong exception in _remove_file

fake was raising exception.FileNotFound error if a file was not found.
However, an actual delete on a non-existent file raises the error
returned by vSphere, which is error_util.FileNotFoundException. This
breaks tests which exercise error paths expecting the real error to be
raised.

Fortunately this change doesn't break any existing tests. However, I'm
not sure that's a good thing.

This change is required to enable a test in change
I3df3d614656e511c909b6c1837582c0d34bf84c6.

Change-Id: I2025bffa887582eaa9e9072d0400f90ca97d1898
(cherry picked from commit 529b5ab2e195181687c7cc30ece8ddbf160bdeab)
VMware: Fix race in spawn() when resizing cached image

spawn() guards against multiple threads simultaneously attempting to
cache the same image, but it wasn't guarding against them
simultanously trying to create a resized copy in the cache. Attempting
to create a large number of images simultaneously of an uncached image
would result in a race to create the resized image. This resulted in 2
classes of failed instance:

1. Instances whose disk was a linked clone of a copy which had been
   subsequently overwritten. These were corrupt.
2. Instances whose spawn() failed in ExtendVirtualDisk_Task due to a
   locked image.

This patch creates a Nova-local lock for the resized image. The image
is in a per-Nova directory on the datastore, so inter-Nova locking is
not a concern. The lock guards both testing for the existence of the
image, and its creation. Therefore when multiple processes race, only
1 will create the resized copy, and all others will find and use it.
In normal usage this will add the overhead of an additional
uncontended local lock creation and deletion in spawn().

In wrapping this code in a lock, we also make certain that any failure
to create the resized image is appropriately cleaned up. Otherwise
subsequent users will attempt to use a corrupt copy.

Conflicts:
	nova/virt/vmwareapi/vmops.py

Required changes:
  datastore.build_path -> ds_util.build_datastore_path
  No datastore object
  vm_util.copy_virtual_disk -> _copy_virtual_disk
  self.fake_image_uuid -> 'fake_image_uuid'
  removed use of _LE() for log message

This change includes a test which depends on change
I2025bffa887582eaa9e9072d0400f90ca97d1898.

Change-Id: I3df3d614656e511c909b6c1837582c0d34bf84c6
Closes-bug: 1333587
(cherry picked from commit 994cdb234b2b16d97f0276c6356db65817944ee2)
Merge "VMware: Fix memory leaks caused by caches" into stable/icehouse
Merge "VMware: Fix fake raising the wrong exception in _remove_file" into stable/icehouse
Merge "VMware: Fix race in spawn() when resizing cached image" into stable/icehouse
Merge remote-tracking branch 'upstream/stable/icehouse' into stable/icehouse