diff options
| author | Sachin Pandit <spandit@redhat.com> | 2015-02-03 05:01:38 +0530 | 
|---|---|---|
| committer | Raghavendra Bhat <raghavendra@redhat.com> | 2015-03-18 04:48:21 -0700 | 
| commit | 286faf01e9ed4387ea36d9bb7e56f4917acd4e58 (patch) | |
| tree | ec63805e1b02016ecaca1d046a3644cb3a42cb6d /cli/src/cli-cmd-volume.c | |
| parent | b46bd7feadd77374ba3d40ac19e127b2073b51d5 (diff) | |
features/quota : Fix XML output for quota list command.
Sample output:
---------------
Sample 1)
----------
[root@snapshot-28 glusterfs]# gluster volume quota vol1 list /dir1 /dir4 /dir5 --xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<cliOutput>
  <opRet>0</opRet>
  <opErrno>0</opErrno>
  <opErrstr/>
  <volQuota>
    <limit>
      <path>/dir1</path>
      <hard_limit>10.0MB</hard_limit>
      <soft_limit>80%</soft_limit>
      <used_space>0Bytes</used_space>
      <avail_space>10.0MB</avail_space>
      <hl_exceeded>No</hl_exceeded>
      <sl_exceeded>No</sl_exceeded>
    </limit>
    <limit>
      <path>/dir4</path>
      <path>No such file or directory</path>
    </limit>
    <limit>
      <path>/dir5</path>
      <path>No such file or directory</path>
    </limit>
  </volQuota>
</cliOutput>
Sample 2)
---------
gluster volume quota vol1 list --xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<cliOutput>
  <opRet>0</opRet>
  <opErrno>0</opErrno>
  <opErrstr/>
  <volQuota/>
</cliOutput>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<cliOutput>
  <volQuota>
    <limit>
      <path>/dir</path>
      <hard_limit>10.0MB</hard_limit>
      <soft_limit>80%</soft_limit>
      <used_space>0Bytes</used_space>
      <avail_space>10.0MB</avail_space>
      <hl_exceeded>No</hl_exceeded>
      <sl_exceeded>No</sl_exceeded>
    </limit>
    <limit>
      <path>/dir1</path>
      <hard_limit>10.0MB</hard_limit>
      <soft_limit>80%</soft_limit>
      <used_space>0Bytes</used_space>
      <avail_space>10.0MB</avail_space>
      <hl_exceeded>No</hl_exceeded>
      <sl_exceeded>No</sl_exceeded>
    </limit>
  </volQuota>
</cliOutput>
Change-Id: I8a8d83cff88f778e5ee01fbca07d9f94c412317a
BUG: 1200297
Signed-off-by: Sachin Pandit <spandit@redhat.com>
Reviewed-on: http://review.gluster.org/9481
Reviewed-by: Vijaikumar Mallikarjuna <vmallika@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Kaushal M <kaushal@redhat.com>
Signed-off-by: Sachin Pandit <spandit@redhat.com>
Reviewed-on: http://review.gluster.org/9847
Reviewed-by: Raghavendra Bhat <raghavendra@redhat.com>
Diffstat (limited to 'cli/src/cli-cmd-volume.c')
| -rw-r--r-- | cli/src/cli-cmd-volume.c | 42 | 
1 files changed, 40 insertions, 2 deletions
diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c index 84209adf936..7b83351bf29 100644 --- a/cli/src/cli-cmd-volume.c +++ b/cli/src/cli-cmd-volume.c @@ -1283,6 +1283,8 @@ cli_cmd_quota_handle_list_all (const char **words, dict_t *options)          unsigned char            buf[16]   = {0};          int                      fd        = -1;          char                     quota_conf_file[PATH_MAX] = {0}; +        gf_boolean_t             xml_err_flag   = _gf_false; +        char                     err_str[NAME_MAX] = {0,};          xdata = dict_new ();          if (!xdata) { @@ -1307,7 +1309,13 @@ cli_cmd_quota_handle_list_all (const char **words, dict_t *options)           * quota enabled as cli_get_soft_limit() handles that           */          if (!_limits_set_on_volume (volname)) { -                cli_out ("quota: No quota configured on volume %s", volname); +                snprintf (err_str, sizeof (err_str), "No quota configured on " +                          "volume %s", volname); +                if (global_state->mode & GLUSTER_MODE_XML) { +                        xml_err_flag = _gf_true; +                } else { +                        cli_out ("quota: %s", err_str); +                }                  ret = 0;                  goto out;          } @@ -1358,7 +1366,18 @@ cli_cmd_quota_handle_list_all (const char **words, dict_t *options)          CLI_LOCAL_INIT (local, words, frame, xdata);          proc = &cli_quotad_clnt.proctable[GF_AGGREGATOR_GETLIMIT]; -        print_quota_list_header (); +        if (!(global_state->mode & GLUSTER_MODE_XML)) { +                print_quota_list_header (); +        } else { +                ret = cli_xml_output_vol_quota_limit_list_begin +                        (local, 0, 0, NULL); +                if (ret) { +                        gf_log ("cli", GF_LOG_ERROR, "Error in printing " +                                "xml output"); +                        goto out; +                } +        } +          gfid_str = GF_CALLOC (1, gf_common_mt_char, 64);          if (!gfid_str) {                  ret = -1; @@ -1394,12 +1413,31 @@ cli_cmd_quota_handle_list_all (const char **words, dict_t *options)                  all_failed = all_failed && ret;          } +        if (global_state->mode & GLUSTER_MODE_XML) { +                ret = cli_xml_output_vol_quota_limit_list_end (local); +                if (ret) { +                        gf_log ("cli", GF_LOG_ERROR, "Error in printing " +                                "xml output"); +                        goto out; +                } +        } +          if (count > 0) {                  ret = all_failed? -1: 0;          } else {                  ret = 0;          } + +  out: +        if (xml_err_flag) { +                ret = cli_xml_output_str ("volQuota", NULL, -1, 0, err_str); +                if (ret) { +                        gf_log ("cli", GF_LOG_ERROR, "Error outputting in " +                                "xml format"); +                } +        } +          if (fd != -1) {                  close (fd);          }  | 
