Replaces exception re-raising in Hyper-V

In a few cases in the Hyper-V driver classes, generic exceptions
are getting caught, logged and a domain specific exception is raised.

This creates issues in identifying the exception cause programmatically
(e.g. in unit tests).

This patch enforces the usage of excutils.save_and_reraise_exception()

Closes-Bug: #1280363

Change-Id: I27cc54941c5f592ea567ccaa8fa369362da1427f
Unmount the NFS and GlusterFS shares on detach

When attaching an NFS or GlusterFS volume, nova mounts the share so it
can be reused by other instances but it is not unmounted when detaching.

This patch adds the disconnect_volume method to both drivers, which will
try to unmount the share. If a volume in that share is still being used
by another instance, the umount command will fail with the error 'target
is busy' and we will ignore it. Any other error while unmounting will be
properly logged. In any case the detach will fail because nova hasn't
been able to unmount the share.

Closes-Bug: #1285209
Change-Id: I79289524541a88ad359b3465719055cd402b4e3d
Skip sqlite-specific tests if sqlite is not configured

There are several tests in test_migration_utils which only work if
sqlite is configured for migration tests, but two of them are missing
the conditional checks for skipping the test.

Also renames test_check_shadow_table_with_unsupported_type to
test_check_shadow_table_with_unsupported_sqlite_type since it's specific
to sqlite.

Closes-Bug: #1275352

Change-Id: I46f1b95e654bc702c76790350a8929d03c04e0a1
neutron_metadata_proxy_shared_secret should not be written to log file

This patch sets secret=True for the following config option
neutron_metadata_proxy_shared_secret

Change-Id: I381ea9e89f76beac11b03def6e3ccfee2a55e48f
Closes-bug: #1288463
xenapi: fix spawn servers with ephemeral disks

The new resize ephemeral disk code uses vdis["ephemerals"] to pass the
list of ephemeral vdis to the resize disk code. This is shared between
spawn and resize. As spawn wants to resize the root disk, resize=True
during the spawn operation.

The code in _attach_disks correctly deals with empty ephemeral disks,
but the code in _resize_up_vdis did not, and failed due to
ephemeral_vdis being None.

This is a quick fix for the issue. We need some refactoring in this area
so there is, ideally, only one place that generates ephemeral disks.

Change-Id: If058c5c17c2ed76569fd98d4a3d8e5274721fbd0
Closes-Bug: #1289361
Fix debug message formatting in server_external_events

Hopefully this will be the last case of invalid debug log messages to
fix before turning on debug level log messages on during unit tests, so
we can gate on issues like this.

Change-Id: I8a2b64222deaf5320bcc2e5215b6bd46565a505f
Use debug level logging during unit tests

When unit tests fail we need to debug, so we should have debug level logging on.
We use fixtures FakeLogger during testing, to  enable debug logging pass
in log level as a parameter.
http://bazaar.launchpad.net/~python-fixtures/python-fixtures/trunk/view/head:/lib/fixtures/_fixtures/logger.py#L68

Change-Id: I70790aa39c0774726de71e5fa5751c45e7e34ffd
Use instance object instead of _instance_update()

Currently, if a user takes a snapshot of a VM, stops nova-cpu
before the snapshot operation is finished, and restart nova-cpu:
nova-cpu will crash with the error:
AttributeError: 'dict' object has no attribute 'task_state'
This happens because the _instance_update() method returns a dict
and not an Instance object.

This patch fixes the issue by not using _instance_update()
in the compute manager which is returning a dict and using
the instance object instead.

Change-Id: I3af0b09aeff7790b147a684f7c90af17d8ee7ae2
Closes-Bug: #1287945
Fix: Unshelving an instance uses original image

The driver uses the property image_ref to boot the
the instance.
This patch updates the image_ref property with the
shelved_image_id stored during the shelving.

Change-Id: I3bba0a230044613e07122a6d122597e5b8d43438
Closes-Bug: #1257594
Fix compute_node stats

The compute_node object has several issues with the stats field
that are cleaned up by this patch, including the following:

- obj_make_compatible() should check the stats property exists
  before attempting to delete it
- from_db_object() should not create the stats property if it
  is not in the database field (it is a nullable field)
- create() should convert the stats property to its database
  field format if it is present
- tests for create() and save() should check that the database
  format conversion is done

This method does not change any fields so there is no change to
the object's version.

Change-Id: I5c68994d618f0ecf9409c37321bc87a006c431ac
Merge "Skip sqlite-specific tests if sqlite is not configured"
Task cleanup_running_deleted_instances can now use slave

Deployments that have a slave_connection configured can offload
read queries generated by this periodic task there. For
deployments with no slave, behavior remains the same.

Partially-implements: blueprint periodic-tasks-to-db-slave
Change-Id: Ie1e6cdfbefab096a2af62ef636786a5c8f659b13
Merge "Replaces exception re-raising in Hyper-V"
Merge "Use instance object instead of _instance_update()"
Merge "Fix debug message formatting in server_external_events"
Merge "Use debug level logging during unit tests"
Merge "xenapi: fix spawn servers with ephemeral disks"
Delete ERROR+DELETING VMs during compute startup.

We should perhaps do this check during message bus reconnection as
well.. Anyhow, if a compute node is offline during a nova API call
to delete an instance, and the rabbit message is lost for some
reason (or alternatively if the delete method throws an error)
then the task state is not cleared and won't be cleared on compute
restart, leaving it wedged forever.

Change-Id: Ie0a47958eb0fb58307902437a95634d5f54f74f3
Fixes-bug: #1281324
Co-Authored-By: Steve Kowalik <steven@wedontsleep.org>
Fix get_download_hander() typo

Clearly, this was meant to be get_download_handler().

Refactor loading modules in GlanceImageService a little to avoid the
get_download_handler() going over the length-of-line limit.

Change-Id: If871413cbb86cd800be8517bb37932df890bf53d
Add py27local tox target

This adds a new tox target that uses sitepackages=False. This is
handy for people running unit tests on a devstack box, where the
site-packages oslo.config interferes.

Change-Id: I1101730f18550de0b391d12bcc5841cb671434a2