summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2019-12-16 08:45:30 +0200
committerLars Wirzenius <liw@liw.fi>2019-12-16 08:45:30 +0200
commitd50891e2cd9312dce9dcf96fc27d753942aac19b (patch)
treec615a2e83ae3bdf779acc4f2afd5e281813abb0c
parent66f9f561fe82820e4e7d6baba509c918f4788ecb (diff)
downloadvmdb2-d50891e2cd9312dce9dcf96fc27d753942aac19b.tar.gz
Fix: do not add filesystems that aren't mounted to fstab
Some disks have partitions that don't get used as filesystems, and vmdb2 doesn't know the mount point for those. Trying to include them in fstab resulted in a runtime error, which is avoided by this change.
-rw-r--r--vmdb/plugins/fstab_plugin.py29
1 files changed, 15 insertions, 14 deletions
diff --git a/vmdb/plugins/fstab_plugin.py b/vmdb/plugins/fstab_plugin.py
index 999d3a4..2f82155 100644
--- a/vmdb/plugins/fstab_plugin.py
+++ b/vmdb/plugins/fstab_plugin.py
@@ -42,20 +42,21 @@ class FstabStepRunner(vmdb.StepRunnerInterface):
for tag in state.tags.get_tags():
device = state.tags.get_dev(tag)
mount_point = state.tags.get_target_mount_point(tag)
- fstype = state.tags.get_fstype(tag)
- output = vmdb.runcmd([
- 'blkid', '-c', '/dev/null', '-o', 'value', '-s', 'UUID', device])
- if output:
- uuid = output.decode().strip()
- filesystems.append({
- 'uuid': uuid,
- 'mount_point': mount_point,
- 'fstype': fstype,
- })
- else:
- raise Exception(
- 'Unknown UUID for device {} (to be mounted on {})'.format(
- device, mount_point))
+ if mount_point is not None:
+ fstype = state.tags.get_fstype(tag)
+ output = vmdb.runcmd([
+ 'blkid', '-c', '/dev/null', '-o', 'value', '-s', 'UUID', device])
+ if output:
+ uuid = output.decode().strip()
+ filesystems.append({
+ 'uuid': uuid,
+ 'mount_point': mount_point,
+ 'fstype': fstype,
+ })
+ else:
+ raise Exception(
+ 'Unknown UUID for device {} (to be mounted on {})'.format(
+ device, mount_point))
fstab_path = os.path.join(chroot, 'etc/fstab')
line = "UUID={uuid} {mount_point} {fstype} errors=remount-ro 0 1\n"