blob: 21762d764091e8b8b59c0427b5559e69344007fc [file] [log] [blame]
Andrea Campanella423962b2016-02-26 13:09:22 -08001#!/bin/bash
2# -----------------------------------------------------------------------------
3# ONOS YANG to XML skeleton convert via pyang
4# -----------------------------------------------------------------------------
5
6[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1
7. $ONOS_ROOT/tools/build/envDefaults
8
9aux=/tmp/pyangversion
10pyang -v $cmd > $aux
11errorstring="Pyang no installed, please download and intall from https://github.com/mbj4668/pyang"
12cat $aux
13grep -q "pyang: command not found" $aux && echo $errorString && exit 1
14
15grep -q "pyang 1" $aux
16
17if ! [ -e "$1" ]; then
18 echo "$1 input directory not found" >&2
19 exit 1
20fi
21if ! [ -d "$1" ]; then
22 echo "$1 not a directory for output" >&2
23 exit 1
24fi
25cd $1
26find . -name '*.yang' | while read file; do f=$(basename $file ".yang"); \
27directory=$ONOS_ROOT/drivers/utilities/src/main/resources/${PWD##*/}; \
28if [ ! -d "$directory" ]; then
29 mkdir $directory; \
30fi
31echo $directory/$f.xml
32pyang -f sample-xml-skeleton $f.yang > $directory/$f.xml; done
33exit 0