Bug 1899525

Summary: Reporting commands ignore --reportformat json option in lvm shell
Product: [Community] LVM and device-mapper Reporter: Peter Rajnoha <prajnoha>
Component: lvm2Assignee: Peter Rajnoha <prajnoha>
lvm2 sub component: Displaying and Reporting QA Contact: cluster-qe <cluster-qe>
Status: POST --- Docs Contact:
Severity: medium    
Priority: unspecified CC: agk, heinzm, jbrassow, msnitzer, prajnoha, zkabelac
Version: unspecifiedFlags: pm-rhel: lvm-technical-solution?
pm-rhel: lvm-test-coverage?
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Peter Rajnoha 2020-11-19 13:38:45 UTC
When running lvm commands inside lvm shell, the --reportformat option is ignored:

❯ lvm
lvm> pvs --reportformat json
  PV         VG     Fmt  Attr PSize   PFree  
  /dev/sda   vg     lvm2 a--  124.00m 124.00m
  /dev/sdb   vg     lvm2 a--  124.00m 124.00m
  /dev/sdc   vg     lvm2 a--  124.00m 124.00m
  /dev/vda3  fedora lvm2 a--  <18.00g      0 

The same works if executed from command line directly:

❯ pvs --reportformat json
  {
      "report": [
          {
              "pv": [
                  {"pv_name":"/dev/sda", "vg_name":"vg", "pv_fmt":"lvm2", "pv_attr":"a--", "pv_size":"124.00m", "pv_free":"124.00m"},
                  {"pv_name":"/dev/sdb", "vg_name":"vg", "pv_fmt":"lvm2", "pv_attr":"a--", "pv_size":"124.00m", "pv_free":"124.00m"},
                  {"pv_name":"/dev/sdc", "vg_name":"vg", "pv_fmt":"lvm2", "pv_attr":"a--", "pv_size":"124.00m", "pv_free":"124.00m"},
                  {"pv_name":"/dev/vda3", "vg_name":"fedora", "pv_fmt":"lvm2", "pv_attr":"a--", "pv_size":"<18.00g", "pv_free":"0 "}
              ]
          }
      ]
  }


I remember this worked, so it must have regressed at some point. I'll try to bisect when I have some spare time...

Comment 1 Peter Rajnoha 2022-08-26 10:40:49 UTC
I got mislead a bit - this hasn't ever been supported. We can change reportformat only for the lvm shell as a whole, not for individual command executed inside the shell. The --reportformat option was just silently ignored so I've added a check and now we error out if an unsupported argument is used.

For example:
  lvm> pvs --reportformat json
    Argument --reportformat cannot be used in interactive mode.
    Error during parsing of command line.


https://sourceware.org/git/?p=lvm2.git;a=commit;h=e6b6a09f90f53a5cea3a712b2b84af57f4514a02