Stylistic improvement of models.ComputeNodeStat

The patch is aimed at improving the readability of models.ComputeNodeStat.

Here, we rename the 'stats' attribute of the class to 'compute_node' (due to
the fact that the corresponding relation actually maps to ComputeNode class,
not to ComputeNodeStat). We also rewrite the relationship() method call to
make it stylistically conforming with the analogous 'service' relationship
in the ComputeNode class: we add the 'foreign_keys' parameter, wrap the
'backref' parameter into a method call and remove the auxiliary 'primary_join'
variable.

Change-Id: I2b1f27b4c1d06f364af01fc82d3490fd3bbf4ac0
Closes-Bug: #1215390
tenant_id implies all_tenants for servers list in V3 API

Makes tenant_id imply all_tenants is also enabled unless
explicitly disabled when a request is made for a list of
servers. This only occurs if the requestor is an admin. The
change is only made for the V3 API as although this behavior is
more intuitive it is too late to change it for the V2 API.

Change-Id: Ia84e62c8dc80ac3a2f16aee3620af31987cce570
Partial-Bug: 1185290
Catch exception while building due to instance being deleted

In run_instance() a instance_update() call in _start_building() can
result in a UnexpectedDeletingTaskStateError if the instance gets
deleted while being built.Since this is an expected situation, we
don't want this exception written in the logs or worse, the instance
be set to error state. Instead catch this and raise a proper
BuildAbortException that gets handled above this call.

Change-Id: Ib9d3dd22b33b104f1593d534876a5387df81d11c
Closes-Bug: #1223843
Checking existence of index before dropping

Migrations modifying indexes drop and recreate the index.
If an index does not exist dropping would fail the migration.
As part of this fix, checking if index exists before dropping it.

Fixes bug 1243553

Change-Id: Ic75744bdccfbc516d36a9711ad6997fd86c7a722
Update quota-class-set/quota-set throw 500 error

The server doesn't check whether the parameter "quota_class_set" is in request
body.So the 500 error has been thrown.

We should catch the KeyError and transfer the KeyError to
400(HTTPBadRequest) instead of 500.

Change-Id: I431a836bd35f846790497d6179515e8d559e2cd0
Closes-Bug: #1249222
Add V3 API sample for server's actions

Adds api sample tests and api samples for server's actions

Partially implements blueprint v3-api-unittests

Change-Id: I4b420f09f9fc9a7f6fab8dbaeaa9b93631909255
VMware: fix snapshot failure when host in maintenance mode

The root cause is due to a bug in the VC's handling of the
VirtualDiskManager.DeleteVirtualDisk_Task API, which allows the picking
of any host in a datacenter with access to the datastore participating
in the disk deletion picked be to perform the operation, even when the
host is in maintenance mode and hence will always reject the call when
sent.

The fix uses an alternative API (FileManager.DeleteDatastoreFile_Task)
to delete the vmdk and -flat vmdk files separately. This API does not
suffer from the above-mentioned failure mode.

Closes-Bug: #1229994

Change-Id: I786365847673e5192a21b654cba951b2e7a6f291
Include image block device maps in info

In cases for example soft/hard reboot, we were just getting volume and
snapshot block device maps. For block devices with a source type image,
Nova would fall back on a local disk location and fail.

This change allows us to include block devices with a source of an
image, so that we correctly get the right the location of the block
device.

Closes-Bug: #1245719
Change-Id: I1f726293e85183d4b84c05b635a7c606a092992f
Fix for reading the xenapi_device_id from image metadata

The xenapi_device_id is set on the image metadata.
This is used to set the device_id on the vm record
before the vm is created. Currently, when we read
the device id from the metadata we are looking at
the key image_meta["xenapi_device_id"].
But the device id is set as
image_meta["properties"]["xenapi_device_id"].

Fixes bug 1253564

Change-Id: Ide174b50db4e440401b5e6389844e7dcfc8a1c76
XenAPI: Fix config section usage

Change I2e9f720ddce284fc112d6a5651fd277e6e31a17a introduced xenserver
sections but a couple of CONF variables were not updated to use the
new sections.

Fixed the few remaining options and add unit tests to ensure they are
caught in future.

The unit tests highlighted that the functions behaved strangely in
the cases where the default was being provided - so updated to be
clear about getting the default.

Closes-bug: 1253064

Change-Id: Ic538069cd087aa3cdc0a1f7fdb94820d5d3b22b1
Merge "Fix for reading the xenapi_device_id from image metadata"
Merge "Checking existence of index before dropping"
Merge "Update quota-class-set/quota-set throw 500 error"
Merge "Stylistic improvement of models.ComputeNodeStat"
Merge "Catch exception while building due to instance being deleted"
Merge "Add V3 API sample for server's actions"
Merge "tenant_id implies all_tenants for servers list in V3 API"
Merge "XenAPI: Fix config section usage"
Merge "VMware: fix snapshot failure when host in maintenance mode"
Merge "Include image block device maps in info"