From 1b361b51a1a6766a80de5265832145c413c32a49 Mon Sep 17 00:00:00 2001 From: Rajesh Joseph Date: Wed, 30 Oct 2013 10:50:45 +0530 Subject: snapshot: Snapshot restore GL-31: Ability to restore snapshot Implemented snapshot restore for thin logical volume. As of now snapshot restore for CG is not tested. Testing for snapshot restore of a volume is done by changing the snapshot create process to create a thick snapshot. This is done because --merge option to restore thin volume is not working in the latest kernel. Change-Id: Ia3ded7e6c4da5957a74e269a25ba3200e6fb2d8b Signed-off-by: Rajesh Joseph --- cli/src/cli-rpc-ops.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'cli/src/cli-rpc-ops.c') diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c index b50721df8..de846974f 100644 --- a/cli/src/cli-rpc-ops.c +++ b/cli/src/cli-rpc-ops.c @@ -7762,6 +7762,38 @@ gf_cli_snapshot_cbk (struct rpc_req *req, struct iovec *iov, snap_name); } break; + case GF_SNAP_OPTION_TYPE_RESTORE: + /* TODO: Check if rsp.op_ret needs to be checked here. Or is + * it ok to check this in the start of the function where we + * get rsp.*/ + if (rsp.op_ret) { + cli_err("snapshot restore: failed: %s", + rsp.op_errstr ? rsp.op_errstr : + "Please check log file for details"); + ret = rsp.op_ret; + goto out; + } + + ret = dict_get_str (dict, "cg-name", &cg_name); + if (ret) { + ret = dict_get_str (dict, "snap-name", &snap_name); + if (ret) { + gf_log (frame->this->name, GF_LOG_ERROR, + "Failed to get CG name or snap name"); + goto out; + } + } + + if (NULL != snap_name) { + cli_out ("Snapshot restore: %s: Snap restored " + "successfully", snap_name); + } else { + cli_out ("Snapshot restore: %s: Consistency group " + "restored successfully", cg_name); + } + + ret = 0; + break; case GF_SNAP_OPTION_TYPE_LIST: if (rsp.op_ret) { -- cgit