diff options
| author | Johannes Erdfelt <johannes.erdfelt@rackspace.com> | 2012-07-09 18:16:23 +0000 |
|---|---|---|
| committer | Johannes Erdfelt <johannes.erdfelt@rackspace.com> | 2012-07-09 18:18:30 +0000 |
| commit | a44fbea08315a30dec9ad69f92c95a532ea045c7 (patch) | |
| tree | 05d9cebd7676c7839a2324656d712f24eec8acf0 /plugins | |
| parent | a97de51e017c9c07eaa3e4a9ddde4193e9528373 (diff) | |
| download | nova-a44fbea08315a30dec9ad69f92c95a532ea045c7.tar.gz nova-a44fbea08315a30dec9ad69f92c95a532ea045c7.tar.xz nova-a44fbea08315a30dec9ad69f92c95a532ea045c7.zip | |
Ignore failure to delete kernel/ramdisk in xenapi driver
Fixes bug 1022681
If deleting the kernel/ramdisk fails because the files don't exist
anymore, then ignore the error and continue. This will ensure that the
instance will get destroyed properly even if the files were deleted
outside of nova.
Change-Id: I5d1f95ea2a6f552c48efbb9e92bb36767df19e34
Diffstat (limited to 'plugins')
| -rwxr-xr-x | plugins/xenserver/xenapi/etc/xapi.d/plugins/kernel | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/plugins/xenserver/xenapi/etc/xapi.d/plugins/kernel b/plugins/xenserver/xenapi/etc/xapi.d/plugins/kernel index a0ca7badc..c3cbb1c9a 100755 --- a/plugins/xenserver/xenapi/etc/xapi.d/plugins/kernel +++ b/plugins/xenserver/xenapi/etc/xapi.d/plugins/kernel @@ -20,6 +20,7 @@ """Handle the manipulation of kernel images.""" +import errno import os import shutil @@ -106,14 +107,22 @@ def create_kernel_ramdisk(session, args): return filename +def _remove_file(filepath): + try: + os.remove(filepath) + except OSError, exc: + if exc.errno != errno.ENOENT: + raise + + def remove_kernel_ramdisk(session, args): """Removes kernel and/or ramdisk from dom0's file system""" kernel_file = optional(args, 'kernel-file') ramdisk_file = optional(args, 'ramdisk-file') if kernel_file: - os.remove(kernel_file) + _remove_file(kernel_file) if ramdisk_file: - os.remove(ramdisk_file) + _remove_file(ramdisk_file) return "ok" |
