Bad except clauses order causes wrong text in http response

InstanceInvalidState is an ancestor class of InstanceIsLocked, so
we need to catch InstanceIsLocked first. Fix the test case to
ensure we get the right http response back

Change-Id: Id22b284d9b7da8db4161ad8703bea1702cb0b82e
Users with admin role in Nova should not re-auth with Neutron

A recent change to the way Nova creates a Neutron clients
https://review.openstack.org/#/c/52954/4 changed the conditions
under which it re-authenticates using the neutron admin credentials
from "if admin" to "if admin or context.is_admin".

This means that any user with admin role in Nova now interacts
with Neutron as a different tenant.  Not only does this cause an
unnecessary re-authentication (The user may/should also have an admin
role in Neutron) it means that they can no longer allocate and assign
a floating IP to their instance via Nova (as the floating ip will now
always be allocated in the context of neutron_admin_tenant).

This change removes the context.is_admin check to revert to the
previous behaviour where the used of admin creds is determined just
on the explicit use of "admin=True" parameter to get_client().

Change-Id: Ib1720420c778960bc90c5b7d703de936ebb7d6b5
Closes-Bug: 1250763
Add a driver method to toggle instance booting

Add a driver method to toggle the ability to boot an instance.

The only implementation provided is for the xenapi virt driver.  Other
drivers will log a warning and treat the method as a no-op.

Implements: blueprint cleanup-running-deleted-shutdown

Change-Id: Ie448c681d653b126cb12d3a48d79ab4febde8828
Fix up spelling mistake

Fixes bug 1253510

This was causing a KeyError when e2label didn't work

Change-Id: I0646409cdffa4d6d5d8b2c7a9e3c300022d1c9b8
Use model_query() instead of session.query in db.instance_destroy

Unify db.instance_destroy() method to use model_query() as others
methods use.

Side effect we won't try to soft delete already soft deleted instance

Change-Id: I36d5bb42b16901c260ff4276e31a6aec46ffa8a4
Sync the DB2 communication error code change from olso

Closes-Bug: #1244092

oslo patch set: 3acd57c2825a8bf6660c3124f12794414622eb26

Change-Id: I62e3a6d1137d53c4aa72b18db5bd9f7e41694436
Fix missing format specifier in ImagePropertiesFilter log message

Commit a52259e introduced some changes to debug log messages in the
ImagePropertiesFilter but with that came a bug due to a missing format
specifier.

Closes-Bug: #1253875

Change-Id: Ic60b7ba179bd43b80c500be084a1809b6b0b32ca
Add FloatField for objects

This adds a Float field type for objects, which will be required for
things like Flavor.

Related to blueprint compute-manager-objects

Change-Id: I260a9855721046f3af24db102a24b974bfb3518a
Adjust the order of notification for shelve instance

When shelve instance, if CONF.shelved_offload_time == 0, then the
notification order for shelve_instance() is as following:
1) compute.instance.shelve.start
2) compute.instance.shelve_offload.start
3) compute.instance.shelve_offload.end
4) compute.instance.shelve.end

This order is not correct, as actually before shelve_offload.start,
the instance was already reached shelve.end, so we should adjust the
order of notification for shelve instance as following:
1) compute.instance.shelve.start
2) compute.instance.shelve.end
3) compute.instance.shelve_offload.start
4) compute.instance.shelve_offload.end

Change-Id: I6e075b3f29e1c3f641ab1e459e1fbe3b05869a9a
Closes-Bug: #1248802
Improved debug ability for log message of cold migration

When cold migration failed because of nova scheduler return no
valid host, conductor only log no valid host, but did not specify
which instance failed.

This patch was specifying instance in the failure log for cold
migration.

Change-Id: Ia9e42f8f253323fb35a58e0be2a24ab043204d29
docker: return hypervisor_version as an int rather than a string

The compute_nodes.hypervisor_version type in the database is an integer
so the docker driver needs to return the hypervisor_version as an
integer rather than a string.

Also adds the missing unit test for get_available_resource.

Closes-Bug: #1253960

Change-Id: I4e2ac13f9203b54e71f1f5cd8e15311921dd85c5
Move flags in libvirt's imagebackend to the libvirt group

This change continues moving libvirt specific flags into a libvirt
specific configuration group.

Progresses blueprint libvirt-opts-group.

DocImpact: the following flags move into the libvirt group:
    libvirt_images_type (now images_type)
    images_volume_group
    sparse_logical_volumes
    lvm_snapshot_types
    images_rbd_pool
    images_rbd_cepf_conf

Change-Id: Ic1bb8076b139787fe5acbc0574b0c75b52bf3bd7
Move flag in libvirt's utils to the libvirt group

This change continues moving libvirt specific flags into a libvirt
specific configuration group.

Progresses blueprint libvirt-opts-group.

DocImpact: the following flag is now in the libvirt group:
    snapshot_compression (formerly libvirt_snapshot_compression)

Change-Id: I9eddec5cdb72a1313e044a3c7c6d75e8ad34533a
Move flag in libvirt's vif to the libvirt group

This change continues moving libvirt specific flags into a libvirt
specific configuration group.

Progresses blueprint libvirt-opts-group.

DocImpact: the following flag has been moved into the libvirt
group:
    use_virtio_for_bridges (formerly libvirt_use_virtio_for_bridges)

Change-Id: I755139f0a470a091e36760836c9200f15aa72c37
Fix log message format issue for api

There is a log message format typo in quota_classes api,
this patch fix it.

Change-Id: Idfb9fb16e4184e226b56bf05ffcaf9fb174feaff
Use 204 instead of 202 for delete of keypairs v3

The delete of keypairs will access db directly. It isn't async call.
So correct it to return 204.

Closes-bug: 1252169
DocImpact

Change-Id: Ie36c16e1773fa7f61b22bd6735342c7308c7ba35
Rename instance_type parameter in migrate_disk_and_power_off to flavor

Renames the 'instance_type' parameter in the nova virt driver's
migrate_disk_and_power_off method to 'flavor' and handles the immediate
related code changes, i.e. the method itself, the implementations in the
various virt drivers, the tests, and anything called solely from
migrate_disk_and_power_off. This patch does not adjust for everything
that calls into migrate_disk_and_power_off, like from the nova compute
manager code.  That will be handled in a later patch in the series.

Part of blueprint flavor-instance-type-dedup

Change-Id: I47f2b9f6597556dca632d94f83cc1428ad73ae74
XenAPI: Fix caching of images

Clearing of the cached images' name_label means it can't be found in future.
Name label of cloned VDI should be cleared so it is not found by the
caching functions.

Main impact of this is in test scenarios where the VM is always deleted, but
a more subtle impact could be data leakage.

Change-Id: I6bb80443d31128b7d5d47e4b252db5eb8ab86940
Closes-bug: 1254714
Do not hide exception in update_instance_cache_with_nw_info

From time to time an exception is raised in this method causing
the nw_info cache not to be saved. If this occurs we should raise
as this error will cause later errors to occur. For example, one
won't be able to associate a floatingip with the instance as there
is no nw_info found in this table. In addition, the fixed_ips on
the instance won't be returned via the api.

This patch also stubs out update_instance_cache_with_nw_info in a
few tests where an exception was being raised previously but went
unnoticed as it was not reraised but now is.

Related-Bug: #1252849
Related-Bug: #1249065

Change-Id: Ic860f72210ba736e11c10df21c4cb7625e9c0928
Remove console 1.X rpc api

A previous change adding support for the 2.x rpc interface but retained
compatibility with 1.x as a transition point.  This commit removes the
old API from the server side.

UpgradeImpact

Part of blueprint rpc-major-version-updates-icehouse

Change-Id: I8a5c4c45baaf237f5be38f6024d5338c8183d1a6