Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for UUID disk and serial number #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sblanchet
Copy link
Contributor

Add support for TrueNAS Scale

It means that we can also specify the enclosure slot with

  • disk serial number
  • partition UUID

Implementation details:

  • for disk serial number I use the output of lsblk --nodeps -o name,serial
  • for partition UUID, I check /dev/disk/by-partuuid to get the partition device
  • to get the disk device from a partition device, I just remove the trailing digits (/dev/sde2 -> /dev/sde)

@sblanchet sblanchet force-pushed the support-uuid-serial-number branch from 6087728 to 6c0dc7b Compare August 30, 2024 15:52
@sblanchet
Copy link
Contributor Author

sblanchet commented Aug 30, 2024

I have just rebased my branch to master to simplify the merging.

disk_device = find_disk( argv[1] ) # by /dev/disk/

if disk_device: # a hard disk device has been found
argv[1] = disk_device # overwrite argv[1] with
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing argv value is not a good practice. Can we just switch the code below (where argv[1]) is used to use of disk_device?

Basically:

    disk_device = find_serial( argv[1] )  # by serial number
    if not disk_device:
        disk_device = find_disk( argv[1] )  # by /dev/disk/
    else:
        disk_device = argv[1]

(and replace all uses of argv[1] with disk device).

for subdir_path in disk_directories:
files = os.listdir( subdir_path )
for f in files:
if re.search(a_disk_name, f, re.IGNORECASE): # the file match
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to support regexps? How do you plan to use it? sdled s.+z?

May be we can just check for case-insensitive match?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants