summaryrefslogtreecommitdiffstats
path: root/ext/solus/lib/parse-return-data
diff options
context:
space:
mode:
authortv <tv@nomic.retiolum>2013-01-30 13:59:28 +0100
committertv <tv@nomic.retiolum>2013-01-30 13:59:28 +0100
commit609dd2e9e89c047399ab2e554e3411df7e6e2676 (patch)
treea2d0337e4843f3c52f4a96885be45b6b36d4f4ca /ext/solus/lib/parse-return-data
parent695a7acf30d0f6be1191a162fe147d4810210c52 (diff)
ext solus client: initial commit to access the SolusVM Client API
Diffstat (limited to 'ext/solus/lib/parse-return-data')
-rwxr-xr-xext/solus/lib/parse-return-data20
1 files changed, 20 insertions, 0 deletions
diff --git a/ext/solus/lib/parse-return-data b/ext/solus/lib/parse-return-data
new file mode 100755
index 00000000..85219727
--- /dev/null
+++ b/ext/solus/lib/parse-return-data
@@ -0,0 +1,20 @@
+#! /bin/sh
+set -euf
+sed '
+ # transform "XML" into lines {key}<tab>{value}-lines
+ s|</[^>]*>|\n|g
+ s|<\([^>]*\)>|\1\t|g
+' |
+sed '
+ # transform ipaddr list into multiple ipaddr_[46]<tab>{ipaddr}-lines
+ /^ipaddr\t/{
+ s|,|\nipaddr\t|g
+ s/\t\([0-9]*[.]\)/_4&/g
+ s/\t\([0-9]*[:]\)/_6&/g
+ }
+ # parse CSVs into multiple lines with proper labels
+ s:^\(hdd\|mem\|bw\)\t\([^,]*\),\([^,]*\),\([^,]*\),\([^,]*\)$:\1_total\t\2\
+\1_used\t\3\
+\1_free\t\4\
+\1_percentused\t\5:
+'