blkinfo is a python package to list information about all available or the specified block devices.
Likely abandoned. No release or commit for years (last release over 5 years ago).
pip install blkinfoblkinfo - 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