DB migration 209: Clean up child rows as well

Fixes bug 1252891

In order to add missing foreign key constraints, rows that reference a
nonexistant key need to be purged. Unfortunately, DB migration 209 does
not clean up any rows in child tables that themselves have a foreign key
constraint on the tables with the missing foreign keys. This can result
in an integrity violation causing the migration to fail.

When purging the rows, make sure to purge rows in any child tables first.

Change-Id: I25bd899383c72cb0670819b030759630ac89acaa
Update Instance from database after destroy

In cases where Nova falls back to simply locally deleting an
instance, the Instance object was not updated with the deleted_at
generated by the database implementation. Due to this, the
notification emitted to signify that the delete finished was
getting emitted without a deleted_at value.

This change uses the result from the instance_destroy call to
update the Instance object with the latest state from the database.
Thus, the compute.instance.delete.end notification is emitted
with the proper deleted_at value.

Closes-Bug: #1250206
Change-Id: I55ed37cf89dd6eb8ea901c6f813191a0ce1058e8
Log exception in _heal_instance_info_cache

Previously, if errors occurred in _heal_instance_info_cache() they would
go unnoticed as their log level was debug and the stace trace was not
displayed. This patch changes that so the exception is logged so periodic
failures here can be more easily detected and fixed.

Change-Id: I15bb3e7e29462e930f6159be9f4bbf4980b1270c
Closes-bug: #1257940
XenAPI: Synchronize on all VBD plug/unplug per VM

Dynamically adding or removing a device needs to be synchronized
to work around a bug in XenServer 6.1 and 6.2 where simultaneous
events can be partially ignored, leading to a failure to plug or
unplug.  The bug is between two internal components in XenServer
which pass messages - the first component will ignore all messages
from the second while a plug/unplug is in progress, expecting
only one message to be received.  If two plug/unplugs occur in
this time, an internal assertion is raised as XAPIs internal state
is inconsistent.

Change I7b86325714e38b00a2f51bbf083b5532a6c51fa9 attempted to
work around the issue by retrying - however that does not catch
all failures.  This change should eliminate some of the known
INTERNAL_ERROR failures, but not all, so I7b8 need not be
reverted.

Change Ie7a64c481a9e3874df9d5924fbb050ac7ab117db does the same
as this, but only for VBD.plug.

Change-Id: If78d4e5f1dd84f1d4a588f25b8f887a7b125bbea
Closes-bug: 1217972
Don't replace instance.info_cache on each save

If we are working on an Instance that came from an older client,
we should not replace an older nested .info_cache object with a
newer one for no reason during a save().

Related-Bug: #1258256
Change-Id: I8cf4a629d454de1a5de16ea4032f39e36aab505a
Merge "XenAPI: Synchronize on all VBD plug/unplug per VM"
Merge "Don't replace instance.info_cache on each save"
Merge "Update Instance from database after destroy"
Merge "Log exception in _heal_instance_info_cache"
Merge "DB migration 209: Clean up child rows as well"