Add missing image to instance booted from volume

When booting an instance from a volume, the image_ref for
the instance will be None. And the API do not get the image
information for the instance also. So when we calling the
related API, we get "" for instance.image.

Change-Id: I3c35ab1d7c8bcec551fb5d67d0b44418266b32a4
Closes-bug: 1317880
Retry db.api.instance_destroy on deadlock

Update the instance_destroy method of the sqlalchemy db API to retry if
it fails because of a deadlock. The decorator that handles this was
introduced in I0293c62d2dd5ac036445bc639cabbd05ba016e83.

This patch does not include a unit test for this bug, as deadlocks are
very hard to reproduce.

Change-Id: I570d91e892a6e1ff4b3cdb8cf81acc483649835e
Closes-Bug: #1342086
libvirt: fix recent test changes to work on libvirt < 0.9.13

The newly used 'listAllDomains' method was only introduced in
libvirt 0.9.13. Although the driver code was written to cope
with older libvirt, the test suite code itself would fail
when faced with such an old libvirt because it was trying to
mock out methods which did not exist.

The fix here recognises that since '_list_instance_domains_fast'
and '_list_instance_domains_slow' both have explicit test cases,
there is no point in mocking out the low level 'listAllDomains'
method in all the other test cases. Instead we can mock out
the much higher level '_list_instance_domains' which means we
avoid any interaction with libvirt in these test cases. The
opportunity is taken to convert the tests in question to use
'mock' instead of 'mox' since it also simplifies the code.

Finally in the test for '_list_instance_domains_fast' simply
skip the test if libvirt is too old to have the required
constants defined.

Closes-bug: 1341729
Change-Id: I554352ea14e6b3306176e7524502e005cebd8c16
Defer raising an exception when deleting volumes

When looping through block device mappings to delete volumes with
delete_on_terminate set the loop should not exit on an exception.
Instead the loop will continue and the last exception can optionally be
raised.

Change-Id: If1c6ec30c6f49009ef42f9a3b3df1594783b0ae5
Closes-Bug: #1341738
Avoid possible timing attack in metadata api

Introduce a constant time comparison function to
nova utils for comparing authentication tokens.

Change-Id: I7374f2edc6f03c7da59cf73ae91a87147e53d0de
Closes-bug: #1325128
Make sure that metadata handler uses constant_time_compare()

This adds a test to ensure that the new behavior of the metadata
API handler persists. It's important that it uses the special
constant_time_compare() method.

Change-Id: I1253661f74dae822be9dc9fe1fdab861ebd64bc9
Merge "Retry db.api.instance_destroy on deadlock"
Merge "Avoid possible timing attack in metadata api"
Merge "Make sure that metadata handler uses constant_time_compare()"
Merge "libvirt: fix recent test changes to work on libvirt < 0.9.13"
Merge "Defer raising an exception when deleting volumes"
Merge "Add missing image to instance booted from volume"