11__author__ = 'desultory'
2- __version__ = '4.17.1 '
2+ __version__ = '4.17.2 '
33
44from pathlib import Path
55from zenlib .util import contains , pretty_print
@@ -362,24 +362,24 @@ def _autodetect_dm(self, mountpoint, device=None) -> None:
362362 slave_source = self ._dm_info [dev_name ]['slaves' ][0 ]
363363
364364 try :
365- dm_info = self ['_blkid_info' ][f"/dev/{ slave_source } " ]
365+ blkid_info = self ['_blkid_info' ][f"/dev/{ slave_source } " ]
366366 except KeyError :
367367 if slave_source in self ['_dm_info' ]:
368- dm_info = self ['_blkid_info' ][f"/dev/mapper/{ self ._dm_info [slave_source ]['name' ]} " ]
368+ blkid_info = self ['_blkid_info' ][f"/dev/mapper/{ self ._dm_info [slave_source ]['name' ]} " ]
369369 else :
370370 raise KeyError ("Unable to find blkid info for device mapper slave: %s" % slave_source )
371371 if source_device .name != self ._dm_info [dev_name ]['name' ] and source_device .name != dev_name :
372372 raise ValueError ("Device mapper device name mismatch: %s != %s" % (source_device .name , self ._dm_info [dev_name ]['name' ]))
373373
374- self .logger .debug ("[%s] Device mapper info: %s\n Device config: %s" % (source_device .name , self ._dm_info [dev_name ], dm_info ))
375- if dm_info .get ('type' ) == 'crypto_LUKS' or source_device .name in self .get ('cryptsetup' , {}):
376- autodetect_luks (self , source_device , dev_name , dm_info )
377- elif dm_info .get ('type' ) == 'LVM2_member' :
378- autodetect_lvm (self , source_device , dev_name , dm_info )
379- elif dm_info .get ('type' ) == 'linux_raid_member' :
380- autodetect_raid (self , source_device , dev_name , dm_info )
374+ self .logger .debug ("[%s] Device mapper info: %s\n Device config: %s" % (source_device .name , self ._dm_info [dev_name ], blkid_info ))
375+ if blkid_info .get ('type' ) == 'crypto_LUKS' or source_device .name in self .get ('cryptsetup' , {}):
376+ autodetect_luks (self , source_device , dev_name , blkid_info )
377+ elif blkid_info .get ('type' ) == 'LVM2_member' :
378+ autodetect_lvm (self , source_device , dev_name , blkid_info )
379+ elif blkid_info .get ('type' ) == 'linux_raid_member' :
380+ autodetect_raid (self , source_device , dev_name , blkid_info )
381381 else :
382- raise RuntimeError ("Unknown device mapper device type: %s" % dm_info .get ('type' ))
382+ raise RuntimeError ("Unknown device mapper device type: %s" % blkid_info .get ('type' ))
383383
384384 autodetect_mount_kmods (self , slave_source )
385385
@@ -393,7 +393,7 @@ def _autodetect_dm(self, mountpoint, device=None) -> None:
393393
394394@contains ('autodetect_root_raid' , "Skipping RAID autodetection, autodetect_root_raid is disabled." , log_level = 30 )
395395@contains ('hostonly' , "Skipping RAID autodetection, hostonly mode is disabled." , log_level = 30 )
396- def autodetect_raid (self , mount_loc , dm_name , dm_info ) -> None :
396+ def autodetect_raid (self , mount_loc , dm_name , blkid_info ) -> None :
397397 """
398398 Autodetects MD RAID mounts and sets the raid config.
399399 Adds kmods for the raid level to the autodetect list.
@@ -402,11 +402,11 @@ def autodetect_raid(self, mount_loc, dm_name, dm_info) -> None:
402402 self .logger .info ("Autodetected MDRAID mount, enabling the mdraid module." )
403403 self ['modules' ] = 'ugrd.fs.mdraid'
404404
405- if level := dm_info .get ('level' ):
405+ if level := self . _dm_info [ dm_name ] .get ('level' ):
406406 self .logger .info ("[%s] MDRAID level: %s" % (mount_loc .name , level ))
407407 self ['_kmod_auto' ] = level
408408 else :
409- raise ValueError ("[%s] Failed to autodetect MDRAID level: %s" % (dm_name , dm_info ))
409+ raise ValueError ("[%s] Failed to autodetect MDRAID level: %s" % (dm_name , blkid_info ))
410410
411411
412412@contains ('autodetect_root_dm' , "Skipping device mapper autodetection, autodetect_root_dm is disabled." , log_level = 30 )
@@ -417,22 +417,22 @@ def autodetect_root_dm(self) -> None:
417417
418418@contains ('autodetect_root_lvm' , "Skipping LVM autodetection, autodetect_root_lvm is disabled." , log_level = 20 )
419419@contains ('hostonly' , "Skipping LVM autodetection, hostonly mode is disabled." , log_level = 30 )
420- def autodetect_lvm (self , mount_loc , dm_num , dm_info ) -> None :
420+ def autodetect_lvm (self , mount_loc , dm_num , blkid_info ) -> None :
421421 """ Autodetects LVM mounts and sets the lvm config. """
422422 if 'ugrd.fs.lvm' not in self ['modules' ]:
423423 self .logger .info ("Autodetected LVM mount, enabling the lvm module." )
424424 self ['modules' ] = 'ugrd.fs.lvm'
425425
426- if uuid := dm_info .get ('uuid' ):
427- self .logger .info ("[%s] LVM volume uuid: %s" % (mount_loc .name , uuid ))
426+ if uuid := blkid_info .get ('uuid' ):
427+ self .logger .info ("[%s] LVM volume contianer uuid: %s" % (mount_loc .name , uuid ))
428428 self ['lvm' ] = {self ._dm_info [dm_num ]['name' ]: {'uuid' : uuid }}
429429 else :
430430 raise ValueError ("Failed to autodetect LVM volume uuid: %s" % mount_loc .name )
431431
432432
433433@contains ('autodetect_root_luks' , "Skipping LUKS autodetection, autodetect_root_luks is disabled." , log_level = 30 )
434434@contains ('hostonly' , "Skipping LUKS autodetection, hostonly mode is disabled." , log_level = 30 )
435- def autodetect_luks (self , mount_loc , dm_num , dm_info ) -> None :
435+ def autodetect_luks (self , mount_loc , dm_num , blkid_info ) -> None :
436436 """ Autodetects LUKS mounts and sets the cryptsetup config. """
437437 if 'ugrd.crypto.cryptsetup' not in self ['modules' ]:
438438 self .logger .info ("Autodetected LUKS mount, enabling the cryptsetup module: %s" % mount_loc .name )
@@ -446,19 +446,19 @@ def autodetect_luks(self, mount_loc, dm_num, dm_info) -> None:
446446 self .logger .error ("Device mapper slaves: %s" % self ._dm_info [dm_num ]['slaves' ])
447447 raise RuntimeError ("Multiple slaves found for device mapper device, unknown type: %s" % mount_loc .name )
448448
449- dm_type = dm_info .get ('type' )
449+ dm_type = blkid_info .get ('type' )
450450 if dm_type != 'crypto_LUKS' :
451- if not dm_info .get ('uuid' ): # No uuid will be defined if there are detached headers
451+ if not blkid_info .get ('uuid' ): # No uuid will be defined if there are detached headers
452452 if not self ['cryptsetup' ][mount_loc .name ].get ('header_file' ):
453453 raise ValueError ("[%s] Unknown LUKS mount type: %s" % (mount_loc .name , dm_type ))
454454 else : # If there is some uuid and it's not LUKS, that's a problem
455455 raise RuntimeError ("[%s] Unknown device mapper slave type: %s" % (self ._dm_info [dm_num ]['slaves' ][0 ], dm_type ))
456456
457457 # Configure cryptsetup based on the LUKS mount
458- if uuid := dm_info .get ('uuid' ):
458+ if uuid := blkid_info .get ('uuid' ):
459459 self .logger .info ("[%s] LUKS volume uuid: %s" % (mount_loc .name , uuid ))
460460 self ['cryptsetup' ] = {self ._dm_info [dm_num ]['name' ]: {'uuid' : uuid }}
461- elif partuuid := dm_info .get ('partuuid' ):
461+ elif partuuid := blkid_info .get ('partuuid' ):
462462 self .logger .info ("[%s] LUKS volume partuuid: %s" % (mount_loc .name , partuuid ))
463463 self ['cryptsetup' ] = {self ._dm_info [dm_num ]['name' ]: {'partuuid' : partuuid }}
464464
0 commit comments