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)
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
Fix rootwrap for non openstack.org iqn's

The encryption methods implemented for attached volumes
require a symbolic link created to the /dev/disk-by* iqn.

The current implementation works fine for LVM, however the rootwrap
is restricted to only allow iqns of the form openstack.org, for
vendors that use their own target and iqn this won't work and will
result in the attach failing for unauthorized command.

This just makes the regex for the rootwrap filter a bit more
permissive, only looking for iscsi-iqn.*

Change-Id: I023ad24867c045a88f72c5ac7ac4e4da097a3643
Closes-Bug: 1362854
(cherry picked from commit 00808f2072c3ee8958ad16eabad7994730bb8b86)
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
Block sqlalchemy migrate 0.9.2 as it breaks all of nova

This is breaking nova unit tests

Closes-Bug: #1368391
(cherry picked from commit 9c2d6f21854bc79f03095163b8133a9fec68f9f2)

Change-Id: Ic82d787e41f7b6d6153d3c6b19902cc11a1c43bb
Add Hyper-V driver in the "compute_driver" option description

The description of the option "compute_driver" should include
hyperv.HyperVDriver along with the other supported driver.

Conflicts:
        nova/virt/driver.py
        nova/virt/hyperv/__init__.py

Closes-bug: #1347777
(cherry picked from commit b856bc5e348cc69923e3ee815303804323730026)

Change-Id: Ic7e16fd5154609987b2ef0b6f8ee52619ccf489c
db: Add @_retry_on_deadlock to service_update()

Add the _retry_on_deadlock decorator to the service_update() method of
nova's sqlalchemy API.  This decorator is scattered throughout the
sqlalchemy API for other methods that may encounter this error.  The
referenced bug report shows a trace from where it occurred on this
method.

Change-Id: I93b370d6457d2e85493be01a62a76404d228a6fa
Closes-bug: #1370191
(cherry picked from commit 61d54f2652424279af81c4084e87651044fac4bd)
Merge "Add Hyper-V driver in the "compute_driver" option description" into stable/icehouse