Improve usage of MagicMocks in ML2 and L3 tests

Removes usage of a MagicMock in a case where it's not needed.
Replaces a manual function replacement with a mock.patch call
so it's correctly cleaned up by mock.patch.stopall.

Partial-Bug: #1316401
Change-Id: I8f2f7e9eca2aeaa3b65be1b451e96ed2146950f4
Add local type driver unittests

Partial-Bug: #1269127

Change-Id: I5b34dc09128bcb879ea46be64cc5104eeefd4ab4
Changed DictModel to dict with attribute access

DictModel is a dict where keys are accessible via attribute access.
The old version was an object with attributes created from dict keys and many
attributes where accessible only via getattr because they did not have a valid
python attribute naming (i.e.: 'provider:network_type' is not a valid
python variable/attribute name)::

    >>> d.provider:network_type
      File "<stdin>", line 1
        d.provider:network_type
              ^
    SyntaxError: invalid syntax

This time we just subclass dict with attribute access to keys.

So dict keys are accessible via attribute access but remain accessible via key
access::

    >>> d = DictModel({'foo': 'bar', 'provider:network_type': 'something'})
    >>> d.foo == d['foo']
    ... True
    >>> getattr(d, 'provider:network_type') == d.get('provider:network_type')
    ... True
    >>> getattr(d, 'provider:network_type') == d['provider:network_type']
    ... True

One of the big advantages when debugging is that now in pdb, pp(d) (where d is
a DictModel instance) shows a nice dictionary structure, while with the old
version whe had to perform a "dir(d)" and introspect each attribute...

Change-Id: I05fad7cd9763f97f61680d45e1b6592a80049541
Closes-Bug: 1251653
Default to setting secure mode on the integration bridge

Set the fail-mode on the integration bridge to be secure. This means if the agent
is stopped or crashes, and OVS is also restarted, OVS will not program a default
NORMAL action. As soon as the agent is restarted, it will correctly program the
integration bridge.

Change-Id: Icf7e3e14ee747c8ce92c14c95a0a1bbf35986252
Closes-Bug: #1324703
Imported Translations from Transifex

Change-Id: I3c8e6595c12a2dabd15eb811f7d3fd5611427c6c
Added RpcProxy class

This class is intended for easy and iterative migration from
oslo-incubator RPC implementation to oslo.messaging. It will adapt
oslo.messaging API to old oslo-rpc interfaces.

Migrated all affected classes to the new RpcProxy class.

blueprint oslo-messaging

Change-Id: I1563c13b470b61eebc982ee81efee47732943d48
Introduced transition RPC exception types

These exception types will ease transition from oslo-rpc to
oslo.messaging.

blueprint oslo-messaging

Change-Id: I48d214d676e863d7a60d78c49d2fa917d47c07d9
Monkey patch threading module as early as possible

In oslo.messaging, local thread store is used to pass RPC request
context [1]. If we try to import oslo.messaging before monkey patching
threading library, it attempts to access unpatched storage and fails
with AttributeError.

[1]: oslo/messaging/localcontext.py#L26

blueprint oslo-messaging

Change-Id: Ied7302fcb1d3e14428540e39e3db704550027890
Make allocation_pools attribute of subnet updateable by PUT

Bug 1111572 was filed about a failed update (PUT) on
'allocation_pools' of subnet. This is currently not allowed by the
neutron API (hence DocImpact below). Following discussion on the
bug and subsequently, it seems this is a desirable feature.

This review makes the allocation_pools attribute of subnet
updateable by PUT. The semantics are that the entire allocation
pools attribute is replaced by the provided parameter (see
provided tests for details).

Unit tests added that exercise successful update of
allocation_pools with sane params and update using erroneous
allocation_pools that fall outside the subnet cidr.

DocImpact

Closes-Bug: 1111572
Change-Id: I47a3a71d0d196b76eda46b1d960193fb60417ba9
Co-Authored-By: Robert Collins <rbtcollins@hp.com>
Refactor code in update_subnet, splitting into individual methods

The update_subnet was already long and complex enough and adding
more code to it was undesirable, after commit

I47a3a71d0d196b76eda46b1d960193fb60417ba9

Hence this refactor splits parts of the update_subnet code into
dedicated sub-methods.

Change-Id: I8f98938da88db287290493dc0daf7c81b8b5f542
Ensure routing key is specified in the address for a direct producer

This change is already merged in oslo-incubator.  Original commit
message body includes:

    Porting this fix from oslo.messaging.  This fixes the impl_qpid.py
    driver to allow it to work with the latest stable upstream QPID broker
    (version 0.28).  See the Apache Qpid Jira bug
    https://issues.apache.org/jira/browse/QPID-5557

Change-Id: If71f78e50f8a9b3acfd1e9d02c8271f17c4ebee7
Related-Bug: #1300318
Merge "Imported Translations from Transifex"
Merge "Added RpcProxy class"
Merge "Introduced transition RPC exception types"
Check the validation of 'delay' and 'timeout'

In health monitor, the 'delay' should be greater or equal than 'timeout'.

Change-Id: I64972881676f2a1269aad8f9cdc77ae957c088d9
Closes-bug: #1320111
Merge "Make allocation_pools attribute of subnet updateable by PUT"
Merge "Default to setting secure mode on the integration bridge"
Merge "Add local type driver unittests"
Merge "Monkey patch threading module as early as possible"
Merge "Ensure routing key is specified in the address for a direct producer"