Refactor configuring of floating ips on a router

This approach to configuring floating ips is stateless and idempotent.
This allows it to handle corner cases, such as reusing a floating ip
address with a different floating ip id in a way that is easier to
understand.

The concept is to wipe the floating ips clean and rebuild them each
time with the following optimizations.  To avoid bad performance in
manipulating iptables, it is called in the context of a call to
defer_apply_on.  To avoid a disruption in network flow a set
difference is use to determine the set of addresses that no longer
belong on the inteface rather than removing them all blindly.

Change-Id: I0cfb58d487b1925e0a0db2a701c5ea3c56a0b2b5
Fixes: Bug #1209011
Removes unused nvp plugin config param

nvp_cluster_uuid is no longer used; it was missed
during the configuration file tweaks that was done
during Havana.

Closes-bug: #1251086
(cherry-picked from commit  Id6dd684833c99453cd97d88584be04d99fd21550)

Change-Id: Id6dd684833c99453cd97d88584be04d99fd21550
Fix update_device_up method of linuxbridge plugin

Also add unit tests covering update_device_up and update_device_down
methods

(cherry picked from commit: 01e45596fae2818b41c76b41bef46e86c5d33231)

Change-Id: I97f2f9249b684aa5350b3f0621754543e80bec70
Closes-Bug: #1241602
Tune up report and downtime intervals for l2 agent

If the neutron server erroneously thinks that the l2 agent is down
it will fail to bind a port, which can lead to VM's spawn errors.
However, the issue is only transient because the agent effectively
is only 'late' in reporting back.

Best solution would be an alpha-count algorithm (so that we can detect
persistent failures more reliably), but for now let's be more tolerant
assuming that the agent is down by waiting at least twice the report
interval plus a tiny teeny bit.

(cherry picked from commit 291048aba2fcaec8afee3011fb4c12c6ca0ebbba)

Close-bug: #1244255

Change-Id: I544135ce1f6b7eaefb34ac44af8f5844d92ddd95
Fix DB integrity issues when using postgres

The IntegrityError faced on network deletion that
spooks Tempest tests is most likely caused by the
fact that the ml2 plugin does a dirty read. By
adding a 'select for update' we should be able to
address the issue once and for all.

Also, there's a chance that the dhcp port gets
reallocated while we are deleting the network. To
this aim, catch the integrity error and attempt
to recover from it.

This patch also removes the handling of errors
on concurrent reads that can no longer occur when
deleting the network.

(Hopefully) Closes-bug: #1239637

PS: This fix may be relevant for bugs #1243726 and #1246737

Change-Id: Iefae7fc8a903cc35d8bf80fc4cee533b7f64032c
(cherry picked from commit 54d79acaab50993f08b50f21019f82f17d38caa3)
Lower severity of log trace for DB integrity error

LOG.exception is not appropriate, since a concurrent
port creation can occur and it has been dealt with
in the except block.

This avoids spooking users who are on the hunt for
real bugs.

Supports fix for 1239637

Change-Id: I9489702ee63db0b004fe41195fa4727af261d514
(cherry picked from commit 4c6906498a5ef0f11ada3ff2224e995f6b3062d8)
Linux device name can have '@' or ':' characters

It's possible to set '@' or ':' character in Linux device name. But
Neutron IP lib doesn't handle correctly these names.

To distinguish VLAN devices from others devices with '@' in their name,
the details option in iproute2 is used.

Change-Id: I7ed24ec00f481207d97bdef052f86388f24d9b21
Closes-Bug: #1245799
(cherry picked from commit 34f30a1d16d81be86a117690ccc5bdfc5bdd0659)
Fix OVS agent reclaims local VLAN

If a port disappears on an OVS agent, the port is removed of the lvm
vif_ports list. And if it's the last port of the network on this agent,
the network local VLAN is reclaim.

Change-Id: I07e03107eb86a84eeb8e4d06f27a1d2fbd7cea57
Closes-Bug: #1252284
(cherry picked from commit a5d996e381bd342f0204fcd99e8548cf28b20e92)
Merge "Tune up report and downtime intervals for l2 agent" into stable/havana
Fix TypeError: <MagicMock name='LinuxBridgeManager().local_ip'

This patch fixes an error that does not result in a test failure but
causes the following error to be logged in the test logs:

TypeError: <MagicMock name='LinuxBridgeManager().local_ip' id='666599248'>
is not JSON serializable

Related-Bug: #1234857

Change-Id: I65cdd997745d8b760031f8f32e3c10682ad2288e
(cherry picked from commit: d26dfed7d47926425bb55893da45f650d6549b9a)
Merge "Removes unused nvp plugin config param" into stable/havana
Merge "Refactor configuring of floating ips on a router" into stable/havana
Merge "Fix TypeError: <MagicMock name='LinuxBridgeManager().local_ip'" into stable/havana
Ensure NVP API connection port is always an integer

Convert the 'port' part of a NVP endpoint to int before passing
it to the NVP API client.

Change-Id: I15137d943ab950cb5cc80d7af2971bce3ac1a265
Closes-Bug: #1255519
Support uncompressed ipv6 address and abbreviated ipv4 address

Now neutron supports zero-compressed ipv6 address like
'2001:db8::10:10:10:0/120' and unabbreviated ipv4 address
like '10.0.0.0/24'.
This path will make neutron also support uncompressed ipv6
address and abbreviated ipv4 address. for example:
1, uncompressed ipv6 address like 'fe80:0:0:0:0:0:0:0/128'
2, ipv6 address with multiple consecutive zero like
   '2001:0db8:0:0:1::1/128' or '2001::0:1:0:0:1100/120'
3, abbreviated ipv4 address like '10/24'

Change-Id: I755e38ea11c139e15488ec60e7d5682a244ab114
Closes-Bug: #1240790
(cherry picked from commit d1b783fd673448381445dce82e9160ba2f715a7c)
Merge "Fix DB integrity issues when using postgres" into stable/havana
Merge "Lower severity of log trace for DB integrity error" into stable/havana
Merge "Linux device name can have '@' or ':' characters" into stable/havana
Creates multiple worker processes for API server

This change to the WSGI code uses openstack.common.service to create
multiple worker processes to handle API load.  The main process will
start up a configurable (workers=??) number of child processes which
will all listen on the bind port.  The main process becomes the parent
and manages the children.  The parent is not a worker.

Backwards compatibility is preserved by setting api_workers to 0, the
default.  In this case, no separate worker processes are spawned and
the worker threads run in the main process.

Implement blueprint multi-workers-for-api-server

Change-Id: Iffa76041d0055840ccca852814b0e71f17a950ac
Merge "Fix OVS agent reclaims local VLAN" into stable/havana