Fix unshortened IPv6 address caused DHCP crash

When unshortened IPv6 address provided to allocation pool, DHCP
agent crashed because OpenStack is trying to add same IPv6 addresses
to dhcp tap device.

The root cause is that current code compares provided unshortened
IPv6 address with the returned result of "ip addr list", which is
shortened. So the same IPv6 address is treated as different ones.

The fix is trying to shorten the provided address before comparison.

Change-Id: If1e183e65c5ab785b73771d9a3d4b525d38284a9
Closes-Bug: 1266780
Remove unused variable

o neutron/services/firewall/drivers/linux/iptables_fwaas.py:FWAAS_CHAIN
  = 'fwaas'

  This variable was added in the following commit.

    commit 7e487160867d2c2059d556d0d3af50bc8e8838fa
    Author: Rajesh Mohan <rajesh.mlists@gmail.com>
    Date:   Fri Jun 21 17:55:08 2013 -0700

        Firewall as a Service (FWaaS) Iptables Driver

  But there is no evidence that was used.

Change-Id: I5633e74e2441b71e3dddaa0c2f6a5804778e21e1
Invalid ovs-agent test case - test_fdb_add_flows

setup_tunnel_port is an attribute of self.agent and not self.agent.tun_br.
This patch fixes the testcase accordingly.

Closes-Bug: #1284265
Change-Id: I70582e477bb53de6482e32d5913c0864c5d910cc
Delete disassociated floating ips on external network deletion

Also remove redundant check for network in use in bigswitch plugin

Closes-Bug: #1238439
Closes-Bug: #1259144

Change-Id: I7586f43c2e99be9df491c68bf1e8658994ffd263
Add support for https requests on nova metadata

Adds new config value for accessing nova metadata api with SSL. In case
nova api requires client certificate other config values were added
providing client certificate and client private key.

DocImpact

Closes-bug: #1293587
Change-Id: I782a12eb77553f4369b782071b4ad19efb82e5e2
ofa_neutron_agent: Fix _phys_br_block_untranslated_traffic

Install the flow to the correct bridge.

Closes-Bug: 1301142
Change-Id: I2aa7ffd6bb297837a39cdd00794af100bf9ab407
Remove RPC to plugin when dhcp sets default route

_set_default_route() was using an RPC to the plugin to get the DHCP
port for the network on the current host, and then used it to form
the tap device name. This happened on every allocation reload too.
This fix removes the RPC and gets the tap device name using local
methods instead. It also removes an unnecessary call to set the
default route in the restart method.

Closes-Bug: 1290068
Related-Bug: 1294254
Change-Id: I639bcf93725c4969d1011d2d20491d461ccfdbed
Enable flake8 E711 and E712 checking

E711 comparison to False should be 'if cond is False:' or 'if not cond:'
     comparison to None should be 'if cond is None:' or 'if not cond:'
E712 comparison to True should be 'if cond is True:' or 'if cond:'

Most violations were in DB queries. Replace as follows:
  False -> sqlalchemy.sql.false()
  None  -> sqlalchemy.sql.null()
  True  -> sqlalchemy.sql.true()

Change-Id: Iff54747b70f504d5466cfdc6e2ec4d7a0f9ddb7c
Closes-bug: #1305377
Exclude .ropeproject from flake8 checks

Change-Id: Ic788c49e5e92b171e20fe132829648ff21539e33
Closes-Bug: #1297016
Fix Metering doesn't respect the l3 agent binding

This patch fix the issue by changing the call to
find the plugin which handles the l3 which is now
the l3_router service plugin instead of the old mixin.

Also change the unit tests to use the l3 service plugin
instead of the l3 mixin and refactor the rpc callbacks
part.

Co-Authored-By: Ala Rezmerita <ala.rezmerita@cloudwatt.com>
Closes-bug: #1257354
Change-Id: Ide26f825005fa63cd3fcc75fa91fffb947e0be7a
Delete DHCP port without DHCP server on a net node

A DHCP-network was deleted from one host using neutron
dhcp-agent-network-remove and then added to another host
using neutron dhcp-agent-network-add command. While the
dhcp-agent-network-remove command was in progress, the
host crashed.  As a result, the removal of the DHCP-network
was partially done. The network was disassociated from
the agent in mysql. However, the agent never made the
release_dhcp_port RPC call to delete the port -- even
after the agent restarted. The end result is that there
are two DHCP ports for the same network. One of these
is found on the host that is no longer hosting the
dhcp-server.

This fix make the DHCP agent invoke the release_dhcp_port
RPC call on a stale network whose dnsmasq process is not
running (not active). Before this change, the RPC call is
made on a stale network only when the dnsmasq process is
running.

Closes-Bug: #1244860
Change-Id: Ie0bafdac698810b5455550c306c6a75ddf91d9bb
Fix uninitialized variable reference

This was probably a copy&paste error. While physical_network is used in
earlier loops, it isn't defined here. The identically named member variable was
probably intended.

Change-Id: I09e38321cf8670c62f4fdf9d99da1df737b2fc68
Closes-Bug: #1308421
Check if bridge exists and make sure it's UP in ensure_bridge

Introduce _bridge_exists_and_ensure_up that checks if the bridge
exists and if it's DOWN sets it UP

Change-Id: Ide9d2bb04016cadb347b00cadbee7007e61bd01e
Closes-bug: #1282741
OFAgent: Process port_update notifications in the main agent loop

Port the following patch to OFAgent.
commit: 5e6e592132aa9a98936ce3bfdb66efc7832caafb
https://review.openstack.org/#/c/61964/

Partial-Bug: 1293265

Change-Id: I53813d12c66dc746cd373fd91ff9bd9bdbf222db
OFAgent: Improve handling of security group updates

Port the following patch to OFAgent.
commit: 3046c4ae22b10f9e4fa83a47bfe089554d4a4681
https://review.openstack.org/#/c/63100/

Partial-Bug: 1293265

Change-Id: Iecdfee894ff2fd5f05f63f040dd70821af124737
Validate IPv6 modes in API when IP version is 4

Add a validation to ipv6_ra_mode and ipv6_address_mode with ip
version. An InvalidInput error is prompted when ipv6_ra_mode
or ipv6_address_mode is specified in subnet create and update
API and ip version is 4.

Change-Id: I9a0356f23e6b162c31f2d289a34f4bd261cee91e
Closes-Bug: 1307788
gw_port should be set as lazy='join'

This forces the object to be ready ahead of accessing time.
The change in loading behavior is also beneficial while listing
routers, as reduces the amount of queries being issued. Tests
show a performance gain of 15-30% for router-list times.

As Mr. Aaron Rosen is used to saying: Woot woot!!

Closes-bug: #1309144

Change-Id: Ibae261b91de26ca7c50e3f6c80e9be2a799785a3
Add nova_ca_certificates_file option to neutron

Previously, neutron had no way to pass a certificates file to the
novaclient.  This change is to add that ability, similar to the way
you can pass a certificates file to neutronclient in nova.conf via
neturon_ca_certificates_file.

Change-Id: I1a3f85505eb44bee604900301af79d773e1952a3
Closes-Bug: #1309694
allow delete_port to work when there are multiple floating ips

It is possible to associate multiple floating ip addresses with a single
port through the use of multiple *fixed* ip addresses, e.g.:

    nova boot ... --nic net-id=my-net-id myserver
    nova add-fixed-ip myserver my-net-id
    nova add-floating-ip --fixed-address x.x.x.1 myserver y.y.y.y.1
    nova add-floating-ip --fixed-address x.x.x.2 myserver y.y.y.y.2

In this situation, neutron.db.l3_db.disassociate_floatingips would throw
an exception:

    Exception: Multiple floating IPs found for port <port-id>

This would prevent someone from deleting an instance that was associated
with multiple floating ips.

This patch corrects disassociate_floatingips so that it will
disassociate all floating ips associated with the port, allowing the
delete operation to proceed correctly.

Change-Id: I68a2131fa8ee80828354c9db4ac405c3f77c3b90
Closes-bug: 1302701
Fix incorrect change of Enum type

In migration 1341ed32cc1e_nvp_netbinding_update Enum type had been
changed incorrectly from ('flat', 'vlan', 'stt', 'gre')
to ('flat', 'vlan', 'stt', 'gre', 'l3_ext') for PostgeSQL.

The same problem is taken place for vlan_type in migrations
38fc1f6789f8_cisco_n1kv_overlay from ('vlan', 'vxlan', 'trunk',
'multi-segment') to ('vlan', 'overlay', 'trunk', 'multi-segment')
and in 46a0efbd8f0_cisco_n1kv_multisegm from ('vlan', 'vxlan') to
('vlan', 'vxlan', 'trunk', 'multi-segment').

In this change request was added separate method for changing Enum
type for PostgreSQL.

Closes-bug: #1301396

Change-Id: I27197fb7405630a55178be8516a4b62bd135e05c