blkinfo - Block Devices Information
Library
About
blkinfo is a python library to list information about all available or the specified block devices.
It bases on lsblk command line tool, provided by util-linux, in addition, it collects information about block
devices, using /sys/block, /sys/devices, /proc directories.
The main goal is to provide Python's binding to lsblk. Old versions of lsblk, provided by util-linux-2.23.2 on
Red Hat Enterprise Linux 7 and Centos 7 (and earlier versions) do not contain an option to output to JSON format.
Additional features to lsblk:
- information about iSCSI target IP address and port number was added
- block device usage statistics
Installation
Install python's package from PyPI repository using pip util (default is Python 3):
pip install blkinfo
pip2 install blkinfo
Install rpm package from Copr (experimental).
dnf copr enable galt/blkinfo
dnf install python2-blkinfo
dnf install python3-blkinfo
Usage example
Information about all available block devices:
import json
from blkinfo import BlkDiskInfo
myblkd = BlkDiskInfo()
all_my_disks = myblkd.get_disks()
json_output = json.dumps(all_my_disks)
print(json_output)
Passing filters as an argument to the get_disks() method:
import json
from blkinfo import BlkDiskInfo
myblkd = BlkDiskInfo()
filters = {
'tran': 'iscsi'
}
my_filtered_disks = myblkd.get_disks(filters)
json_output = json.dumps(my_filtered_disks)
print(json_output)
Filters
- name: device name
- name_glob: globex for a device name
- kname: internal kernel device name
- size: size of the device
- min_size: min size for a device
- max_size: max size for a device
- maj:min major and minor device numbers
- ra: read-ahead device (e.g. type)
- ro: read-only device
- rm: removable device
- hotplug: removable or hotplug device (usb, pcmcia, ...)
- model: device identifier, including vendor name
- serial: disk serial number
- state: state of the device
- hctl: string with 'Host:Channel:Target:Lun' string (for SCSI)
- rota: rotational device
- tran: device transport type
- iscsi_target_ip: used together with 'tran': 'iscsi'
- iscsi_target_port: used together with 'tran': 'iscsi'
- is_mounted: does a disk have mounted partition
Roadmap
- Now
blkinfolibrary is usinglsblkcommand line tool directly. The good idea is to createlsblkcore library in C and just add bindings in Python. https://github.com/karelzak/util-linux/issues/839
NOTE:
If you have got a question or suggestion, please, file an issue on GitHub or submit a PR. https://github.com/grinrag/blkinfo
Metadata
Release files for blkinfo 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| blkinfo-0.2.0.tar.gz | 7.9 kB | Without provenance | Details for blkinfo-0.2.0.tar.gz |
Release files / blkinfo-0.2.0.tar.gz
| Download URL | blkinfo-0.2.0.tar.gz |
|---|---|
| Size | 7.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
322a906595f78832d6725ac74a0b9fd2794df3388584d9f05c1a2f8e19324851
|
|
BLAKE2b-256 checksum How to use checksums |
510492c0f6d2cae019384f01db784014408c98c01a9520a757cd1fd382ab95c4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10
|
Security for blkinfo 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.