L3 Agent restart causes network outage

When a L3 agent controlling multiple qrouter namespaces
restarts, it destroys all qrouter namespaces even if
some of them are still in use.  As a result, network
traffic could be stopped on the VMs that use the
networks associated with these namespaces.

So what is needed is for the L3 agent to preserve those
qrouter namespaces a L3 agent instance recognizes and to
destroy those it does not know about.

Closes-Bug: #1175695

Change-Id: Idae77886bd195d773878c3d212ccfd56269216fb
(cherry picked from commit 011d99f300ea5d5f4ce48023bd04a795a4872287)

Backported-from: icehouse
Closes-rally-bug: DE833
Upstream-Review: https://review.openstack.org/#/c/84420/
Merge pull request #32 from CiscoSystems/de833

L3 Agent restart causes network outage
DE734: Instance not getting DHCP due to missing of vlan tag on openvswitch port

- Initial refactoring of a patch authored by AT&T
- Moved get_port_tag_dict to ovs_lib.py which seemed more appropriate.
- Now only examining a port to look for a tag on specific types of tenant networks.
- Added tenant_network_type to the initialization of OVSNeutronAgent
- Now checking for specific tenant network types before looking for vlan tags.
- Now setting self.tenant_network_type from the OVS config.
- Adjusted unit test.
- Adjusted log message when port in forced to resync.
- Clean up test values.
- Removed incorrect spacing.

Closes-rally-bug: DE734
Not-in-upstream: true
Revert "DE734: Instance not getting DHCP due to missing of vlan tag on openvswitch port"
Merge pull request #39 from CiscoSystems/revert-35-de734

Revert "DE734: Instance not getting DHCP due to missing of vlan tag on o...
Fix DHCP Agent Debug Logging

The DHCP agent calling rebuild availability ranges will throw
"Returning exception Parent instance <IPAllocationPool at 0x4ab9b90>
is not bound to a Session; lazy load operation of attribute 'subnet'
 cannot proceed to caller" exception.

This fix just logs the subnet id, as we do not have the db session
to query for the entire IPAllocationPool object.

Closes-rally-bug: DE975
Not-in-upstream: true
Merge remote-tracking branch 'origin/cis-havana-staging' into merge-cis-havana-staging
Merge pull request #44 from mattpopow/bugs/de975

Fix DHCP Agent Debug Logging
Merge pull request #45 from retr0h/merge-cis-havana-staging

Merge cis havana staging
Handle IPAddressGenerationFailure during get_dhcp_port

If a network/subnet is deleted while the dhcp agent is trying
to get/create a dhcp port for that network, the exception
will be raised because no IP Allocation Range is available.

However, this particular failure mode causes just noise, because
the dhcp agent can cope with it without problems.

A follow-up patch will deal with the other exception traces during
create_dhcp_port

Partial-bug: #1253344
Partial-rally-bug: DE1004
Upstream-Review: https://review.openstack.org/#/c/57775/
Backported-from: icehouse
Change-Id: I7fe35455ce905daa22ff96367e120864a7d3fb92
Merge pull request #47 from marcsolanas/DE1004/57775

Handle IPAddressGenerationFailure during get_dhcp_port
Handle exceptions on create_dhcp_port

If a network/subnet is deleted while creating the dhcp
port, the agent will detect a conflict on state of the
network and deal with it accordingly.

A concurrent delete may manifest itself via a number
of exceptions, IPAddressGenerationFailure amongst others,
hence the refactoring of the error handling logic into its
own utility method.

Partial-bug: #1253344
Related-bug: #1243726
Partial-rally-bug: DE1004
Upstream-Review: https://review.openstack.org/#/c/57812/
Backported-from: icehouse
Change-Id: I442beb5f82f3db8786eea53926903ef0ba0efbf1
Handle failures on update_dhcp_port

Ensure exceptions due to conflicting
state of network or subnet resources
are dealt with by the dhcp agent.

Closes-bug:  #1253344
Related-bug: #1243726
Partial-rally-bug: DE1004
Upstream-Review: https://review.openstack.org/#/c/59664/
Backported-from: icehouse
Change-Id: I4fd51442c034fabc91d5a3f065f4df98f5fad35b
Merge pull request #48 from marcsolanas/DE1004/59664

De1004/59664
Provide way to reserve dhcp port during failovers

This change provides a way to save the dhcp port when failing
over a network from one dhcp agent to another.  When a
dhcp-agent-network-remove is issued, the dhcp port device_id is
marked as reserved which causes it to not be deleted. When a
subsequent dhcp-agent-network-add is issued, the reserved port
is used and the device_id is corrected.  This is desirable
in order to maintain the dhcp port ip address so that dns doesn't
get impacted. Unit test added.

Change-Id: I531d7ffab074b01adfe186d2c3df43ca978359cd
Closes-Bug: #1288923
(cherry picked from commit d5c0a37999f9e3a611a322baacabebc06b13283b)

Backported-from: juno
Upstream-review: https://review.openstack.org/#/c/79018/
Partial-rally-bug: DE515
Merge pull request #50 from TieWei/DE515

Provide way to reserve dhcp port during failovers
Fix hostname regex pattern

Current hostname_pattern regex complexity grows exponentially
when given a string of just digits, which can be exploited to
cause neutron-server to freeze.

Closes-bug: #1378450
Closes-rally-bug: DE1514
Upstream-Review: https://review.openstack.org/#/c/135616/
  https://review.openstack.org/#/c/135623/
  https://review.openstack.org/#/c/135624/
Not-in-upstream: false
Backported-from: icehouse
Merge pull request #52 from CiscoSystems/de1514

Neutron DoS through invalid DNS configuration
Gracefully handle consumer cancel notifications
Back ported from oslo.messaging in Icehouse.
With mirrored queues and clustered rabbit nodes a queue is still
mastered by a single rabbit node. When the rabbit node dies an
election occurs amongst the remaining nodes and a new master is
elected. When a slave is promoted to master it will close all the
open channels to its consumers but it will not close the
connections. This is reported to consumers as a consumer cancel
notification (CCN). Consumers need to re-subscribe to these queues
when they recieve a CCN.

kombu 2.1.4+ reports CCNs as channel errors. This patch updates
the ensure function to be more inline with the upstream kombu
functionality. We now monitor for channel errors as well as
connection errors and initiate a reconnect if we detect an error.

Implements: rally-user-story US6888
Upstream-Review: https://review.openstack.org/#/c/77276/
Not-in-upstream: true
Merge pull request #53 from zhencisco/TA8452

Gracefully handle consumer cancel notifications