diff options
author | Pádraig Brady <pbrady@redhat.com> | 2013-01-03 03:09:00 +0000 |
---|---|---|
committer | Pádraig Brady <pbrady@redhat.com> | 2013-01-03 18:12:19 +0000 |
commit | 54ee787d7ae1d7635bd5dac8efd985e3a93ad1c2 (patch) | |
tree | 8e610449e9fc4a6dd59c67a3b7b8629706ad5535 /nova/virt/disk/vfs/guestfs.py | |
parent | 1b1b955e86086054496f96e0d9a2631ee5dd678f (diff) | |
download | nova-54ee787d7ae1d7635bd5dac8efd985e3a93ad1c2.tar.gz |
fix resize of unpartitioned images with libguestfs
Following on from I9c974e138ff90e8b7a5a40f5b31dcdb25a59622d
Ensure that the libguestfs path also throws a NovaException,
handled by can_resize_fs().
* nova/virt/disk/vfs/guestfs.py (setup): Move the debug message
and guestfs handle outside the exception handler as we
don't want to map failure of those to a NovaException
that indicates an issue with the image as opposed to the
nova code or libguestfs installation. Change to a more explicit
exception thrown by guestfs, so as to avoid masking other issues.
(teardown): Remove redundant calls to str().
* nova/virt/disk/api.py (can_resize_fs): Cleanup the debug messages,
and use the newer vfs API directly, rather than the slightly
hacky call to inject_data() with no data to inject.
Fixes bug: 1094373
Change-Id: I3e1305cf6bb64278a8caf37e4c5005cb9683f632
Diffstat (limited to 'nova/virt/disk/vfs/guestfs.py')
-rw-r--r-- | nova/virt/disk/vfs/guestfs.py | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/nova/virt/disk/vfs/guestfs.py b/nova/virt/disk/vfs/guestfs.py index 5fe599b89c..66c6849d4d 100644 --- a/nova/virt/disk/vfs/guestfs.py +++ b/nova/virt/disk/vfs/guestfs.py @@ -89,18 +89,23 @@ class VFSGuestFS(vfs.VFS): self.handle.mount_options("", mount[1], mount[0]) def setup(self): - try: - LOG.debug(_("Setting up appliance for %(imgfile)s %(imgfmt)s") % - {'imgfile': self.imgfile, 'imgfmt': self.imgfmt}) - self.handle = guestfs.GuestFS() + LOG.debug(_("Setting up appliance for %(imgfile)s %(imgfmt)s") % + {'imgfile': self.imgfile, 'imgfmt': self.imgfmt}) + self.handle = guestfs.GuestFS() + try: self.handle.add_drive_opts(self.imgfile, format=self.imgfmt) self.handle.launch() self.setup_os() self.handle.aug_init("/", 0) - except Exception, e: + except RuntimeError, e: + self.handle = None + raise exception.NovaException( + _("Error mounting %(imgfile)s with libguestfs (%(e)s)") % + {'imgfile': self.imgfile, 'e': e}) + except Exception: self.handle = None raise @@ -109,15 +114,15 @@ class VFSGuestFS(vfs.VFS): try: self.handle.aug_close() except Exception, e: - LOG.debug(_("Failed to close augeas %s"), str(e)) + LOG.debug(_("Failed to close augeas %s"), e) try: self.handle.shutdown() except Exception, e: - LOG.debug(_("Failed to shutdown appliance %s"), str(e)) + LOG.debug(_("Failed to shutdown appliance %s"), e) try: self.handle.close() except Exception, e: - LOG.debug(_("Failed to close guest handle %s"), str(e)) + LOG.debug(_("Failed to close guest handle %s"), e) self.handle = None @staticmethod |