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
Ensure assertion matches dict iter order in test

Fixes a test_linux_ip_lib test that made an assertion
on a command that was called that could fail depending
on the order of the dictionary when it was iterated over.

This patch makes the assertion match the order that the
command is constructed by iterating through the dictionary
as well.

Partial-Bug: #1348818
Change-Id: I7baa518169c193f7e98d38632e1db16eb57ffee7
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
Use call to report state when ovs_agent starts up

Make sure to report ovs_agent state when starting up, otherwise
ovs_agent start_time would not be updated and thus l2pop does
not send fdb entries.

Change-Id: Idd770a85a9eabff112d9613e75d8bb524020234a
Closes-Bug: #1347452
Raise NotImplementedError instead of NotImplemented

NotImplementedError is the name of the exception
(https://docs.python.org/2/library/exceptions.html).

NotImplemented is the name of a constant
(https://docs.python.org/2/library/constants.html).

It makes no sense to raise a constant. The exception should
be raised instead.

Change-Id: I4969e26eb7b46f008ea3c8bd0093490c425f7069
Closes-Bug: #1339855
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
NSX: Avoid floating IP status reset

The method for setting the floating IP status in the NSX plugin
has a flaw that causes in some cases the status to be reset.
This patch removes this bug and also protects against regression
adding status check in the unit test covering floating ip
creation.

This patch also moves the above mentioned unit test in a more
suitable place in the test same module.

Change-Id: Ib08c421ade20ce23b5c08145203a2df6a8f3efa5
Closes-Bug: #1357514
Fix config option names in ml2_conf_sriov.ini

Config option names in ml2_conf_sriov.ini file are
not in sync with definitions in source code.

Change-Id: Ic8f7b6b8e9acd022623daabd2b209b864caa0b06
Closes-Bug: #1357339
Update DVR Binding when router_id changes

In this patch I modified update_dvr_port_binding to update the
binding if router_id changes.
When a new router namespace is created on a host, sync_router
will call _ensure_host_set_on_port that will update the DVR binding.
With the current code update_dvr_port_binding won't update the
binding if there's an existing binding unless the binding
vif_type is VIF_TYPE_BINDING_FAILED . There's a race when
the router namespace is destroyed and then recreated on the same
host.
The DVR binding is deleted only when the message
update_device_down is processed. If this message is processed
after the update_dvr_port_binding triggered by the namespace creation,
update_dvr_port_binding won't update the binding. When the router
interface will be detected as UP, no DVR binding will be found.

Closes-bug: #1358554
Change-Id: I37fd4ed67dc2019b57e36d082b584c517d8f67a8
Change nexus_dict to accept port lists

When users configured a server to have two logical connections to a
single switch, the nexus driver would never know about the second
connection because the nexus_dict stored the interface as a single
value, which would just get overwritten.  This has been fixed by
allowing the port value to be a comma seperated list.  All
operations on ports have been update to loop over multiple ports
per switch. New test added for host with dual connections to one
switch.

Change-Id: Iefb30452083747b45496600c81f8d0a6f378bd08
Closes-Bug: 1288393
Send HTTP exceptions in the format expected by neutronclient

Neutron client for the v2 API expects exceptions to have 'type',
'message' and 'detail' attributes. That is why they need to be
included in the body of HTTP Exceptions.

Change-Id: I70bd47977e42ad7bac760600329e9440452b74bc
Closes-Bug: 1355902
Reorder operations in create_vip

Previously VIP's port creation was moved outside the transaction
to avoid deadlocks related to rpc calls.
It led to small chance of VIP being fetched by rpc code with
port being still None.

This patch reorders VIP association with the pool so it's done
only after port has been created.

This patch also leaves small possibility of uncaught exception in
case of pool being concurrently deleted in the process of VIP creation

Change-Id: I584558aecc92db4d19fb72b1d006868b840a4d8c
Closes-Bug: #1356227
Big Switch: Check for 'id' in port before lookup

Check for the presence of the 'id' key before trying
to do a lookup based on the value. This is necessary
because a 'fields' param to get_port(s) may exclude
the 'id' field before the host_id lookup.

Closes-Bug: #1358668
Change-Id: If30567d5deaeabd2de6c6287fac7a81695a41cc5
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
Set InnoDB engine for all existing tables

Added the method in heal script that checks if mysql_engine
parameter is needed to be changed and if it is neseccary do this.
Also this change adds migation that set 'mysql_engine' to InnoDB
for all tables that were added into the database after healing.

Closes-bug: #1346966

Change-Id: Ia4d9038b99b2559d37272a17f5819a9dedd53f72
Fix migration set_length_of_description_field_metering

If PostgreSQL version is less than 9.1.13 migration
set_length_of_description_field_metering fails as there is no
special 'create if not exist' expression. This change add special
function for this case.

Closes-bug: #1348138

Change-Id: Ibe4f370fe400072abd281bd2313261790335eae2
Remove invalid or useless initialization in test_type_vxlan

In test_type_vxlan, vni_ranges option is overriden with an invalid and unused
value, vxlan_group is overrriden but never used.

Change-Id: Ie1ce1d7a8ef54692d122276e371ec5efc2e68d9c
Ensure ip6tables are used only if ipv6 is enabled in kernel

On systems where ipv6 module is not loaded in kernel we need to avoid
usage of ip6tables. This patch reads
/proc/sys/net/ipv6/conf/default/disable_ipv6 file and if ipv6 is
disabled then ip6tables are not used in IptablesManager

Closes-Bug: #1352893

Change-Id: I07e5851aa25eb98b7a97dff86b9850475df85f64
Add config for visibility of cisco-policy-profile

This change adds a configuration option to cisco_plugin.ini to control the
visibility of cisco-policy-profile among tenants. The default is false or
unrestricted, so all tenants can view all policy profiles. If the option
is set to true, tenants can only view policy profiles that are assigned
to that tenant. The admin user can always view all policy profiles. This
was implemented by adding a check of the configuration option in
get_policy_profiles().

Change-Id: I5d77544d75366d39714def971eb949cfdc40023e
Implements: blueprint cisco-policy-profile-visibility