YANG keywords "action" and "belongs-to" implemented by syntactically by parser (but not proper semantics).
This commit is contained in:
parent
270bf78e1f
commit
366cf041bd
8 changed files with 41 additions and 9 deletions
|
|
@ -72,6 +72,7 @@
|
||||||
example backend_main() and others if you need details.
|
example backend_main() and others if you need details.
|
||||||
|
|
||||||
### Minor changes
|
### Minor changes
|
||||||
|
* YANG keywords "action" and "belongs-to" implemented by syntactically by parser (but not proper semantics).
|
||||||
* clixon-config YAML file has new revision: 2018-10-21.
|
* clixon-config YAML file has new revision: 2018-10-21.
|
||||||
* Allow new lines in CLI prompts
|
* Allow new lines in CLI prompts
|
||||||
* uri_percent_encode() and xml_chardata_encode() changed to use stdarg parameters
|
* uri_percent_encode() and xml_chardata_encode() changed to use stdarg parameters
|
||||||
|
|
|
||||||
|
|
@ -68,12 +68,12 @@ depend:
|
||||||
install:
|
install:
|
||||||
for i in $(SUBDIRS) doc; \
|
for i in $(SUBDIRS) doc; \
|
||||||
do (cd $$i; $(MAKE) $(MFLAGS) $@)||exit 1; done; \
|
do (cd $$i; $(MAKE) $(MFLAGS) $@)||exit 1; done; \
|
||||||
echo "Install for compilation by: make install-include"
|
@echo "Install for compilation by: make install-include"
|
||||||
|
|
||||||
install-include:
|
install-include:
|
||||||
for i in $(SUBDIRS) doc; \
|
for i in $(SUBDIRS) doc; \
|
||||||
do (cd $$i && $(MAKE) $(MFLAGS) $@)||exit 1; done; \
|
do (cd $$i && $(MAKE) $(MFLAGS) $@)||exit 1; done; \
|
||||||
echo "To install example app: cd example; make; make install"
|
@echo "To install example app: cd example; make; make install"
|
||||||
|
|
||||||
uninstall:
|
uninstall:
|
||||||
for i in $(SUBDIRS) doc example docker; \
|
for i in $(SUBDIRS) doc example docker; \
|
||||||
|
|
|
||||||
|
|
@ -1738,7 +1738,7 @@ yang_parse_str(char *str,
|
||||||
/*! Parse yang spec from an open file descriptor
|
/*! Parse yang spec from an open file descriptor
|
||||||
* @param[in] fd File descriptor containing the YANG file as ASCII characters
|
* @param[in] fd File descriptor containing the YANG file as ASCII characters
|
||||||
* @param[in] name For debug, eg filename
|
* @param[in] name For debug, eg filename
|
||||||
* @param[in] ysp Yang specification. Should ave been created by caller using yspec_new
|
* @param[in] ysp Yang specification. Should have been created by caller using yspec_new
|
||||||
* @retval ymod Top-level yang (sub)module
|
* @retval ymod Top-level yang (sub)module
|
||||||
* @retval NULL Error
|
* @retval NULL Error
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -418,6 +418,7 @@ submodule_header_stmts : submodule_header_stmts submodule_header_stmt
|
||||||
|
|
||||||
submodule_header_stmt : yang_version_stmt
|
submodule_header_stmt : yang_version_stmt
|
||||||
{ clicon_debug(2,"submodule-header-stmt -> yang-version-stmt"); }
|
{ clicon_debug(2,"submodule-header-stmt -> yang-version-stmt"); }
|
||||||
|
| belongs_to_stmt { clicon_debug(2,"submodule-header-stmt -> belongs-to-stmt"); }
|
||||||
;
|
;
|
||||||
|
|
||||||
/* linkage */
|
/* linkage */
|
||||||
|
|
@ -1359,6 +1360,15 @@ prefix_stmt : K_PREFIX string ';' /* XXX prefix-arg-str */
|
||||||
clicon_debug(2,"prefix-stmt -> PREFIX string ;");}
|
clicon_debug(2,"prefix-stmt -> PREFIX string ;");}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
belongs_to_stmt : K_BELONGS_TO id_arg_str ';'
|
||||||
|
|
||||||
|
{ if (ysp_add(_yy, Y_BELONGS_TO, $2, NULL)== NULL) _YYERROR("100");
|
||||||
|
clicon_debug(2,"belongs-to-stmt -> BELONGS-TO id-arg-str ;");}
|
||||||
|
| K_BELONGS_TO id_arg_str '{' prefix_stmt '}'
|
||||||
|
{ if (ysp_add(_yy, Y_BELONGS_TO, $2, NULL)== NULL) _YYERROR("98");
|
||||||
|
clicon_debug(2,"belongs-to-stmt -> BELONGS-TO id-arg-str { prefix-stmt } ");}
|
||||||
|
;
|
||||||
|
|
||||||
description_stmt: K_DESCRIPTION string ';'
|
description_stmt: K_DESCRIPTION string ';'
|
||||||
{ if (ysp_add(_yy, Y_DESCRIPTION, $2, NULL)== NULL) _YYERROR("101");
|
{ if (ysp_add(_yy, Y_DESCRIPTION, $2, NULL)== NULL) _YYERROR("101");
|
||||||
clicon_debug(2,"description-stmt -> DESCRIPTION string ;");}
|
clicon_debug(2,"description-stmt -> DESCRIPTION string ;");}
|
||||||
|
|
|
||||||
|
|
@ -54,10 +54,12 @@ cat <<EOF > $cfg
|
||||||
<CLICON_STREAM_PATH>streams</CLICON_STREAM_PATH>
|
<CLICON_STREAM_PATH>streams</CLICON_STREAM_PATH>
|
||||||
<CLICON_STREAM_URL>https://localhost</CLICON_STREAM_URL>
|
<CLICON_STREAM_URL>https://localhost</CLICON_STREAM_URL>
|
||||||
<CLICON_STREAM_RETENTION>60</CLICON_STREAM_RETENTION>
|
<CLICON_STREAM_RETENTION>60</CLICON_STREAM_RETENTION>
|
||||||
<CLICON_STREAM_PUB>http://localhost/pub</CLICON_STREAM_PUB>
|
|
||||||
</config>
|
</config>
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
# For nchan testing add this line to above config
|
||||||
|
# <CLICON_STREAM_PUB>http://localhost/pub</CLICON_STREAM_PUB>
|
||||||
|
|
||||||
# RFC5277 NETCONF Event Notifications
|
# RFC5277 NETCONF Event Notifications
|
||||||
# using reportingEntity (rfc5277) not reporting-entity (rfc8040)
|
# using reportingEntity (rfc5277) not reporting-entity (rfc8040)
|
||||||
cat <<EOF > $fyang
|
cat <<EOF > $fyang
|
||||||
|
|
@ -261,6 +263,7 @@ fi
|
||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
# NCHAN Need manual testing
|
# NCHAN Need manual testing
|
||||||
echo "Nchan streams requires manual testing"
|
echo "Nchan streams requires manual testing"
|
||||||
|
echo "Add <CLICON_STREAM_PUB>http://localhost/pub</CLICON_STREAM_PUB> to config"
|
||||||
echo "Eg: curl -H \"Accept: text/event-stream\" -s -X GET http://localhost/sub/EXAMPLE"
|
echo "Eg: curl -H \"Accept: text/event-stream\" -s -X GET http://localhost/sub/EXAMPLE"
|
||||||
|
|
||||||
#-----------------
|
#-----------------
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Test: YANG parser tests
|
# Test: YANG parser tests
|
||||||
|
# First an example yang, second all openconfig yangs
|
||||||
#PROG="valgrind --leak-check=full --show-leak-kinds=all ../util/clixon_util_yang"
|
#PROG="valgrind --leak-check=full --show-leak-kinds=all ../util/clixon_util_yang"
|
||||||
PROG=../util/clixon_util_yang
|
PROG=../util/clixon_util_yang
|
||||||
|
OPENCONFIG=~/syssrc/openconfig
|
||||||
|
|
||||||
# include err() and new() functions and creates $dir
|
# include err() and new() functions and creates $dir
|
||||||
. ./lib.sh
|
. ./lib.sh
|
||||||
|
|
@ -13,13 +15,28 @@ module test{
|
||||||
description "Example from RFC 6020";
|
description "Example from RFC 6020";
|
||||||
argument "name";
|
argument "name";
|
||||||
}
|
}
|
||||||
ex:not-defined ARGUMENT;;
|
ex:not-defined ARGUMENT;
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
|
|
||||||
new "yang parse"
|
new "yang parse"
|
||||||
expecteof "$PROG" 0 "$YANG" "^$YANG$"
|
#expecteof "$PROG" 0 "$YANG" "^$YANG$"
|
||||||
|
|
||||||
|
if [ ! -d $OPENCONFIG ]; then
|
||||||
|
echo "$OPENCONFIG not found. Do git clone https://github.com/openconfig/public and point DIR to it to run these tests"
|
||||||
|
rm -rf $dir
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Openconfig
|
||||||
|
new "Openconfig"
|
||||||
|
files=$(find $OPENCONFIG -name "*.yang")
|
||||||
|
for f in $files; do
|
||||||
|
new "$f"
|
||||||
|
YANG=$(cat $f)
|
||||||
|
# expecteof "$PROG" 0 "$YANG" "module"
|
||||||
|
done
|
||||||
rm -rf $dir
|
rm -rf $dir
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ APPSRC += clixon_util_xpath.c
|
||||||
APPS = $(APPSRC:.c=)
|
APPS = $(APPSRC:.c=)
|
||||||
|
|
||||||
all: $(APPS)
|
all: $(APPS)
|
||||||
echo "You may want to make clixon_util_stream separately (curl dependency)"
|
@echo "You may want to make clixon_util_stream separately (curl dependency)"
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f $(APPS) *.core
|
rm -f $(APPS) *.core
|
||||||
|
|
|
||||||
|
|
@ -78,10 +78,11 @@ main(int argc, char **argv)
|
||||||
usage(argv[0]);
|
usage(argv[0]);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
clicon_log_init("clixon_util_yang", LOG_INFO, CLICON_LOG_STDERR);
|
||||||
if ((yspec = yspec_new()) == NULL)
|
if ((yspec = yspec_new()) == NULL)
|
||||||
goto done;
|
goto done;
|
||||||
if (yang_parse_file(0, "yang test", yspec) < 0){
|
if (yang_parse_file(0, "yang test", yspec) == NULL){
|
||||||
fprintf(stderr, "xml parse error %s\n", clicon_err_reason);
|
fprintf(stderr, "yang parse error %s\n", clicon_err_reason);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
yang_print(stdout, (yang_node*)yspec);
|
yang_print(stdout, (yang_node*)yspec);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue