baremetal: Add missing method to volume driver

Added get_hypervisor_version(), which is called by underlying
LibvirtVolumeDrivers. Also added tests roughly checking if the
underlying drivers can be loaded and be called without error.

Partial-Bug: #1208707
Change-Id: Ida6b6800d1ef518c6e76d6b2ab4ac2f795a744ca
Port server actions unittests to V3 API Part 2

Ports the server actions unittests to test the V3 API.
This mostly involved CamelCase to camel_case changes
and adpating the URLs to point to the V3 API instead of
the V2 API.

It also includes
- Fixing a bug in the admin_password extension picked up by
  the tests where bad request data is not always handled properly
- Generate image ref urls that point to glance api rather than
  the nova api. This fits in with the decision to not port the images
  extension to the V3 API which is implemented here:
  https://review.openstack.org/#/c/40565/
- Moves admin password related tests to the admin password unittests
  test file as this functionality has been moved out from core.

Partially implements blueprint v3-api-unittests

Change-Id: I58b4c0103c824898183fca890c74c3c1cbe19633
Remove xenapi rpm building code

Nova shouldn't be building any types of packages. And if we are we should
be testing this code in gate somewhere.

Change-Id: I70d82a6173b5eda183d4e49d330ae97dd14f9078
Add V3 API sample for admin-password

Adds api sample tests and api samples for admin-password

Partially implements blueprint v3-api-unittests

Change-Id: Iade39ff931471d1d68e358ac5d35a1921e85df66
Adding support for multiple hypervisor versions

This is to prevent instances with newer tools from being provisioned
on older hypervisors.
Added comparison of hypervisor version from the compute-node and image
metadata in the image properties filter.
In host scheduler image_prop_filter, the 'hypervisor_version_requires'
image properties, if available, is compared to the host_state's
hypervisor_version, if available.
hypervisor_version_requires should be added on the image as metadata and
should have a operator and version value.
Examples : ">=6.0", ">6.0, <6.2", ""!=6.1"

Partially Implements blueprint xen-support-for-hypervisor-versions
Cell scheduler changes coming up in another commit.
DocImpact

Change-Id: I6fbf232adf9ac78ebb8ac2985739f163f4517d14
xenapi: Speeding up the easy cases of test_xenapi

These were the tests that only required changing the base class. The remaining
tests in test_xenapi will need to have their stubs modified to not hit the DB.

nosetests nova/tests/virt/xenapi/test_xenapi.py

BEFORE: Ran 201 tests in 25.957s
AFTER: Ran 201 tests in 24.573s

Change-Id: Ia0478ac81f1b2b316a22b15e3171250d3b839073
Hyper-v: Change the hyper-v error log for debug when resize failed

The error message is not sufficient enough for debug of hyper-v
when resize error occured, this patch adding the necessary info
in error log.

Change-Id: Ic8ecb8f08139face2c7bdca258de5e719d81833c
Closes-bug: #1238430
migrate server doesn't raise correct exception

Currently a BadRequest is raised for the migrate and live-migrate API
operations when the given instance isn't found. This patch changes the
APIs to raise a InstanceNotFound instead to be consistent with the other
admin action APIs which hit the same type of error.

Closes-Bug: #1239038

Change-Id: I28cd367c5885481ea19ace43855b2518a2afd955
Sync lockutils from oslo

d498c42	Fix to properly log when we release a semaphore...
3e3ac0c	Modify lockutils.py due to dispose of eventlet...

Change-Id: I2786527cba16cb4cd94999927e9d7aed2ed99357
Related-Bug: #1235437
nova.exception does not have a ProcessExecutionError

Looks like a refactoring problem. utils.execute throws
processutils.ProcessExecutionError

Change-Id: Ia1e2f4761f555fa834826000e91bb3592e3eea7f
Raise an error if module import fails.

Previously a missing module would cause the config file generator
to pass (mostly) silently with only a small message going to
stdout. If we can't import a module that seems like it is a bad
thing so lets just bail.

Change-Id: I391220e1344ba1785bf04654c7c5f52e2e8e82fc
Add block device handling to build_and_run_instance

If we have block device mappings we want to prep them and pass them to
the virt driver spawn method so they can be attached to the instance.
If there's a failure during the instance creation the volumes will get
cleaned up.

A failure to prep the block devices will abort a build because it can't
be built as desired and the failure is not likely to be related to the
compute node itself.

On an instance build failure we make an attempt to clean up the block
devices for the instance.  If that fails we are left in a bad state and
will not attempt to reschedule the instance.

This is one part of a series of patches to build up the
build_and_run_instance method.

Part of bp remove-cast-to-schedule-run-instance

Change-Id: I4f9e3fd0b7bb443406645c1d98e673a4d3624b58
Remove duplicates from exceptions list

Duplicated exceptions:
 exception.QuotaError
 exception.SecurityGroupLimitExceeded

Change-Id: Ie8d40cf6e0a1a7b2191877059b757a752aeb4e29
make libvirt driver get_connection thread-safe

libvirt driver's get_connection is not thread safe in the
presence of a libvirtd restart during concurrent incoming
requests.

With existing code each will in turn call get_connection,
find the connection is broken, try to create new one, block
for a while and yield to the next thread to do the same.
You get as many connections as there are incoming requests
and only the last one is used finally. If enough are incoming
these connections can exhaust the client pool configured
for libvirtd.
One fix is to hold a lock while creating the connection.
Note that has_min_version calls _conn which calls get_connection
and thus the direct call to _has_min_version()

Also added the exception text if it fails to register an event
handler for lifecycle events.

Change-Id: I090765802bfe443440f16722bc7c43b6280fe56a
Fixes: bug #1240905
Fix compute_api tests for migrate

They are actually testing resize because of 'flavor_id_passed' being
passed in as True to _test_resize(), when that is already the default
for testing resize.

Change-Id: Iae31dad8e869481898579b5cd752e8e5baa306d1
Fix bad typo in cloudpipe.py

Looks like a refactoring problem. we should be raising
exc.HTTPBadRequest where exc is in webob.

Change-Id: Id6d4e1d43f1d49c05d9da1234e40a603022d35c2
Change testing of same flavor resize

Resizing to same flavor for compute cells should not fail, so this patch
reworks the current test such that it'll be easier to modify when the
compute cells bug is fixed in an upcoming patch.

Change-Id: I4331db8636c2256f18cd0a2196033e1a2257c971
Call baselineCPU for full feature list

Since the libvirt API getCapabilities doesn't return a full list of CPU features we need
to call the libvirt API baselineCPU with the new flag VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES
to get all features.

Since the flag is new this code checks for its existence before calling baselineCPU.

Also, due to some rather stringent input checking on libvirt's part, just calling
baselineCPU with the output from getCapabilities doesn't work, you have to extract
just the <cpu> stanza from the XML returned by getCapabilities.

Add unit test to make sure that the current verion of libvirt works (although
it will hide some features) and the new version of libvirt will correctly
return all features.

Fixes bug 1217630

Change-Id: I266bacb7e0c79d9c5b13ff163f01d14cad9ab57b
Add tests for compute (child) cell

When testing the compute API, we should also be testing when the
cell_type is 'compute'.

Change-Id: Ib0a82e00040eed5814ed7a031070b343d32ee2db
Fix migrate w/ cells

While in a child cell, do not raise when the current flavor is passed
into compute API's resize().  This is behavior that should be limited to
nova-api.

Closes-bug: 1243816

Change-Id: Ie67af3ab3003164e9742a8c4d5bd75502dca96c4