Adds 'instance_type' param to build_request_spec

This change adds a new optional parameter to
scheduler.utils.build_request_spec. It also fixes Bug 1219761
by adding the new 'flavor' for cold migration instead of the
instance current one.

Change-Id: I28ac5f636e22e4d02ad5495b7b50c8226678c413
Check ephemeral and swap size in the API

Validate that ephemeral and swap disks passed in trough the API are
within size limits for the given instance type. The validation is done
in the API layer.

Closes-bug #1218977

Change-Id: I96c6e651e4b221313c39dfc41e79d536585fb955
Improves Hyper-V vmutils module for subclassing

Blueprint: hyper-v-wmi-v2

This refactoring is needed to enable subclassing of the
vmutils.VMUtils class to support the Hyper-V WMI V2
namespace.

Change-Id: Id17b066a05d347ad6b34f826f265208cc4bb22a4
Merge "Adds 'instance_type' param to build_request_spec"
Merge "Check ephemeral and swap size in the API"
Merge "Add os-block-device-mapping to v3 API"
Allow block devices without device_name

This patch removes the check in the API that prevented having block
devices without 'device_name' and makes the compute manager capable of
guessing those names.

Before creating the instance, the manager will try to guess a valid name
using the method 'default_device_names_for_instance',  which should be
implemented by the drivers, or defer to the generic function from the
utils module 'default_device_names_for_instance' which uses the already
existing 'get_device_name_for_instance' function.

It also takes care of assigning the correct device name to the root
device (boot_index=0) to make it agree with the field `root_device_name'
from the instance. If none were supplied - it will try to guess it by
calling driver 'default_root_device_name' or defer to the generic
'get_device_name_for_instance'. if driver does not provide it.

What is worth noting also is that, should the drivers override the
two methods mentioned above expect to be passed the standard
block device mapping format, and not the one used in other driver
methods.

get_device_name_for_instance is also reused to guess a missing
root_device_name when converting legacy_bdm on the API side of things.

DocImpact

Part of blueprint: improve-block-device-handling

Co-authored-by: Xavier Queralt <xqueralt@redhat.com>

Change-Id: I84541f8ff6e1b5978734e5def69946d014c66fdf
Enable libvirt driver to use the new BDM format

This patch makes the necessary changes in the libvirt driver to enable
it to use some of the features of the new block device mapping format.

After this patch it will be possible to set the bus, and device_type per
block device, and libvirt driver will honor these when spawning an
instance (note that attaching a volume still does not use the new data
format).

It utilizes some of the existing code in the blockinfo module to be able
to default device names (it does so by overriding the methods introduced
in I84541f8ff6e1b5978734e5def69946d014c66fdf), and also assign default
values to fields like device_type and disk_bus if it is not provided or
if it is bogus. As this implies the driver changing the block devices in
the database, a new virtapi method block_device_mapping_update is added
to accommodate this. Some of the libvirt specific code paths in the
general defaulting function in compute utils have been removed as they
are not needed since the driver now takes care of this.

Further to that, this patch modifies some of the code paths in the
libvirt driver that use the block device info directly (and not through
the blockinfo module) to be aware of the new format. Due to very nicely
factored code - there were only a few instances of this in the driver
itself.

It also overrides the libvirt driver's need_legacy_block_device_info
method to tell the compute manager to feed it the new format when
needed.

Adds mock to test-requirements - it is already present in the
requirements project.

This patch concludes the blueprint: improve-block-device-handling

Change-Id: I8efd6af6706a097fb540e040a86ccbeaf131631f
Get image properties instead of the whole image

Change-Id: Ibcd60510cc909fcaa0d6d4769f91c070dfaf22ff