2019-11-11 18:30:46 -08:00
|
|
|
# jc.parsers.lsblk
|
|
|
|
jc - JSON CLI output utility lsblk Parser
|
|
|
|
|
|
|
|
Usage:
|
2019-12-12 09:47:14 -08:00
|
|
|
|
2019-11-11 18:30:46 -08:00
|
|
|
specify --lsblk as the first argument if the piped input is coming from lsblk
|
|
|
|
|
2019-12-12 09:21:20 -08:00
|
|
|
Compatibility:
|
2019-12-12 09:47:14 -08:00
|
|
|
|
2019-12-12 09:21:20 -08:00
|
|
|
'linux'
|
|
|
|
|
2019-11-11 18:30:46 -08:00
|
|
|
Examples:
|
|
|
|
|
|
|
|
$ lsblk | jc --lsblk -p
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"name": "sda",
|
|
|
|
"maj_min": "8:0",
|
|
|
|
"rm": false,
|
|
|
|
"size": "20G",
|
|
|
|
"ro": false,
|
|
|
|
"type": "disk",
|
|
|
|
"mountpoint": null
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "sda1",
|
|
|
|
"maj_min": "8:1",
|
|
|
|
"rm": false,
|
|
|
|
"size": "1G",
|
|
|
|
"ro": false,
|
|
|
|
"type": "part",
|
|
|
|
"mountpoint": "/boot"
|
|
|
|
},
|
|
|
|
...
|
|
|
|
]
|
|
|
|
|
|
|
|
$ lsblk -o +KNAME,FSTYPE,LABEL,UUID,PARTLABEL,PARTUUID,RA,MODEL,SERIAL,STATE,OWNER,GROUP,MODE,ALIGNMENT,MIN-IO,OPT-IO,PHY-SEC,LOG-SEC,ROTA,SCHED,RQ-SIZE,DISC-ALN,DISC-GRAN,DISC-MAX,DISC-ZERO,WSAME,WWN,RAND,PKNAME,HCTL,TRAN,REV,VENDOR | jc --lsblk -p
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"name": "sda",
|
|
|
|
"maj_min": "8:0",
|
|
|
|
"rm": false,
|
|
|
|
"size": "20G",
|
|
|
|
"ro": false,
|
|
|
|
"type": "disk",
|
|
|
|
"mountpoint": null,
|
|
|
|
"kname": "sda",
|
|
|
|
"fstype": null,
|
|
|
|
"label": null,
|
|
|
|
"uuid": null,
|
|
|
|
"partlabel": null,
|
|
|
|
"partuuid": null,
|
|
|
|
"ra": 4096,
|
|
|
|
"model": "VMware Virtual S",
|
|
|
|
"serial": null,
|
|
|
|
"state": "running",
|
|
|
|
"owner": "root",
|
|
|
|
"group": "disk",
|
|
|
|
"mode": "brw-rw----",
|
|
|
|
"alignment": 0,
|
|
|
|
"min_io": 512,
|
|
|
|
"opt_io": 0,
|
|
|
|
"phy_sec": 512,
|
|
|
|
"log_sec": 512,
|
|
|
|
"rota": true,
|
|
|
|
"sched": "deadline",
|
|
|
|
"rq_size": 128,
|
|
|
|
"disc_aln": 0,
|
|
|
|
"disc_gran": "0B",
|
|
|
|
"disc_max": "0B",
|
|
|
|
"disc_zero": false,
|
|
|
|
"wsame": "32M",
|
|
|
|
"wwn": null,
|
|
|
|
"rand": true,
|
|
|
|
"pkname": null,
|
|
|
|
"hctl": "0:0:0:0",
|
|
|
|
"tran": "spi",
|
|
|
|
"rev": "1.0",
|
|
|
|
"vendor": "VMware,"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "sda1",
|
|
|
|
"maj_min": "8:1",
|
|
|
|
"rm": false,
|
|
|
|
"size": "1G",
|
|
|
|
"ro": false,
|
|
|
|
"type": "part",
|
|
|
|
"mountpoint": "/boot",
|
|
|
|
"kname": "sda1",
|
|
|
|
"fstype": "xfs",
|
|
|
|
"label": null,
|
|
|
|
"uuid": "05d927bb-5875-49e3-ada1-7f46cb31c932",
|
|
|
|
"partlabel": null,
|
|
|
|
"partuuid": null,
|
|
|
|
"ra": 4096,
|
|
|
|
"model": null,
|
|
|
|
"serial": null,
|
|
|
|
"state": null,
|
|
|
|
"owner": "root",
|
|
|
|
"group": "disk",
|
|
|
|
"mode": "brw-rw----",
|
|
|
|
"alignment": 0,
|
|
|
|
"min_io": 512,
|
|
|
|
"opt_io": 0,
|
|
|
|
"phy_sec": 512,
|
|
|
|
"log_sec": 512,
|
|
|
|
"rota": true,
|
|
|
|
"sched": "deadline",
|
|
|
|
"rq_size": 128,
|
|
|
|
"disc_aln": 0,
|
|
|
|
"disc_gran": "0B",
|
|
|
|
"disc_max": "0B",
|
|
|
|
"disc_zero": false,
|
|
|
|
"wsame": "32M",
|
|
|
|
"wwn": null,
|
|
|
|
"rand": true,
|
|
|
|
"pkname": "sda",
|
|
|
|
"hctl": null,
|
|
|
|
"tran": null,
|
|
|
|
"rev": null,
|
|
|
|
"vendor": null
|
|
|
|
},
|
|
|
|
...
|
|
|
|
]
|
|
|
|
|
|
|
|
$ lsblk -o +KNAME,FSTYPE,LABEL,UUID,PARTLABEL,PARTUUID,RA,MODEL,SERIAL,STATE,OWNER,GROUP,MODE,ALIGNMENT,MIN-IO,OPT-IO,PHY-SEC,LOG-SEC,ROTA,SCHED,RQ-SIZE,DISC-ALN,DISC-GRAN,DISC-MAX,DISC-ZERO,WSAME,WWN,RAND,PKNAME,HCTL,TRAN,REV,VENDOR | jc --lsblk -p -r
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"name": "sda",
|
|
|
|
"maj_min": "8:0",
|
|
|
|
"rm": "0",
|
|
|
|
"size": "20G",
|
|
|
|
"ro": "0",
|
|
|
|
"type": "disk",
|
|
|
|
"mountpoint": null,
|
|
|
|
"kname": "sda",
|
|
|
|
"fstype": null,
|
|
|
|
"label": null,
|
|
|
|
"uuid": null,
|
|
|
|
"partlabel": null,
|
|
|
|
"partuuid": null,
|
|
|
|
"ra": "4096",
|
|
|
|
"model": "VMware Virtual S",
|
|
|
|
"serial": null,
|
|
|
|
"state": "running",
|
|
|
|
"owner": "root",
|
|
|
|
"group": "disk",
|
|
|
|
"mode": "brw-rw----",
|
|
|
|
"alignment": "0",
|
|
|
|
"min_io": "512",
|
|
|
|
"opt_io": "0",
|
|
|
|
"phy_sec": "512",
|
|
|
|
"log_sec": "512",
|
|
|
|
"rota": "1",
|
|
|
|
"sched": "deadline",
|
|
|
|
"rq_size": "128",
|
|
|
|
"disc_aln": "0",
|
|
|
|
"disc_gran": "0B",
|
|
|
|
"disc_max": "0B",
|
|
|
|
"disc_zero": "0",
|
|
|
|
"wsame": "32M",
|
|
|
|
"wwn": null,
|
|
|
|
"rand": "1",
|
|
|
|
"pkname": null,
|
|
|
|
"hctl": "0:0:0:0",
|
|
|
|
"tran": "spi",
|
|
|
|
"rev": "1.0",
|
|
|
|
"vendor": "VMware,"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "sda1",
|
|
|
|
"maj_min": "8:1",
|
|
|
|
"rm": "0",
|
|
|
|
"size": "1G",
|
|
|
|
"ro": "0",
|
|
|
|
"type": "part",
|
|
|
|
"mountpoint": "/boot",
|
|
|
|
"kname": "sda1",
|
|
|
|
"fstype": "xfs",
|
|
|
|
"label": null,
|
|
|
|
"uuid": "05d927bb-5875-49e3-ada1-7f46cb31c932",
|
|
|
|
"partlabel": null,
|
|
|
|
"partuuid": null,
|
|
|
|
"ra": "4096",
|
|
|
|
"model": null,
|
|
|
|
"serial": null,
|
|
|
|
"state": null,
|
|
|
|
"owner": "root",
|
|
|
|
"group": "disk",
|
|
|
|
"mode": "brw-rw----",
|
|
|
|
"alignment": "0",
|
|
|
|
"min_io": "512",
|
|
|
|
"opt_io": "0",
|
|
|
|
"phy_sec": "512",
|
|
|
|
"log_sec": "512",
|
|
|
|
"rota": "1",
|
|
|
|
"sched": "deadline",
|
|
|
|
"rq_size": "128",
|
|
|
|
"disc_aln": "0",
|
|
|
|
"disc_gran": "0B",
|
|
|
|
"disc_max": "0B",
|
|
|
|
"disc_zero": "0",
|
|
|
|
"wsame": "32M",
|
|
|
|
"wwn": null,
|
|
|
|
"rand": "1",
|
|
|
|
"pkname": "sda",
|
|
|
|
"hctl": null,
|
|
|
|
"tran": null,
|
|
|
|
"rev": null,
|
|
|
|
"vendor": null
|
|
|
|
},
|
|
|
|
...
|
|
|
|
]
|
|
|
|
|
2019-12-14 23:35:42 -08:00
|
|
|
## info
|
|
|
|
```python
|
|
|
|
info(self, /, *args, **kwargs)
|
|
|
|
```
|
|
|
|
|
2019-11-11 18:30:46 -08:00
|
|
|
## process
|
|
|
|
```python
|
|
|
|
process(proc_data)
|
|
|
|
```
|
|
|
|
|
2019-11-12 11:28:10 -08:00
|
|
|
Final processing to conform to the schema.
|
|
|
|
|
|
|
|
Parameters:
|
|
|
|
|
2019-11-13 08:04:40 -08:00
|
|
|
proc_data: (dictionary) raw structured data to process
|
2019-11-12 11:28:10 -08:00
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
2019-12-17 09:56:09 -08:00
|
|
|
List of dictionaries. Structured data with the following schema:
|
2019-11-11 18:30:46 -08:00
|
|
|
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"name": string,
|
|
|
|
"maj_min": string,
|
|
|
|
"rm": boolean,
|
|
|
|
"size": string,
|
|
|
|
"ro": boolean,
|
|
|
|
"type": string,
|
|
|
|
"mountpoint": string,
|
|
|
|
"kname": string,
|
|
|
|
"fstype": string,
|
|
|
|
"label": string,
|
|
|
|
"uuid": string,
|
|
|
|
"partlabel": string,
|
|
|
|
"partuuid": string,
|
|
|
|
"ra": integer,
|
|
|
|
"model": string,
|
|
|
|
"serial": string,
|
|
|
|
"state": string,
|
|
|
|
"owner": string,
|
|
|
|
"group": string,
|
|
|
|
"mode": string,
|
|
|
|
"alignment": integer,
|
|
|
|
"min_io": integer,
|
|
|
|
"opt_io": integer,
|
|
|
|
"phy_sec": integer,
|
|
|
|
"log_sec": integer,
|
|
|
|
"rota": boolean,
|
|
|
|
"sched": string,
|
|
|
|
"rq_size": integer,
|
|
|
|
"disc_aln": integer,
|
|
|
|
"disc_gran": string,
|
|
|
|
"disc_max": string,
|
|
|
|
"disc_zero": boolean,
|
|
|
|
"wsame": string,
|
|
|
|
"wwn": string,
|
|
|
|
"rand": boolean,
|
|
|
|
"pkname": string,
|
|
|
|
"hctl": string,
|
|
|
|
"tran": string,
|
|
|
|
"rev": string,
|
|
|
|
"vendor": string
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
## parse
|
|
|
|
```python
|
|
|
|
parse(data, raw=False, quiet=False)
|
|
|
|
```
|
|
|
|
|
2019-11-12 11:18:00 -08:00
|
|
|
Main text parsing function
|
2019-11-11 18:30:46 -08:00
|
|
|
|
2019-11-12 11:18:00 -08:00
|
|
|
Parameters:
|
2019-11-11 18:30:46 -08:00
|
|
|
|
2019-11-12 11:18:00 -08:00
|
|
|
data: (string) text data to parse
|
|
|
|
raw: (boolean) output preprocessed JSON if True
|
|
|
|
quiet: (boolean) suppress warning messages if True
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
2019-12-17 10:09:19 -08:00
|
|
|
List of dictionaries. Raw or processed structured data.
|
2019-11-11 18:30:46 -08:00
|
|
|
|