Security groups: add missing translation

Commit d562012f34eadfe6b68dd5ebe06a2fa565de3b2e added exceptions
that were not translated.

Change-Id: I06dbd32a9bc6d99068e06576e4ea7a8594764db5
Adds tests for Hyper-V VM Utils

Adds unit tests for Hyper-V VMUtils and VMUtilsV2 classes.

Co-Authored-By: Bogdan Teleaga <bteleaga@cloudbasesolutions.com>

Partial-Bug: #1220256

Change-Id: I87a13697b0a83dc8905573081f735b542bc9bf17
Add some v2 flavor_manage API tests

On most APIs, the unit test coverage of v3 is better than the one of v2.
This patch ports v3 flavor_manage API tests to v2 tests for improving v2
API tests.

Change-Id: Ic52b68ea864ba9c4649fe22a431e5e55e72141c5
libvirt: add serial ports config

This is the first patch for exposing serial ports on openstack
instances. It contains setting up the instance XML config that creates a
TCP chardevice in libvirt.

Author: Ian Wells
Co-autherd by: Vladan Popovic, Sushma Korati

partialy implements blueprint serial-ports

Change-Id: Ia77909dffe6b48be7e6642cbe8bbab27fb6a627d
Partial oslo-incubator sync -- log.py

This patch pulls in the changes in openstack/common/log.py that fix
a problem exposed by the removal of translation from LOG.debug
messages.  This removal causes the messages to no longer be unicode, which
can cause formatting problems.  The changes in log.py ensure that any
message that is not of six.test_type is coverted to six.text_type.

Note that this is required to complete blueprint: i18n-enablement.

Generated with:
python update.py --base nova --dest-dir /opt/stack/nova --modules log

log:
 759bd87 Merge "Set keystonemiddleware and routes.middleware to log on WARN l
 71d072f Merge "Except socket.error if syslog isn't running"
 37c0091 Add unicode coercion of logged messages to ContextFormatter
 6614413 Correct coercion of logged message to unicode
 1188d88 Except socket.error if syslog isn't running
 ac995be Fix E126 pep8 errors
 36e5c2d Merge "Adjust oslo logging to provide adapter is enabled for"
 631f880 Set keystonemiddleware and routes.middleware to log on WARN level
 726d00a Adjust oslo logging to provide adapter is enabled for

Change-Id: I255a68fc60963386e8fefe65c3ffd269795adbf4
Closes-Bug: 1348244
Fixes Hyper-V agent force_hyperv_utils_v1 flag issue

WMI root\virtualization namespace v1 (in Hyper-V) has been removed
from Windows Server / Hyper-V Server 2012 R2.

Hyper-V compute agent now creates instances which uses
root\virtualization\v2 namespace if the agent's OS is
Windows Server / Hyper-V Server 2012 R2 or newer.

Closes-Bug: #1344036

Change-Id: I874ade4456b92a63959a765c7851bcd001befa32
Treat instance like an object in _start_building

The _start_building method gets an instance object
but was treating it like a dict, so this change
uses dot notation on the instance object fields.

Adds a unit test since this method wasn't directly
unit tested before.

Part of blueprint compute-manager-objects-juno

Change-Id: I8d6b23c70e82fbc7740f3d6af1362905b895addb
Treat instance like an object in _prebuild_instance

The _prebuild_instance method is given an instance object
but was treating it like a primitive dict, so this change
uses dot notation to enforce the object usage.

Adds unit tests since this wasn't directly unit tested
before.

Part of blueprint compute-manager-objects-juno

Change-Id: Id22eb46ed3b4bd8fb48189a40f9df9bb114cd3d4
Treat instance like object in _validate_instance_group_policy

The _validate_instance_group_policy method gets passed an
instance object but was treating it like a primitive dict,
so this changes it to use dot notation when accessing
fields on the instance object.

Updates the existing test to pass an instance object.

Part of blueprint compute-manager-objects-juno

Change-Id: Icbe9fa06ad8f1b32a556241ec7b3269b1fcd5cd2
nova-network: treat instance like object in allocate_for_instance

The allocate_for_instance method gets an instance object from the
compute manager so treat it like an object by using dot notation.

This change updates the docstrings for the base API and nova-network API
methods and updates the nova-network API unit tests to use instance
objects when testing allocate_for_instance.

Part of blueprint compute-manager-objects-juno

Change-Id: Ia6d1d8dd46820d48cd9a3f3d4e98fb48e85d1188
neutronv2: treat instance like object in allocate_for_instance

The allocate_for_instance method gets an instance object from the
compute manager so treat it like an object by using dot notation.

Updates the existing unit tests to use an instance object.

Part of blueprint compute-manager-objects-juno

Change-Id: Ia9305a67d1b9bd8601443da3288f710ab02b3f37
Updated from global requirements

Change-Id: I21afa9b0b3465ef24246a5c20bc7ebfcd2f6b780
virt: helper for processing NUMA topology configuration

Add helper class / methods to nova/virt/hardware.py to assist
in handling the various NUMA related image & flavor extra spec
properties and calculating host usage.

Blueprint: virt-driver-numa-placement
Change-Id: I46c92166d5252f3bf9867dc08935df8c636d9b7d
Add dict and json methods to VirtNUMATopology classes

We will need to serialize and de-serialise these, so we add a method to
base Cell and Topology classes that will handle transformations to and
from JSON. Internally this uses (also newly added) _{to,from}_dict()
methods, which are handy to have (especially for testing), but should
not be used outside of the serialization logic.

We also add defaults to the VirtNUMATopologyCellUsage for the usage
bits, and add a class attribute 'cell_class'  to VirtNUMATopology that
makes it possible to write most of the serialization methods in a
more general manner.

Blueprint: virt-driver-numa-placement
Change-Id: I552d642994f273215c307da7e0f11d77ee410acb
Direct-load Instance.fault when lazy-loading

This breaks out instance.fault lazy-loading from the other attributes,
since we have a direct and more efficient way of fetching the fault than
re-querying the entire instance with the fault attached.

This also should help address fault-related races in the API where a
list of instances is queried, one of those is deleted, and the fault
attribute later triggers an InstanceNotFound whilst trying to do the
lazy-load.

Change-Id: Iceb552663db93fa2a01fb90ece0c1eebecdb783f
Closes-bug: #1352659
Include child_versions in object hashes

This adds the child_versions array to the object hash test. This helps
remind contributors and reviewers that changing that mapping also requires
a bump to the list object version.

Change-Id: Ieb9c6ebe0dc1ca65d0541187fcbba4e73fe0f8d1
Report all objects with hash mismatches in a single go

The object hash test previously stopped when it hit the first object with
a mismatched hash. This meant that if you changed a couple objects, you
had to run the test, fix the first, run the test, fix the next, etc.
This patch collects all the data and then asserts the delta set, if
there were mismatches.

Change-Id: Ie35a4dbd6941a1f31e0cef7ea56fa2cc5e9a8ef0
Image caching: update image caching to use objects

Commit 1023e703bd41c2a42b1159af0d9e907e94440b34 added support
for objects. This patch ensures that the parsing of the instances
is correct.

The patch does the following:
1. In the method _list_running_instances it treats all instances
   as an object
2. Fixes the bug mentioned below. The code was making a string from
   None. This would lead to invalid image details.
3. Ensures that the unit tests actually pass instance objects instead
   of an instance dict
4. In relevant tests updates assertEquals to have the expected parameter
   first

Closes-bug: #1354664

Change-Id: Ib028baab4d4c823f22c371a83f7a813c24d77570
Image cache tests: ensure that assertEquals has expected param first

Update the tests to ensure that the expected parameter is first.

TrivialFix

Change-Id: I5a860d7a217f69bc1d5e7e0e470e724e62a69372
Pull transfer module unit tests from glance tests

Separates the unit tests of the file transfer download module (the only
one that is implemented in nova.image.download) out into its own unit
test file test_transfer_modules.py out of test_glance.py. In the
process, properly limited the unit test boundaries of the transfer module
unit tests to just the transfer module class' download() method, instead
of testing all the way through the GlanceImageService class
unnecessarily (since that is already tested thoroughly in
test_glance.py). As an added benefit, the unit tests of the download and
transfer module stuff went from around 4 seconds to less than a
quarter-second for all the tests.

Change-Id: I2ff6e31359d343b78dc4d03cf2beafd8a99b0a29