1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-25 01:34:38 +03:00

config: add report/compact_output_cols to control which columns to compact in report output

The new report/compact_output_cols setting has exactly the same effect
as report/compact_output setting. The difference is that with the new
setting it's possible to define which cols should be compacted exactly
in contrast to all cols in case of report/compact_output.

In case both compact_output and compact_output_cols is enabled/set,
the compact_output prevails.

For example:

$ lvmconfig --type full report/compact_output report/compact_output_cols
compact_output=0
compact_output_cols=""

$ lvs vg
  LV    VG   Attr       LSize Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  lvol0 vg   -wi-a----- 4.00m

---

$ lvmconfig --type full report/compact_output report/compact_output_cols
compact_output=0
compact_output_cols="data_percent,metadata_percent,pool_lv,move_pv,origin"

$ lvs vg
  LV    VG   Attr       LSize Log Cpy%Sync Convert
  lvol0 vg   -wi-a----- 4.00m

---

$ lvmconfig --type full report/compact_output report/compact_output_cols
compact_output=1
compact_output_cols="data_percent,metadata_percent,pool_lv,move_pv,origin"

$ lvs vg
  LV    VG   Attr       LSize
  lvol0 vg   -wi-a----- 4.00m
This commit is contained in:
Peter Rajnoha 2015-10-16 16:25:51 +02:00
parent 508f0f5a21
commit c3bfe07f2a
6 changed files with 28 additions and 4 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.133 -
======================================
Add report/compact_output_cols to lvm.conf to define report cols to compact.
Do not change logging in lvm2 library when it's already set.
Check for enough space in thin-pool in command before creating new thin.
Make libblkid detect all copies of the same signature if use_blkid_wiping=1.

View File

@ -1501,6 +1501,15 @@ activation {
# This configuration option has an automatic default value.
# compact_output = 0
# Configuration option report/compact_output_cols.
# Do not print empty values for given report fields.
# The same as compact_output setting, but the compaction is not done
# globally for all fields in report but only for given fields. If both
# compact_output and compact_output_fields is used at the same time,
# the compact_output setting prevails.
# This configuration option has an automatic default value.
# compact_output_cols = ""
# Configuration option report/aligned.
# Align columns in report output.
# This configuration option has an automatic default value.

View File

@ -1421,6 +1421,13 @@ cfg(report_compact_output_CFG, "compact_output", report_CFG_SECTION, CFG_PROFILA
"skipped and not printed. Compact output is applicable only if\n"
"report/buffered is enabled.\n")
cfg(report_compact_output_cols_CFG, "compact_output_cols", report_CFG_SECTION, CFG_ALLOW_EMPTY | CFG_PROFILABLE | CFG_DEFAULT_COMMENTED, CFG_TYPE_STRING, DEFAULT_COMPACT_OUTPUT_COLS, vsn(2, 2, 133), NULL, 0, NULL,
"Do not print empty values for given report fields.\n"
"The same as compact_output setting, but the compaction is not done\n"
"globally for all fields in report but only for given fields. If both\n"
"compact_output and compact_output_fields is used at the same time,\n"
"the compact_output setting prevails.\n")
cfg(report_aligned_CFG, "aligned", report_CFG_SECTION, CFG_PROFILABLE | CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, DEFAULT_REP_ALIGNED, vsn(1, 0, 0), NULL, 0, NULL,
"Align columns in report output.\n")

View File

@ -201,6 +201,8 @@
#define DEFAULT_REP_LIST_ITEM_SEPARATOR ","
#define DEFAULT_TIME_FORMAT "%Y-%m-%d %T %z"
#define DEFAULT_COMPACT_OUTPUT_COLS ""
#define DEFAULT_LVS_COLS "lv_name,vg_name,lv_attr,lv_size,pool_lv,origin,data_percent,metadata_percent,move_pv,mirror_log,copy_percent,convert_lv"
#define DEFAULT_VGS_COLS "vg_name,pv_count,lv_count,snap_count,vg_attr,vg_size,vg_free"
#define DEFAULT_PVS_COLS "pv_name,vg_name,pv_fmt,pv_attr,pv_size,pv_free"

View File

@ -2552,7 +2552,7 @@ int dm_report_compact_fields(struct dm_report *rh);
* The same as dm_report_compact_fields, but for selected fields only.
* The "fields" arg is comma separated list of field names (the same format
* as used for "output_fields" arg in dm_report_init fn).
*/
*/
int dm_report_compact_given_fields(struct dm_report *rh, const char *fields);
/*

View File

@ -618,6 +618,7 @@ static int _report(struct cmd_context *cmd, int argc, char **argv,
unsigned args_are_pvs;
int lv_info_needed, lv_segment_status_needed;
int lock_global = 0;
const char *fields_to_compact;
aligned = find_config_tree_bool(cmd, report_aligned_CFG, NULL);
buffered = find_config_tree_bool(cmd, report_buffered_CFG, NULL);
@ -817,9 +818,13 @@ static int _report(struct cmd_context *cmd, int argc, char **argv,
break;
}
if (find_config_tree_bool(cmd, report_compact_output_CFG, NULL) &&
!dm_report_compact_fields(report_handle))
log_error("Failed to compact report output.");
if (find_config_tree_bool(cmd, report_compact_output_CFG, NULL)) {
if (!dm_report_compact_fields(report_handle))
log_error("Failed to compact report output.");
} else if ((fields_to_compact = find_config_tree_str_allow_empty(cmd, report_compact_output_cols_CFG, NULL))) {
if (!dm_report_compact_given_fields(report_handle, fields_to_compact))
log_error("Failed to compact given columns in report output.");
}
dm_report_output(report_handle);