Fix pep8 issues with test_manager.py

Fixes E231 (missing whitespace) problems with
nova/tests/network/test_manager.py

Change-Id: I99d4c3bf7ed1a137fbfb26e9fe2f31d9104d5ae4
More gracefully handle TimeoutException in test

Sometimes although the test_killed_worker_recover test passes, the
cleanup of a forked child takes too long and a TimeoutException
occurs. This patch better handles the TimeoutException and
ensures the child process is killed.

Fixes bug #1128574

Change-Id: I39ea2fbb6c9cb95ad10b68bfa216686467951a93
ensure we run db tests in CI

CI had a set of environmental variables that refused to allow the
tests from failing gracefully. These seem to have gotten lost
along the way in refactoring.

Change-Id: Ib19b5d472c51ed72b8acf1571dd19f41474532c5
Removed duplicate spawn code in PowerVM driver

After introducing resize/migrate in PowerVM there was
some code that was duplicated after a rebase. The commit
removes the duplicate code. The functionality of
resize/migrate remains the same as introducted in
Change I72345626

Bug #1130680

Change-Id: I1fe3d8e1f2a19fd40a03c8c38d90c01711356b38
libvirt: fix volume walk of /dev/disk/by-path

If /dev/disk/by-path does not exist, then _get_iscsi_devices() will
raise an IndexError. Handle this case and return an empty list. This
fixes a test on OSX.

Fixes bug 1130841

Change-Id: Ibae2f1238feac9a10b8dc2b74886ea59edac0bcc
Make nova security groups more pluggable

This patch moves the nova security group code out of nova/compute/api.py
into nova/network/security_group. It also removes any query to the database
from security group api into the nova security group driver. This allows
security group drivers the ability to decouple themselves from storing
security group information in the nova_db.

Change-Id: Ib183515a0418203c8bcc88176e3a1498d7333300
Add Nova quantum security group proxy

Implements blueprint nova-quantum-security-group-proxy

Change-Id: I21d70f1dc8e61d6412d14e30ab2aa1a83a711de2
Wait for baremetal deploy inside driver.spawn

Previously, baremetal driver.spawn returned as soon as the
machine power turned on, but before the user-image was deployed to the
hardware node, and long before the node was available on the network.
This meant the nova instance was marked as ACTIVE before provisioning
had actually finished. If the deploy failed and the baremetal node was
set to an ERROR state, the nova instance could still be left as ACTIVE
and the user was never informed of the error.

This patch introduces a LoopingCall to monitor the deployment status in
the baremetal database. As the deployment is performed by
nova-baremetal-deploy-helper, the database record is updated. Once the
deployment is complete, driver.spawn() sets the baremetal node status
and the nova instance status is also set properly. If an error occurs
during the deployment, an exception is raised within driver.spawn()
allowing nova to follow the normal cleanup and notify paths.

This also allows the baremetal PXE driver to delete cached image files
when a baremetal deployment fails.

Fixes bug 1088655.

Change-Id: I4feefd462fd956c9780995ec8b05b13e78278c8b
Better error handling in baremetal spawn & destroy

Improve the exception handling in baremetal driver spawn and destroy.

Adds unit tests for destroy to check that bm_node is disassociated
from instance_uuid only when destroy succeeds, and is set to ERROR state
(but still associated) if any exception is not handled.

Change-Id: I75853210d4883b352da9876a682dbb7288689541
Improve performance of baremetal list_instances.

This patch adds two new methods to baremetal/db/api:
 - bm_node_get_associated
 - bm_node_get_unassociated
which return a list of nodes either associated or not associated to a
Nova instance, as determined by the instance_uuid field, respectively.

Now, list_instances and get_available_nodes methods only fetch assocated
and unassociated nodes from the baremetal database, instead of fetching
all nodes.

Change-Id: Ib875d26d7b85a9dbf08c925a89802e2cd614e363
Identify baremetal nodes by UUID.

- add a new 'uuid' column to 'bm_nodes' table
- provide a new db/api method for accessing nodes by their uuid
- return this to Nova as the nodename / hypervisor_hostname

In this way, a baremetal node is uniquely identified to the user,
whether they use a per-compute baremetal db or global baremetal db.

It will also allow for an instance to be booted on a specific baremetal
node using a means akin to the current force-hosts (TBD in later patch).

Also, creates two new Exceptions to disambiguate between
InstanceNotFound and NodeNotFound / NodeNotFoundByUUID.

Change-Id: I81105a201588fdef31cffabdae260bb43017bcd1
Baremetal driver returns accurate list of instance

Add 'instance_name' to bm_nodes table so that baremetal driver is able
to return the names of all instances it believes are still running.

Previously, baremetal.driver.list_instances was fetching all allocated
instances from baremetal database, then calling VirtAPI to get the
instance name. This would raise an InstanceNotFound exception for
deleted instances. This prevented ComputeManager from ever detecting
a running-but-deleted baremetal instance, and could leave baremetal
instances in an undeletable state.

Fixes bug 1096723.

Change-Id: Ifae532e8e70e97e48c589608cb3c7000bb6a7609
Move some context checking code from sqlalchemy

Move some context related code from sqlalchemy into nova/context.py
where it can be used outside of sqlalchemy.

Change-Id: I6522a072132e27b42561435cb4fd671a2ece4867
Remove race condition (in Networks)

Soft delete all duplicate rows with the same vlan except one with
the biggest value in `id` column.

Create UC on fields (vlan, deleted)

Replace Select then Insert -> Try to Insert.

Fix error in network_update method. We were able to update
vlan to duplicate.

Fix typo in description of method drop_old_duplicate_entries_from_table()

blueprint db-enforce-unique-keys

Change-Id: Ia1b58ab5a5e369a1939de0b5c2f89aee6fc2c40b
Fix message envelope keys.

update.py from oslo-incubator broke the keys used in the rpc message
envelope.  This fixes it.

Change-Id: Idabd18720cad8c4469c5dc3ec1ffd20a3a39e897
Merge "Make nova security groups more pluggable"
Merge "Add Nova quantum security group proxy"
Merge "Wait for baremetal deploy inside driver.spawn"
Merge "Better error handling in baremetal spawn & destroy"
Merge "Improve performance of baremetal list_instances."