-
-
Notifications
You must be signed in to change notification settings - Fork 290
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
Storage mangment API: disks infos #1953
base: dev
Are you sure you want to change the base?
Storage mangment API: disks infos #1953
Conversation
cb97422
to
6dbe2e1
Compare
6dbe2e1
to
a2b7e81
Compare
a2b7e81
to
a1a394f
Compare
Ok I think this is a good first step. Here is an exemple of the result this produces:
In a future PR, I'd like to add the device type (HDD, SSD, …) and RPM for HDDs. I don't really know how to do that. TrueNAS does it by using its own library. In the meantime, this is ready for review. |
81d9fa7
to
e83e7b3
Compare
A few notes here: I rewrote this PR to use the udisks2 API which provides much more details about disks and is easier to use that udev + other sources of infos. But as a pure dbus API, the code is less self-explanatory. It's mainly about parsing dictionary. Maybe I can make use of something like Tell me if it's OK to add the udisk daemon to Ynh. I'm not aware of everything it entails. |
Naively udisk sounds fine to me 👍 |
Yes i think udisk is a good idea, also because it could help to automount external usb or disk... |
You can know if it's a HDD or SSD by checking directly the info inside /sys...
0 -> SSD /sys/block/sda/queue/removable to know if it's an usb removable disk i guess We could also imagine check for ssd how many written is made, in order to compute an end of life percentage. |
udisks2 provides the information so I don't need a solution anymore. Thanks. |
7d9c4de
to
06e2219
Compare
src/disks.py
Outdated
for k, v in manager.get_dbus_method( | ||
"GetManagedObjects", "org.freedesktop.DBus.ObjectManager" | ||
)().items(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does someone knows a more efficient way to interact with dbus than just list all the objects managed by Udisks2 here?
def infos(): | ||
result = {} | ||
|
||
bus = dbus.SystemBus() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it be file-scoped? I don't know how it is efficient to create a bus at each call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess you could use this kind of info:
/sys/block/sda/size -> Size in Byte
/sys/block/sda/removable -> USB or not
/sys/block/sda/queue/rotational -> HDD or not
/sys/block/sda/ro -> read only mode
/sys/block/sda/stat -> https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-block
/sys/block/sda/sdaX -> partition name and info
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but maybe dbus is ok... (i am not a dbus expert)
I don't believe it is useful to test this. We'd basically be testing the |
06e2219
to
bcfd1ae
Compare
bcfd1ae
to
ea7051a
Compare
ea7051a
to
0961615
Compare
The problem
Rel: YunoHost/issues#1823.
Add API for getting infos on hard drives.