Port rescue API to v3 Part 1

This changeset only copies the v2 files (implementation and test)
into the appropriate v3 directories unchanged. The copy as-is
will not be loaded by either the v2 or v3 extension loaders. The
second changeset will then make the changes required for it to
work as a v3 extension.

This is being tried in order to make reviewing of extension
porting easier as gerrit will display only what is actually
changed for v3 rather than entirely new files

Partially implements blueprint nova-v3-api

Change-Id: I8dc2b42b4ffb4618978856d5520485cd34e726d9
Port rescue API to v3 Part 2

This patch contains the changes required to adapt the rescue
extension and the corresponding unittest to the v3 framework

Partially implements blueprint nova-v3-api

Change-Id: Iaa6d0cf7708b0887512db952b1e26ccde75d24ef
Port evacuate API to v3 Part 1

This changeset only copies the v2 files (implementation and test)
into the appropriate v3 directories unchanged. The copy as-is
will not be loaded by either the v2 or v3 extension loaders. The
second changeset will then make the changes required for it to
work as a v3 extension.

This is being done in order to make reviewing of extension porting
easier as gerrit will display only what is actually changed for v3
rather than entirely new files

Partially implements blueprint nova-v3-api

Change-Id: I2c77b445b1e7a1b63993ae86cebea9922e9d098c
Port evacuate API to v3 Part 2

This patch contains the changes required to adapt the evacuate
extension and the corresponding unittest to the v3 framework

Partially implements blueprint nova-v3-api

Change-Id: Id9ca6a7a92a087cb063fe265af1ad6a626c63510
Cleanup overshadowing in test_evacuate.py

Fixes overshadowing problem of uuid in test_evacuate identified in
the v2 to v3 evacuate port but separated into a separate changeset
to fix both the v2 and v3 versions at the same time

Change-Id: If1006d86eab7198484a6d5f82a3f3f328724f4d4
Adds expected_errors decorator for API v3

Adds an expected_errors decorator for v3 API methods which allows
the specification of what exceptions can be raised within the
method. If an unexpected error occurs a 500 is instead returned
which plus a request to file a bug report

Partially implements blueprint v3-api-expected-errors

Change-Id: I5723e576b30b47744394517cdb1ff6bab1d8f78b
Modify _assertEqualListsOfObjects() function.

Function _assertEqualListsOfObjects() changed in order to compare lists of
objects without `id` key. It can be usefull if we have no `id` in test data.

Change-Id: Ic3d599166e5a83969ef804bc9f7801cd2c9d0770
Handle NoMoreFixedIps in _shutdown_instance.

Bug 1192893

If no fixed ips is found, continue to perform the rest of the instance
shutdown, instead of propogating the exception.

Steps to reproduce:
1. Create a network
2. Reserve all fixed ips of the network
3. Try to create an instance but failed
4. Try to delete the instance

Results:
Cannot delete the instance due to the 'NoMoreFixedIps' exception.

Change-Id: I42776c427773f1f81c16062a9aaa54850ec68bfd
XenApi virt driver should throw exception on failure

Virt xenapi driver does not throw InstancePowerOffFailure exception
on a failure while destroying an instance.
_shutdown_instance in compute manager expects InstancePowerOffFailure
and reraises it.
This ensures that instances are not wrongly marked as deleted.

Change-Id: Id57f48a00202bd5ed3125f8e4396a51c12e142cb
Fixes: bug #1190076
Do not raise NEW exceptions

Raising NEW exception is bad practice, because we lose TraceBack.
So all places like:

except SomeException as e:
    raise e

should be replaced by

except SomeException:
    raise

If we are doing some other actions before reraising we should
store information about exception then do all actions and then
reraise it. This is caused by eventlet bug. It lost information
about exception if it switch threads.

fixes bug 1191730

Change-Id: Ia375ecef9f16bda65d5146d14ed4b37a988abb0c
Perform additional check before live snapshotting

Bug 1193146

Move blockJobAbort() out of the _live_snapshot function, such that
it continues to terminate existing jobs, while also doubling as a
method for confirming that our version of Qemu/KVM is new enough to
execute a _live_snapshot.

Change-Id: Ife5d2fd768a34dabf25a1bfc24e54bd6db762c89
refactor security group api not to raise http exceptions

The SecurityGroupAPI had been raising http exceptions,
resulting in a difference in behavior depending on the
driver being used: nova or quantum. The nova driver
re-raises nova exceptions by default, while the quantum
driver was raising the built-in http exceptions. Since
servers.py handles nova exceptions, in some cases the
quantum driver's http exceptions weren't being handled
and resulted in a different http return code to the
user.

Both SecurityGroupAPI classes inherit from
NativeSecurityGroupExceptions and call its static
methods to raise exceptions.

This change refactors SecurityGroupAPI to raise nova
exceptions by modifying NativeSecurityGroupExceptions.
The nova exceptions are then translated to http
exceptions in the security group wsgi extension.

Fixes bug 1183347

Change-Id: I7177183154b4c41037623f443cf9958ac457a020
Fix orphaned instance from get_by_uuid() and _from_db_object()

We need to set _context on the Instance object we create during
get_by_uuid(), but more specifically during _from_db_object().
In order to properly initialize things like nested objects that
themselves need a _context, we should pass it to _from_db_object()
always.

Same thing for InstanceInfoCache.

Related to blueprint unified-object-model

Change-Id: I09ab6b5d7d8961b69294536885e8432943b3a611
Fix serialization of iterable types

So far, we have not supported serialization of iterable type
arguments to RPC methods. However, the recent change to pass
args as a tuple instead of forcing everything to kwargs means
that serialization of non-keyword args is broken. This patch
adds that support, as well as tests for the serializer, which
should have been there in the first place.

Related to blueprint unified-object-model

Change-Id: Ie02fffd89d9b79b4bc8270c14b2860c0e37d7a92
Add invalid number checking in flavor creation api

Flavor creation api doesn't check whether 'memory_mb'
argument number is integer,add invalid number checking
into the flavor creation function to remind the user to
input right value

Fixes bug #1171278

Change-Id: I8308f66c485d8c872864661148e9eac7b685e406
Merge "Do not raise NEW exceptions"
Merge "Port evacuate API to v3 Part 1"
Merge "Port evacuate API to v3 Part 2"
Merge "Cleanup overshadowing in test_evacuate.py"
Merge "Port rescue API to v3 Part 1"