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
Adds v3 API extension discovery filtering

Adds ability for a v3 loaded extension to be visible in
/v3/extensions to be dependent on the discoverable action policy
for that extension. Note that this does not actually effect whether
or not the functionality provided by the extension is accessible

Implements blueprint nova-v3-api-filter

Change-Id: I3f6ba7ea59e7abfa9d57b79ab18aa5b675e64118
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
Quantumapi returns an empty network list

When nova retries network list and if the list is empty, quantumapi
should return a empty list instead of an empty dictionnary.

Fixes bug 1189976

Change-Id: I5b8c498a6c86e92d0de14d8de9e55722408c5669
port agent API into v3 part1

This changeset only copies the v2 files 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: bp v3-api-extension-versioning

Change-Id: Ib7c489769d9b07797366be5920cc23ab2074a768
Fix the ServerPasswordController class doc string

The code must have been copied from the flavor access extension to start
with and the old class doc string was left in place.

Fixes bug 1191232

Change-Id: Ie60ea629270c8185abc05fd4e08bbd7a9945c2b5
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
Clean up scheduler tests

Removed some unused variables in the scheduler tests.
Fixed a docstring that did not make sense.
Added an assert to make a test actually test something.

Change-Id: I6ddb1075924375b38df82aa9a54e03a67316d8f6
Allow scheduler manager NoValidHost exception to pass over RPC

Calls to scheduler.manager.select_hosts are expected to throw NoValidHost
exceptions if no hosts match such requests. For the exception to be passed
over RPC, the method must be decorated with:

@rpc_common.client_exceptions(exception.NoValidHost)

Resolves bug 1192693.

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