scylla_raid_setup: check uuid and device path are valid

Added code to check make sure uuid and uuid based device path are valid.
This commit is contained in:
Takuya ASADA
2022-08-27 02:16:19 +09:00
parent 0dbcd13a0f
commit 40134efee4

View File

@@ -152,7 +152,18 @@ if __name__ == '__main__':
os.makedirs(mount_at, exist_ok=True)
uuid = out(f'blkid -s UUID -o value {fsdev}')
uuid = get_partition_uuid(fsdev)
uuidpath = f'/dev/disk/by-uuid/{uuid}'
if not uuid:
raise Exception(f'Failed to get UUID of {fsdev}')
if not os.path.exists(uuidpath):
raise Exception(f'{uuidpath} is not found')
if not stat.S_ISBLK(os.stat(uuidpath).st_mode):
raise Exception(f'{uuidpath} is not block device')
if not is_unused_disk(uuidpath):
raise Exception(f'{uuidpath} is busy')
after = 'local-fs.target'
wants = ''
if raid and args.raid_level != '0':
@@ -169,7 +180,7 @@ After={after}{wants}
DefaultDependencies=no
[Mount]
What=/dev/disk/by-uuid/{uuid}
What={uuidpath}
Where={mount_at}
Type=xfs
Options=noatime{opt_discard}