Replace custom patching in `setUp` on HypervisorsSampleJsonTests

It would be better if we get rid of `setUp` method in 
`HypervisorsSampleJsonTests` in which happens 
patching and replace it on class-mock.

Change-Id: If3758564c4febf2019ecdb4fce972580a562f759
Handle exception better in v2.1 attach_interface

Add more information when exception occurs in attach interface at Nova
v2.1 API layer.
The commit I7402cfc28d4ee7989c7eb054556df57918bbaeee has been merged
for v2.0 API, this patch does the same change for v2.1 API.

Partially implements blueprint v2-on-v3-api

Change-Id: I1b175501e6db48f27a894db2e66e09d31f8b50e2
Compute: catch more specific exception for _get_instance_nw_info

There are cases when the method _heal_instance_info_cache tries to
update the network cache. The problem here is that the instance no
longer exists. The exception handling was very broad. This adds
treatment for the specific exception.

Change-Id: I04372cec81fde6ef06e9d7f2b59c1e47e15c0905
Closes-bug: #1385246
Make test_host_filters a NoDBTestCase

This is the final patch in the refactoring series. This changes the
test_host_filters.py file to contain just the test of the filter handler
system and cleans up the previously database-creating TestHostFilters
class.

The entire set of host filter unit tests (around 350 of them) now run in
less than 2 seconds, down from over a 45 seconds on my workstation.

Change-Id: I2f2518a08ac3f8c6addcd4055ee4c706c4c92e8e
Move setup_instance_group to conductor

During prework of scheduler split, we identified that
there is a call from setup_instance_group to the Nova object
InstanceGroup. That prevents the scheduler to be split as a
separate project because it would have an external dependency to
a Nova object.
The implementation here is providing the call by the conductor
before the call to select_destinations as this method only
modifies filter_properties for adding group details.

Co-Authored-By: Ed Leafe <ed@leafe.com>

Change-Id: Ib6556c8f6d6e6dcdb65a0bdb1894c66e92b35230
scheduler: Remove assert on the exact number of weighers

Since the weighers code is by design pluggable, downstream packagers may have
added additional weigher classes, causing this assert to fail.

Rather than require downstream maintain a patch against this line, the
proposal is to remove it since the asserts after it are sufficient.

Change-Id: I13765fae188af92a2e729dcd14caf981db01acb4
Use sizelimit from oslo.middleware

Module sizelimit in nova and oslo.middleware is the same, so
switch nova to use RequestBodySizalimiter from oslo.middleware
lib

Replace RequestBodySizalimiter and LimitingReader by temporal
aliases of this classes in oslo.middleware due to failures in grenade
jobs. Remove tests for this module

Change-Id: I6296215857c2b16035c9081e13ac4345ed5c420a
Return HTTP 400 if use invalid fixed ip to attach interface

When posting an 'attach interface' request to Nova with an invalid fixed ip,
Nova need to return HTTP 400, instead of HTTP 500, in order to inform the
user to correct the fixed ip in HTTP request. It is an API v2 only problem.

Change-Id: I34fc813f38b463460c59672e6c3364aea9ef347d
Closes-Bug: 1365579
Make test_quotas compatible with nosetests

Nosetests detects any function that ends with `test` as a test function which
causes `is_v20_api_test` to be run as a test. This fails because `plugin`
won't be defined yet.

In the interest of being developer friendly and supporting this common
test-runner, we should prefix with an underscore so it doesn't get picked up
as an actual test.

Change-Id: I0802b9f2271cc6f555a409784cfb52911098c2d6
Merge "Use sizelimit from oslo.middleware"
Make test_security_groups nose compatible

With nose, `TestNeutronSecurityGroupRulesBase` will be picked up as an actual
test because it starts with `Test`. Since this is an abstract class, we should
prefix it with an underscore so we don't run those tests directly, rather, run
them in their concrete subclasses instead.

Change-Id: Ifa96152ef71b2b27d8b8c76e25a4136186831032
Merge "Replace custom patching in `setUp` on HypervisorsSampleJsonTests"
libvirt: safe_decode domain.XMLDesc(0) for i18n logging

domain.XMLDesc(0) can return a utf-8 encoded string which will cause a
UnicodeDecodeError when substituting the variable in the _LE unicode
translated Message object in oslo.i18n.

This change simply decodes domain.XMLDesc(0) before passing it onto the
logging method when used with a translated message.

Closes-Bug: #1388386

Change-Id: Id56d6564cfb15cc479e664020ae6f1c82acacb09
Merge "Move setup_instance_group to conductor"
Merge "Make test_host_filters a NoDBTestCase"
Merge "Make test_quotas compatible with nosetests"
Merge "Make test_security_groups nose compatible"
Fix instance_usage_audit_log test to use admin context

Nova V2 API 'os-instance_usage_audit_log' is for admin only
and Nova policy.json has rule for the same But
test_instance_usage_audit_log tests this API as non admin.

This patch fix test_instance_usage_audit_log test to use admin
context.

Also adding some more tests to verify this API with non-admin context.

Closes-Bug: #1387901

Change-Id: I20a477786ef0f3e1132629c4a12af40524e2b09f
Merge "libvirt: safe_decode domain.XMLDesc(0) for i18n logging"
Merge "Compute: catch more specific exception for _get_instance_nw_info"