Skip to content

Commit

Permalink
Ignore failure to delete kernel/ramdisk in xenapi driver
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Johannes Erdfelt committed Jul 9, 2012
1 parent a97de51 commit a44fbea
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions plugins/xenserver/xenapi/etc/xapi.d/plugins/kernel
Expand Up @@ -20,6 +20,7 @@

"""Handle the manipulation of kernel images."""

import errno
import os
import shutil

Expand Down Expand Up @@ -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"


Expand Down

0 comments on commit a44fbea

Please sign in to comment.