summaryrefslogtreecommitdiffstats
path: root/cli
diff options
context:
space:
mode:
Diffstat (limited to 'cli')
-rw-r--r--cli/src/cli-cmd-parser.c2
-rw-r--r--cli/src/cli-cmd-volume-bdevice.c47
-rw-r--r--cli/src/cli-rpc-ops.c6
3 files changed, 53 insertions, 2 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c
index f7ee29a10..ae754b97c 100644
--- a/cli/src/cli-cmd-parser.c
+++ b/cli/src/cli-cmd-parser.c
@@ -369,7 +369,7 @@ cli_cmd_volume_create_parse (const char **words, int wordcount, dict_t **options
cli_err ("Block Device backend volume does not support multiple"
" bricks");
gf_log ("", GF_LOG_ERROR,
- "Block Device backend volumer does not support multiple"
+ "Block Device backend volume does not support multiple"
" bricks");
ret = -1;
goto out;
diff --git a/cli/src/cli-cmd-volume-bdevice.c b/cli/src/cli-cmd-volume-bdevice.c
index ea7edab65..19325754f 100644
--- a/cli/src/cli-cmd-volume-bdevice.c
+++ b/cli/src/cli-cmd-volume-bdevice.c
@@ -41,6 +41,8 @@ cli_cmd_bd_parse (dict_t *dict, const char **words)
char *size = NULL;
char *eptr = NULL;
gf_xl_bd_op_t bd_op = GF_BD_OP_INVALID;
+ char *dest_lv = NULL;
+
/* volname:/path */
if (!strchr (words[2], ':') || !strchr (words[2], '/')) {
@@ -64,6 +66,10 @@ cli_cmd_bd_parse (dict_t *dict, const char **words)
bd_op = GF_BD_OP_NEW_BD;
else if (!strcasecmp (words[1], "delete"))
bd_op = GF_BD_OP_DELETE_BD;
+ else if (!strcasecmp (words[1], "clone"))
+ bd_op = GF_BD_OP_CLONE_BD;
+ else if (!strcasecmp (words[1], "snapshot"))
+ bd_op = GF_BD_OP_SNAPSHOT_BD;
else
return -1;
@@ -83,6 +89,30 @@ cli_cmd_bd_parse (dict_t *dict, const char **words)
ret = dict_set_dynstr (dict, "size", size);
if (ret)
goto out;
+ } else if (bd_op == GF_BD_OP_SNAPSHOT_BD ||
+ bd_op == GF_BD_OP_CLONE_BD) {
+ /*
+ * dest_lv should be just dest_lv, we don't support
+ * cloning/snapshotting to a different volume or vg
+ */
+ if (strchr (words[3], ':') || strchr (words[3], '/')) {
+ cli_err ("invalid parameter %s, volname/vg not needed",
+ words[3]);
+ ret = -1;
+ goto out;
+ }
+ dest_lv = gf_strdup (words[3]);
+ ret = dict_set_dynstr (dict, "dest_lv", dest_lv);
+ if (ret)
+ goto out;
+
+ /* clone needs size as parameter */
+ if (bd_op == GF_BD_OP_SNAPSHOT_BD) {
+ ret = dict_set_dynstr (dict, "size",
+ gf_strdup (words[4]));
+ if (ret)
+ goto out;
+ }
}
ret = 0;
@@ -94,13 +124,15 @@ out:
/*
* bd create <volname>:/path <size>
* bd delete <volname>:/path
+ * bd clone <volname>:/path <newbd>
+ * bd snapshot <volname>:/<path> <newbd> <size>
*/
int32_t
cli_cmd_bd_validate (const char **words, int wordcount, dict_t **options)
{
dict_t *dict = NULL;
int ret = -1;
- char *op[] = { "create", "delete", NULL };
+ char *op[] = { "create", "delete", "clone", "snapshot", NULL };
int index = 0;
for (index = 0; op[index]; index++)
@@ -120,6 +152,12 @@ cli_cmd_bd_validate (const char **words, int wordcount, dict_t **options)
} else if (!strcasecmp (words[1], "delete")) {
if (wordcount != 3)
goto out;
+ } else if (!strcasecmp (words[1], "clone")) {
+ if (wordcount != 4)
+ goto out;
+ } else if (!strcasecmp (words[1], "snapshot")) {
+ if (wordcount != 5)
+ goto out;
} else {
ret = -1;
goto out;
@@ -193,6 +231,13 @@ struct cli_cmd cli_bd_cmds[] = {
{ "bd delete <volname>:<bd>",
cli_cmd_bd_cbk,
"Delete a block device"},
+ { "bd clone <volname>:<bd> <newbd>",
+ cli_cmd_bd_cbk,
+ "clone device"},
+ { "bd snapshot <volname>:<bd> <newbd> <size>",
+ cli_cmd_bd_cbk,
+ "\n\tsnapshot device where size can be "
+ "suffixed with KB, MB etc. Default size is in MB"},
{ NULL, NULL, NULL }
};
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c
index 9e4e03d07..da239b51e 100644
--- a/cli/src/cli-rpc-ops.c
+++ b/cli/src/cli-rpc-ops.c
@@ -2647,6 +2647,12 @@ gf_cli_bd_op_cbk (struct rpc_req *req, struct iovec *iov,
case GF_BD_OP_DELETE_BD:
operation = gf_strdup ("delete");
break;
+ case GF_BD_OP_CLONE_BD:
+ operation = gf_strdup ("clone");
+ break;
+ case GF_BD_OP_SNAPSHOT_BD:
+ operation = gf_strdup ("snapshot");
+ break;
default:
break;
}