Fedora Account System
Red Hat Associate
Red Hat Customer
This is an enhancement to bug #1334674 ("Issue warnings, errors and status per object from lvm2 command line tools via report"). Since status is going to be reported as any other report, reuse existing selection mechanism to query for status of last command when the command is run within lvm shell. Any subsequent command will destroy previous status report and new status report is active which can be queried again. This feature requires some minor modifications and enhancements to existing code supporting report selection. For now, selection is defined during report intialization (dm_report_init_with_selection) and lines from report are selected as soon as they're reported (dm_report_object). To support the new feature, we need: - to be able to keep data reported even after it's reported on output (currently, the data is trashed as soon as they're reported on output) - to be able to define selection criteria any time, not just during report initialization so we can use several queries on same report data set - to be able to output same report several times, taking into account current selection criteria
LVM2 supports this feature since lvm2 2.02.158 with the "lastlog" command together with keeping data from any last report. This works while running commands in LVM shell. Then, it's possible to call lastlog as many times as needed with different possible selections (-S|--select). See also "man 7 lvmreport" for more information. Example: # lvm lvm> lvs Logical Volume ============== LV LSize Cpy%Sync lvol1 4.00m 100.00 lvol0 4.00m Command Log =========== Seq LogType Context ObjType ObjName ObjGrp Msg Errno RetCode 1 status processing lv lvol0 vg success 0 1 2 status processing lv lvol1 vg success 0 1 3 status processing vg vg success 0 1 4 status shell cmd lvs success 0 1 lvm> lastlog Command Log =========== Seq LogType Context ObjType ObjName ObjGrp Msg Errno RetCode 1 status processing lv lvol0 vg success 0 1 2 status processing lv lvol1 vg success 0 1 3 status processing vg vg success 0 1 4 status shell cmd lvs success 0 1 lvm> lastlog -S log_object_type=lv Command Log =========== Seq LogType Context ObjType ObjName ObjGrp Msg Errno RetCode 1 status processing lv lvol0 vg success 0 1 2 status processing lv lvol1 vg success 0 1 lvm> lastlog -S log_context=shell Command Log =========== Seq LogType Context ObjType ObjName ObjGrp Msg Errno RetCode 4 status shell cmd lvs success 0 1 lvm> abc Command Log =========== Seq LogType Context ObjType ObjName ObjGrp Msg Errno RetCode 1 error shell cmd abc No such command 'abc'. Try 'help'. -1 0 2 status shell cmd abc failure -1 2