summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSachin Pandit <spandit@redhat.com>2013-11-05 11:38:42 +0000
committerSachin Pandit <spandit@redhat.com>2013-11-05 12:08:06 +0000
commit045b1058c01ae0dbbda2dac508e8ced91b1c1734 (patch)
tree7cfd065b2e52169c807c17e4a38cb235cb2f0acc
parenta1941b9a20635b2fa5d041e19cc38e367862cdca (diff)
mgmt/glusterd : Printing error message if volume does not exist.
If user tries to list the snap details of volumes which does not exist, then corresponding error message is displayed. Change-Id: I205738be3dc632ccb074b639a2088cdd44aa35a7 Signed-off-by: Sachin Pandit <spandit@redhat.com>
-rw-r--r--cli/src/cli-rpc-ops.c13
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-snapshot.c31
2 files changed, 41 insertions, 3 deletions
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c
index c6ed33592..fa77f1a14 100644
--- a/cli/src/cli-rpc-ops.c
+++ b/cli/src/cli-rpc-ops.c
@@ -7427,13 +7427,24 @@ list_snap_of_volume (dict_t *dict_n, char *prefix_str) {
* if volume not present then display that volume doesnot exist
* and try to fetch next volume mentioned
*/
+
+ ret = snprintf (buffer, sizeof (buffer), "%s.err_str", prefix_str);
+ if (ret < 0) {
+ goto out;
+ }
+ ret = dict_get_str (dict_n, buffer, &get_buffer);
+ if (ret == 0) {
+ cli_out (get_buffer);
+ ret = 0;
+ goto out;
+ }
ret = snprintf (buffer, sizeof(buffer), "%s.volname", prefix_str);
if (ret < 0) { /* Negative value is an error */
goto out;
}
ret = dict_get_str (dict_n, buffer, &get_buffer);
if (get_buffer == NULL){
- cli_out ("Volume doesnot exist");
+ ret = 0;
goto out;
}
cli_out ("Vol Name : %s", get_buffer);
diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
index b3d077a43..077bf33ad 100644
--- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c
+++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
@@ -1769,6 +1769,9 @@ glusterd_snapshot_get_snaplist (dict_t *voldict, dict_t *rspdict,
char *volname = NULL;
xlator_t *this = NULL;
char key[256] = {0,};
+ gf_boolean_t exist = _gf_false;
+ char *err_str = NULL;
+ char err_prefix[PATH_MAX] = "";
this = THIS;
@@ -1808,12 +1811,36 @@ glusterd_snapshot_get_snaplist (dict_t *voldict, dict_t *rspdict,
goto out;
}
- /* Now for each volume get the snap list */
ret = snprintf (key, sizeof (key), "%s.vol%ld", keyprefix, i);
if (ret < 0) { /* Only negative value is error */
goto out;
}
+ exist = glusterd_check_volume_exists (volname);
+ if (!exist) {
+ err_str = (char *) GF_CALLOC(1, PATH_MAX, sizeof(char));
+ gf_log ("", GF_LOG_ERROR,
+ "Volume %s Does not exist", volname);
+ ret = snprintf (err_str, PATH_MAX,
+ "Volume %s Does not exist",volname);
+ if (ret < 0) {
+ goto out;
+ }
+ ret = snprintf (err_prefix, sizeof (err_prefix),
+ "%s.err_str", key);
+ if (ret < 0) {
+ goto out;
+ }
+ ret = dict_set_str (rspdict, err_prefix, err_str);
+ if (ret < 0 ) {
+ gf_log ("", GF_LOG_ERROR, "Could not"
+ "save the err_str");
+ goto out;
+ }
+ continue;
+ }
+
+ /* Now for each volume get the snap list */
ret = glusterd_snapshot_vol_get_snaplist_by_name (rspdict, key,
volname, snapname, detail);
if (ret) {
@@ -1851,9 +1878,9 @@ glusterd_handle_snapshot_list (rpcsvc_request_t *req, glusterd_op_t op,
char *keyprefix = "snaplist";
char *cgname = NULL;
char *snapname = NULL;
+ char *err_str = "Operation failed";
dict_t *voldict = NULL;
xlator_t *this = NULL;
- char *err_str = "Operation failed";
char key[256] = {0,};
this = THIS;