Use openstack.common.lockutils module for locks in tox functional tests.

Tox test has been switched to use openstack.common.lockutils module
for interprocess locks. However neutron tox functional tests was
left behind probably because locking is not required by the existing
functional test cases. This change makes neutron tox functional tests
adopt openstack.common.lockutils for locking.

Closes-Bug: 1332380
Change-Id: I4d6076e5f7586a11ea5381f18774d4bab57b0081
Log exceptions inside spawned functions

eventlet pool will discards all exception raised inside spawn(_n), it is
hard to discover problems inside spawned green-threads, it is better to
add a function wrapper to log the exceptions raised inside spawned
function.

Change-Id: I753df36c4614759f49134667a55f2a91f0c08317
Closes-bug: #1340708
Do not assume order of parameters in OVSBridge.add_flow call

This fixes neutron.tests.unit.agent.linux.test_ovs_lib.OVS_Lib_Test.test_add_flow
unit test that breaks with a randomized PYTHONHASHSEED.

The test assumed that the parameters passed to add_flow had
elements in a particular order. Found with PYTHONHASHSEED=2455351445.
The fix refactors the test case to match parameters as set.

Partial-bug: #1348818

Note: There are several other unrelated unit tests that also break with a
randomized PYTHONHASHSEED, but they are not addressed here. They will be
addressed in separate patches.

Change-Id: Ibe2f4d929b8b42c8c909c2306d2554faf7109b49
Ignore http_proxy while connecting to test WSGI server

urllib2.urlopen uses $http_proxy/$HTTP_PROXY environment variables by
default.  If set (and pointing to a remote host), then the WSGI tests
that spin up a local server and connect to it using
http://127.0.0.1:$port/ instead connect to $port *on the proxy*,
and (hopefully) fail.

This change uses urllib2 in a way that ignores proxy settings.

Change-Id: I4d94fcc06925d0c947345a07ae20352e1898e46d
Closes-Bug: #1356665
Use oslo.db create_engine instead of SQLAlchemy

oslo.db may set additional options to engines that we may be interested in.

blueprint enable-mysql-connector

Closes-Bug: #1350942
Change-Id: I6f67bb430c50ddacb2d53398de75fb5f494964a0
Arista Layer 3 Sevice Plugin

This sevice plugin implements routing functions on Arista HW.

Change-Id: Ide411540254db015167111defee7d8c6c1c27347
Implements: blueprint arista-l3-service-plugin
Assign Cisco nw profile to multi-tenants in single request

Currently with Cisco N1kv plugin, user can assign cisco network
profile to only one tenant in a request. So user has to send
multiple requests to assign a cisco network profile to multiple
tenants.
This fix is going to add the support to assign to multiple tenants
in a single request

This fix has corresponding changes in neutron, python-neutronclient
and horizon. All the changes should be committed at the same time

Change-Id: I42ffbd17a80f741d9cf1094dc79b588444bd9d4b
Implements: blueprint cisco-network-profile-multi-tenants-support
Refactor type_tunnel/gre/vxlan to reduce duplicate code

gre and vxlan type drivers have similar implementation for multiple
methods. This change abstracts these methods and move them to
TunnelTypeDriver.

sync_allocations method is not shared between gre and vxlan type drivers
because they use different strategies and the targeted one is unclear.

Change-Id: I717b70eb718f7ae82f1bc0c81543b0c438e8bddd
Fix policy rules for adding and removing router interfaces

Currently "add_router_interface" and "remove_router_interface"
policy rules have the "update_router" prefix and thus are never
enforced. Removing the prefix activates the rules.

Also moved some rules, so that all router-related rules are
now grouped together.

Closes-Bug: 1356678
Change-Id: Ib6cc45f2c6d0c7ae394274d6196262529b9fd855
Add specific docs build option to tox

Add doc venv to align with other OpenStack projects (such as keystone,
heat and nova) who are using 'docs' for there doc builds.

Change-Id: I0094130224ec2667cdd76f497edf595f09a86d12
Do not log WARN messages about lack of L3 agents for DVR routers

DVR routers are scheduled only when there is need to: for instance when
there's an external gateway associated with it, or when there are
interfaces attached to subnets on which VM's are actually being deployed.

Therefore, do not log misleading messages that apply only to the
centralized case.

Closes-bug: 1358998

Change-Id: Ica7f0d25fe576f05a9adf8eb8239704f09c0b0ac
VPNaaS: Enable UT cases with newer oslo.messaging

Now that 1.4.0.0a3 of oslo.messaging has been added to Neutron
requirements, the unit test cases in VPNaaS code can be
uncommented and included in the tests. These tests ensure that
the correct validator is called, when validation is performed.
This adds similar tests to the reference and Cisco VPNaaS
implementation.

Change-Id: I62e3f8f3ec5fcceccd13891b1aa142869e1d88a1
Closes-Bug: 1349829
Add ipv6 forwarding for router namespaces

Change-Id: I35101e6b32ab84bebb228cf0c43162eda761b17b
Closes-Bug: 1355195
Minor refactoring of auto_schedule_routers

The method is more complicated than it needs to be, and it makes it difficult
to target fixes for it.

This is done in preparation of fix for DB lock timeout errors observed while
dealing with DVR routers.

Test coverage is already provided, and more granular coverage is added to
reflect the new structure being introduced.

Partial-bug: #1356121

Change-Id: Ifb7a742b64139f3a5d9b88c3c6261b1b890946f9
Removing sorted() function from assertEqual()

Removing unnecessary sorted() function from assertEqual() function
calls in functions used for sorting and pagination testing

Using sorted() breaks sorting tests objective which is to test sorting.
This is causing every unit test using this functions
(_test_list_with_sort, _test_list_with_pagination, _test_list_with_pagination_reverse)
for sorting tests to always succeed

Switched the parameters for assertEqual() function within the fixed code to meet
its signature - assertEqual(self, expected, observed, message='')

Test neutron.tests.unit.vmware.vshield.test_lbaas_plugin.TestLoadbalancerPlugin.test_list_vips
was succeeding because of this bug, although it should fail. It failed after the bug was fix.
Test was fixed.

Change-Id: Ia36b81d9a7fd32cae3b567ac1899b56481eb62ce
Closes-Bug: #1355251
Do not explicitly set mysql_engine

Setting the mysql_engine when creating a table is not needed
anymore as this is automatically done by an event listener
added with commit 466e89970f11918a809aafe8a048d138d4664299

Change-Id: I0df978dbf2bb44f17102da3c17fd4e93c9e4df8d
Closes-Bug: #1361176
Raise proper exception in case duplicate ipv6 address is allocated

In case neutron tries to generate ipv6 address for slaac subnet,
it doesn't check that generated ip is unique and throws DB exception
that results in 500 HTTP error.

The fix throws proper IpAddressInUse exception.

Closes-Bug: #1358731
Change-Id: I66aed81b8d31d1eff6c87a77c4c4a813179ba458
Refactor plugin setup helpers out of test.base

Helper methods for plugin and notification setup were previously
defined on neutron.tests.base.BaseTestCase.  The imports required to
support these helpers were preventing the api tests from consuming
tempest due to configuration conflicts that resulted between neutron
and tempest.  This change moves the helpers to a new module in
tests/unit so that BaseTestCase can be safely used across all types of
tests.

Partially-Implements: blueprint retargetable-functional-testing

Change-Id: I44251db399cd73390a9d1931a7f253662002ba10
Updated from global requirements

Change-Id: I922b382fa75ecc6a8e14f25914c27e3eb245766e
Add _store_ip_allocation method

This refactor supports patch [1]
The code to store the IPAllocation is moved to a specific
method _store_ip_allocation

[1] https://review.openstack.org/#/c/100963

Change-Id: I9492dcb9479d6e6dadb79b137a273052d948412b