libvirt: Use VIR_DOMAIN_AFFECT_LIVE for paused instances

When a volume is attached to a paused instance, it does not
appear in the instance's block devices list (i.e. lsblk)
after the instance has resumed. A similar situation
happens when detaching a volume from a paused instance; the
block device continues to exists in the block devices list,
where it should not.  It was found that the volume is only
persisted in the domain's config settings and not its active
settings, since only the VIR_DOMAIN_AFFECT_CONFIG flag was used
on attach and detach volume.  In order to affect the active
settings, the VIR_DOMAIN_AFFECT_LIVE flag has to be added when
attaching and detaching volumes.

Change-Id: I9c90a410a7ecb91f5a4de28acee21fe7da49242c
Closes-Bug: #1242366
Related-Bug: #1299331
Catch ProcessExecutionError in revoke_cert

Catch processExecutionError if revoking the
certificate fails.

This change has been abandoned by Chuck Short, so
I am continuing where he left off (mattoliverau).

Continues abandoned change: 17741

Change-Id: I9714ea8cece87256ff5f9a936286c1da3d628af9
Closes-Bug: #883320
Co-Authored-By: chuck.short@canonical.com
Add missing stats info to BaremetalNodeState

This is the first of two patches to prepare baremetal for the removal
of capabilities in Nova HostManager.

BaremetalHostManager used to rely on capabilities info to decide which
host state class to use, VM or baremetal. This has been broken since
host capabilities reporting were removed in Nova, resulting in Nova
HostState class always being used.

BaremetalNodeState lacks stats info needed by some filters during
scheduling. This may result in failures like ComputeCapabilitiesFilter
not returning any hosts. This must be fixed before BaremetalNodeState
can be used again.

Change-Id: I63d992371640b2fd33d35eae72201fd41944f8a4
Partial-Bug: #1260265
Fix BaremetalHostManager node detection logic

This is the second patch to prepare baremetal for the removal of
capabilities in Nova HostManager.

BaremetalHostManager used to rely on capabilities info to decide which
host state class to use, VM or baremetal. This has been broken since
host capabilities reporting were removed in Nova, resulting in Nova
HostState class always being used.

This patch fixes the detection logic in BaremetalHostManager to
correctly choose BaremetalHostState class for use with baremetal nodes.
Tests are added to verify that the correct class is used for both vm
and baremetal nodes.

In reality, the new detection logic will not start to deliver the
correct HostState class until the Nova HostManager change that follows
has landed.

Change-Id: I0c2e6d985fb29f35b823cdf9a83fead2fa45082a
Partial-Bug: #1260265
Remove traces of now unused host capabilities from scheduler

This is take two of this patch. This time after preparing Baremetal
and Ironic code to work with the HostManager changes introduced in
this patch.

Host capabilities updates are no longer used by the scheduler. All host
state is instead fetched from the DB. Some left over fields are still
kept by the host manager but contain no data. This change remove the
last traces of host capabilities from the scheduler.

Baremetal/Ironic host managers used to rely on capabilities info to
decide which host state class to use, VM or baremetal. This has been
broken since host capabilities reporting were removed. This change
works in tandem with prior updates to Baremetal/Ironic node detection
logic to fix this problem.

Important: This must not be approved until the Ironic patch in
https://review.openstack.org/97447 has first landed!

Change-Id: Id5f88c0aa1df9152ddb62904b0544801a8bcfd2a
Closes-Bug: #1260265
Drop support for scheduler 2.x rpc interface

In commit 741661a6695ccc56e5f50c4d85954cd3ed9ebda5, a part of
Icehouse, we added support for the 3.x interface.  Now that Juno
development is open, we can drop support for the old 2.x API.

For more information on this change, see:

    https://wiki.openstack.org/wiki/RpcMajorVersionUpdates

UpgradeImpact

Change-Id: I7bfad51ae46e999b30e003a5a5c7e341461dba02
Instance and volume cleanup when a build fails

On failed builds the _shutdown_instance method used to get called which
would clean up leftover instance artifacts, volume attachments, and
networking.  This no longer happens which is causing volumes to be left
in an attached state when they're not attached to anything.

Network deallocation is already handled in this code path so it should
not happen in _shutdown_instance.

Change-Id: I899b64ac5941acc282ccae7e1963d6f714c01e8b
Closes-bug: #1332198
Allow evacuate from vm_state=Error

We currently allow reboot/rebuild/rescue for an instance in the Error state.
This commit allows "evacuate" as well, since it is essentially a "rebuild"
on a different compute node.

This is useful in a number of cases, in particular if an initial evacuation
attempt fails.

Change-Id: I3f513eb738c91fe71767308f57251629639efd6a
Closes-Bug: 1298061
Conductor: remove irrelevant comment

Commit c346befc630fd12623d9dc72f9f0c608aaaf2303 added a comment
that was not related to the actual code. This was removed.

TrivialFix

Change-Id: I1b329bb615e82d511b3e6ed2c58c8319c1687f7a
libvirt: remove unused 'get_disks' method

The 'get_disks' method was a virt driver public API used by
the old compute monitor class. This class was deleted in

  commit 07646e85841a4f7c81e80254ac63715bece2aadd
  Author: Brian Waldon <brian.waldon@rackspace.com>
  Date:   Tue Aug 2 10:09:58 2011 -0400

      removing compute monitor

Leaving no in-tree user of the 'get_disks' method. This
method is not declared in the ComputeDriver base class
nor implemented by any virt driver besides libvirt, so
can be safely deleted.

Partial-bug: #1333219
Change-Id: I4d3f53499d088a82e471ab68feef1ae50d3f8bdc
libvirt: add '_' prefix to all get_guest_*_config methods

The get_guest_*_config methods are all internal helpers so should
have a '_' prefix to indicate they are not part of public virt
driver API.

Related-bug: #1333219
Change-Id: I76108c4992144cc7c3273bfd753aa76f7a821a56
Add API schema for v2.1/v3 flavor_manage API

By defining the API schema, it is possible to separate the validation
code from the API method. The API method can be more simple.
In addition, a response of API validation error can be consistent for
the whole Nova API.

Partially implements blueprint v3-api-schema

Change-Id: I92de34f6b9801b7ff9e4a9cc77baf2bf2bb36f6f
Imported Translations from Transifex

Change-Id: I463940f9d9f980e0b4a8a70e13832ea2e2d19cae
Add API schema for v2.1/v3 aggregates API

By defining the API schema, it is possible to separate the validation
code from the API method. The API method can be more simple.
In addition, a response of API validation error can be consistent for
the whole Nova API.

Partially implements blueprint v3-api-schema

Change-Id: I67a1b723f37256e8bdfaf38d9f5ad0a4c4d2e53e
Merge "libvirt: Use VIR_DOMAIN_AFFECT_LIVE for paused instances"
Merge "Instance and volume cleanup when a build fails"
Merge "Imported Translations from Transifex"
Merge "Allow evacuate from vm_state=Error"
Merge "Conductor: remove irrelevant comment"
Merge "Catch ProcessExecutionError in revoke_cert"