From 30e6c5364a0484fddc655d43cd3a0224f21343e4 Mon Sep 17 00:00:00 2001 From: Sachin Pandit Date: Thu, 24 Oct 2013 10:35:58 +0000 Subject: CLI : Snapshot List,Integration with glusterd Change in Naming convention: "snap_details", "snap_count" and so on is replaced by "snap-details", "snap-count" so on. Total snapcount introduced. Separate check is made for repeated Volume Name Ex : "gluster snapshot list vol1 vol2 vol1 vol2" is considered as "gluster snapshot list vol1 vol2" *This is still a work in progress* *have to test CG list once CG Store is ready* Change-Id: I45e2904eb8bdbf78de8665f20ba9605c38320307 Signed-off-by: Sachin Pandit --- xlators/mgmt/glusterd/src/glusterd-snapshot.c | 30 ++++++++++++++++++--------- 1 file changed, 20 insertions(+), 10 deletions(-) (limited to 'xlators') diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c index f8ce8a654..c946e4dbd 100644 --- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c +++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c @@ -472,7 +472,7 @@ glusterd_snapshot_get_snapdetail_lk (dict_t *dict, char *keyprefix, goto out; } - snprintf (key, sizeof (key), "%s.snap-name", keyprefix); + snprintf (key, sizeof (key), "%s.snapname", keyprefix); ret = dict_set_dynstr (dict, key, value); if (ret) { gf_log (this->name, GF_LOG_ERROR, "Failed to set " @@ -751,7 +751,7 @@ glusterd_snapshot_vol_get_snaplist_lk (dict_t *dict, char *keyprefix, } /* First set the volume name */ - ret = snprintf (key, sizeof (key), "%s.vol-name", keyprefix); + ret = snprintf (key, sizeof (key), "%s.volname", keyprefix); if (ret < 0) { /* Only negative value is error */ goto out; } @@ -762,6 +762,16 @@ glusterd_snapshot_vol_get_snaplist_lk (dict_t *dict, char *keyprefix, goto out; } + ret = snprintf (key, sizeof (key), "%s.snap-count-total", keyprefix); + if (ret < 0) { + goto out; + } + + ret = dict_set_int64 (dict, key, volinfo->snap_count); + if (ret) { + gf_log (this->name, GF_LOG_ERROR, "Failed to set total snap count"); + goto out; + } /* Ownership of value transferred to dict. Therefore we must initalize * it to NULL */ value = NULL; @@ -773,7 +783,7 @@ glusterd_snapshot_vol_get_snaplist_lk (dict_t *dict, char *keyprefix, list_for_each_entry_safe_reverse (entry, tmp, &volinfo->snaps, snap_list) { ++index; - ret = snprintf (key, sizeof (key), "%s.snap%ld", keyprefix, index); + ret = snprintf (key, sizeof (key), "%s.snap-%ld", keyprefix, index); if (ret < 0) { /* Only negative value is error */ goto out; } @@ -802,7 +812,7 @@ glusterd_snapshot_vol_get_snaplist_lk (dict_t *dict, char *keyprefix, } /* snap found */ - ret = snprintf (key, sizeof (key), "%s.snap0", keyprefix); + ret = snprintf (key, sizeof (key), "%s.snap-0", keyprefix); if (ret < 0) { /* Only negative value is error */ goto out; } @@ -989,7 +999,7 @@ glusterd_snapshot_cg_get_snaplist_lk (dict_t *dict, glusterd_snap_cg_t *cg, goto out; } - ret = snprintf (key, sizeof (key), "%s.cg-name", keyprefix); + ret = snprintf (key, sizeof (key), "%s.cgname", keyprefix); if (ret < 0) { /* Only negative value is error */ goto out; } @@ -1245,7 +1255,7 @@ glusterd_snapshot_get_snaplist (dict_t *voldict, dict_t *rspdict, ret = dict_get_str (voldict, key, &volname); if (ret) { - gf_log (this->name, GF_LOG_ERROR, "Failed to " + gf_log (this->name, GF_LOG_ERROR, "Failed to get" "volname for %s", key); goto out; } @@ -1309,14 +1319,14 @@ glusterd_handle_snapshot_list (rpcsvc_request_t *req, glusterd_op_t op, /* All these options are optonal. Therefore ignore * error returned by following dictionary operations */ - ret = dict_get_str (dict, "snap-name", &snapname); + ret = dict_get_str (dict, "snapname", &snapname); /* Ignore error */ ret = dict_get_int8 (dict, "snap-details", &detail); ret = dict_get_int64 (dict, "vol-count", &volcount); if (ret) { /* Ignore error */ - ret = dict_get_str (dict, "cg-name", &cgname); + ret = dict_get_str (dict, "cgname", &cgname); } @@ -1339,7 +1349,7 @@ glusterd_handle_snapshot_list (rpcsvc_request_t *req, glusterd_op_t op, */ /* TODO: Handle multiple CG if needed */ - ret = snprintf (key, sizeof (key), "%s.cg0", keyprefix); + ret = snprintf (key, sizeof (key), "%s.cg-0", keyprefix); if (ret < 0) { /* Only negative value is error */ goto out; } @@ -1374,7 +1384,7 @@ glusterd_handle_snapshot_list (rpcsvc_request_t *req, glusterd_op_t op, } /* Get the volume count */ - ret = dict_get_int32 (voldict, "vol-count", &vol_count); + ret = dict_get_int32 (voldict, "vol_count", &vol_count); if (ret) { gf_log (this->name, GF_LOG_ERROR, "Failed to get volume" " count"); -- cgit