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
Small cleanup in db.sqlalchemy.api.action_finish()

This function was pulling back a row, updating the returned object,
then returning a reference to it. This potentially races, as the
object may be updated in another transaction after fetching. In
practise it's probably fine, but the new code is more obviously
correct, and probably slightly nicer to sqlalchemy.

Change-Id: I879e973180278faa51e664d526d75e5f095a64ea
Fix spelling error in compute api

Change-Id: Ie6b2d998dea6c5b9c7d3eee9c1c01f9169679451
libvirt: disk_bus setting is being lost when migration is reverted

finish_revert_migration() should use image_meta, if it exist,
when constructing the disk_info.

Closes-Bug: #1389850
Change-Id: Ia373771eaaad4154a2aa0695bf3878713a68dd9f
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
hardware: make get_constraints to return topology for hugepages

Whether a numa node is defined or not, if using hugepages we
should create an numa instance topology.

Work-Item: Enhance libvirt driver to report available
           large pages per NUMA node in the host state data

Partial-Implement: blueprint virt-driver-large-pages
Change-Id: I23e0ca58bd8c6a16bff5d36c5d108056e4135351
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
virt: pass instance object to block_stats & get_instance_disk_info

The block_stats and get_instance_disk_info methods are the last
two virt driver methods which do not take a full Nova Instance
object. They are trivially convertable.

Blueprint: libvirt-driver-class-refactor
Change-Id: I87ef651383c9b4ab3abe4bf8a5c49501e353abc4
Merge "Fix spelling error in compute api"
Merge "Small cleanup in db.sqlalchemy.api.action_finish()"
Merge "libvirt: disk_bus setting is being lost when migration is reverted"
Merge "hardware: make get_constraints to return topology for hugepages"
Merge "virt: pass instance object to block_stats & get_instance_disk_info"
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