OpenMediaVault-Plugin-Developers / openmediavault-zfs

OpenMediaVault plugin for zfs
74 stars 15 forks source link

Allow to use devices with complex names when aliasing "by-id" #53

Closed mdziekon closed 6 years ago

mdziekon commented 6 years ago

Resolves #52

Basically, allows device names to contains signs like dashes or underscores when matching their names in getDevId() (which for some reason was already used in getDevByID(), but not the "discovery helper" itself). This should allow to eg. create pools on LUKS-encrypted devices (that are usually called /dev/dm-0, /dev/dm-1 and so on) and use their IDs, instead of raw dev names.

I also took the liberty of reformatting the Utils file a bit, as the formatting was all over the place. Now it should be mostly consistent with what seems to be the default approach (but bear in mind that it was based on my hunch and a brief look at other files). The reformatting takes place in the last commit, so it can be easily reverted if needed. I would strongly suggest adding some kind of a linter to the repo (however, I'm not a PHP programmer on a daily basis, so I don't know what tools could be used to do that).

mdziekon commented 6 years ago

@ryecoaaron the change is based on the previous implementation of getDevById, which for some reason already supported more than just a hyphen. It can easily be changed, but shouldn't these two functions behave in the same way?

mdziekon commented 6 years ago

BTW, getDevById's change was introduced here: https://github.com/OpenMediaVault-Plugin-Developers/openmediavault-zfs/commit/96b44922bfe2ceed8fddb2e1bc9596a9e8b82ee8#diff-3fddb3949068b09d7322dacd89253be7L151

ryecoaaron commented 6 years ago

That was just the first commit I looked at. I guess it is better since it at least narrows the search to /dev/