-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2024-11-11: TR-383 Amendment 8 Common YANG Modules for Access Networks
- Loading branch information
BBF Tools
committed
Nov 12, 2024
1 parent
eaac2c3
commit c66a929
Showing
37 changed files
with
2,850 additions
and
662 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,79 +1,144 @@ | ||
#!/bin/sh | ||
#!/bin/bash | ||
# | ||
# BBF check script (loosely) based on the IETF one. | ||
# | ||
# Invoke without arguments in a YangModels/yang checkout | ||
# Invoke without arguments from the top level of a YangModels/yang checkout. | ||
# | ||
# Or specifying the pyang version and enabling debug output | ||
# | ||
# PYTHONPATH=$MYROOT/pyang/default standard/bbf/check.sh '' '' $MYROOT/pyang/default/bin/pyang true | ||
# Invoke with the -h option to see command-line options. | ||
|
||
# remember the current directory | ||
cwd=`pwd` | ||
|
||
# experimental YANG | ||
exp_dir="$cwd/experimental" | ||
|
||
# default arguments | ||
# process arguments | ||
bbf_dir="$cwd/standard/bbf" | ||
before_dir="$cwd/experimental" | ||
ietf_dir="$cwd/standard/ietf" | ||
after_dir="" | ||
ieee_dir="$cwd/standard/ieee" | ||
pyang=pyang | ||
pyang="pyang" | ||
debug="" | ||
dryrun="" | ||
while getopts "b:e:i:E:I:p:dnh" option; do | ||
case "$option" in | ||
b) bbf_dir="$OPTARG";; | ||
e) before_dir="$OPTARG";; | ||
i) ietf_dir="$OPTARG";; | ||
E) after_dir="$OPTARG";; | ||
I) ieee_dir="$OPTARG";; | ||
p) pyang="$OPTARG";; | ||
d) debug="true";; | ||
n) dryrun="true";; | ||
h|*) cat <<END | ||
Usage: $0 | ||
-b BBF-DIR # BBF YANG directory (default "$bbf_dir") | ||
-e BEFORE-DIR # IETF experimental YANG directory (default "$before_dir") | ||
-i IETF-DIR # IETF published YANG directory (default "$ietf_dir") | ||
-E AFTER-DIR # IETF experimental YANG directory (default "$after_dir") | ||
-I IEEE-DIR # IEEE YANG directory (default "$ieee_dir") | ||
-p PYANG # pyang command (default "$pyang") | ||
-d # whether to generate debug output (default NO) | ||
-n # whether to perform a try run (default NO) | ||
-h # output this help | ||
Run pyang to check YANG files in BBF-DIR. The pyang path is set to BBF-DIR, | ||
BEFORE-DIR, IETF-DIR, AFTER-DIR, IEEE-DIR, so IETF experimental YANG can be | ||
searched before or after IETF published YANG (or both before and after). | ||
END | ||
exit 0 | ||
;; | ||
esac | ||
done | ||
|
||
# step over options | ||
shift $(($OPTIND - 1)) | ||
|
||
# $1 overrides bbf_dir | ||
# process remaining command line arguments (backwards compatibility) | ||
if [ -n "$1" ]; then | ||
bbf_dir="$1" | ||
echo "warning: should use -b to override BBF-DIR" | ||
bbf_dir="$1" | ||
fi | ||
|
||
# $2 overrides ietf_dir | ||
if [ -n "$2" ]; then | ||
ietf_dir="$2" | ||
echo "warning: should use -i to override IETF-DIR" | ||
ietf_dir="$2" | ||
fi | ||
|
||
# $3 overrides pyang (may also need to set PYTHONPATH) | ||
if [ -n "$3" ]; then | ||
pyang="$3" | ||
echo "warning: should use -p to override PYANG" | ||
pyang="$3" | ||
fi | ||
if [ -n "$4" ]; then | ||
echo "warning: should use -d to set DEBUG" | ||
debug="$4" | ||
fi | ||
|
||
# $4 if non-empty enables debug output | ||
debug="$4" | ||
|
||
# ieee_dir can't currently be overridden | ||
# BBF-DIR and IETF-DIR must exist | ||
if [ ! -d "$bbf_dir" ]; then | ||
echo "$bbf_dir doesn't exist" | ||
exit 1 | ||
fi | ||
if [ ! -d "$ietf_dir" ]; then | ||
echo "$ietf_dir doesn't exist" | ||
exit 1 | ||
fi | ||
|
||
# get the BBF-DIR absolute path, and collect YANG to be processed | ||
cd $bbf_dir | ||
to_check=`find standard draft -mindepth 1 -maxdepth 1 -type d` | ||
bbf_dir=`pwd` | ||
paths="standard" | ||
[ -d draft ] && paths+=" draft" | ||
to_check=`find $paths -mindepth 1 -maxdepth 1 -type d` | ||
|
||
# get the IETF-DIR absolute path | ||
cd $cwd | ||
cd $ietf_dir | ||
ietf_dir=`pwd` | ||
|
||
# return to the starting directory | ||
cd $cwd | ||
|
||
pyang_flags="--max-line-length=70 --lint --lint-modulename-prefix=bbf --lint-namespace-prefix=urn:bbf:yang: --lint-ensure-hyphenated-name --verbose --path=$bbf_dir --path=$exp_dir --path=$ietf_dir --path=$ieee_dir" | ||
# form the pyang flags | ||
pyang_flags="--max-line-length=70 --lint --lint-modulename-prefix=bbf --lint-namespace-prefix=urn:bbf:yang: --lint-ensure-hyphenated-name" | ||
|
||
checkDir () { | ||
for dir in $bbf_dir $before_dir $ietf_dir $after_dir $ieee_dir; do | ||
if [ ! -r $dir ]; then | ||
2>&1 echo "warning: $dir doesn't exist" | ||
else | ||
pyang_flags+=" --path=$dir" | ||
fi | ||
done | ||
|
||
if [ -n "$debug" ]; then | ||
pyang_flags+=" --verbose" | ||
fi | ||
|
||
# helper function for checking YANG files in a directory | ||
check_dir () { | ||
local dir="$bbf_dir/$1" | ||
printf "\n" | ||
echo Checking YANG files in $dir | ||
exit_status="" | ||
for f in `find $dir -name '*.yang'`; do | ||
if [ -n "$debug" ]; then | ||
echo Checking $f | ||
fi | ||
errors=`$pyang $pyang_flags $f 2>&1 | grep "error:"` | ||
if [ -n "$errors" ]; then | ||
echo Errors in $f | ||
printf "\n $errors \n" | ||
exit_status="failed!" | ||
echo "Checking $f" | ||
fi | ||
if [ -n "$dryrun" ]; then | ||
echo "$pyang $pyang_flags" | ||
else | ||
errors=`$pyang $pyang_flags $f 2>&1 | grep "error:"` | ||
if [ -n "$errors" ]; then | ||
echo "Errors in $f" | ||
printf "\n $errors \n" | ||
exit_status="failed!" | ||
fi | ||
fi | ||
done | ||
if [ -n "$exit_status" ]; then | ||
exit 1 | ||
fi | ||
} | ||
|
||
echo Checking modules with pyang command: | ||
echo "Checking modules with pyang command:" | ||
printf "\nPYTHONPATH=$PYTHONPATH $pyang $pyang_flags MODULE\n" | ||
|
||
for d in $to_check; do | ||
checkDir $d | ||
check_dir "$d" | ||
done |
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Oops, something went wrong.