summaryrefslogtreecommitdiff
path: root/tools/dumpconfig.c
diff options
context:
space:
mode:
authorPeter Rajnoha <prajnoha@redhat.com>2014-05-20 14:45:20 +0200
committerPeter Rajnoha <prajnoha@redhat.com>2014-05-20 16:27:07 +0200
commit9c937e7d54221a783d294768efbaad12473a0265 (patch)
tree43bfa584dd1775ecc77c5d03aa226ef0c39e8ac4 /tools/dumpconfig.c
parent9e3e4d69944f072742fd13c5ac74d68e41a3db55 (diff)
downloadlvm2-9c937e7d54221a783d294768efbaad12473a0265.tar.gz
dumpconfig: add --type profilable-command/profilable-metadata, --metadataprofile/--commandprofile
The dumpconfig now understands --commandprofile/--profile/--metadataprofile The --commandprofile and --profile functionality is almost the same with only one difference and that is that the --profile is just used for dumping the content, it's not applied for the command itself (while the --commandprofile profile is applied like it is done for any other LVM command). We also allow --metadataprofile for dumpconfig - dumpconfig *does not* touch VG/LV and metadata in any way so it's OK to use it here (just for dumping the content, checking the profile validity etc.). The validity of the profile can be checked with: dumpconfig --commandprofile/--profile/--metadataprofile --validate ...depending on the profile type. Also, mention --config in the dumpconfig help string so users know that dumpconfig handles this too (it did even before, but it was not documented in the help string).
Diffstat (limited to 'tools/dumpconfig.c')
-rw-r--r--tools/dumpconfig.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/tools/dumpconfig.c b/tools/dumpconfig.c
index 141a03041..09f2119e5 100644
--- a/tools/dumpconfig.c
+++ b/tools/dumpconfig.c
@@ -92,6 +92,7 @@ int dumpconfig(struct cmd_context *cmd, int argc, char **argv)
struct config_def_tree_spec tree_spec = {0};
struct dm_config_tree *cft = NULL;
struct cft_check_handle *cft_check_handle = NULL;
+ struct profile *profile = NULL;
int r = ECMD_PROCESSED;
tree_spec.cmd = cmd;
@@ -132,6 +133,18 @@ int dumpconfig(struct cmd_context *cmd, int argc, char **argv)
return EINVALID_CMD_LINE;
/*
+ * The profile specified by --profile cmd arg is like --commandprofile,
+ * but it is used just for dumping the profile content and not for
+ * application.
+ */
+ if (arg_count(cmd, profile_ARG) &&
+ (!(profile = add_profile(cmd, arg_str_value(cmd, profile_ARG, NULL), CONFIG_PROFILE_COMMAND)) ||
+ !override_config_tree_from_profile(cmd, profile))) {
+ log_error("Failed to load profile %s.", arg_str_value(cmd, profile_ARG, NULL));
+ return ECMD_FAILED;
+ }
+
+ /*
* Set the 'cft' to work with based on whether we need the plain
* config tree or merged config tree cascade if --mergedconfig is used.
*/
@@ -188,9 +201,18 @@ int dumpconfig(struct cmd_context *cmd, int argc, char **argv)
tree_spec.type = CFG_DEF_TREE_PROFILABLE;
/* profilable type does not require check status */
}
+ else if (!strcmp(type, "profilable-command")) {
+ tree_spec.type = CFG_DEF_TREE_PROFILABLE_CMD;
+ /* profilable-command type does not require check status */
+ }
+ else if (!strcmp(type, "profilable-metadata")) {
+ tree_spec.type = CFG_DEF_TREE_PROFILABLE_MDA;
+ /* profilable-metadata type does not require check status */
+ }
else {
log_error("Incorrect type of configuration specified. "
- "Expected one of: current, default, missing, new, profilable.");
+ "Expected one of: current, default, missing, new, "
+ "profilable, profilable-command, profilable-metadata.");
r = EINVALID_CMD_LINE;
goto out;
}
@@ -218,6 +240,8 @@ int dumpconfig(struct cmd_context *cmd, int argc, char **argv)
out:
if (cft && (cft != cmd->cft))
dm_pool_destroy(cft->mem);
+ else if (profile)
+ remove_config_tree_by_source(cmd, CONFIG_PROFILE_COMMAND);
/*
* The cmd->cft (the "current" tree) is destroyed