Skip to contentSkip to conversation

master - libdm: report: implement DM_REPORT_GROUP_JSON for JSON report output

PATCH Peter Rajnoha 1 participant 1 message Jun 20, 2016

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=094fce37765964a9c3b32d1473e75c7d121eace1
Commit:        094fce37765964a9c3b32d1473e75c7d121eace1
Parent:        230b7ff0f6c844bde2185baa9db63961baefb3d0
Author:        Peter Rajnoha <[email protected]>
AuthorDate:    Mon May 2 14:21:40 2016 +0200
Committer:     Peter Rajnoha <[email protected]>
CommitterDate: Mon Jun 20 10:42:26 2016 +0200

libdm: report: implement DM_REPORT_GROUP_JSON for JSON report output

This patch introduces DM_REPORT_GROUP_JSON report group type. When using this group type and when pushing a report to such a group, these flags are automatically unset:

DM_REPORT_OUTPUT_ALIGNED
DM_REPORT_OUTPUT_HEADINGS
DM_REPORT_OUTPUT_COLUMNS_AS_ROWS

...and this flag is set:

DM_REPORT_OUTPUT_BUFFERED

The whole group is encapsulated in { } for the outermost JSON object and then each report is reported on output as array of objects where each object is the row from report:

  {
     "report_name1": [
         {field1="value", field2="value",...},
         {field1="value", field2="value",...}
         ...
     ],
     "report_name2": [
         {field1="value", field2="value",...},
         {field1="value", field2="value",...}
         ...
     ]
     ...
  }
---
 WHATS_NEW_DM         |    1 +
 libdm/libdevmapper.h |    3 +-
 libdm/libdm-report.c |  241 +++++++++++++++++++++++++++++++++++++++++++++++---
 3 files changed, 233 insertions(+), 12 deletions(-)
WHATS_NEW_DM +1 -0
index 9e1985a..da36f49 100644
@@ -1,5 +1,6 @@
 Version 1.02.128 -
 =================================
+  Introduce DM_REPORT_GROUP_JSON for report group with JSON output format.
   Introduce DM_REPORT_GROUP_BASIC for report group with basic report output.
   Introduce DM_REPORT_GROUP_SINGLE for report group having single report only.
   Add dm_report_group_{create,push,pop,destroy} to support report grouping.
libdm/libdevmapper.h +2 -1
index fbe4322..cad79dd 100644
@@ -2710,7 +2710,8 @@ struct dm_report_group;
 
 typedef enum {
 	DM_REPORT_GROUP_SINGLE,
-	DM_REPORT_GROUP_BASIC
+	DM_REPORT_GROUP_BASIC,
+	DM_REPORT_GROUP_JSON
 } dm_report_group_type_t;
 
 struct dm_report_group *dm_report_group_create(dm_report_group_type_t type, void *data);
libdm/libdm-report.c +230 -11

360 lines not on this page · raw message