shelve doesn't work on nova-cells environment

The compute_api shelve/unshelve methods expect an Instance object,
but cell is still passing the sqlalchemy form.
So adding shelve/unshelve to the list of methods that will receive an
Instance object when using nova-cell.

When shelving instance with nova-cell environment,
instance object needs to contain 'metadata' and 'info_cache'.
So fetching the same from databse and adding it to
instance object before calling shelve/unshelve methods.

Conflicts:
    nova/cells/messaging.py

Closes-Bug: #1338451
Change-Id: Ia31b33c9a1d347f15d3e0a67fa31ef6b25a7407a
(cherry picked from commit 9d4b49c542e2076c8a572d1e8c6d50e255efe087)
libvirt: convert cpu features attribute from list to a set

Currently, the cpu features list which is being sent to libvirt,
when creating a domain or calling compareCPU, must contain only
unique entries. Multiple issues arise when we are updating the
features attribute in LibvirtConfigCPU class (for example during
migration).

This change will change the features attribute from being a list
to a set. This make the LibvirtConfigCPU class keep only unique
features.
Adjusting the LibvirtConfigCPUFeature class to support set
operations by overriding the __eq__, __ne__ and __hash__
methods.

Closes-Bug: #1303536
Change-Id: I6350fe0e827c860aea77cc4fe56f18f5c1483580
Cherry-pick-x: 60c899b9da8d64b4a5979b69c43c77ed9d5bf248
replace NovaException with VirtualInterfaceCreate when neutron fails

Currently NovaException is being raised by the _neutron_failed_callback()
and being treated in a try..except block that wraps the _crate_domain method.
The exception is too generic and will catch any exceptions, which are
subclasses of NovaException (for example: ObjectActionError),
making the domain variable not be defined and will mask the original exception.

Suggesting to raise and catch the VirtualInterfaceCreateException and
treat the domain destroy and cleanup with save_and_reraise_exception
in the except block.

Conflicts:
        nova/virt/libvirt/driver.py

Related-Bug: #1337860

Change-Id: Ic972e286ded4e8b9d79ce1b0aa514bb4623d5f0b
(cherry picked from commit f0388d6fec0c4830c730af1adb3d02027eb2cd1d)
Fixes Hyper-V SCSI slot selection

Currently, when attaching volumes, the Hyper-V driver selects the
slot on the SCSI controller by using the number of drives
attached to that controller.

This leads to exceptions when detaching volumes having lower
numbered slots and then attaching a new volume, as Hyper-V will
then try to use an occupied slot.

This patch fixes the issue by simply getting a list of used slots
and getting a slot that it's not among those. It also checks
for the slot number to be smaller than the maximum number of slots
per SCSI controller.

Fixes bug: #1329764

(cherry-picked from commit a73e31022c9fef532cc2d66462d13f4ab2358565)

Change-Id: Id0c09c4debc848004a78971670cc3caef2f77ce3
Add expire reservations in backport position.

Change-Id: If0e58da50ebe9b50b414737a9bd81d93752506e2
Related-bug: #1348720
(cherry picked from commit f4454f4c6962dd2c57c08dc7fecfcdebe7924e3b)
Add a retry_on_deadlock to reservations_expire

Now that we have an index for the reservations_expire query, we
have uncovered a race with quota usage updates due to the foreign
key on the table, so just retry if there is a deadlock. This is
a fix to unblock the gate while we try to remove the deadlocks
completely.

Change-Id: I1993c3bd1f81facf1d98a4e29f9e8df4858a7d66
Partial-bug: #1350466
(cherry picked from commit 3619c1914e9925e18c062bc11bc3e708137f8322)
Read deleted instances during lifecycle events

This prevents us from failing to find the associated instance if
the lifecycle event happens after the instance has been deleted,
as in the case of a ... delete.

Change-Id: I819ddf8ff68edc407d7932bf43771c440f514f26
Closes-bug: #1304968
(cherry picked from commit 53ad788af6ced83bd9d6e58a25196a325d60fc4e)
Fix FloatingIP.save() passing FixedIP object to sqlalchemy

This prevents the FloatingIP.save() method from passing the
calculated FixedIP object to the sqlalchemy floating_ip_update()
function, which would expect it to be an SA object. It also
aborts any attempt to save the object with a modified fixed_ip_id
linkage, as associate/disassociate should be used for that.

This also fixes a bug where FloatingIP expects the result of
floating_ip_update() to be a FloatingIp SA object.

Added missing import to allow tests to work in stable/icehouse.

Change-Id: I065caedf4d81c8583a3b390934a1d403cf2e87bd
Closes-bug: #1334164
(cherry picked from commit 48de2895b9a550a0944b31212349275605a4061d)
Bump stable/icehouse next version to 2014.1.3

Bump stable/icehouse next version to 2014.1.3

Change-Id: If0b0267b047e9a9e1e67c49f62f2e11e9a9b18ea
Signed-off-by: Chuck Short <chuck.short@canonical.com>
Merge "shelve doesn't work on nova-cells environment" into stable/icehouse
Merge "Fixes Hyper-V SCSI slot selection" into stable/icehouse
Merge "libvirt: convert cpu features attribute from list to a set" into stable/icehouse
Fix expected error details from jsonschema

The jsonschema 2.4.0 release slightly changed some of the error messages
that are provided when validation fails. This updates the unit tests to
expect the proper string and avoid failing as a result.

Change-Id: Ic8e32140e49e394659e7ebbecb28afb704b23b7c
Closes-bug: #1358881
Merge "replace NovaException with VirtualInterfaceCreate when neutron fails" into stable/icehouse
Merge "Bump stable/icehouse next version to 2014.1.3" into stable/icehouse
make lifecycle event logs more clear

Instead of logging integers in a cryptic way, log the human
readable strings for VM event state transitions. Also use the
existing instance_uuid port of the logger instead of putting that
separately into our log message.

Partial-Bug: #1357063

Change-Id: I96c39ad4494aa06a8dd5bd942c669a16836a8b9c
(cherry picked from commit 79c8bee9be7b6cf4e9fd3365a162f93a2b014bb5)
add repr for event objects

When an event object gets dumped in a stack trace, because there
is no __repr__ of it, we don't get any details about what it was.
Add a __repr__ to all the event objects so that we can get this
information on a fail.

Closes-Bug: #1357063

Change-Id: I9a62a4348871b748c53b7354ad1b821fe987127d
(cherry picked from commit 8c98b601f2db1f078d5f42ab94043d9939608f73)
Merge "Fix FloatingIP.save() passing FixedIP object to sqlalchemy" into stable/icehouse
Fix race condition with vif plugging in finish migrate

The tempest test that does a resize on an instance from time to time fails
with neutron with a virtual interface timout error. The reason why this
occurs is that nova-compute calls a vifs_unplug() then vifs_plug() fairly
quickly and the neutron-agent doesn't realize this happens because the way
it detects this is via polling. This patch fixings this problem by passing
vifs_already_plugged=True to _create_domain_and_network to avoid waiting
for the neutron notifcation.

Initially, I thought this problem could be solved by setting
vifs_already_plugged=True if migrate.source_host == migrate_desk.dest_host
but it turns out that this race condition can still occur if migrated to
another host though it's fairly unlikely. Always setting
vifs_already_plugged=True ensures we never hit this issue on migrate.

Change-Id: I90424ad50ac993c4abb049aa0654a94b225b5ebb
Closes-bug: 1357599
Closes-bug: 1357476
(cherry picked from commit 80deed660815b9ba69e424b83805a21768b02bb6)
Make floatingip-ip-delete atomic with neutron

The infra guys were noticing an issue where they were leaking floating ip
addresses. One of the reasons this would occur for them is they called
nova floating-ip-delete which first disassocates the floating-ip in neutron
and then deletes it. Because nova-api makes two calls to neutron if the
first one succeeds and the second fails it results in the instance no longer
being associated with the floatingip. They have retry logic but they base it on
the instance and when they go to retry cleaning up the instance the floatingip
is no longer on the instance so they never delete it.

This patch fixes this issue by creating a new method
disassocate_and_delete_floating_ip which contains the different logic
needed to atomically do this for neutron rather than putting the logic
in the api layer to do something differently if one is using neutron.

This patch also adds additional code coverage for nova-network in the
delete floatingip case.

Closes-bug: 1356157

Conflicts:
	nova/api/openstack/compute/contrib/floating_ips.py
	nova/network/base_api.py

Change-Id: I53b0c9d949404288e8687b304361a74b53d69ef3
(cherry picked from commit 5f391087d1d75dd4e7532252c312256e9c3ea2b9)