Make usage_from_instances consider current usage

VirtNUMAHostTopology.usage_from_instances will now consider the current
usage of the passed host, and also accepts a 'free' keyword argument,
which if set to True, will cause the instance usage to be taken out of
the considered host. Also adds better handling of  None and emtpy
params.

Blueprint: virt-driver-numa-placement
Change-Id: I62c59b5e1dcbd4db247282f170c6f2f501bafd3d
Power off commands should give guests a chance to shutdown

Currently in libvirt operations which power off an instance such as stop,
shelve, rescue, and resize simply destroy the underlying VM. Some
GuestOS's do not react well to this type of power failure, and so it would
be better if these operations followed the same approach as soft_reboot
and give the guest as chance to shutdown gracefully.

The shutdown behavior is defined by two values:

- shutdown_timeout defines the overall period a Guest is allowed to
complete it's shutdown.  The default valus is set via nova.conf and can be
overridden on a per image basis by image metadata allowing different types
of guest OS to specify how long they need to shutdown cleanly.

- shutdown_retry_interval defines how frequently within that period
the Guest will be signaled to shutdown.  This is a protection against
guests that may not be ready to process the shutdown signal when it
is first issued. (e.g. still booting).  This is defined as a constant.

This is one of a set of changes that will eventually expose the choice
of whether to give the GuestOS a chance to shutdown via the API.

This change implements the libvirt changes to power_off() and adds
a clean shutdown to compute.manager.stop().

Subsequent patches will:
- Add clean shutdown to Shelve
- Add clean shutdown to Rescue
- Convert soft_reboot to use the same approach
- Expose clean shutdown via rpcapi
- Expose clean shutdown via API

Partially-Implements: blueprint user-defined-shutdown
Closes-Bug: #1196924
DocImpact

Change-Id: I432b0b0c09db82797f28deb5617f02ee45a4278c
Resize should give guests a chance to shutdown

Currently in libvirt operations which power off an instance such as stop,
shelve, rescue, and resize simply destroy the underlying VM. Some
GuestOS's do not react well to this type of power failure, and so it would
be better if these operations followed the same approach as soft_reboot
and give the GuestOS as chance to shutdown gracefully.

This is one of a set of changes that will eventually expose the choice
of whether to give the GuestOS a chance to shutdown via the API.

This change implements the compute manager changes to resize for libvirt.

Partially-Implements: blueprint user-defined-shutdown
DocImpact

Change-Id: I03a52cfcc77d89e0982fcdf88be0651b3f12cbdd
Rescue should give guests a chance to shutdown

Currently in libvirt operations which power off an instance such as stop,
shelve, rescue, and resize simply destroy the underlying VM. Some
GuestOS's do not react well to this type of power failure, and so it would
be better if these operations followed the same approach as soft_reboot
and give the GuestOS as chance to shutdown gracefully.

This is one of a set of changes that will eventually expose the choice
of whether to give the GuestOS a chance to shutdown via the API.

This change implements the compute manager changes to rescue.

Partially-Implements: blueprint user-defined-shutdown
DocImpact

Change-Id: I296397f4fe3308be3727ec127929cea60d46b882
Merge "Make usage_from_instances consider current usage"
Fix expected error details from jsonschema

The jsonschema 2.4.0 release slightly changed some of the error messages
that are provided when validation fails. This updates the unit tests to
expect the proper string and avoid failing as a result.

Change-Id: Ic8e32140e49e394659e7ebbecb28afb704b23b7c
Closes-bug: #1358881
Merge "Power off commands should give guests a chance to shutdown"
Merge "Resize should give guests a chance to shutdown"
Merge "Rescue should give guests a chance to shutdown"