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
sync periodic_task fix from incubator

Set the value of time the periodic task was last run to a multiple of the
spacing value rather than the actual last time run. This ensures tasks runs
regularly but avoids synchronizing that interval with other nodes.

This patch also removes the coalescing of tasks which are _nearby_ (0.2
seconds away).

4dbd3aa Make periodic tasks run on regular spacing interval
21249f1 Fix parenthesis typo misunderstanding in periodic_task

Change-Id: I8873545578f104fd204fbc25493350128b2bc8d4
Bump min required version for dnsmasq to 2.63

This patch bumps the min version requirement from 2.59 to 2.63
for dnsmasq which is needed to use multiple tags for dual stack IPv4/6.

DocImpact

Change-Id: Ib71b8a3a866f5781b57d1589741bcaae594b76db
Closes-bug: 1233339
NSX: remove unnecessary checks on network delete

Since commit b50e66f router interfaces are not deleted
automatically when the network hosting them is deleted.

The NSX plugin still has additional logic to ensure all the
corresponding backend resources have been deleted as well.
Such logic is now obsolete and can be removed. Moreover it
also wasteful as it perform queries for retrieving NSX
resource identifiers.

This patch also amends a few related log statement to make
them clearer.

Change-Id: If3d8d98096a8363b216707f2558e37c80f58e515
Closes-Bug: #1339401
Add a gate-specific tox env for functional tests

The functional gate jobs (*-neutron-dsvm-functional) need special
configuration (e.g. OS_SUDO_TESTING, OS_ROOTWRAP_CMD) to run tests.
This patch adds a new gate-specific tox env (tox -e dsvm-functional)
that sets the appropriate values and allows easy duplication of the
results of the upstream job on a host that has successfully run
devstack with neutron enabled.

A new configuration option, OS_FAIL_ON_MISSING_DEPS, is also set by
the dsvm-functional tox env to ensure that dependency failures will
result in failures rather than skips when run in the gate.

Change-Id: Idbfef1ba72ed129a3021509c7969e2685b8a6d09
Partial-bug: #1336172
Move _convert_to_nsx_transport_zones into nsx_utils

This routine does not need to be in the plugin class. This patch
transforms it into an utility method and adds unit tests to
increase coverage.

Change-Id: Ieacc36e729c4db90efd33944f7cf05dcb30e1de9
Closes-Bug: 1340210
Mock out tunnel_sync in test to avoid sleeping

The tunnel_sync call in the daemon loop for the ovs tunnel
tests blocks for 30 seconds. This patch mocks it out to stop
that.

Closes-Bug: #1340570
Change-Id: I58c3907ed564413a8251bc1bb7922e25f673db18
Validate expected parameters in add/remove router interfaces

The add and remove router interface methods check that interface_info
is not empty but don't check if it contains any of expected parameters:
port_id and subnet_id
This patch adds a helper method to validate that interface_info contains
at least one of the expected parameters
Include a unit test for the empty port_id and subnet_id case

Closes-Bug: #1325982

Change-Id: Ia370565235a33a847704b972c875d8f1573306c0
Split up metering test case into plugin + test case

Currently the metering test case includes setUp code as well
as the tests themselves. Splitting up the test case class
into two allows other test cases to inherit the metering
plugin class without inherting (And implicitly re-running)
the tests themselves.

Closes-Bug: #1336198
Change-Id: I4427fcd17cc3d28189f9f74df487084cf35c1634
Allow unsharing a network used as gateway/floatingip

If network has ports that connect it as gateway to another network, such
as an external network, or "floating ip" ports it should still be
possible to "unshare" it since these ports represent usage of the
network as an external network, not as a VM data network.

Change-Id: Ic33ae7ac193e4fc9fe06a4cfd579a4aacf0e6354
Closes-bug: #1293184
Clear entries in Cisco N1KV specific tables on rollback

During rollback operations, resources are cleaned up from neutron
database but leaves a few stale entries in the n1kv specific tables.
This change addresses the proper clean up of tables. i.e. VLAN/VXLAN
allocation tables, profile binding and vm network table.

Change-Id: I7a09d34f3a9dee0a43b76c5d781ee9eb9938953a
Closes-bug: #1336596
Missing max_routes in neutron.conf

We have the define of "max_routes" in neutron/db/extraroute_db.py
but we do not have them in neutron.conf.

Change-Id: I4a9586023b7d09a64296b44f4d9285f30be1fd63
Closes-Bug: #1341378
NSX: Optionally not enforce nat rule match length check

This patch adds the 'raise_on_len_mismatch' parameter to the
'delete_nat_rules_by_match' function. The plugin then leverages
this parameter for ensuring NAT rules deletion operations
are completed successfully even when duplicate rules are found
or no corresponding rules are found at all.

With this change, the 'remove_router_interface' operation will
correctly complete even in cases when NAT rules in Neutron and
the NSX backend are out of sync.

This patch also changes a check in delete_nat_rules_by_match in
order to make it less expensive.

Closes-Bug: 1328181

Change-Id: I856d67ef5ff6264374cb8f2569668da4c205ad9f
Cisco: Fix test cases which make incorrect create requests

Some test cases in the test_n1kv_plugin module are sending more than
one dictionary while creating the network profile resources. This
patch corrects these erroneous test cases while preserving the test
cases intended behavior.

Change-Id: I99de0b708218cf5217ecf47c74a30f75d0733e25
Closes-bug: #1347963
Expand arp_responder help text

Add additional text to arp_responder help to ensure that
proper documentation is included in the configuration guide.

Make ML2 and L2population references consistent.

Closes-Bug: #1321320

Change-Id: I0fc0691fc3729aa39888c90ca871ad7f711343f8
Use method's logger in log decorator

Previously decorators shared logger. This patch makes LOG object in
closure for every decorated method in order to use correct logging
level.

Closes-Bug: #1340778
Change-Id: If907acbab34f8bf23e1277e66c3ddd839f668764
Fix incorrect default paramater in migration

Migration 5446f2a45467_set_server_default try to set incorrect default
boolean value on Integer column cisco_network_profiles.

Closes-bug: #1341518

Change-Id: I594a6811af23fced7105252f47d72232bf37184c
Dnsmasq config files syntax issue when dhcp_domain is empty

When using dhcp-agent with the following property dhcp_domain=""
addn_hosts and host files genererated for Dnsmasq have wrong syntax
concerning hostname parameter (dot char at the end).

As described in RFC-952 the hostname grammar is as follows:
<hname> ::= <name>*["."<name>]
<name>  ::= <let>[*[<let-or-digit-or-hyphen>]<let-or-digit>]
Hence it can't be conclude with a dot char.

Dnsmasq process is waiting for a hostname (2nd parameter) in the
following files:
"addn_hosts" file contains:
   20.0.0.3 host-20-0-0-3. host-20-0-0-3
"host" file contains:
   fa:16:3e:bf:e1:e4,host-20-0-0-3.,20.0.0.3

With the patch you will get:
"addn_hosts":
   20.0.0.3 host-20-0-0-3 host-20-0-0-3
"host":
   fa:16:3e:bf:e1:e4,host-20-0-0-3,20.0.0.3

Change-Id: I4c10169019becaed6b2968b74f03ef356244a057
Closes-Bug: #1326256
update vsm credential correctly

Today if we modify the n1kv VSM credential in the cisco_plugins.ini, the
older VSM ip address remains in the db, and all requests are sent to
the older VSM. This patch deletes all n1kv VSM credentials on neutron
start up before adding the newer VSM credentials. Hence making sure
that there is only one n1kv VSM IP address and credential in the db.

Change-Id: I772a86bf896a1d3d9c69c545ce6918b0fe3a2e48
Closes-Bug: #1341014
NSX: Remove unneed call to _ensure_default_security_group

This patch removes an unneeded call to _ensure_default_security_group
which does not need to be called in create_security_group_rule_bulk()
as one would need to call get_security_groups() to look up the uuid
of the default security group which be would created it for us, BOOM!

Change-Id: I628a94c7ea9553dcefa68fa956f25244f0abbb18
Closes-bug: 1340536