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
xenapi: ensure pool based migrate is live

The current code is missing a flag to pool_migrate that should be
included to ensure the migrate is live. This change adds that flag to
both uses of VM.pool_migrate, namely the live-migrate call and the
host_maintenance call.

Fixes bug 1201795
Change-Id: I265baaba5e9bd9132bd5e1c6f9fb18cefab02cfb
xenapi: move kernel/ramdisk methods to vm_utils

A previous change has now removed the duplication between spawn and
finish_migration, into create_kernel_and_ramdisk. This change moves the
code into vm_utils, and covers the code with some unit tests.

This will makes is easier to share code between spawn and finish_resize
and gives a more logical public interface to vm_utils.

I have also simplified the call to destroy_kernel_ramdisk in spawn so
that can be shared more easily between spawn and finish_migration in a
later change.

Change-Id: I73523d93be0a7afa9fe814af280c582e47064d69
xenapi: tidy ups to some spawn related methods

There were server methods using during spawn that are only used
internally, but not named that way. They have been renamed in this
change.

There were also several methods that are currently called in a single
place, but had logic around the call that should have been inside that
method. This has been tided up, so it will be easier to re-use and/or
move those calls in future refactoring.

This is one of the building blocks towards sharing more code between
spawn and finish_migration.

Change-Id: I424daf8334ad9904572b9df511d8e6bc1ff6d21f
xenapi: add tests for finish_migration and spawn

Before making finish_migration and spawn share more code, lock down the
current code with unit tests.

There are also some methods that are split up, to help with some of the
next refactoring steps.

Change-Id: Icfc214ea2c7470705f5605816b8313e0ba2a1429
xenapi: stop injecting the hostname during resize

The windows PV tools will set the hostname of a server to the value
given in the hostname xenstore key. If we inject that during resize, the
users will be unable to change their server hostname, and in addition it
will be reset to the original name.

Fixes bug 1207829
Change-Id: I49ba9d9f4f8b4a86488e427d99f69236bd959c78
xenapi: regroup spawn steps for better progress

Currently the operations are not very logically grouped. Now we can see
all the individual actions more clearly, we can re-arrange the
operations so each step make more sense, and should be better at
reporting progress.

Rather than checking very late that there is no duplicate VM and enough
memory, I have moved these checks before the expensive operation of
downloading the disk.

After this change there are 10 clear steps during spawn:
* initial step so progress is not zero during download disks
* download and create disks step
* download and create kernel and ramdisk step
* create the VM record, now the disks have been downloaded
* setup the disks; resizingi up disk, and attaching, adding rescue disk
* injecting instance data, currently this means writing to xenstore
* setting up the networking, including the initial firewall setup
* starting the VM and waiting for it to boot
* configuring the VM using the agent (takes a long time on windows)
* applying the final firewall filters, now the VM is running

With this in place, it will be easy to decide which steps are required
and which are not required when reusing the spawn code to implement
finish_migration in a later change.

Change-Id: I0e33dd7d298390630f632e116c8866a64e769102
xenapi: ensure finish_migration cleans on errors

This change makes finish_migration share code with spawn.

This fixes some inconsistencies, such as applying the security
group filters during finish_migration.

Fixes bug 1073303
Fixes bug 1073306

Change-Id: Ib4f2a96618692c141708535f9463c856f3395922
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