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
Log Content-Type/Accept API request info

Also remove an unused content type mapping dictionary.

Change-Id: I5af1357b614b50af4a842151b8c0d652a84e7ec6
Ensure is_image_available handles V2 Glance API

The V2 Glance API uses warlock to validate returned models
from calls such as GET /images/{id}. The get_locations() call in
the Nova Glance image driver was using the V2 Glance API call
to GET /images/{id} (which is correct, since image locations only
exist in the V2 API), but the GlanceImageService._is_image_available()
method was checking the is_public attribute of the supplied image model.

This caused warlock to throw an exception since is_public is not
an attribute on the V2 API's returned image model in glanceclient.
This change adds some checks that can handle both the V2 and V1 returned
image models from glanceclient and a bunch of unit tests to thoroughly
exercise the is_image_available method.

Change-Id: I35b5af8331c5972bd89e1a674091fa2e3bde28a7
Closes-bug: #1291014
VMware: ensure that deprecation does not appear for VC driver

Commit d041b95b8977e77a51e6031c38f0011b44d3266a added the
deprecation warning for the ESX driver. This warning should
not appear for the VC driver.

Change-Id: Ide7b47afbd9e7e4c66a4cdc621fbf511b9c3c953
Closes-bug: #1291238
Recover from REBOOT-* state on compute manager start-up

If a compute manager is stopped / fails during certain REBOOT-*
operations then the instance will be left stuck in a transitional
task_state

This change handles two possible task states REBOOT_PENDING and
REBOOT_STARTED (for both soft and hard reboots). And either clears
these states or retries the reboot depending on the instance state.

Both task states are set after the request has gotten to the compute
manager so we can handle these safely knowing the operation has
ended/failed with the restart of the compute manager.

We retry the reboot where the state is PENDING and where the state is
STARTED and the instance is not running.

Where the instance is running and the state is STARTED we simply
transition the instance to an ACTIVE state. The user can retry the
reboot if required.

Related to blueprint recover-stuck-state

Change-Id: Ib318b3d444a67616441302f3daa8de20ee946f3f
Merge "Log Content-Type/Accept API request info"
Merge "Recover from REBOOT-* state on compute manager start-up"
Merge "Fix: Unshelving an instance uses original image"
Merge "Fix compute_node stats"
Merge "VMware: ensure that deprecation does not appear for VC driver"
Merge "Ensure is_image_available handles V2 Glance API"