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
Make scheduler disk_filter take swap into account

The disk_filter, which makes sure a node has enough disk space for an
instance doesn't take the swap partition into account, but swap takes up
disk space so it should.

Change-Id: I0779dcf0f1cd60017b5b49ca38c0a15b23d802d7
Closes-Bug: #1239009
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
Fix the ConsolesController class doc string

The code must have been copied from the console output extension to start
with and the old class doc string was left in place.

Change-Id: I4924e69763027043aace8e34aac55701be2ea823
Closes-bug: #1241685
Fix all scripts to honor the enabled_ssl_apis flag

Add logic to allow configuration of SSL for all the cmd scripts
that start a WSGIService

Change-Id: I921013d113081a91a3fe9bb574bae5cd7bb06bcc
Closes-Bug: 1237126
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
Fix wrong description when updating quotas

when updating quota for a resource, with 'force_update=false', an
exception will be raised when the new value is less than the used quota
values(used and reserved). This patch changes the description of
exception.

Change-Id: Iede70444341817afb6953eb604fe4de186622916
Closes-bug: #1243062
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
Drop RPC securemessage.py and crypto module.

As of 579109cab946a54f86b04724f0b6cb71fb027c04 Nova should
have the openstack common crypto modules to support
rpc/securemessage.

The RPC securemessage stuff will eventually get integrated into
oslo.message. As is it is only partially complete in oslo-incubator
and it is getting synced into various projects (and breaking
some things).

This commit drops securemessage.py which was missing classes in
the crypto module anyway and would not have worked.

Closes-bug #1241634

Change-Id: I050d620a51042007aa4696fa439bd99c7597a9a4
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
Refactor unit tests code for python3 compatability

The builtin basestring abstract type was removed in python3,
use str instead, we need to using six.string_types to replace
the basestring for py3 compatibility.

Partial Implements bp basestring-py3-compatible

Change-Id: I0f6a0f9ca4e17800407f3c1bbdce11a46288f693