Adds V3 API samples for cells and multinic

Adds V3 API samples for cells and multinic extensions.
Bundling them together to save on review load

Partially implements blueprint v3-api-unittests
Partially implements blueprint v3-api-specification

Change-Id: I50840b3d900fbc8ff4f655e4188cc886d7065729
Revert "Importing correlation_id middleware from oslo-incubator"

This reverts commit 26ecf7b02377b860b4412aa554ed2392f42f8d40.

This patch was merged in preparation for
https://review.openstack.org/#/c/29480/ which was never merged.

Change-Id: Iefa1478af03f748ccb5f27f8bd4ad0f5b24af070
Clean up check for migration 213

Migration 213 for PCI device needs to check whether the pci_stats column
and the PCI device table exist or not after and before migration.

For pci_stats column check, interface assertColumnExists and
assertColumnNotExists could be used to simplify.

PS: remove an unnecessary word 'image_id' in models.py.

Change-Id: I7f1ba266523bca68c950bd76449324cece09393f
Signed-off-by: Shane Wang <shane.wang@intel.com>
Fixes unexpected exception message in PciConfigInvalidWhitelist

When an exception PciConfigInvalidWhitelist occurs, the message "An
unknown exception occurred." was obtained. This is due to the content
of the variable not being overriden correctly. The same typo applies
to PciTrackerInvalidNodeId.

Closes-Bug: #1221493
Change-Id: I589cb8d0a1426eb84bbbc4a819b5585e4e746843
Fixes unexpected exception message in ProjectUserQuotaNotFound

When an exception ProjectUserQuotaNotFound occurs, the message "Quota
could not be found" was obtained. This is because the name of the
variable to override is incorrect. There is a similar bug in
ConsoleTypeUnavailable and ISERTargetNotFoundForVolume.

Change-Id: If709aff55b9042eaca49aaebddc31c366681a36c
Closes-Bug: #1221527
Fixes race cond between delete and confirm resize

If we delete an instance after a confirming resize operation,
and if the instance is deleted firstly at the dest compute node,
then the *_resize dir and network info of this instance will be
left alone on the source compute node, never be cleaned up.
Please refer the bug page to get the reproduce steps

Fixes bug 1202484

Change-Id: Ib1e3d976373bd7f4d086d4f9716b0bca4b383bab
Catch more accuracy exception for _lookup_by_name

When an instance is not found by libvirtd, _lookup_by_name in libvirt
driver raises InstanceNotFound. This patch catchs this exception instead
of NotFound who is the father of InstanceNotFound.

Closes-Bug: #1222663
Change-Id: I1b4ce8f6c44eef29617a42151152cda2159a0088
Add V3 API samples for flavor-manage,flavor-extra-specs

Partially implements bp v3-api-extension-versioning

Change-Id: I54881677005cc085e5a2a604fc83eb4225ffd5d0
Remove unused exceptions

* nova/exception (ImageDownloadModuleLoadError):
Never referenced.
* nova/exception (ISERTargetNotFoundForVolume):
Never referenced.
* nova/exception (InstanceMetadataNotFound):
Unreferenced since commit 0d417fa73
* nova/exception (ISCSITargetNotFoundForVolume):
Unreferenced since commit 4123094b2

This commit removes them.

Change-Id: I224c6b1d711add12320ca8e89486257a6517a1c9
Add Neutron port check for the creation of multiple instances

Exception is thrown if multiple instances are launched with a single
Neutron port. Remove one duplicated test case
"test_create_instance_with_security_group_enabled".

Fixed Bug 1193434.

Change-Id: Ie5d426db0e0785043833e4e7f9a16c9591bee743
Adds v3 API samples for limits and simple tenant usage

Adds the v3 API samples for the limits and simple tenant
usage extensions. Bundled together to reduce review load

Partially implements blueprint v3-api-specification

+DocImpact

Change-Id: I1b73d7acf8d1bbccec2fff6180799edd3f3b12aa
disable direct mounting of qcow2 images by default

* nova/virt/disk/api.py: Set the default for the
'resize_fs_using_block_device' option to False,
so that we don't enable this functionality because:
1. It's not needed for newer images that resize themselves.
2. It enables direct mounting of images which might otherwise
   be disabled for security reasons.
3. It's not supported on systems without the nbd module.
4. It gives noisy diagnostics on such systems.

Fixes bug: 1212734

Change-Id: Ifbd687eae46606176ea196888eeffdde08559c01
Enable test_create_multiple_servers test for V3 API

Now that the multiple create extension has merged we can enable
this test for the V3 API. Need to also override post_server
for the test client for the V3 API as the data return when requesting
a reservation id in the V3 API has changed

Change-Id: I7f34f1e90b872c4679b5c54fe9e4b0f4420910ab
Closes-Bug: #1206884
Ensure get_all_flavors returns deleted items

When a flavor is deleted a new one may be created with the same name.
However when calling flavors.get_all_flavors(inactive=True) only the
latest flavor with the same name is returned. When inactive=True all
flavors should be returned regardless of their name or replacement
state.

Change the key used in the returned dictionary from
flavors.get_all_flavors() to the flavorid rather than the name. This
allows multiple flavors with the same name to be returned.

Fixes bug 1215295
Change-Id: I1b0c93b3e12714a5c0798aa87c9e3fe9bc14519a
Add filter for soft-deleted instances to periodic cleanup task

The periodic cleanup task added recently does a db query to get
instances in need of cleanup. The filters applied to the query
must have a filter to not include soft-deleted instances.

This fix adds the required filter and adds a test to verify the
correct behavior.

Change-Id: I0c5d7e317d1fdd4e1e618c1c38870e775a715eab
Closes-Bug: #1223345
Don't lose exception info

Using eventlet introduces some extra fun into exception handling.  After
catching an exception, it is required to save off the exception details
if you want to be able to re-raise it later after doing other operations
which may do a greenthread switch.  That's what this patch does.  It
saves off the original exception that we intend to re-raise later and
ensures that nothing stomps on it in the meantime.

A test case was also added to exercise this code path to make sure the
exception saving and re-raising worked as expected.

Change-Id: Ibf5f06a30839b93ece500ce7dbb714f6509f85af
Closes-bug: #1202177
Adds V3 API samples for remote consoles, deferred delete

Adds V3 API samples for remote consoles, deferred delete
extensions. Bundling them together to save on review load

Partially implements blueprint v3-api-unittests
Partially implements blueprint v3-api-specification

Change-Id: I595532d9e1b8eed80336c0258be3e9d07ec7461e
disassociate_address response should match ec2

The current behavior of disassociate_address does not match that of
what EC2 would return when calling it upon an unassociated address.
In EC2 when disassociate_address is called on an unassociated
address, it returns successfully as such:

<DisassociateAddressResponse
    xmlns="http://EC2.amazonaws.com/doc/2012-08-15/">
    <requestId>aabbccdd-0146-4952-bdbe-710e4fee8387</requestId>
    <return>true</return>
</DisassociateAddressResponse>

However, when this same called is made against the OpenStack EC2
implementation, this would return a 400:

<Response><Errors><Error><Code>InvalidInstanceID.NotFound</Code>
<Message>Instance None could not be found.</Message></Error></Errors>
<RequestID>req-7a9b4d03-b9f5-4243-95d8-f1ccab180631</RequestID>
</Response>

This is due to the fact that we continue to attempt disassociation
despite instance_id == None.

Modify this behavior to match EC2 by simply checking that instance_id
is set before continuing disassociation. Else, bail early, and in
either case report success.

This change also modifies unit tests to account for this change.

Change-Id: I17c822d70918fefa55da2ab096af5b98b87e23e7
Closes-Bug: #1224251
Code change for nova support glance ipv6 address

This code change is for nova can parse glance api servers which is
IPv6 address correctly, also make sure nova commands can be run
successfully in pure ipv6 environment, such as 'nova image-list'
and 'nova boot' command.

Fixes bug 1182830

Change-Id: Ia71002c7038b820db7a63f7d6892e76de4743d8d
Fix V3 API server extension point exception propagation

Adds the propagate_map_exception parameter to extension
manager initialisation in the servers plugin so extension
points for the V3 API propagate exceptions rather than
supress them. The parameter was missing from some of the
extension point managers.

Also adds a missing V3 API personality test which exposed
the problem with exceptions not being correctly propagated.

Very minor spelling fix to one of the tests

Change-Id: I53fa680cfab9219442610a5dceeb35b150314f6f
Closes-Bug: 1224293