Skip to content

Commit

Permalink
* [Need an option to disable restconf mandatory action of overwriting…
Browse files Browse the repository at this point in the history
… startup_db #230](#230)

  * Disable RFC 8040 mandatory copy of running to startup after commit
* Rename CLICON_RESTCONF_INSTALL_DIR -> CLICON_RESTCONF_INSTALLDIR
  • Loading branch information
olofhagsand committed May 25, 2021
1 parent 60c9172 commit 5b39418
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 25 deletions.
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,15 @@ Users may have to change how they access the system
* Changed config and install options for Restconf
* clixon_restconf daemon is installed in /usr/local/sbin (as clixon_backend), instead of /www-data
* `configure --with-wwwdir=<dir>` remains but only applies to fcgi socket and log
* New option `CLICON_RESTCONF_INSTALL_DIR` is set to where clixon_restconf is installed, with default `/usr/local/sbin/`
* New option `CLICON_RESTCONF_INSTALLDIR` is set to where clixon_restconf is installed, with default `/usr/local/sbin/`
* Restconf drop privileges user is defined by `CLICON_RESTCONF_USER`
* `configure --with-wwwuser=<user>` is removed
* clixon_restconf drop of privileges is defined by `CLICON_RESTCONF_PRIVILEGES` option
* New clixon-config@2020-05-20.yang revision
* Added: `CLICON_RESTCONF_USER`
* Added: `CLICON_RESTCONF_PRIVILEGES`
* Added: `CLICON_RESTCONF_INSTALL_DIR`
* Added: `CLICON_RESTCONF_INSTALLDIR`
* Added: `CLICON_RESTCONF_STARTUP_DONTUPDATE`
* New clixon-restconf@2020-05-20.yang revision
* Added: restconf `log-destination`
* RESTCONF error replies have changed
Expand All @@ -71,6 +72,8 @@ Users may have to change how they access the system

### Minor features

* [Need an option to disable restconf mandatory action of overwriting startup_db #230](https://github.com/clicon/clixon/issues/230)
* Disable RFC 8040 mandatory copy of running to startup after commit
* Add default network namespace constant: `RESTCONF_NETNS_DEFAULT` with default value "default".
* CLI: Two new hide variables added (thanks: shmuelnatan)
* hide-database : specifies that a command is not visible in database. This can be useful for setting passwords and not exposing them to users.
Expand Down
4 changes: 2 additions & 2 deletions apps/backend/backend_plugin_restconf.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,12 @@ restconf_pseudo_process_control(clicon_handle h)
clicon_err(OE_UNIX, errno, "cbuf_new");
goto done;
}
/* CLICON_RESTCONF_INSTALL_DIR is where we think clixon_restconf is installed
/* CLICON_RESTCONF_INSTALLDIR is where we think clixon_restconf is installed
* Problem is where to define it? Now in config file, but maybe it should be in configure?
* Tried Makefile but didnt work on Docker since it was moved around.
* Use PATH?
*/
cprintf(cb, "%s/clixon_restconf", clicon_option_str(h, "CLICON_RESTCONF_INSTALL_DIR"));
cprintf(cb, "%s/clixon_restconf", clicon_option_str(h, "CLICON_RESTCONF_INSTALLDIR"));
argv[i++] = cbuf_get(cb);
argv[i++] = "-f";
argv[i++] = clicon_option_str(h, "CLICON_CONFIGFILE");
Expand Down
10 changes: 8 additions & 2 deletions apps/restconf/restconf_methods.c
Original file line number Diff line number Diff line change
Expand Up @@ -522,8 +522,11 @@ api_data_write(clicon_handle h,
* configuration datastore, after the "running" datastore has been altered
* as a consequence of a RESTCONF edit operation.
*/
if ((IETF_DS_NONE == ds) && if_feature(yspec, "ietf-netconf", "startup"))
if ((IETF_DS_NONE == ds) &&
if_feature(yspec, "ietf-netconf", "startup") &&
!clicon_option_bool(h, "CLICON_RESTCONF_STARTUP_DONTUPDATE")){
cprintf(cbx, " copystartup=\"true\"");
}
cprintf(cbx, " autocommit=\"true\"");
cprintf(cbx, "><target><candidate /></target>");
cprintf(cbx, "<default-operation>none</default-operation>");
Expand Down Expand Up @@ -760,8 +763,11 @@ api_data_delete(clicon_handle h,
* configuration datastore, after the "running" datastore has been altered
* as a consequence of a RESTCONF edit operation.
*/
if ((IETF_DS_NONE == ds) && if_feature(yspec, "ietf-netconf", "startup"))
if ((IETF_DS_NONE == ds) &&
if_feature(yspec, "ietf-netconf", "startup") &&
!clicon_option_bool(h, "CLICON_RESTCONF_STARTUP_DONTUPDATE")){
cprintf(cbx, " copystartup=\"true\"");
}
cprintf(cbx, " autocommit=\"true\"");
cprintf(cbx, "><target><candidate /></target>");
cprintf(cbx, "<default-operation>none</default-operation>");
Expand Down
5 changes: 4 additions & 1 deletion apps/restconf/restconf_methods_post.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,11 @@ api_data_post(clicon_handle h,
* configuration datastore, after the "running" datastore has been altered
* as a consequence of a RESTCONF edit operation.
*/
if ((IETF_DS_NONE == ds) && if_feature(yspec, "ietf-netconf", "startup"))
if ((IETF_DS_NONE == ds) &&
if_feature(yspec, "ietf-netconf", "startup") &&
!clicon_option_bool(h, "CLICON_RESTCONF_STARTUP_DONTUPDATE")){
cprintf(cbx, " copystartup=\"true\"");
}
cprintf(cbx, " autocommit=\"true\"");
cprintf(cbx, "><target><candidate /></target>");
cprintf(cbx, "<default-operation>none</default-operation>");
Expand Down
2 changes: 1 addition & 1 deletion test/test_restconf_internal.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ cat <<EOF > $cfg
<CLICON_BACKEND_DIR>/usr/local/lib/$APPNAME/backend</CLICON_BACKEND_DIR>
<CLICON_BACKEND_REGEXP>example_backend.so$</CLICON_BACKEND_REGEXP>
<CLICON_RESTCONF_DIR>/usr/local/lib/$APPNAME/restconf</CLICON_RESTCONF_DIR>
<CLICON_RESTCONF_INSTALL_DIR>$RESTCONFDIR</CLICON_RESTCONF_INSTALL_DIR>
<CLICON_RESTCONF_INSTALLDIR>$RESTCONFDIR</CLICON_RESTCONF_INSTALLDIR>
<CLICON_CLI_DIR>/usr/local/lib/$APPNAME/cli</CLICON_CLI_DIR>
<CLICON_CLI_MODE>$APPNAME</CLICON_CLI_MODE>
<CLICON_SOCK>/usr/local/var/$APPNAME/$APPNAME.sock</CLICON_SOCK>
Expand Down
10 changes: 5 additions & 5 deletions test/test_restconf_internal_usecases.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ cat <<EOF > $cfg
<CLICON_BACKEND_DIR>/usr/local/lib/$APPNAME/backend</CLICON_BACKEND_DIR>
<CLICON_BACKEND_REGEXP>example_backend.so$</CLICON_BACKEND_REGEXP>
<CLICON_RESTCONF_DIR>/usr/local/lib/$APPNAME/restconf</CLICON_RESTCONF_DIR>
<CLICON_RESTCONF_INSTALL_DIR>$RESTCONFDIR</CLICON_RESTCONF_INSTALL_DIR>
<CLICON_RESTCONF_INSTALLDIR>$RESTCONFDIR</CLICON_RESTCONF_INSTALLDIR>
<CLICON_CLI_DIR>/usr/local/lib/$APPNAME/cli</CLICON_CLI_DIR>
<CLICON_CLI_MODE>$APPNAME</CLICON_CLI_MODE>
<CLICON_SOCK>/usr/local/var/$APPNAME/$APPNAME.sock</CLICON_SOCK>
Expand Down Expand Up @@ -194,15 +194,15 @@ ps aux|grep clixon_ # XXX

new "Check $pid1 exists"
# Here backend dies / is killed
#while sudo kill -0 $pid1 2> /dev/null; do
if sudo kill -0 $pid1; then # XXX
# if sudo kill -0 $pid1; then # XXX
while sudo kill -0 $pid1 2> /dev/null; do
new "kill $pid1 externally"
sudo kill $pid1
sleep 1 # There is a race condition here when restconf is killed while waiting for reply from backend
echo "pid1:$pid1" # XXX
ps aux|grep clixon_ # XXX
fi
#done
done
# fi

echo "pid1:$pid1" # XXX
ps aux|grep clixon_ # XXX
Expand Down
22 changes: 13 additions & 9 deletions test/test_restconf_startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,18 @@ function testrun(){
start_backend -s init -f $cfg -y $fyang $option
fi

new "waiting"
new "wait backend"
wait_backend

new "kill old restconf daemon"
stop_restconf_pre
if [ $RC -ne 0 ]; then
new "kill old restconf daemon"
stop_restconf_pre

new "start restconf daemon"
start_restconf -f $cfg -y $fyang $option
new "start restconf daemon"
start_restconf -f $cfg -y $fyang $option
fi

new "waiting"
new "wait restconf"
wait_restconf

new "restconf put 42"
Expand All @@ -90,9 +92,11 @@ function testrun(){
new "restconf delete 42"
expectpart "$(curl $CURLOPTS -X DELETE $RCPROTO://localhost/restconf/data/example:x/y=42)" 0 "HTTP/1.1 204 No Content"

new "Kill restconf daemon"
stop_restconf

if [ $RC -ne 0 ]; then
new "Kill restconf daemon"
stop_restconf
fi

if [ $BE -ne 0 ]; then
new "Kill backend"
# Check if premature kill
Expand Down
18 changes: 15 additions & 3 deletions yang/clixon/clixon-config@2021-05-20.yang
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ module clixon-config {
"Added option:
CLICON_RESTCONF_USER
CLICON_RESTCONF_PRIVILEGES
CLICON_RESTCONF_INSTALL_DIR
CLICON_RESTCONF_INSTALLDIR
CLICON_RESTCONF_STARTUP_DONTUPDATE
Released in Clixon 5.2";
}
revision 2021-03-08 {
Expand Down Expand Up @@ -479,7 +480,7 @@ module clixon-config {
Note: Obsolete, use fcgi-socket in clixon-restconf.yang instead";
status obsolete;
}
leaf CLICON_RESTCONF_INSTALL_DIR {
leaf CLICON_RESTCONF_INSTALLDIR {
type string;
default "/usr/local/sbin";
description
Expand All @@ -489,7 +490,18 @@ module clixon-config {
installation moves the binaries, and this may be true elsewehere too.
Maybe one could locate it via PATHs search";
}

leaf CLICON_RESTCONF_STARTUP_DONTUPDATE {
type boolean;
default false;
description
"According to RFC 8040 Sec 1.4:
If the NETCONF server supports :startup, the RESTCONF server MUST automatically
update the [...] startup configuration [...] as a consequence of a RESTCONF
edit operation.
Setting this option disables this behaviour, ie the startup configuration is NOT
automatically updated.
If this option is false, the startup is autoamtically updated following the RFC";
}
leaf CLICON_RESTCONF_PRETTY {
type boolean;
default true;
Expand Down

0 comments on commit 5b39418

Please sign in to comment.