except RuntimeError:
self._scrub_support = False
+ def inspect(self):
+ """Inspect the media to check if it is supported"""
+
+ if self.image.is_unsupported():
+ return
+
+ self.out.output('Running OS inspection:')
+ try:
+ if not self.mount(readonly=True):
+ raise FatalError("Unable to mount the media read-only")
+ self._do_inspect()
+ finally:
+ self.umount()
+
+ self.out.output()
+
def collect_metadata(self):
"""Collect metadata about the OS"""
try:
return
for name, param in self.needed_sysprep_params.items():
- self.out.output("\t%s (%s): %s" %
+ self.out.output("\t%s [%s]: %s" %
(param.description, name,
self.sysprep_params[name] if name in
self.sysprep_params else "(none)"))
def do_sysprep(self):
"""Prepare system for image creation."""
+ self.out.output('Preparing system for image creation:')
+
+ if self.image.is_unsupported():
+ self.out.warn(
+ "System preparation is disabled for unsupported media")
+ return
+
try:
if not self.mount(readonly=False):
raise FatalError("Unable to mount the media read-write")
- self.out.output('Preparing system for image creation:')
-
enabled = [task for task in self.list_syspreps() if task.enabled]
size = len(enabled)
if has_ftype(f, ftype):
action(full_path)
+ def _do_inspect(self):
+ """helper method for inspect"""
+ pass
+
def _do_collect_metadata(self):
"""helper method for collect_metadata"""
- self.meta['ROOT_PARTITION'] = \
- "%d" % self.image.g.part_to_partnum(self.root)
+
+ try:
+ self.meta['ROOT_PARTITION'] = \
+ "%d" % self.image.g.part_to_partnum(self.root)
+ except RuntimeError:
+ self.out.warn("Unable to identify the partition number from root "
+ "partition: %s" % self.root)
+
self.meta['OSFAMILY'] = self.image.g.inspect_get_type(self.root)
self.meta['OS'] = self.image.g.inspect_get_distro(self.root)
if self.meta['OS'] == "unknown":