Verify ML2 type driver exists before calling del

Verifies that an ML2 type driver exists for a given
segment type before attempting to call the release_segment
method on it. Logs an error if a type driver is not
found.

This covers the case where a segment is created with
a given type and then ML2 is reconfigured without
support for that type.

DocImpact
The ML2 documentation should be updated with a warning
that disabling a network type driver and re-enabling
it later may lead to possible DB inconsistencies.

Closes-Bug: #1292102
Change-Id: I65a35abf3ed57347bb6e8fee228f8c0697217c00
(cherry picked from commit af89d74d2961db6a04572375150ad908c9e72e78)
Fixes Hyper-V agent issue on Hyper-V 2008 R2

The vmutils.HyperVUtils class used on versions of Hyper-V prior of 2012
is missing the "remove_all_security_rules" method.

Change-Id: Ib14e643c400b230c912589f9480acf59d6e7b147
Closes-Bug: #1360817
Perform policy checks only once on list responses

The policy engine is currently being called for every attribute
of every resource to be returned by a list response. This is
harming the API performance; moreover such a high number of checks
is also unnecessary.

This patch therefore slightly changes the API logic so that list
response first determine the list of attributes which should be
returned querying the policy engine and then use this list for
all resource items to be returned.

To this aim a few methods in base.py needed to be refactored.
This patch also removes the routine check_if_exists from policy.py
and the related PolicyNotFound exception.

Finally, this patch also removes unnecessary admin_or_owner rules
when applied to attributes. This kind of rule indeed has no effect
anyway because of Neutron's ownership checks. The rules were removed
because this change won't allow anymore for having attribute-level
policies whose evaluation result depends on the resource value.

Implements blueprint faster-list-responses

Change-Id: I21b8273add5d5984f512ad94af5a99cf0b0a5d93
(cherry picked from commit 9b2b5e1482ebec818556946230066984bf647186)
Call policy.init() once per API request

This patch changes the policy engine behaviour and the API base
controller in order to ensure policy.init is invoked only once
for each API request.
This will avoid issues arising from policy file updates during
API processing and speed up response generation for list operations,
by about 5%.

This patch also removes an obsolete TODO comment.

Change-Id: I108ebd26fccdea19cb00959f70d87c3bc1587df9
Closes-Bug: 1302611
(cherry picked from commit 1d41ba485f060a4d6dbe0767845391f955247b08)
Pass object to policy when finding fields to strip

During the evaluation of fields to strip in responses to list
operations, pass also the first object in the list to the
policy engine.
This will avoid errors in policy evaluation if during
an upgrade from icehouse policy.json was not updated to remove
attribute-level policies dependent on resource values.

Closes-Bug: #1323715

Change-Id: Iaa6ed3bbf4a07ce0b614a4197cabdfa1cb36d427
(cherry picked from commit 2bd97d205b98292be709b0257bda5fc489eb643a)
Merge "Call policy.init() once per API request" into stable/icehouse
Neutron should not use the neutronclient utils module for import_class

Fixes code to use openstack.common.importutils instead.

Conflicts:
	neutron/debug/shell.py

Change-Id: Ia449f8b1d7d03f37483cfdc595ad77e71ea6598c
Closes-bug: 1366917
(cherry picked from commit dbc9c0c799bcbfa378cee3ea1e428d4a41547db7)
NSX: Correct allowed_address_pair return value on create_port

This patch fixes the NSX plugin to return [] rather than None for a
port does not have any allowed_address_pairs when a create_port api
call is made. Currently the NSX plugin is failing every patch because
now tempest is checking for this value to be [].

Change-Id: Ic82c564ff62000c367c544f44a76694be9375790
Closes-bug: 1366921
(cherry picked from commit 1361ad99969d2a729599720f06f8373db230e0ed)
Merge "Perform policy checks only once on list responses" into stable/icehouse
Merge "Pass object to policy when finding fields to strip" into stable/icehouse
NSX: log request body to NSX as debug

Previously we never logged the request body that we sent to NSX. This makes
things hard to debug when issues arise as we don't actually log the body of
the request that we made. This patch adds the body to our issue request log
statement.

Change-Id: I7d98e3d844ebe565fb5919aac3f9afd5b4040e69
Closes-bug: 1360394
(cherry picked from commit 2bc898ff7a18928e94eb81b24dc99d5cb20eae8a)
BSN: Allow concurrent reads to consistency DB

Allow concurrent reads to the consistency DB since the
database lock the block was originally protecting against
is gone.

Closes-Bug: #1357102
Change-Id: I1618b4046e995c796757e723f99288e486683339
(cherry picked from commit b09c9950649c4c9fffa0b096eb21152cd84fe56f)
Merge "NSX: Correct allowed_address_pair return value on create_port" into stable/icehouse
Merge "Neutron should not use the neutronclient utils module for import_class" into stable/icehouse
Merge "NSX: log request body to NSX as debug" into stable/icehouse
Merge "Verify ML2 type driver exists before calling del" into stable/icehouse
Merge "Fixes Hyper-V agent issue on Hyper-V 2008 R2" into stable/icehouse
Merge "BSN: Allow concurrent reads to consistency DB" into stable/icehouse
loadbalancer: add driver for LVS loadbalancing
remove bad import