summaryrefslogtreecommitdiffstats
path: root/cli
diff options
context:
space:
mode:
authorAvra Sengupta <asengupt@redhat.com>2016-04-12 12:26:54 +0530
committerRajesh Joseph <rjoseph@redhat.com>2016-11-01 23:33:45 -0700
commit098cace25fe192ced2812259633dc7a8ef20faa9 (patch)
tree325d292a0e244bdaaabe8b1ddc0e41d33bcd8d6c /cli
parent247ccb0b3a305decda2147204a749ec2491a030f (diff)
snapshot/cli: Fix snapshot status xml output
Backport of http://review.gluster.org/#/c/14018/ snap status --xml errors out if a brick is down and doesn't have pid. It is handled in the cli of the snap status where "N/A" is displayed in such a scenario. Handled the same in xml snap status <snapname> --xml fails as the writer is not initialised for the same. Using GF_SNAP_STATUS_TYPE_ITER instead of GF_SNAP_STATUS_TYPE_SNAP for all snap's status to differentiate between the two scenarios. Added testcase volume-snapshot-xml.t to check all snapshot commands xml outputs > Reviewed-on: http://review.gluster.org/14018 > Smoke: Gluster Build System <jenkins@build.gluster.org> > CentOS-regression: Gluster Build System <jenkins@build.gluster.org> > NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> > Reviewed-by: Rajesh Joseph <rjoseph@redhat.com> Change-Id: I99563e8f3e84f1aaeabd865326bb825c44f5c745 BUG: 1369363 Signed-off-by: Avra Sengupta <asengupt@redhat.com> Reviewed-on: http://review.gluster.org/15290 Smoke: Gluster Build System <jenkins@build.gluster.org> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Rajesh Joseph <rjoseph@redhat.com>
Diffstat (limited to 'cli')
-rw-r--r--cli/src/cli-rpc-ops.c8
-rw-r--r--cli/src/cli-xml-output.c78
2 files changed, 52 insertions, 34 deletions
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c
index dfdcc251be9..3a5b8e67b08 100644
--- a/cli/src/cli-rpc-ops.c
+++ b/cli/src/cli-rpc-ops.c
@@ -9795,7 +9795,7 @@ cli_populate_req_dict_for_status (dict_t *snap_dict, dict_t *dict, int index) {
GF_ASSERT (dict);
ret = dict_set_uint32 (snap_dict, "sub-cmd",
- GF_SNAP_STATUS_TYPE_SNAP);
+ GF_SNAP_STATUS_TYPE_ITER);
if (ret) {
gf_log ("cli", GF_LOG_ERROR, "Could not save command "
"type in snap dict");
@@ -9887,7 +9887,8 @@ cli_snapshot_status (dict_t *dict, gf_cli_rsp *rsp,
goto out;
}
- if (status_cmd != GF_SNAP_STATUS_TYPE_SNAP) {
+ if ((status_cmd != GF_SNAP_STATUS_TYPE_SNAP) &&
+ (status_cmd != GF_SNAP_STATUS_TYPE_ITER)) {
dict_copy (dict, local->dict);
goto out;
}
@@ -10370,7 +10371,8 @@ gf_cli_snapshot_for_status (call_frame_t *frame, xlator_t *this,
* is already handled. Therefore we can return from here.
* If want to get status of all snaps in the system or volume then
* we should get them one by one.*/
- if (cmd == GF_SNAP_STATUS_TYPE_SNAP) {
+ if ((cmd == GF_SNAP_STATUS_TYPE_SNAP) ||
+ (cmd == GF_SNAP_STATUS_TYPE_ITER)) {
ret = 0;
goto out;
}
diff --git a/cli/src/cli-xml-output.c b/cli/src/cli-xml-output.c
index 673decec160..cdce2d79870 100644
--- a/cli/src/cli-xml-output.c
+++ b/cli/src/cli-xml-output.c
@@ -5075,8 +5075,16 @@ cli_xml_snapshot_volume_status (xmlTextWriterPtr writer, xmlDocPtr doc,
ret = dict_get_str (dict, key, &buffer);
if (ret) {
- gf_log ("cli", GF_LOG_INFO, "Unable to get Brick Path");
- goto out;
+ gf_log ("cli", GF_LOG_ERROR,
+ "Unable to get Brick Path");
+ /*
+ * If path itself is not present, then end *
+ * this brick's status and continue to the *
+ * brick *
+ */
+ ret = xmlTextWriterEndElement (writer);
+ XML_RET_CHECK_AND_GOTO (ret, out);
+ continue;
}
ret = xmlTextWriterWriteFormatElement (writer,
@@ -5088,14 +5096,14 @@ cli_xml_snapshot_volume_status (xmlTextWriterPtr writer, xmlDocPtr doc,
ret = dict_get_str (dict, key, &buffer);
if (ret) {
- gf_log ("cli", GF_LOG_INFO,
+ gf_log ("cli", GF_LOG_ERROR,
"Unable to get Volume Group");
- goto out;
- }
+ ret = xmlTextWriterWriteFormatElement (writer,
+ (xmlChar *) "volumeGroup", "N/A");
+ } else
+ ret = xmlTextWriterWriteFormatElement (writer,
+ (xmlChar *) "volumeGroup", "%s", buffer);
- ret = xmlTextWriterWriteFormatElement (writer,
- (xmlChar *) "volumeGroup",
- "%s", buffer);
XML_RET_CHECK_AND_GOTO (ret, out);
snprintf (key, sizeof (key), "%s.brick%d.status", keyprefix, i);
@@ -5104,19 +5112,25 @@ cli_xml_snapshot_volume_status (xmlTextWriterPtr writer, xmlDocPtr doc,
if (ret) {
gf_log ("cli", GF_LOG_ERROR,
"Unable to get Brick Running");
- goto out;
- }
+ ret = xmlTextWriterWriteFormatElement (writer,
+ (xmlChar *) "brick_running", "N/A");
+ } else
+ ret = xmlTextWriterWriteFormatElement (writer,
+ (xmlChar *) "brick_running", "%s", buffer);
+
+ XML_RET_CHECK_AND_GOTO (ret, out);
snprintf (key, sizeof (key), "%s.brick%d.pid", keyprefix, i);
ret = dict_get_int32 (dict, key, &pid);
if (ret) {
- gf_log ("cli", GF_LOG_ERROR, "Unable to get pid");
- goto out;
- }
+ gf_log ("cli", GF_LOG_INFO, "Unable to get pid");
+ ret = xmlTextWriterWriteFormatElement (writer,
+ (xmlChar *) "pid", "N/A");
+ } else
+ ret = xmlTextWriterWriteFormatElement (writer,
+ (xmlChar *) "pid", "%d", pid);
- ret = xmlTextWriterWriteFormatElement (writer,
- (xmlChar *) "pid", "%d", pid);
XML_RET_CHECK_AND_GOTO (ret, out);
snprintf (key, sizeof (key), "%s.brick%d.data", keyprefix, i);
@@ -5125,28 +5139,29 @@ cli_xml_snapshot_volume_status (xmlTextWriterPtr writer, xmlDocPtr doc,
if (ret) {
gf_log ("cli", GF_LOG_ERROR,
"Unable to get Data Percent");
- goto out;
- }
+ ret = xmlTextWriterWriteFormatElement (writer,
+ (xmlChar *) "data_percentage", "N/A");
+ } else
+ ret = xmlTextWriterWriteFormatElement (writer,
+ (xmlChar *) "data_percentage", "%s", buffer);
- ret = xmlTextWriterWriteFormatElement (writer,
- (xmlChar *) "lvUsage",
- "%s", buffer);
XML_RET_CHECK_AND_GOTO (ret, out);
snprintf (key, sizeof (key), "%s.brick%d.lvsize",
keyprefix, i);
ret = dict_get_str (dict, key, &buffer);
if (ret) {
- gf_log ("cli", GF_LOG_INFO, "Unable to get LV Size");
- goto out;
- }
+ gf_log ("cli", GF_LOG_ERROR, "Unable to get LV Size");
+ ret = xmlTextWriterWriteFormatElement (writer,
+ (xmlChar *) "lvSize", "N/A");
+ } else {
+ /* Truncate any newline character */
+ buffer = strtok (buffer, "\n");
- /* Truncate any newline character */
- buffer = strtok (buffer, "\n");
+ ret = xmlTextWriterWriteFormatElement (writer,
+ (xmlChar *) "lvSize", "%s", buffer);
+ }
- ret = xmlTextWriterWriteFormatElement (writer,
- (xmlChar *) "lvSize",
- "%s", buffer);
XML_RET_CHECK_AND_GOTO (ret, out);
/* </brick> */
@@ -5284,7 +5299,8 @@ cli_xml_snapshot_status (xmlTextWriterPtr writer, xmlDocPtr doc, dict_t *dict)
goto out;
}
- if (GF_SNAP_STATUS_TYPE_SNAP == status_cmd) {
+ if ((GF_SNAP_STATUS_TYPE_SNAP == status_cmd) ||
+ (GF_SNAP_STATUS_TYPE_ITER == status_cmd)) {
snapcount = 1;
} else {
ret = dict_get_int32 (dict, "status.snapcount", &snapcount);
@@ -6041,7 +6057,7 @@ cli_xml_snapshot_begin_composite_op (cli_local_t *local)
goto out;
}
- if (cmd == GF_SNAP_STATUS_TYPE_SNAP ||
+ if (cmd == GF_SNAP_STATUS_TYPE_ITER ||
cmd == GF_SNAP_DELETE_TYPE_SNAP){
ret = 0;
goto out;
@@ -6086,7 +6102,7 @@ cli_xml_snapshot_end_composite_op (cli_local_t *local)
goto out;
}
- if (cmd == GF_SNAP_STATUS_TYPE_SNAP ||
+ if (cmd == GF_SNAP_STATUS_TYPE_ITER ||
cmd == GF_SNAP_DELETE_TYPE_SNAP){
ret = 0;
goto out;