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 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
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
Remove _assert_compute_node_has_enough_memory from filter_scheduler.py

Now the function _assert_compute_node_has_enough_memory has no use
in filter_scheduler.py, just remove it to make code more clean.

Change-Id: Ie6f104368140b69a60e124ea96ef6bf7715fe34e
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
Port server actions unittests to V3 API Part 1

This changeset just copies the test file to the V3 directory.
Part 2 will make the changes required to test against the
V3 API

Partially implements blueprint v3-api-unittests

Change-Id: I1e73832c567d69d8e428133f5258ac09cfdb74b7
Remove cached console auth token after migration

After migrating to another server, the cached instance console auth
tokens become invalid, so we remove the tokens associated with the instance.

Fix bug #1214829

Co-authored-by: Takashi Natsume <natsume.takashi@lab.ntt.co.jp>
Change-Id: I7fddcd13da128a6bec5e2cdb6fa8c8636d6adb24
Add v3 API samples for os-extended-volumes

Partially implements blueprint v3-api-unittests

Change-Id: I347b220890980a588eaecda644b15257d85b4a85