Merge BadRequest tests of "attach interfaces" API

In test_attach_interfaces, there are BadRequest tests of "attach interfaces".
Most parts of them are duplicated.
This patch merges them for the readability and clarifying their purposes.

Change-Id: Ib9dd2840be46dec6b70fe9e3fda35de88f84b4a9
libvirt: fix _disk_resize to make sure converted image will be restored

During the process of resizing disk if an image is in qcow2 with
partition less the process converts the image to raw.
After the extend we should to restore the original format in all cases
not only if 'use_cow_images' is configured to True.

Change-Id: I792e0fb986a6c5cf9ac477cef0949c8a40099faa
Closes-Bug: #1298976
Move _is_mapping to more central location

The logic to identify volumes is currently a nested function
in _default_block_device_names, named _is_mapping. It should
be moved to a more general location so others could utilize it
and allow it to be properly unit tested. The following patch
moves _is_mapping to nova/virt/block_device.py and renames it
to is_block_device_mapping.

Change-Id: I560abc4b57ca5bd195282af7cd1ab9bbf7600b67
Closes-Bug: #1351810
Change 'admin_password' into v2 style for servers extension

This patch changes 'admin_password' to 'adminPass' that same
with v2 api. And also change the related unittest.

The differences between v2 and v3 are described on the wiki page
https://wiki.openstack.org/wiki/NovaAPIv2tov3.

Partially implements blueprint v2-on-v3-api

Change-Id: Ie5675f98bb15c55a191a207171e2ffe3be8e6deb
Change 'image_ref'/'flavor_ref' into v2 style for servers

This patch changes 'image_ref'/'flavor_ref' to 'imageRef'/'flavorRef'
that same with v2 api. And also change the related unittest.
The differences between v2 and v3 are described on the wiki page

https://wiki.openstack.org/wiki/NovaAPIv2tov3.

Partially implements blueprint v2-on-v3-api

Change-Id: Ic17334e0a9de89488d5e0c8b75950027d51a3cd4
Add some v2 agents API tests

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

Change-Id: I045c8fa64eb4cd2bf5852d4656d1067ec12a8564
Fix the exception for a nonexistent flavor

flavor_get_by_flavor_id() raises a FlavorNotFound exception when trying to
delete a nonexistent flavor and REST API layer should catch the exception.
However, one of v2 API catches a NotFound exception instead, and it has
been fixed on v3 API.
This patch fixes the one of v2 API.

This patch is required for v2.1 API development. On the development, we are
sharing current v2 unit tests between v2 and v2.1 for avoiding duplicated
code. Now on v3 API which is source of v2.1, "delete a flavor" API catches
a FlavorNotFound exception. So current unit test test_delete fails against
v2.1 API if not merging this patch, because current v2 unit test raises more
generic exception NotFound but v3 "delete a flavor" API catches more specific
exception FlavorNotFound.

Partially implements blueprint v2-on-v3-api

Change-Id: Iec7bca55f0e9f4b8a85f3b9cd54d8deff2904f86
Remove _instance_update usage in _default_block_device_names

We have an instance object in _default_block_device_names so
we can just call instance.save() directly.  We don't need to
update resource tracker stats so there is no need to call
_instance_update in this method.

Part of blueprint compute-manager-objects-juno

Change-Id: Ia8faa67a36ff31a3ba526770f5d8a0361326ffc7
Treat instance like an object in _build_instance

The _build_instance method has an instance object already
but treats it like a primitive dict.  This change uses
dot notation to access fields on the object and updates
the unit tests to use instance objects.

Part of blueprint compute-manager-objects-juno

Change-Id: I19c5abc502b57579b4706e8a8e7b7a64f6f9b6ca
Remove _instance_update usage in _build_instance

The _build_instance method has an instance object so
just call instance.save() rather than _instance_update
which does a separate call to conductor to update the
instance updates the resource tracker, which is
unnecessary in this case. Compare to the _build_resources
method.

Part of blueprint compute-manager-objects-juno

Change-Id: Ic350a424f83638e8129d55dda168913798ebc31a
Backport some v3 availability zones API UT to v2 API

This patch adds below v3 availability zones API unittest
into V2 API to improve V2 API unittesting.

Change-Id: Icf5875b68ecde85c044efb1e2b05416de8b0c9db
Restore backward compat for int/float in extra_specs

In icehouse, we were able to store ints, floats in
extra_specs, with I195bd5d45a896e9b26dd81dab1e49c9f939b4805 we
forced the value(s) to be just strings. Let's loosen up
this restriction and still enforce a length check.

Closes-Bug: #1358818
Change-Id: I7687d0214e44d4af1b595c6c6c7ce685d4083556
Merge "Change 'admin_password' into v2 style for servers extension"
Merge "Change 'image_ref'/'flavor_ref' into v2 style for servers"
Merge "Backport some v3 availability zones API UT to v2 API"
Merge "Fix the exception for a nonexistent flavor"
Merge "Restore backward compat for int/float in extra_specs"
Merge "Remove _instance_update usage in _default_block_device_names"
Merge "Treat instance like an object in _build_instance"
Merge "Remove _instance_update usage in _build_instance"