summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Rajnoha <prajnoha@redhat.com>2016-05-26 15:12:38 +0200
committerPeter Rajnoha <prajnoha@redhat.com>2016-06-02 14:38:13 +0200
commitd063c6dca8fc04f364e6197bb9db0af169d092e6 (patch)
tree736dd3c0aefa39aa89e3e8f926edc839c99cdcd4
parentec6ff758f76652a6faf1b555b6bb76e4636cda1f (diff)
downloadlvm2-d063c6dca8fc04f364e6197bb9db0af169d092e6.tar.gz
report: recognize list of keys to sort report by (-O|--sort) for each subreport; make -O|--sort groupable
-rw-r--r--tools/args.h2
-rw-r--r--tools/reporter.c27
2 files changed, 26 insertions, 3 deletions
diff --git a/tools/args.h b/tools/args.h
index 049ea5a72..1c5ecaa1c 100644
--- a/tools/args.h
+++ b/tools/args.h
@@ -191,7 +191,7 @@ arg(nofsck_ARG, 'n', "nofsck", NULL, 0)
arg(novolumegroup_ARG, 'n', "novolumegroup", NULL, 0)
arg(oldpath_ARG, 'n', "oldpath", NULL, 0)
arg(options_ARG, 'o', "options", string_arg, ARG_GROUPABLE)
-arg(sort_ARG, 'O', "sort", string_arg, 0)
+arg(sort_ARG, 'O', "sort", string_arg, ARG_GROUPABLE)
arg(maxphysicalvolumes_ARG, 'p', "maxphysicalvolumes", int_arg, 0)
arg(permission_ARG, 'p', "permission", permission_arg, 0)
arg(partial_ARG, 'P', "partial", NULL, 0)
diff --git a/tools/reporter.c b/tools/reporter.c
index d3bc1aff6..fc2a8b50b 100644
--- a/tools/reporter.c
+++ b/tools/reporter.c
@@ -900,10 +900,33 @@ static int _get_report_keys(struct cmd_context *cmd,
struct report_args *args,
struct single_report_args *single_args)
{
- int r = ECMD_PROCESSED;
+ struct arg_value_group_list *current_group;
+ const char *keys;
+ report_idx_t idx;
+ int r = ECMD_FAILED;
+
+ dm_list_iterate_items(current_group, &cmd->arg_value_groups) {
+ if (!grouped_arg_is_set(current_group->arg_values, sort_ARG))
+ continue;
+
+ keys = grouped_arg_str_value(current_group->arg_values, sort_ARG, NULL);
+ if (!keys || !*keys) {
+ log_error("Invalid keys string: %s", keys);
+ r = EINVALID_CMD_LINE;
+ goto out;
+ }
+
+ if (!(keys = _get_report_idx(keys, &idx)))
+ goto_out;
+
+ if (!_should_process_report_idx(single_args->report_type, idx))
+ continue;
- single_args->keys = arg_str_value(cmd, sort_ARG, single_args->keys);
+ args->single_args[idx].keys = keys;
+ }
+ r = ECMD_PROCESSED;
+out:
return r;
}