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
Return a NetworkInfo object instead of a list

This return a NetworkInfo object instead of a list when there are no
configured networks available.

Fixes bug #1222781

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