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)
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)
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>
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)
Merge "Make floatingip-ip-delete atomic with neutron" into stable/icehouse
Merge "make lifecycle event logs more clear" into stable/icehouse
Merge "add repr for event objects" into stable/icehouse
Move the error check for "brctl addif"

The git commit 873aad92944f8840e772d65eda4b3320d65a9ce7[1] has moved
"brctl addif" command, but the commit did not move its error check.

Now the error check sees the result of "ip addr show dev <interface>
scope global" command wrongly, and the command outputs "Dump was
interrupted and may be inconsistent" sometimes because of a kernel change.
As the result, gate failures happen sometimes.

This patch moves the error check to right place.

[1]: https://github.com/openstack/nova/commit/873aad92944f8840e772d65eda4b3320d

Change-Id: I92ee96e3aa34f7cd154a8ce4b33852b96cabe8c9
Closes-Bug: #1334142
(cherry picked from commit c250696ba12ead71e741cf8f608ce5212b0cc7bb)
Merge "Add expire reservations in backport position." into stable/icehouse
Merge "Add a retry_on_deadlock to reservations_expire" into stable/icehouse
Merge "Move the error check for "brctl addif"" into stable/icehouse