Hash device_id only if it is longer than the allowed MAX size for NVP

This ensure that a VM uuid stays untouched, avoiding potential
confusion when inspecting NVP port tags. This patch also abstracts
the hashing method out by introducing a device_id_to_vm_id method.
Filtering logic is preserved, and a test has been added to ensure
that. However such a logic is not currently used in the NeutronPlugin
(because of the introduction of async status updates), but it has
been added as utility method to nvplib.

Fixes bug #1215204

Change-Id: Ib96ecae438e30f195c8b45176abc1cf55b4b363f
Fix incorrect NotImplementedError

neutron.common.exceptions doesn't define NotImplementedError, but
some codes still use it. We should use builtin
exceptions.NotImplementedError instead.

Note: this patch also fixes a never run code in nvp.

Closes-Bug: #1221500
Change-Id: I5f367ab5edc1e7fbbc2e4eba5fe36d148d4d062d
Ensure pid file is removed when metadata ns daemon receives SIGTERM

These files from the metadata namespace proxy are not being removed
because delete_pid() is registered with atexit. This means it only runs
when a process exits normally and won't run when a process receives a
signal.

This patch registers a signal handler for SIGTERM that calls exit()
to make the process exit normally so delete_pid() gets called.

Fixes bug: 1223250

Change-Id: I6309802e2109359560ccc084559ec8e4d310cce2
Change daemon Pidfile class to not use root_helper

Some users of the Pidfile class don't specify root_helper,
which then defaults to 'sudo', which will generate an error.
Remove root_helper altogether since we actually don't need
root priveleges to read /proc/$pid/cmdline.

Changed code to use open.readline() instead of a shell, and
tweaked tests accordingly.

Also cleaned-up the rootwrap filters that allow it as they
are not used anymore.

Fixes bug 1218142

Change-Id: I6691feb1c9f7bfa261a7ec464fd8f3f92168c302
Fix ovs_lib's issue of parsing flow proto field

When 'proto' other than 'ip' and nw_src/nw_dst are provided at the same
time, the proto parameter will be ignored.

Fixes bug: 1223668

Change-Id: Ie813e66995e2a9310ec4b48c0f7de673db2097f1
Support for NVP advanced service router

When creating an LR:
    - deploy an Edge asynchronously
    - create a L2 switch for connecting LR and Edge
    - attach a router port to the L2 switch.
    - assign ip address 169.254.2.1/28 and nexthop 169.254.2.3 to LR
When set external gateway:
    - configure Edge interface and default gateway
    - Add static routes to Edge for all logic networks attached to LR via nexthop 169.254.2.1
    - configure SNAT rules for all logic networks attached to LR
When add router interface:
    - Add static route/SNAT rule for the network attached to LR
When associate floating IP address:
    - configure DNAT rule for the floating ip and the port

Tests being done:
    - Verified Edge is deployed asynchronously and LR is attached to the internal created L2 switch
    - Manually attach Edge's vNic to the L2 switch and Edge is able to ping 169.254.2.1
    - Verified router-delete deletes Edge asynchronously and remove the internal L2 switch
    - Verified SNAT/DNAT/static-routes rules are configured on Edge in correct order
    - Verified external vnic ip address/netmask and default gateway is configured

Implements: blueprint nvp-service-router
Change-Id: If9eff53df4d65cf4e318dedbfaafc742f6c6ab7f
Don't add neutron metadata_nat_rules if disable metadata proxy

This patchset fixes this issue by adding a condition when adding nat
rules of neutron metadata proxy.

fixes bug #1212168

Change-Id: I99775aad73c49a8df3043690440d214614279a2b
Don't need to init testr in run_tests.sh

In run_tests.sh, function init_testr will initialize testr if the
directory .testrepository is not existed. Actually, testr will do
the check before run the test:

In Python package testrepository, setuptools_command.py:Testr.run

68 def run(self):
69     """Set up testr repo, then run testr"""
70     if not os.path.isdir(".testrepository"):
71         self._run_testr("init")

So, init_testr can be removed safely.

Fixes Bug #1224285

Change-Id: Ia74d9fff92b8efba9b72e5c7387f761144daa193
Merge "Ensure pid file is removed when metadata ns daemon receives SIGTERM"
Merge "Support for NVP advanced service router"
Prevent update_port ip_address from matching address_pair

Previously one could update a port to match one of the address_pairs.
This patch prevents that.

Fixes bug: 1223646

Change-Id: Ic8cecfdb83b3fd9d2691bb41e0427cf578577fc8
Fix unable to ping floating ip from internal_ip

The following patch adds a no-dnat rule so that an internal_ip
can communicate with it's floatingip.

Fixes bug: 1221419

Change-Id: I3899b01f316902d1139e47b153aadb7ecb1ff983
bp: pxeboot-port, provide  pxeboot on ports

Add extra_dhcp_opts extension to Ml2 plugin.

Implements:bp:pxeboot-ports

Change-Id: Id1d3923c4d2e3cf86731e2f2e9013fbee4ed68c7
Add l2 population base classes

This patch initiates the blueprint l2-population
Implemented as a ml2 Mechanism driver.

OVS & LinuxBridge drivers will be added as dependencies.

Rebased on ML2 Portbinding.

Change-Id: Ia2345aa262ec791c9f38b6e41e1e4b46f69cadac
OVS agent implementation of l2-population

This patchset implements l2-population RPC callbacks in OVS agents,
it enables plugin to populate forwarding table following portbindings
events.

For now, it doesn't include ARP responder implementation which is
deferred to a future patchset (As this feature isn't yet supported by
OVS, it will require the use of an external responder such as ebtables)

It anyway brings some improvements in tunnelling management, as agent
will tear-down unecessary tunnels, and flood packets on a per-network
basis rather than to all other agents.

These changes should anyway have a limited risk, as tunnel management
won't be affected as long as l2_population option is not set. This
option must be used in conjonction with ml2 plugin using l2population
mechanism driver.

Implements: blueprint l2-population

Change-Id: I5185eefedb0ff392bc8b99d16f810813e26ff58d
Merge "Fix unable to ping floating ip from internal_ip"
Vxlan / L2population support to Linuxbridge Agent

This patch introduces VXLAN support for Linuxbridge agent alongside
with ml2 plugin support in linubridge mechnism driver.

A new vxlan configuration section is added for vxlan related parameters.

The agent also implements l2population RPC callbacks which allows ml2
plugin using l2population mechnism driver to populate vxlan forwarding
and neighbor tables following portbinding events. It allows agent to
respond locally to ARP requests for remote VMs and avoid dataplane based
learning. This should help limiting the use of multicast or flooding
for broadcast emulation in vxlan networks.

These changes should anyway have a limited risk, as agent behaviour
shouldn't be affected, except when vxlan is enabled alongside ml2 plugin.

Implements: blueprint l2-population

Change-Id: I99a961c53f9e451409f1affb079042936d8ae5c6
Merge "Add l2 population base classes"
Merge "OVS agent implementation of l2-population"
Merge "Vxlan / L2population support to Linuxbridge Agent"