mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-24 19:28:53 +03:00
JSON output support for zfs version and zfs get
This commit adds support for JSON output for zfs version and zfs get commands. '-j' flag can be used to get output in JSON format. Information is collected in nvlist objects which is later printed in JSON format. Existing options that work for zfs get and zfs version also work with '-j' flag. man pages for zfs get and zfs version are updated accordingly. Reviewed-by: Tony Hutter <hutter2@llnl.gov> Reviewed-by: Ameer Hamza <ahamza@ixsystems.com> Signed-off-by: Umer Saleem <usaleem@ixsystems.com> Closes #16217
This commit is contained in:
committed by
Brian Behlendorf
parent
6c7d41a643
commit
aa15b60e58
@@ -46,6 +46,7 @@
|
||||
.Cm get
|
||||
.Op Fl r Ns | Ns Fl d Ar depth
|
||||
.Op Fl Hp
|
||||
.Op Fl j Op Ar --json-int
|
||||
.Oo Fl o Ar field Ns Oo , Ns Ar field Oc Ns … Oc
|
||||
.Oo Fl s Ar source Ns Oo , Ns Ar source Oc Ns … Oc
|
||||
.Oo Fl t Ar type Ns Oo , Ns Ar type Oc Ns … Oc
|
||||
@@ -91,6 +92,7 @@ dataset.
|
||||
.Cm get
|
||||
.Op Fl r Ns | Ns Fl d Ar depth
|
||||
.Op Fl Hp
|
||||
.Op Fl j Op Ar --json-int
|
||||
.Oo Fl o Ar field Ns Oo , Ns Ar field Oc Ns … Oc
|
||||
.Oo Fl s Ar source Ns Oo , Ns Ar source Oc Ns … Oc
|
||||
.Oo Fl t Ar type Ns Oo , Ns Ar type Oc Ns … Oc
|
||||
@@ -128,6 +130,11 @@ The value
|
||||
can be used to display all properties that apply to the given dataset's type
|
||||
.Pq Sy filesystem , volume , snapshot , No or Sy bookmark .
|
||||
.Bl -tag -width "-s source"
|
||||
.It Fl j Op Ar --json-int
|
||||
Display the output in JSON format.
|
||||
Specify
|
||||
.Sy --json-int
|
||||
to display numbers in integer format instead of strings for JSON output.
|
||||
.It Fl H
|
||||
Display output in a form more easily parsed by scripts.
|
||||
Any headers are omitted, and fields are explicitly separated by a single tab
|
||||
@@ -283,6 +290,50 @@ The following command gets a single property value:
|
||||
on
|
||||
.Ed
|
||||
.Pp
|
||||
The following command gets a single property value recursively in JSON format:
|
||||
.Bd -literal -compact -offset Ds
|
||||
.No # Nm zfs Cm get Fl j Fl r Sy mountpoint Ar pool/home | Nm jq
|
||||
{
|
||||
"output_version": {
|
||||
"command": "zfs get",
|
||||
"vers_major": 0,
|
||||
"vers_minor": 1
|
||||
},
|
||||
"datasets": {
|
||||
"pool/home": {
|
||||
"name": "pool/home",
|
||||
"type": "FILESYSTEM",
|
||||
"pool": "pool",
|
||||
"createtxg": "10",
|
||||
"properties": {
|
||||
"mountpoint": {
|
||||
"value": "/pool/home",
|
||||
"source": {
|
||||
"type": "DEFAULT",
|
||||
"data": "-"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"pool/home/bob": {
|
||||
"name": "pool/home/bob",
|
||||
"type": "FILESYSTEM",
|
||||
"pool": "pool",
|
||||
"createtxg": "1176",
|
||||
"properties": {
|
||||
"mountpoint": {
|
||||
"value": "/pool/home/bob",
|
||||
"source": {
|
||||
"type": "DEFAULT",
|
||||
"data": "-"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.Ed
|
||||
.Pp
|
||||
The following command lists all properties with local settings for
|
||||
.Ar pool/home/bob :
|
||||
.Bd -literal -compact -offset Ds
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
.Fl ?V
|
||||
.Nm
|
||||
.Cm version
|
||||
.Op Fl j
|
||||
.Nm
|
||||
.Cm subcommand
|
||||
.Op Ar arguments
|
||||
@@ -153,10 +154,14 @@ Displays a help message.
|
||||
.It Xo
|
||||
.Nm
|
||||
.Cm version
|
||||
.Op Fl j
|
||||
.Xc
|
||||
Displays the software version of the
|
||||
.Nm
|
||||
userland utility and the zfs kernel module.
|
||||
Use
|
||||
.Fl j
|
||||
option to output in JSON format.
|
||||
.El
|
||||
.
|
||||
.Ss Dataset Management
|
||||
|
||||
Reference in New Issue
Block a user