diff --git a/image_creator/os_type/__init__.py b/image_creator/os_type/__init__.py index 524ca32579f6729db67a5fa3d9b37bc53ab2fde8..ba1f6e3070668d47633099f9ca7b5e930f8dbe8a 100644 --- a/image_creator/os_type/__init__.py +++ b/image_creator/os_type/__init__.py @@ -199,6 +199,9 @@ class OSBase(object): self.meta = {} self.mounted = False + # This will host the error if mount fails + self._mount_error = "" + # Many guestfs compilations don't support scrub self._scrub_support = True try: @@ -340,7 +343,9 @@ class OSBase(object): try: if not self.mount(readonly=False): - raise FatalError("Unable to mount the media read-write") + msg = "Unable to mount the media read-write. Reason: %s" % \ + self._mount_error + raise FatalError(msg) enabled = [task for task in self.list_syspreps() if task.enabled] @@ -365,6 +370,7 @@ class OSBase(object): mount_type = 'read-only' if readonly else 'read-write' self.out.output("Mounting the media %s ..." % mount_type, False) + self._mount_error = "" if not self._do_mount(readonly): return False @@ -466,7 +472,7 @@ class OSBase(object): self.image.g.mount_options( 'ro' if readonly else 'rw', self.root, '/') except RuntimeError as msg: - self.out.warn("unable to mount the root partition: %s" % msg) + self._mount_error = str(msg) return False return True diff --git a/image_creator/os_type/freebsd.py b/image_creator/os_type/freebsd.py index ce875dd7a700375e4c91e388cb476181f72bcea4..dce0458e42b78e72cf6c42b150d21b6d78692914 100644 --- a/image_creator/os_type/freebsd.py +++ b/image_creator/os_type/freebsd.py @@ -118,7 +118,7 @@ class Freebsd(Unix): self.image.g.mount_vfs(mopts, 'ufs', dev, mp) except RuntimeError as msg: if mp in critical_mpoints: - self.out.warn('unable to mount %s. Reason: %s' % (mp, msg)) + self._mount_error = str(msg) return False else: self.out.warn('%s (ignored)' % msg) diff --git a/image_creator/os_type/unix.py b/image_creator/os_type/unix.py index ce90964dccb9b4775b4045ab97bd46006732973a..00ede281bd3c3b1ae755cba2088cb9b187f1a119 100644 --- a/image_creator/os_type/unix.py +++ b/image_creator/os_type/unix.py @@ -63,7 +63,7 @@ class Unix(OSBase): self.image.g.mount_options(mopts, dev, mp) except RuntimeError as msg: if mp in critical_mpoints: - self.out.warn('unable to mount %s. Reason: %s' % (mp, msg)) + self._mount_error = str(msg) return False else: self.out.warn('%s (ignored)' % msg) diff --git a/image_creator/os_type/unsupported.py b/image_creator/os_type/unsupported.py index 918f094fccfe4e173207a482d74e55b7a192c300..93b711f92ef8c16f42aa97f4a1fdaab4f388b9ef 100644 --- a/image_creator/os_type/unsupported.py +++ b/image_creator/os_type/unsupported.py @@ -31,7 +31,7 @@ class Unsupported(OSBase): def _do_mount(self, readonly): """Mount partitions in correct order""" - self.out.warn('not supported on this media.') + self._mount_error = "not supported on this media" return False # vim: set sta sts=4 shiftwidth=4 sw=4 et ai : diff --git a/image_creator/os_type/windows/__init__.py b/image_creator/os_type/windows/__init__.py index 69c898a7ad27028d6d11cdef91ce5443e3421fb1..66acd5c83e7c5f3bcc63193cca69d7abc774102b 100644 --- a/image_creator/os_type/windows/__init__.py +++ b/image_creator/os_type/windows/__init__.py @@ -315,8 +315,12 @@ class Windows(OSBase): timeout = self.sysprep_params['boot_timeout'].value shutdown_timeout = self.sysprep_params['shutdown_timeout'].value - self.mount(readonly=False) try: + if not self.mount(readonly=False): + msg = "Unable to mount the media read-write. Reason: %s" % \ + self._mount_error + raise FatalError(msg) + virtio_state = self._virtio_state() if len(virtio_state['viostor']) == 0: raise FatalError(