3 # Copyright (c) 2019 Lumina Networks, Inc. and others. All rights reserved.
5 # This program and the accompanying materials are made available under the
6 # terms of the Eclipse Public License v1.0 which accompanies this distribution,
7 # and is available at http://www.eclipse.org/legal/epl-v10.html
10 # This script checks the YANG modules collected by the extract_modules.sh
11 # script. The check is done by the pyang tool and an error text file is
12 # generated for every opendaylight project so proper actions can be taken
17 OUTPUT="$BIN_DIR/../opendaylight-models"
19 # Exit if yang module folder is not found
20 [ ! -d "$OUTPUT" ] && echo "ERROR: no modules found, run extract_module.sh first" && exit 1
22 # Assemble the pyang command options
24 PROJECTS=`ls -d $OUTPUT/*`
25 for proj in $PROJECTS; do
27 flags="$flags -p $OUTPUT/$proj"
30 # Run pyang on opendaylight yang modules and generate error file per project
31 for proj in $PROJECTS; do
33 [ -f "$OUTPUT/$proj/errors.txt" ] && rm $OUTPUT/$proj/errors.txt
34 touch $OUTPUT/$proj/errors.txt
35 YANGS=`find $OUTPUT/$proj -type f -name '*.yang'`
36 for yang in $YANGS; do
37 less $yang | grep -q namespace.*opendaylight &&
38 echo $yang && pyang $flags $yang 2>> $OUTPUT/$proj/errors.txt
40 echo "Write error file: $OUTPUT/$proj/errors.txt"