Advertisement
Guest User

Untitled

a guest
Jan 25th, 2017
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. # If there is an instance.host the instance has been scheduled and
  2. # sent to a cell/compute which means it was pulled from the cell db.
  3. # Normal delete should be attempted.
  4. if not instance.host:
  5. try:
  6. if self._delete_while_booting(context, instance):
  7. return
  8. # If instance.host was not set it's possible that the Instance
  9. # object here was pulled from a BuildRequest object and is not
  10. # fully populated. Notably it will be missing an 'id' field
  11. # which will prevent instance.destroy from functioning
  12. # properly. A lookup is attempted which will either return a
  13. # full Instance or None if not found. If not found then it's
  14. # acceptable to skip the rest of the delete processing.
  15. cell, instance = self._lookup_instance(context, instance.uuid)
  16. if cell and instance:
  17. with nova_context.target_cell(context, cell):
  18. instance.destroy()
  19. return
  20. if not instance:
  21. # Instance is already deleted.
  22. return
  23. except exception.ObjectActionError:
  24. # NOTE(melwitt): This means the instance.host changed
  25. # under us indicating the instance became scheduled
  26. # during the destroy(). Refresh the instance from the DB and
  27. # continue on with the delete logic for a scheduled instance.
  28. # NOTE(danms): If instance.host is set, we should be able to
  29. # do the following lookup. If not, there's not much we can
  30. # do to recover.
  31. cell, instance = self._lookup_instance(context, instance.uuid)
  32. if not instance:
  33. # Instance is already deleted
  34. return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement