summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorRoman Rakus <rrakus@redhat.com>2012-11-07 15:26:38 +0100
committerRoman Rakus <rrakus@redhat.com>2012-11-07 15:26:38 +0100
commitff3d4f0da089a9012b980336ce416d66c52c31b1 (patch)
treed94814fa12fea79ab2fb527112379a9646e7f0a4 /tools
parentfcba47aa00263ffd0e6372d7de4ce20b04132559 (diff)
downloadopenlmi-providers-ff3d4f0da089a9012b980336ce416d66c52c31b1.tar.gz
openlmi-providers-ff3d4f0da089a9012b980336ce416d66c52c31b1.tar.xz
openlmi-providers-ff3d4f0da089a9012b980336ce416d66c52c31b1.zip
mof2wiki script
Script allows to create wiki table of classes defined in mof file. Signed-off-by: Roman Rakus <rrakus@redhat.com>
Diffstat (limited to 'tools')
-rwxr-xr-xtools/mof2wiki.sh41
1 files changed, 41 insertions, 0 deletions
diff --git a/tools/mof2wiki.sh b/tools/mof2wiki.sh
new file mode 100755
index 0000000..bbd9b0f
--- /dev/null
+++ b/tools/mof2wiki.sh
@@ -0,0 +1,41 @@
+#!/bin/bash
+
+schemasurl='http://schemas.dmtf.org/wbem/cim-html/2.31.0/'
+
+usage()
+{
+ printf "$0 usage:\n"
+ printf "$0 file\n"
+ printf "$0 will read file and show which classes are defined in mof file "
+ printf "and print in pretty format usable easy in wiki\n"
+}
+
+die()
+{
+ printf "%s\n" "$@"
+ exit 1
+} >&2
+
+(( $# > 0 )) || die "Invalid number of parameters"
+
+if [[ "$1" == "-h" || "$1" == "--help" ]]; then
+ usage
+ exit 0
+fi
+
+moffile="$1"
+
+[[ -r "$moffile" ]] || die "$moffile is not readable"
+
+export LC_ALL=C
+
+printf "||= Defined class name =||= Inherited from =||\n"
+
+while IFS= read line; do
+ if [[ $line =~ ^class[[:blank:]]*([[:alnum:]_]*)":"[[:blank:]]*([[:alnum:]_]*) ]]; then
+ newclass=${BASH_REMATCH[1]}
+ derived=${BASH_REMATCH[2]}
+ printf "|| [wiki:%s %s] || [$schemasurl%s.html %s] ||\n" "$newclass" "$newclass" "$derived" "$derived"
+ fi
+done < "$moffile"
+