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
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
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
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
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
Don't fail if volume has no image metadata

In the same way that nova shouldn't fail when booting an instance if the
image has no metadata, when booting from a volume it should accept the
fact that it has no image_metadata and return an empty dict.

Fixes bug #1220814

Change-Id: Idc0ff2106415a0662e57021e918dc5c6bf9a9a92
Libvirt: volume driver set correct device type

Due to a typo, libvirt volume driver was assigning the device type
passed to the connect_volume method to the wrong attribute of the
LibvirtConfigGuestDisk class (non existing device_type which is
completely disregarded, instead of the expected source_device), which
caused the rendered XML to always have the device set to 'disk'. This
patch fixes that issue.

Also adds the 'lun' type to the list of supported device_types since it
is supported by libvirt but was missed in the previous refactoring.

Tests are added to prevent future regressions.

Closes-bug: #1223890

Change-Id: Iee160afcc23f762a752df1ca20372944d5100291
Fixes misuse of assertTrue in virt test scripts

Misuse of assertTrue in places where assertEqual should be used.

If assertTrue is used, the test will always pass
if the first argument's boolean cast is True.
The second argument passed to assertTrue() will be regarded
as the error message when the assertion fails.

Fixes bug #1220541

Change-Id: I63ec4f35ee1a2430a5f6b54e40108b2c4ce3d480
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
xenapi: fix where root_gb=0 causes problems

Auto_config disk and resize up should be able to correctly handle when
the flavor specifies root_gb=0.

When you try to resize down to root_gb=0, it doesn't really make sense,
so throw a reasonable error message, instead of failing in the middle of
the resize calculations.

Fixes bug 1152268
Change-Id: Ib26170d7d563cc8fd664c3680fecc4ac04e57b04
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
Fix logging of failed baremetal commands.

Subprocess output is bytestrings, not unicode, so %r is the right
format to use.

Change-Id: Ia6cd0986d6970093c859775bb321ecea632e0264
Closes-Bug: #1223253
Fix create's response is different with requested for sec-grps V3

The create's response always shows the default security-groups even the request
with different security-groups.

Fix bug 1221651

Change-Id: I0c3de3c4d00ed15f3e4a0717c0a1f123ccbf3068
Ensure anti affinity scheduling works

The query for the group in the system_metadata would not correctly
filter the instances with the groups.

In addition to this change 4a03071db23196c4ac1ec0d8ea163c46887d3b08
ensured that the scheduling filter was only run once.
In cases when provisioning fails and rescheduling
takes place the filter must be invoked (if it is in the filter tool
chain).

Fixes bug: 1218878
Fixes bug: 1206502

Change-Id: I623c73635c36ffa038ae01476a25ba0c0863e536