Skip to content

Commit

Permalink
Yang files reorganized into three classes: clixon, mandatory, optional
Browse files Browse the repository at this point in the history
  • Loading branch information
olofhagsand committed Nov 26, 2019
1 parent 9575d10 commit 0d22a8b
Show file tree
Hide file tree
Showing 29 changed files with 166 additions and 462 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Expand Up @@ -3,7 +3,6 @@ language: c
branches:
only:
- master
- develop
before_script:
- sudo apt-get install -y libfcgi-dev
- ./test/travis/before_script.sh
Expand Down
6 changes: 5 additions & 1 deletion CHANGELOG.md
@@ -1,6 +1,6 @@
# Clixon Changelog

## 4.3.0 (Expected: ~December 2019)
## 4.3.0 (Expected: December 2019)

### Minor changes
* Added "canonical" global namespace context: `nsctx_global`
Expand All @@ -12,6 +12,10 @@
* Fixed multi-namespace for augmented state which was not covered in 4.2.0.

### API changes on existing features (you may need to change your code)
* Yang files reorganized into three classes: clixon, mandatory, optional (previous "standard" split into mandatory and optional).
* Clixon and mandatory yang spec are always installed
* Optional yang files are loaded only if configured with `--enable-optyangs` (flipped lofgic and changed from `disable-stdyangs`). NOTE: you must do this to run examples and tests.
* Optional yang files can be installed in a separate dir with `--with-opt-yang-installdir=DIR` (renamed from `with-std-yang-installdir`)
* The multi-namespace augment state may rearrange the XML namespace attributes.
* Main example yang changed to incorporate augmented state, new revision is 2019-11-15.

Expand Down
9 changes: 9 additions & 0 deletions apps/backend/backend_plugin.c
Expand Up @@ -149,6 +149,15 @@ clixon_plugin_statedata(clicon_handle h,
goto done;
goto fail;
}
#if 1
if (debug){
cbuf *ccc=cbuf_new();
if (clicon_xml2cbuf(ccc, x, 0, 0, -1) < 0)
goto done;
clicon_debug(1, "%s MERGE: %s", __FUNCTION__, cbuf_get(ccc));
cbuf_free(ccc);
}
#endif
if ((ret = netconf_trymerge(x, yspec, xret)) < 0)
goto done;
if (ret == 0)
Expand Down
55 changes: 28 additions & 27 deletions configure
Expand Up @@ -621,7 +621,7 @@ ac_includes_default="\

ac_subst_vars='LTLIBOBJS
LIBOBJS
STD_YANG_INSTALLDIR
OPT_YANG_INSTALLDIR
YANG_INSTALLDIR
EGREP
GREP
Expand All @@ -633,7 +633,7 @@ YACC
CPP
wwwuser
wwwdir
enable_stdyangs
enable_optyangs
with_restconf
SH_SUFFIX
CLIXON_DEFAULT_CONFIG
Expand Down Expand Up @@ -711,14 +711,14 @@ ac_user_opts='
enable_option_checking
enable_debug
with_cligen
enable_stdyangs
enable_optyangs
enable_publish
with_restconf
with_wwwuser
with_configfile
with_libxml2
with_yang_installdir
with_std_yang_installdir
with_opt_yang_installdir
'
ac_precious_vars='build_alias
host_alias
Expand Down Expand Up @@ -1355,8 +1355,8 @@ Optional Features:
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--enable-debug Build with debug symbols, default: no
--disable-stdyangs Include standard yang files in clixon install,
default: yes
--enable-optyangs Include standard yang files in clixon install,
default: no
--enable-publish Enable publish of notification streams using SSE and
curl
Expand All @@ -1369,7 +1369,7 @@ Optional Packages:
--with-configfile=FILE set default path to config file
--with-libxml2 use gnome/libxml2 regex engine
--with-yang-installdir=DIR Install Clixon yang files here (default: ${prefix}/share/clixon)
--with-std-yang-installdir=DIR Install standard yang files here (default: ${prefix}/share/clixon)
--with-opt-yang-installdir=DIR Install standard yang files here (default: ${prefix}/share/clixon)
Some influential environment variables:
CC C compiler command
Expand Down Expand Up @@ -4247,22 +4247,22 @@ fi
# Disable/enable standard Yang files.
# If enable - include yang/standard/*.yang in clixon yang files (default)
# If disable - get standard yang files from elsewhere
# Check whether --enable-stdyangs was given.
if test "${enable_stdyangs+set}" = set; then :
enableval=$enable_stdyangs;
# Check whether --enable-optyangs was given.
if test "${enable_optyangs+set}" = set; then :
enableval=$enable_optyangs;
if test "$enableval" = no; then
enable_stdyangs=no
enable_optyangs=no
else
enable_stdyangs=yes
enable_optyangs=yes
fi

else
enable_stdyangs=yes
enable_optyangs=no
fi


{ $as_echo "$as_me:${as_lineno-$LINENO}: result: stdyangs is $enable_stdyangs" >&5
$as_echo "stdyangs is $enable_stdyangs" >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: optyangs is $enable_optyangs" >&5
$as_echo "optyangs is $enable_optyangs" >&6; }

# Experimental: Curl publish notification stream to eg Nginx nchan.
# Check whether --enable-publish was given.
Expand Down Expand Up @@ -4933,8 +4933,8 @@ $as_echo "Have getsockopt SO_PEERCRED" >&6; }
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext

# YANG_INSTALLDIR is where clixon installs the Clixon yang files
# (the files in in yang/clixon)
# YANG_INSTALLDIR is where clixon installs the Clixon yang files and mandatory
# standard yang files: the files in in yang/clixon and yang/mandatory
# Each application designer may need to place YANG_INSTALLDIR in their config:
# <CLICON_YANG_DIR>$YANG_INSTALLDIR</CLICON_YANG_DIR>

Expand All @@ -4950,22 +4950,22 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: Clixon yang files are installed in ${YANG_INSTALLDIR}" >&5
$as_echo "Clixon yang files are installed in ${YANG_INSTALLDIR}" >&6; }

# STD_YANG_INSTALLDIR is where clixon installs standard yang files
# (the files in in yang/standard)
# OPT_YANG_INSTALLDIR is where clixon installs standard yang files
# ( the files in in yang/standard)
# that Clixon needs to run (or examples rely on). These may be retreived from
# elsewhere (eg yangmodels repo)

# Check whether --with-std-yang-installdir was given.
if test "${with_std_yang_installdir+set}" = set; then :
withval=$with_std_yang_installdir; STD_YANG_INSTALLDIR="$withval"
# Check whether --with-opt-yang-installdir was given.
if test "${with_opt_yang_installdir+set}" = set; then :
withval=$with_opt_yang_installdir; OPT_YANG_INSTALLDIR="$withval"
else
STD_YANG_INSTALLDIR="${prefix}/share/clixon"
OPT_YANG_INSTALLDIR="${prefix}/share/clixon"

fi


{ $as_echo "$as_me:${as_lineno-$LINENO}: result: Standard yang files are installed in ${STD_YANG_INSTALLDIR}" >&5
$as_echo "Standard yang files are installed in ${STD_YANG_INSTALLDIR}" >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: Optional yang files are installed in ${OPT_YANG_INSTALLDIR} (if enabled)" >&5
$as_echo "Optional yang files are installed in ${OPT_YANG_INSTALLDIR} (if enabled)" >&6; }

# Default location for config file

Expand All @@ -4976,7 +4976,7 @@ _ACEOF



ac_config_files="$ac_config_files Makefile lib/Makefile lib/src/Makefile lib/clixon/Makefile apps/Makefile apps/cli/Makefile apps/backend/Makefile apps/netconf/Makefile apps/restconf/Makefile include/Makefile etc/Makefile etc/clixonrc example/Makefile example/main/Makefile example/hello/Makefile extras/rpm/Makefile docker/Makefile docker/main/Makefile docker/base/Makefile util/Makefile yang/Makefile yang/clixon/Makefile yang/standard/Makefile doc/Makefile test/Makefile"
ac_config_files="$ac_config_files Makefile lib/Makefile lib/src/Makefile lib/clixon/Makefile apps/Makefile apps/cli/Makefile apps/backend/Makefile apps/netconf/Makefile apps/restconf/Makefile include/Makefile etc/Makefile etc/clixonrc example/Makefile example/main/Makefile example/hello/Makefile extras/rpm/Makefile docker/Makefile docker/main/Makefile docker/base/Makefile util/Makefile yang/Makefile yang/clixon/Makefile yang/mandatory/Makefile yang/optional/Makefile doc/Makefile test/Makefile"

cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
Expand Down Expand Up @@ -5692,7 +5692,8 @@ do
"util/Makefile") CONFIG_FILES="$CONFIG_FILES util/Makefile" ;;
"yang/Makefile") CONFIG_FILES="$CONFIG_FILES yang/Makefile" ;;
"yang/clixon/Makefile") CONFIG_FILES="$CONFIG_FILES yang/clixon/Makefile" ;;
"yang/standard/Makefile") CONFIG_FILES="$CONFIG_FILES yang/standard/Makefile" ;;
"yang/mandatory/Makefile") CONFIG_FILES="$CONFIG_FILES yang/mandatory/Makefile" ;;
"yang/optional/Makefile") CONFIG_FILES="$CONFIG_FILES yang/optional/Makefile" ;;
"doc/Makefile") CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;;
"test/Makefile") CONFIG_FILES="$CONFIG_FILES test/Makefile" ;;
Expand Down
35 changes: 18 additions & 17 deletions configure.ac
Expand Up @@ -89,7 +89,7 @@ AC_SUBST(CLIXON_DEFAULT_CONFIG)
AC_SUBST(LIBS)
AC_SUBST(SH_SUFFIX)
AC_SUBST(with_restconf) # If yes, compile apps/restconf
AC_SUBST(enable_stdyangs)
AC_SUBST(enable_optyangs)
AC_SUBST(wwwdir,/www-data)
AC_SUBST(wwwuser,www-data)

Expand Down Expand Up @@ -151,16 +151,16 @@ fi
# Disable/enable standard Yang files.
# If enable - include yang/standard/*.yang in clixon yang files (default)
# If disable - get standard yang files from elsewhere
AC_ARG_ENABLE(stdyangs, AS_HELP_STRING([--disable-stdyangs],[Include standard yang files in clixon install, default: yes]),[
AC_ARG_ENABLE(optyangs, AS_HELP_STRING([--enable-optyangs],[Include optional yang files for examples and testing in clixon install, default: no]),[
if test "$enableval" = no; then
enable_stdyangs=no
enable_optyangs=no
else
enable_stdyangs=yes
enable_optyangs=yes
fi
],
[ enable_stdyangs=yes])
[ enable_optyangs=no])

AC_MSG_RESULT(stdyangs is $enable_stdyangs)
AC_MSG_RESULT(optyangs is $enable_optyangs)

# Experimental: Curl publish notification stream to eg Nginx nchan.
AC_ARG_ENABLE(publish, AS_HELP_STRING([--enable-publish],[Enable publish of notification streams using SSE and curl]),[
Expand Down Expand Up @@ -229,8 +229,8 @@ AC_CHECK_FUNCS(inet_aton sigaction sigvec strlcpy strsep strndup alphasort versi
AC_TRY_COMPILE([#include <sys/socket.h>], [getsockopt(1, SOL_SOCKET, SO_PEERCRED, 0, 0);], [AC_DEFINE(HAVE_SO_PEERCRED, 1, [Have getsockopt SO_PEERCRED])
AC_MSG_RESULT(Have getsockopt SO_PEERCRED)])

# YANG_INSTALLDIR is where clixon installs the Clixon yang files
# (the files in in yang/clixon)
# YANG_INSTALLDIR is where clixon installs the Clixon yang files and mandatory
# standard yang files: the files in in yang/clixon and yang/mandatory
# Each application designer may need to place YANG_INSTALLDIR in their config:
# <CLICON_YANG_DIR>$YANG_INSTALLDIR</CLICON_YANG_DIR>
AC_ARG_WITH(yang-installdir,
Expand All @@ -241,17 +241,17 @@ AC_ARG_WITH(yang-installdir,
AC_SUBST(YANG_INSTALLDIR)
AC_MSG_RESULT(Clixon yang files are installed in ${YANG_INSTALLDIR})

# STD_YANG_INSTALLDIR is where clixon installs standard yang files
# (the files in in yang/standard)
# OPT_YANG_INSTALLDIR is where clixon installs standard yang files
# ( the files in in yang/standard)
# that Clixon needs to run (or examples rely on). These may be retreived from
# elsewhere (eg yangmodels repo)
AC_ARG_WITH(std-yang-installdir,
[ --with-std-yang-installdir=DIR Install standard yang files here (default: ${prefix}/share/clixon) ],
[STD_YANG_INSTALLDIR="$withval"],
[STD_YANG_INSTALLDIR="${prefix}/share/clixon"]
AC_ARG_WITH(opt-yang-installdir,
[ --with-opt-yang-installdir=DIR Install optional yang files here (default: ${prefix}/share/clixon) ],
[OPT_YANG_INSTALLDIR="$withval"],
[OPT_YANG_INSTALLDIR="${prefix}/share/clixon"]
)
AC_SUBST(STD_YANG_INSTALLDIR)
AC_MSG_RESULT(Standard yang files are installed in ${STD_YANG_INSTALLDIR})
AC_SUBST(OPT_YANG_INSTALLDIR)
AC_MSG_RESULT(Optional yang files are installed in ${OPT_YANG_INSTALLDIR} (if enabled))

# Default location for config file
AC_DEFINE_UNQUOTED(CLIXON_DEFAULT_CONFIG,"${CLIXON_DEFAULT_CONFIG}",[Location for apps to find default config file])
Expand Down Expand Up @@ -280,7 +280,8 @@ AC_OUTPUT(Makefile
util/Makefile
yang/Makefile
yang/clixon/Makefile
yang/standard/Makefile
yang/mandatory/Makefile
yang/optional/Makefile
doc/Makefile
test/Makefile
)
Expand Down
6 changes: 4 additions & 2 deletions doc/FAQ.md
Expand Up @@ -77,12 +77,14 @@ One of the examples is [a hello world example](../example/hello). Please start w
## How do you build and install Clixon?
Clixon:
```
./configure;
./configure --enable-optyang;
make;
sudo make install;
sudo make install-include
```
The main example:
(note: optyang enable only if you need to run the main example, otherwise it is not necessary).

The main example:
```
cd example;
make;
Expand Down
2 changes: 1 addition & 1 deletion docker/main/Dockerfile
Expand Up @@ -62,7 +62,7 @@ RUN adduser -D -H www-data
RUN apk add --update nginx

# Configure, build and install clixon
RUN ./configure --prefix=/clixon/build --with-cligen=/clixon/build --with-wwwuser=www-data
RUN ./configure --prefix=/clixon/build --with-cligen=/clixon/build --with-wwwuser=www-data --enable-optyangs
RUN make
RUN make install
RUN make install-include
Expand Down
3 changes: 2 additions & 1 deletion example/main/README.md
Expand Up @@ -30,13 +30,14 @@ This directory contains a Clixon example used primarily for testing. It can be u
* `example_netconf.c` Netconf callback plugin
* `Makefile.in` Example makefile where plugins are built and installed


## Compile and run

Before you start,
* You must configure with: `--enable-optyangs` to run the main example.
* Make [group setup](../../doc/FAQ.md#do-i-need-to-setup-anything-important)
* Setup [restconf](../../doc/FAQ.md#how-do-i-use-restconf)


```
cd example
make && sudo make install
Expand Down
1 change: 0 additions & 1 deletion lib/src/clixon_xml.c
Expand Up @@ -151,7 +151,6 @@ static const map_str2int xsmap[] = {
{NULL, -1}
};


/*! Translate from xml type in enum form to string keyword
* @param[in] type Xml type
* @retval str String keyword
Expand Down
4 changes: 2 additions & 2 deletions lib/src/clixon_xml_sort.c
Expand Up @@ -617,8 +617,8 @@ xml_insert2(cxobj *xp,
xc = xml_child_i(xp, mid);
if ((yc = xml_spec(xc)) == NULL){
if (xml_type(xc) != CX_ELMNT)
clicon_err(OE_XML, 0, "No spec found %s (wrong xml type:%d)",
xml_name(xc), xml_type(xc));
clicon_err(OE_XML, 0, "No spec found %s (wrong xml type:%s)",
xml_name(xc), xml_type2str(xml_type(xc)));
else
clicon_err(OE_XML, 0, "No spec found %s", xml_name(xc));
goto done;
Expand Down
7 changes: 4 additions & 3 deletions yang/Makefile.in
Expand Up @@ -37,12 +37,13 @@ prefix = @prefix@
bindir = @bindir@
includedir = @includedir@
datarootdir = @datarootdir@
enable_stdyangs = @enable_stdyangs@
enable_optyangs = @enable_optyangs@

SUBDIRS = clixon
SUBDIRS += mandatory
# See configure.ac
ifeq ($(enable_stdyangs),yes)
SUBDIRS += standard
ifeq ($(enable_optyangs),yes)
SUBDIRS += optional
endif

.PHONY: all clean depend install $(SUBDIRS)
Expand Down
14 changes: 14 additions & 0 deletions yang/README.md
@@ -0,0 +1,14 @@
# Yang files

There are three classes of Yang files
* Clixon yang files.
* Mandatory: "Standard" yang files necessary for clixon lib/client/backend to run
* Optional: "Standard" yang files for examples and tests

The first two (clixon and mandatory) are always installed. If you want
to change where the are installed, configure with: `--with-yang-installdir=DIR`

The third (optional) is only installed if configure flag
`--enable-optyang` is set. Further, the optional yang files are
installed in `--with-opt-yang-installdir=DIR` if given, otherwise in
the same dir as the mandatory.
2 changes: 1 addition & 1 deletion yang/clixon/Makefile.in
Expand Up @@ -38,7 +38,7 @@ bindir = @bindir@
includedir = @includedir@
datarootdir = @datarootdir@

# See also STD_YANG_INSTALLDIR for the standard yang files
# See also OPT_YANG_INSTALLDIR for the standard yang files
YANG_INSTALLDIR = @YANG_INSTALLDIR@

YANGSPECS = clixon-config@2019-09-11.yang
Expand Down
2 changes: 1 addition & 1 deletion yang/clixon/clixon-config@2019-09-11.yang
Expand Up @@ -358,7 +358,7 @@ module clixon-config {
type string;
default "base";
description
"Startup CLI mode. This should match a CLICON_MODE set in
"Startup CLI mode. This should match a CLICON_MODE variable set in
one of the clispec files";
}
leaf CLICON_CLI_GENMODEL {
Expand Down

0 comments on commit 0d22a8b

Please sign in to comment.