Remove duplicate index from model

Migration 249 dropped this duplicate index, but didn't update the model
to match what happened in the migration.

Change-Id: I3f63d31a0bb6f2652f49d8505cf0c02b090de89e
Reduce the complexity of stub_out_db_network_api()

stub_out_db_network_api' is too complex (57)

Running flake8 to check for cyclomatic complexity showed that the test
method stub_out_db_network_api() in the db/fakes.py module had a
complexity of 57. This change refactors the code to reduce that
method's complexity to 2. No functional changes are included.

Change-Id: Ieb77066ba1133eae5c201121d27a970ce040117e
Fix order of arguments in assertEqual

Some tests used incorrect order assertEqual(observed, expected).

The correct order expected by testtools is
assertEqual(expected, observed).

Change-Id: I87f90b9fefbf39e92446d7724e7b8e457e114716
Partial-Bug: #1259292
ironic: use instance object for plug_vifs

It will be better if we'll use `instance` like object.

Change-Id: I8af1afc8eb7feafae25e6f14045528d2ceb74cbd
ironic: use instance object for `rebuild`

It will be better if we'll use `instance` like object.

Change-Id: Ib713357bd55ed5db27dbfd1c657479bd2ed5e90d
ironic: use instance object for `get_info`

It will be better if we'll use `instance` like object.

Change-Id: I9e465c1eba9347c2f0ae686de7476b2f0c5bb17f
ironic: use instance object for `_wait_for_active`

It will be better if we'll use `instance` like object.

Change-Id: I9e263cd4f94f25c3902a98e1471f8d093d0b2030
ironic: use instance object for `_add_driver_fields`

It will be better if we'll use `instance` like object.

Change-Id: I81099563a8f76577c2b5c6901d2b0b89b86182a2
Make v2.1 tests use wsgi_app_v21 and remove wsgi_app_v3

Nova v3 API has disappeared but some tests still access v3 URLs.
This patch makes them use wsgi_app_v21 and access to v2.1 URLs.
In addition, this patch removes wsgi_app_v3 because it is not
used after this change.

Partially implements blueprint v2-on-v3-api

Change-Id: Ic36d86dce8a35933c15ec820b273825bb0353864
libvirt: fully parse PCI vendor/product IDs to integer data type

When parsing node device XML, the PCI vendor/product IDs were left
in their string form, which is unhelpful for later code wishing to
use their raw values. Fully parse them to the integer form instead.

Blueprint: virt-driver-get-available-resources-object
Change-Id: I46b9c33e08122eb7c28601752ecfc652e09175c1
Remove LOG outputs from v2.1 API layer

There are some debug/audit log messages about normal API operations
in each API method, but Nova WSGI framework has already output the
similar messages. So these messages are meaningless, and this patch
removes them.
This patch removes LOG outputs of InterfaceAttachFailed cases also,
because they are already output on driver layer(vmwareapi, libvirt)
and duplicated now.

Partially implements blueprint v2-on-v3-api

Change-Id: Ib645d1c320e6104bad34c2d7238db399e8d1ea42
Add API validation schema for floating_ip_dns

This patch adds validation json schema for the floating_ip_dns api.

Partially implements blueprint v2-on-v3-api

Change-Id: Iefb6a4503781fcc349cf5101d4ce10cc3422f52b
Fix the unittest use wrong controller for SecurityGroups V2

V2.1 and V2 API are sharing some set of unittest. But the unittest
for SecurityGroups V2 use the wrong controller. This patch fixes this.

Change-Id: I03cc6f3e4c1985fd961378d819c032f7a7c3d8ba
resource-tracker: Begin refactor unit tests

The current unit tests for the resource tracker are in
/nova/tests/compute/test_resource_tracker.py, and they are virtually
impossible to work with, due to a number of things:

 * They rely on a real conductor service being started during
   each test method
 * They rely on database state since they are not NoDBTestCase-derived
 * They use random nested dicts all over the place for fixtures, instead
   of nova.objects where appropriate, making the unit tests very
   difficult to alter along with changes to "objectify" the resource
   tracker.

This patch is the start of a refactoring effort that removes the
database and conductor service calls and replaces them with mocks and
derives the unit test cases from nova.test.NoDBTestCase. This first
patch simply tests the logic of a single important method of the
resource tracker: update_available_resource(). The test methods test the
various code branches that can occur if the compute node has active
instances running on it, no instances running on it, migrations running
on it, and more.

This patch introduces a new test file called test_tracker.py. When all
code paths in the resource tracker have been tested in test_tracker.py,
I will delete the original test_resource_tracker.py and rename
test_tracker.py to test_resource_tracker.py.

Change-Id: I8373203db5f20fc81c47fea2d7fe5f67eadc98b4
blueprint: make-resource-tracker-use-objects
Split agg image props isolation filter unit tests

Breaks out the unit tests for aggregate image properties isolation
filters from test_host_filters.py. In the process, we remove use of the
database and mock out the calls to db.aggregate_metadata_get_by_host(),
which results in the reduction of unit test times.

Change-Id: Ie6742fcb26364684e4a998168d14a7f29e238edb
Split out agg multitenancy isolation unit tests

Breaks out the aggregate multitenancy isolation unit tests from
test_host_filters.py into its own file and refactors them to not have
any database accesses.

Change-Id: I88c4f1918b4e4257da867a8fdbb7a8e21031896f
Network: manage neutron client better in allocate_for_instance

A neutron client only needs to be created twice in the aforementioned
method. The first time is for the tenant and the second, if necessary,
is for the admin. This is in the event that a port binding extension
is supported (only an admin user can read this).

In addition to this is a client exists then the method will make use
of it passing it to all internal methods called. This will enable them
to reuse that client instead of creating a new one.

Change-Id: Ia826199ea600ab55447ca4e8a78738c21b473efa
Closes-bug: #1377647
Compute: maint: adjust code to use instance object format

Update the code to use instance object format instead of dict format.

TrivialFix

Change-Id: I98814c5960f6fa83e3ace36039783ea36e39b3f9
fix the error log print in encryptor __init__.py

when attach an encrypted volume to vm, the error
log print is not right in encryptor __init__.py.
It will raise wrong exception info.

This change will fix the log print using correct
format.

Change-Id: Ibbe41e64ae6320efa53bdd97cdd5312457e65be7
Closes-bug: #1384531
Switch Nova to use oslo.concurrency

Let's switch to the newly released oslo library for
the processutils and lockutils.

Change-Id: Icf7831261322abd0a6fc5439fe09b1d4cb614cb7