[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[lvm-devel] [PATCH 14/22] Replicator: add new command option read functions



site_arg - reads name of the site.
sitemode_arg - reads site mode.

Signed-off-by: Zdenek Kabelac <zkabelac redhat com>
---
 tools/lvmcmdline.c |   24 ++++++++++++++++++++++++
 tools/tools.h      |    2 ++
 2 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index 8ff74ac..7d55e48 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -473,6 +473,30 @@ int readahead_arg(struct cmd_context *cmd __attribute((unused)), struct arg *a)
 	return 1;
 }
 
+int site_arg(struct cmd_context *cmd __attribute((unused)), struct arg *a)
+{
+	if (!validate_name(a->value)) {
+		log_error("Invalid site name.");
+		return 0;
+	}
+
+	return 1;
+}
+
+int sitemode_arg(struct cmd_context *cmd __attribute((unused)), struct arg *a)
+{
+	struct replicator_site rsite;
+
+	if (!replicator_site_set_op_mode(&rsite, a->value)) {
+		log_error("Invalid site mode %s.", a->value);
+		return 0;
+	}
+
+	a->ui_value = rsite.op_mode;
+
+	return 1;
+}
+
 /*
  * Non-zero, positive integer, "all", or "unmanaged"
  */
diff --git a/tools/tools.h b/tools/tools.h
index 2e06fc2..3104d0a 100644
--- a/tools/tools.h
+++ b/tools/tools.h
@@ -153,6 +153,8 @@ int segtype_arg(struct cmd_context *cmd, struct arg *a);
 int alloc_arg(struct cmd_context *cmd, struct arg *a);
 int readahead_arg(struct cmd_context *cmd, struct arg *a);
 int metadatacopies_arg(struct cmd_context *cmd __attribute((unused)), struct arg *a);
+int site_arg(struct cmd_context *cmd, struct arg *a);
+int sitemode_arg(struct cmd_context *cmd, struct arg *a);
 
 /* we use the enums to access the switches */
 unsigned arg_count(const struct cmd_context *cmd, int a);
-- 
1.7.1.1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]