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
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
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
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
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
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
Add linked clone related unit tests for VMware Hyper

Test image file is cached when linked clone is enabled, and image file
is downloaded and  stored to instance dir directly when it's disabled.

Fix bug #1226450

Change-Id: I90f940de3de19a41b122e098d6788a5652287605
send the good binding to neutron after live-migration

Nova was sending the host that previously hosted the vm

Closes-Bug: #1224960

Change-Id: If4677c0d1e11a8cf16f9d49e9ca854ca2fcfb698
Don't use ModelBase.save() inside of transaction

We using block 'with session.begin()' to organize some operations in
one transaction. session.begin() returns a transaction instance, then
does some operations, and will commit or rollback automatically
before leaving the block. ModelBase.save() always submit a commit,
and that is not expected.
When we get a persistent object from database, we just modify the
object inside of block 'with session.begin()' and sqlalchemy will
update it,don't need method session.add() or ModelBase.save()

Fixes bug #1224429

Change-Id: I8af3fd4b62a915833bf303b6892d432043fb57a9