Ensure changes to api.QUOTA_SYNC_FUNCTIONS are restored.

Add a local callable restore_sync_functions() that is
established as an addCleanup() fixture callable,
making use of a copy of the QUOTA_SYNC_FUNCTIONS
dictionary to restore its previous contents in-place.

Change-Id: I7fa69ea91e517121aba0ee22a71b0594591ae308
Closes-Bug: #1329482
Fix Flavor object extra_specs and projects handling

The Flavor.save() method was not properly handling extra_specs
and projects when deletions occur, and was doing a read/edit/save
cycle, which could involve some stale data.

This patch keeps the object-y interface to adding/removing things
from those lists, but ensures that they're added/removed individually
on the backend. The save() method is strange on Flavor, in that only
these two sets of data are actually mutable. Because of this, it's
fairly convenient to make that method no longer remotable and
break the actions into two new remotable methods that take fine-
grained lists of add/remove tasks.

Note that Flavor was not used over RPC in any previous release,
so the remotability change doesn't really affect anything. However,
if a client were to issue a remoted save() call, it would still work
and would still have the same (broken) behavior as before, where
deletes don't propagate and we just always add/update every key.

Related to blueprint compute-manager-objects-juno

Change-Id: Ic4439e05b9c0b8274e54768cbd7949aced45cc69
Fix resource cleanup in NetworkManager.allocate_fixed_ip

NetworkManager.allocate_fixed_ip isn't cleaning up the resources it
allocates in the event of a failure. This means that if, for example,
_setup_network_on_host fails, the instance will still have a fixed IP
allocated to it. Every attempt to spawn the instance will result in
another fixed ip being allocated.

Closes-Bug: #1328539

Change-Id: Idfa1f4015acb10dc14fcec448257bcfe6971fc99
Object-ify APIv2 flavorextraspecs extension

This makes the flavorextraspecs extension use the Flavor object.

Related to blueprint compute-manager-objects-juno

Change-Id: I28bcc24382f1e993b98b3f7342fed53c9ae85cbf
Object-ify APIv3 flavor_extraspecs extension

This makes the APIv3 flavor_extraspecs extension use the Flavor
object instead of going direct to the database.

Related to blueprint compute-manager-objects-juno

Change-Id: Ibe9211fb944bb64f722e2417725e29506b17ee30
Target host in evacuate can't be the original one

'Evacuate' function aims to help administrator/operator to evacuate
servers if this compute node fails.

If no protection, the API returns a successful response,
but the vm_state will be changed to ERROR after nova-compute started,
due to the 'InstanceExists' exception raised from 'rebuild_instance()'.

So we need to add verification here, the target host should not be the
original host.

Change-Id: Ic468cd57688b370a18cacfc6e0844a8201eb9ab3
Closes-Bug: #1271821
Merge "Fix resource cleanup in NetworkManager.allocate_fixed_ip"
Merge "Fix Flavor object extra_specs and projects handling"
Merge "Object-ify APIv2 flavorextraspecs extension"
Merge "Object-ify APIv3 flavor_extraspecs extension"
Merge "Ensure changes to api.QUOTA_SYNC_FUNCTIONS are restored."
Merge "Target host in evacuate can't be the original one"