diff options
Diffstat (limited to 'cli/src')
| -rw-r--r-- | cli/src/cli-rpc-ops.c | 4 | ||||
| -rw-r--r-- | cli/src/cli-xml-output.c | 78 | ||||
| -rw-r--r-- | cli/src/cli.h | 4 | 
3 files changed, 84 insertions, 2 deletions
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c index 19451e0590e..44202037169 100644 --- a/cli/src/cli-rpc-ops.c +++ b/cli/src/cli-rpc-ops.c @@ -3307,8 +3307,8 @@ gf_cli_gsync_set_cbk (struct rpc_req *req, struct iovec *iov,                  goto out;          if (global_state->mode & GLUSTER_MODE_XML) { -                ret = cli_xml_output_dict ("volGeoRep", dict, rsp.op_ret, -                                           rsp.op_errno, rsp.op_errstr); +                ret = cli_xml_output_vol_gsync (dict, rsp.op_ret, rsp.op_errno, +                                                rsp.op_errstr);                  if (ret)                          gf_log ("cli", GF_LOG_ERROR,                                  "Error outputting to xml"); diff --git a/cli/src/cli-xml-output.c b/cli/src/cli-xml-output.c index 34b046cc976..47c0854b2ed 100644 --- a/cli/src/cli-xml-output.c +++ b/cli/src/cli-xml-output.c @@ -3168,3 +3168,81 @@ out:          return 0;  #endif  } + +int +cli_xml_output_vol_gsync (dict_t *dict, int op_ret, int op_errno, +                          char *op_errstr) +{ +#if (HAVE_LIB_XML) +        int                     ret = -1; +        xmlTextWriterPtr        writer = NULL; +        xmlBufferPtr            buf = NULL; +        char                    *master = NULL; +        char                    *slave = NULL; + +        int             type = 0; + +        GF_ASSERT (dict); + +        ret = cli_begin_xml_output (&writer, &buf); +        if (ret) +                goto out; + +        ret = cli_xml_output_common (writer, op_ret, op_errno, op_errstr); +        if (ret) +                goto out; + +        /* <geoRep> */ +        ret = xmlTextWriterStartElement (writer, (xmlChar *)"geoRep"); +        XML_RET_CHECK_AND_GOTO (ret, out); + +        ret = dict_get_int32 (dict, "type", &type); +        if (ret) { +                gf_log ("cli", GF_LOG_ERROR, "Failed to get type"); +                goto out; +        } + +        ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)"type", +                                               "%d", type); +        XML_RET_CHECK_AND_GOTO (ret, out); + +        switch (type) { +        case GF_GSYNC_OPTION_TYPE_START: +        case GF_GSYNC_OPTION_TYPE_STOP: +                if (dict_get_str (dict, "master", &master) != 0) +                        master = "???"; +                if (dict_get_str (dict, "slave", &slave) != 0) +                        slave = "???"; + +                ret = xmlTextWriterWriteFormatElement (writer, +                                                       (xmlChar *)"master", +                                                       "%s", master); +                XML_RET_CHECK_AND_GOTO (ret, out); + +                ret = xmlTextWriterWriteFormatElement (writer, +                                                       (xmlChar *)"slave", +                                                       "%s", slave); +                XML_RET_CHECK_AND_GOTO (ret, out); + +                break; + +        case GF_GSYNC_OPTION_TYPE_CONFIG: +        case GF_GSYNC_OPTION_TYPE_STATUS: +                // TODO: XML output for these two types. +        default: +                ret = 0; +                break; +        } + +        /* </geoRep> */ +        ret = xmlTextWriterEndElement (writer); +        XML_RET_CHECK_AND_GOTO (ret, out); + +        ret = cli_end_xml_output (writer, buf); +out: +        gf_log ("cli",GF_LOG_DEBUG, "Returning %d", ret); +        return ret; +#else +        return 0; +#endif +} diff --git a/cli/src/cli.h b/cli/src/cli.h index 0221f2e85e9..a5f85ec8835 100644 --- a/cli/src/cli.h +++ b/cli/src/cli.h @@ -361,4 +361,8 @@ cli_xml_output_vol_create (dict_t *dict, int op_ret, int op_errno,  int  cli_xml_output_generic_volume (char *op, dict_t *dict, int op_ret, int op_errno,                                 char *op_errstr); + +int +cli_xml_output_vol_gsync (dict_t *dict, int op_ret, int op_errno, +                          char *op_errstr);  #endif /* __CLI_H__ */  | 
