Bug 1334667

Summary: Add new lvm2 command to do complete report per VG
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: CLOSED UPSTREAM Docs Contact:
Severity: low    
Priority: medium CC: agk, heinzm, jbrassow, msnitzer, prajnoha, zkabelac
Version: unspecifiedFlags: prajnoha: lvm-technical-solution+
rule-engine: lvm-test-coverage?
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-08-24 08:39:53 UTC 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:
Bug Depends On: 1334655    
Bug Blocks: 1334682, 1346079    

Description Peter Rajnoha 2016-05-10 09:37:15 UTC
Add new lvm2 command (e.g. "lvm fullreport") that does complete and full report for each VG. Such complete report includes these types which are going to be subreports of the whole report group (see also bug #1334655 which adds support for report groups):

  - "pv" (for PV-related fields for PVs which are in the VG),
  - "vg" (for VG-related fields),
  - "lv" (for LV-related fields for LVs which are in the VG),
  - "segs" (for LV segments for each LV in the VG),
  - "pvsegs" (for PV segments for each PV in the VG).

All these subreports are reported per VG, that also means per one VG lock.

For PVs which are not yet in in a VG, only "pv" subreport is going to be reported.

By default, each type will output all that is possible for that subreport, that means pv_all, vg_all, lv_all, segs_all and pvsegs_all fields which automatically expands to complete set of fields and including extra fields necessary to make a relation among subreports:

  - "lv_uuid" field for "segs" subreport,
  - "pv_uuid" and "lv_uuid" field for "pvsegs" subreport.
  - ("pv"/"vg"/"lv" subreports already has fields which makes it easy to identify where the entity belongs)

User should be able to change fields to display in "lvm fullreport" by new lvm.conf settings, similarly to existing <subreport_type>_cols setting, as well as fields defined directly on command line using "-o|--options". When using "-o|--options" on command line, it should be possible to select which subreport we're defining options for, for example "-o <subreport_type>,field1,field2,..." So the first item in the list of options defines the subreport for which the list that follows belongs to.

Also, the new "lvm fullreport" command should be able to switch among different report formats, JSON for starters, just like any other reporting command (see also bug #1334659).

Comment 1 Peter Rajnoha 2016-05-11 13:59:03 UTC
Example (I've used only limited number of fields so it's still readable here):


# pvs -o pv_name
  PV        
  /dev/sda  
  /dev/vda2 

# vgs -o vg_name
  VG    
  fedora
  vg    

# lvs -o lv_name
  LV   
  root 
  swap 
  lvol0

# lvs --segments -o lv_name,seg_size
  LV    SSize  
  root   19.00g
  swap  500.00m
  lvol0   4.00m

# pvs --segments -o pv_name,pvseg_size
  PV         SSize
  /dev/sda       1
  /dev/sda      30
  /dev/vda2   4864
  /dev/vda2    125


# lvm fullreport --reportformat json -o pv,pv_name -o vg,vg_name -o lv,lv_name -o seg,lv_name,seg_size -o pvseg,pv_name,pvseg_size
  {
      "report": [
          {
              "vg": [
                  {"vg_name":"vg"}
              ]
              ,
              "pv": [
                  {"pv_name":"/dev/sda"}
              ]
              ,
              "lv": [
                  {"lv_name":"lvol0"}
              ]
              ,
              "pvseg": [
                  {"pv_name":"/dev/sda", "pvseg_size":1},
                  {"pv_name":"/dev/sda", "pvseg_size":30}
              ]
              ,
              "seg": [
                  {"lv_name":"lvol0", "seg_size":"4.00m"}
              ]
          }
          ,
          {
              "vg": [
                  {"vg_name":"fedora"}
              ]
              ,
              "pv": [
                  {"pv_name":"/dev/vda2"}
              ]
              ,
              "lv": [
                  {"lv_name":"root"},
                  {"lv_name":"swap"}
              ]
              ,
              "pvseg": [
                  {"pv_name":"/dev/vda2", "pvseg_size":4864},
                  {"pv_name":"/dev/vda2", "pvseg_size":125}
              ]
              ,
              "seg": [
                  {"lv_name":"root", "seg_size":"19.00g"},
                  {"lv_name":"swap", "seg_size":"500.00m"}
              ]
          }
      ]
  }

Comment 2 Peter Rajnoha 2016-09-22 11:22:11 UTC
There's a new "lvm fullreport" command to do complete report per VG which contains 5 subreports (vg, pv, lv, pvseg and seg). This feature is available since lvm2 2.02.158.

For more information, see "man 8 lvm fullreport" and "man 7 lvmreport".