Refactor Ironic driver tests as per review comment

During the Ironic driver merge into Nova, there were some
suggestions on refactoring the tests as per this review
(https://review.openstack.org/#/c/111425/19/nova/...
...tests/virt/ironic/test_driver.py)

This patch implements these suggestions.

Change-Id: I05e8b3d01bffebe2f68bbd50fc775e1ef48616cc
libvirt: add support for hyperv timer source with windows guests

The hyperv timer source enables Windows guests to keep accurate
time, much like kvmclock does for Linux guests. It should be
enabled for all windows guests, as it doesn't harm older windows
versions which don't know about it.

Related-bug: #1400315
Change-Id: I6af05b4e8e0b2145733c0f301c04555da23b7da8
libvirt: change representation of guest features

While the current acpi, apic & pae features are mere single elements,
further feature will require complex data structures. The libvirt
config class must thus change from using a simple string to represent
a feature, to a full class

Related-bug: #1400315
Change-Id: Ia6fa2602dd7a9e7623abcfd46c8b57d3631372ef
Use osapi_compute worker for api v2 service

osapi_compute is intended to be a superset of the compute APIs (v1
through v3 and beyond). So use the worker settings for osapi_compute
when launching any service that starts with 'openstack_compute_api' that
might be defined in paste.ini and in enabled_apis. While this could
result in the single setting causing nX workers, where n is each
openstack_compute_api_* thing defined, it is expected that only one is
enabled, or the full superset is enabled.

Change-Id: Ic1bb69c8675f2ffb71cdf8a4b38ba7b02e697458
Use constant for microversions header name (cleanup)

Define and use a constant for the microversion header
name rather than repeat the string literal in multiple places.

Partially implements blueprint api-microversions

Change-Id: Ief296211d5cff8b3ccfc8231cb2336582bd47ef1
Cleanup in ResourceExtension ALIAS(v2.1api)

Add global variables ALIAS if it's not existing and use it in
ResourceExtension if the the alias of the extension happen to be
the same as ALIAS.

Partially implements blueprint v2-on-v3-api

Change-Id: Id6b3ecde499e9b54804175d635b89e62c1fed804
objects: add method to verify requested hugepages

Introduces a new method can_fit_hugepages to numa cell object

Work-Item: Enhance libvirt driver to configure guests based on
           the flavour parameter for page sizes

Partial-Implement: blueprint virt-driver-large-pages
Change-Id: I600840a96b13c1de4f2f409069f452e18e1c1c52
hardware: determine whether a pagesize request is acceptable

Enhances numa_fit_isintance_cell to return whether the cell host
can handle the page size request

Work-Item: Enhance libvirt driver to configure guests based on
           the flavour parameter for page sizes

Partial-Implement: blueprint virt-driver-large-pages
Change-Id: Ib8546c2a22017f738f644b94dcf00f4afd3582fc
Fix ironic delete fails when flavor deleted

The ironic virt driver looks up the flavor of an instance
when it is going to delete it. This is to obtain extra
specs details that are not available in the instance details.
If the flavor has been deleted this lookup fails and causes
the delete to fail.

The fix makes the lookup include deleted flavors. Note that
extra specs handling is changing in nova, so this code is
likely to become obsolete when they are available by
other means.

Change-Id: I47ba78abfe60e82226acc6a17752db503d9f21d8
Co-Authored-By: Nicholas Randon <nicholas.randon@hp.com>
Co-Authored-By: Phil Day <phil.day@hp.com>
Closes-Bug: #1400269
libvirt: enhance driver to configure guests based on hugepages

Work-Item: Enhance libvirt driver to configure guests based on
           the flavour parameter for page sizes

Partial-Implement: blueprint virt-driver-large-pages
Change-Id: Id9d826e83f3ee5720486efb8cb0ff38c0dfcc990
libvirt: introduce a fixture for mocking out libvirt connections

The various libvirt test suites all have different ways of mocking
out libvirt connections. Some use fakelibvirt, others create their
own lame re-implementation of fakelibvirt, others mock random
methods. To improve sanity, introduce a standard fixture to be used
by all libvirt tests for mocking libvirt. This will ensure that the
libvirt.openAuth method always returns an instance of fakelibvirt
virConnect object. This should allow for a number of the fakelibvirt
reimplementations to be eliminated eventually.

Blueprint: libvirt-driver-class-refactor
Change-Id: I2a61dba5a273455d6b3c15e9cae0f3bff7f641fa
libvirt: convert test_host.py to use FakeLibvirtFixture

Instead of monkey patching the Host class to use fakelibvirt,
just use the FakeLibvirtFixture. Also create an instance of
the Host class in setUp since every test case needs it.

Blueprint: libvirt-driver-class-refactor
Change-Id: I1d737fc22bc26b686790c06362eb7c61b26bd39d
libvirt: sanitize use of mocking in test_host.py

Tidy up the test_host.py test suite, so that it uses mock
exclusively instead of stubs. Also annotate test methods
in preference to using nested contexts since it leads to
clearer test methods.

Blueprint: libvirt-driver-class-refactor
Change-Id: Idc536e408b22cadf8b12ec2bd4ed978f1110fd83
libvirt: remove unused get_connection parameter from VIF driver

Previously the VIF driver would have to take different action
for OpenVSwitch depending on the libvirt version. Since we
bumped the min libvirt version this is no longer required, so
the get_connection parameter to the VIF driver is unused.

Blueprint: libvirt-driver-class-refactor
Change-Id: I1925a433a00f5ea3b65899ecb64d904045519340
Fix recent regression filling in flavor extra_specs

In commit cb338cb7692e12cc94515f1f09008d0e328c1505, we dropped an extra
DB query to fill in flavor extra_specs because the object should already
have those set. However, if we pulled the flavor from the instance,
extra_specs are mostly not stored, which means we effectively cut off
the scheduler filters from access to those things.

This adds that back in for that case, but only temporarily. Soon we will
be merging a change to stash real flavor objects with the instance, which
will make this moot. However, that may take a while to merge and this is
broken now.

Change-Id: Ia728025345b09687da9744004f0f47ad73ce196c
Closes-Bug: #1403547
Merge "Refactor Ironic driver tests as per review comment"
Merge "objects: add method to verify requested hugepages"
Merge "hardware: determine whether a pagesize request is acceptable"
Merge "Fix recent regression filling in flavor extra_specs"
Merge "libvirt: introduce a fixture for mocking out libvirt connections"