Clixon 5.5.0

This commit is contained in:
Olof hagsand 2022-01-20 15:18:34 +01:00
parent 95f6fe8b1a
commit 6d955160ed
6 changed files with 87 additions and 76 deletions

View file

@ -1,6 +1,6 @@
# Clixon Changelog # Clixon Changelog
* [5.5.0](#550) Planned January, 2022 * [5.5.0](#550) 20 January 2022
* [5.4.0](#540) 30 November 2021 * [5.4.0](#540) 30 November 2021
* [5.3.0](#530) 27 September 2021 * [5.3.0](#530) 27 September 2021
* [5.2.0](#520) 1 July 2021 * [5.2.0](#520) 1 July 2021
@ -33,58 +33,50 @@
* [3.3.1](#331) June 7 2017 * [3.3.1](#331) June 7 2017
## 5.5.0 ## 5.5.0
Planned: January, 2022 20 January 2022
This release introduces a new autocli design with a new clixon-autocli YANG file
### New features ### New features
* Changed auto-cli design * Changed auto-cli design
* See [autocli documentation](https://clixon-docs.readthedocs.io/en/latest/cli.html#autocli) * See [autocli documentation](https://clixon-docs.readthedocs.io/en/latest/cli.html#autocli) for overview
* Added new YANG clixon-autocli.yang, placing autocli options there * Added new YANG `clixon-autocli.yang` moving all autocli options there
* Default rules for module exclusion, list-keywords, completion, edit-modes, treeref-state * Default rules for module exclusion, list-keywords, edit-modes, treeref-state and completion
* Specialized rules for module exclusion and compression * Specialized rules for module exclusion and compression
* Replaced separate autocli trees with a single `@basemodel` tree by using filter labels * Replaced separate autocli trees with a single `@basemodel` tree by using filter labels
* Filter labels are added to the fill tree and then filtered out using `@remove:<label>` * Filter labels are added to the basemodel tree and then filtered out using `@remove:<label>`
* Labels include: termfirstkeys, termlist, termleaf, leafvar, nonconfig,
* For detailed docs see yang2cli_post()
* This method reduces memory usage and is more generic * This method reduces memory usage and is more generic
* Backward compatible: can continue use the "old" trees. * Backward compatible: can continue use the "old" trees.
* Translation to new method as follows:
* `@datamodel` translated to `@basemodel, @remove:termfirstkeys, @remove:termlist, @remove:termleaf, @remove:nonconfig`
* `@datamodelshow` translated to `@basemodel, @remove:leafvar, @remove:nonconfig`
* `@datamodelstate` translated to `@basemodel, @remove:leafvar`
* Note: while @datamodel etc are backward compatible, the autocli redesign is NOT backward compatible * Note: while @datamodel etc are backward compatible, the autocli redesign is NOT backward compatible
* see API changes * see API changes
* New automatic edit-mode design * New autocli edit-mode design
* Control which modes to use with `edit-mode-default` * Control which modes to use with `edit-mode-default`
* Default is create edit-mode for all containers and list entries * Default is create edit-mode for all containers and list entries
* New edit-mode tree: @datamodelmode * New edit-mode tree: `@datamodelmode`
* Moved hide extensions from `clixon-lib` to `clixon-autocli` * Moved hide extensions from `clixon-lib` to `clixon-autocli`
### API changes on existing protocol/config features ### API changes on existing protocol/config features
Users may have to change how they access the system Users may have to change how they access the system
* CLI-spec variable `CLICON_PROMPT` `%W` changed semantics due to long prompt
* From "Full Working edit path" to "Last element of working path"
* New `%w` has "Full working path"
* Auto-cli edit-modes changed * Auto-cli edit-modes changed
* CLI-spec variable `CLICON_PROMPT` `%W` changed semantics due to long prompt
* From "Full Working edit path" to "Last element of working path"
* Use `%w` if you want to keep "Full working path"
* Edit modes only for list and container nodes * Edit modes only for list and container nodes
* Change cli spec entry to `edit @datamodelmode, cli_auto_edit("basemodel");` * Change cli spec entry to `edit @datamodelmode, cli_auto_edit("basemodel");`
* This is part of new clixon-autocli.yang feature
* New `clixon-lib@2021-12-05.yang` revision * New `clixon-lib@2021-12-05.yang` revision
* Extension `autocli-op` obsoleted and no longer supported * Extension `autocli-op` obsoleted and no longer supported, use clixon-autocli `hide` and `hide-show` instead as follows:
* You need to change to use clixon-autocli `hide` and `hide-show` instead.
* Translate as follows:
* `cl:autocli-op hide` -> `autocli:hide` * `cl:autocli-op hide` -> `autocli:hide`
* `cl:autocli-op hide-database` -> `autocli:hide-show` * `cl:autocli-op hide-database` -> `autocli:hide-show`
* `cl:autocli-op hide-database-auto-completion` -> `autocli:hide; autocli:hide-show` * `cl:autocli-op hide-database-auto-completion` -> `autocli:hide; autocli:hide-show`
* New `clixon-config@2021-12-05.yang` revision * New `clixon-config@2021-12-05.yang` revision
* Imported (as a sub-spec): clixon-clispec.yang
* Removed obsolete options: * Removed obsolete options:
* `CLICON_YANG_LIST_CHECK` * `CLICON_YANG_LIST_CHECK`
* Fixed: Configure option `CLICON_RESTCONF_PRETTY` was marked as obsolete but was still used. * Fixed: Configure option `CLICON_RESTCONF_PRETTY` was marked as obsolete but was still used.
* `CLICON_RESTCONF_PRETTY` is now obsolete for sure * `CLICON_RESTCONF_PRETTY` is now obsolete for sure
* Instead restconf/pretty is used with API function restconf_pretty_get() * Use: `restconf/pretty`
* Fixed: Configure option `CLICON_RESTCONF_PATH` was marked as obsolete but was still used. * Fixed: Configure option `CLICON_RESTCONF_PATH` was marked as obsolete but was still used.
* `CLICON_RESTCONF_PATH` is now obsolete for sure * `CLICON_RESTCONF_PATH` is now obsolete for sure
* Instead if you use fgci/nginx: * Instead if you use fgci/nginx:
@ -92,17 +84,19 @@ Users may have to change how they access the system
* Ensure `<CLICON_FEATURE>clixon-restconf:fcgi</CLICON_FEATURE>` is set * Ensure `<CLICON_FEATURE>clixon-restconf:fcgi</CLICON_FEATURE>` is set
* Marked as obsolete and moved autocli config options from clixon-config.yang to clixon-autocli.yang * Marked as obsolete and moved autocli config options from clixon-config.yang to clixon-autocli.yang
* Use: `<config><autocli>...` for configuring the autocli * Use: `<config><autocli>...` for configuring the autocli
* For details, see [autocli upgrade documentation](https://clixon-docs.readthedocs.io/en/latest/cli.html#upgrade-from-clixon-5-4) * For details, see [autocli upgrade documentation](https://clixon-docs.readthedocs.io/en/latest/cli.html#upgrade-from-pre-clixon-5-5)
### Minor features ### C/CLI-API changes on existing features
Developers may need to change their code
* Removed `#ifdef __GNUC__` around printf-like prototypes since both clang and gcc have format/printf macros defined
* Removed ifdef __GNUC__ around printf-like prototypes since both clang and gcc have format/printf macros defined
* Test changes * Test changes
* Use `YANG_STANDARD_DIR` from `./configure --with-yang-standard-dir=DIR` instead of `YANGMODELS` from site.sh * Use `YANG_STANDARD_DIR` from `./configure --with-yang-standard-dir=DIR` instead of `YANGMODELS` from site.sh
* Remove dependency of IETF YANGs on most tests * Remove dependency of IETF YANGs on most tests
* Remove dependnency of example/main in most tests, instead make local copy of example yang * Remove dependency of example/main in most tests, instead make local copy of example yang
* New `clixon-dev` development container (Work-in-progress) * Changed `configure --with-yang-standard-installdir` to `configure --with-yang-standard-dir`
* Changed typo `configure --with-yang-standard-installdir` to `configure --with-yang-standard-dir`
### Corrected Bugs ### Corrected Bugs

View file

@ -17,6 +17,6 @@ Clixon has a master branch continuously tested with CI, but releases are made ca
Clixon interaction is best done posting issues, pull requests, or joining the Clixon interaction is best done posting issues, pull requests, or joining the
[slack channel](https://clixondev.slack.com). [slack channel](https://clixondev.slack.com).
[Slack invite](https://join.slack.com/t/clixondev/shared_invite/zt-za7p40vq-l_Ib1Cq9rX~cHCkLCdu~Aw) (updated 26/11 2021) [Slack invite](https://join.slack.com/t/clixondev/shared_invite/zt-11yvaaum9-J4zEVnp~8KkTXFlQSE0Kmg)(updated 20/1 2022)
Clixon is sponsored by [Rubicon Communications LLC(Netgate)](https://www.netgate.com/) Clixon is sponsored by [Rubicon Communications LLC(Netgate)](https://www.netgate.com/)

View file

@ -244,50 +244,18 @@ cli_interactive(clicon_handle h)
return retval; return retval;
} }
/*! Generate autocli, ie if enabled, generate clispec from YANG and add to cligen parse-trees /*! Create pre-5.5 tree-refs for backward compatibility
* * should probably be moved to clispec default
* Generate clispec (basemodel) from YANG dataspec and add to the set of cligen trees
* This tree is referenced from the main CLI spec (CLICON_CLISPEC_DIR) using the
* "tree reference" syntax.
*
* @param[in] h Clixon handle
* @param[in] printgen Print CLI syntax generated from dbspec
* @retval 0 OK
* @retval -1 Error
*/ */
static int static int
autocli_start(clicon_handle h, autocli_trees_default(clicon_handle h)
int printgen)
{ {
int retval = -1; int retval = -1;
yang_stmt *yspec; cbuf *cb = NULL;
pt_head *ph; int mode = 0;
parse_tree *pt = NULL; parse_tree *pt = NULL;
int enable = 0; pt_head *ph;
cbuf *cb = NULL;
int mode = 0;
clicon_debug(1, "%s", __FUNCTION__);
/* There is no single "enable-autocli" flag,
* but set
* <module-default>false</module-default>
* with no rules:
* <rule><operation>enable</operation>
* is disable
*/
if (autocli_module(h, NULL, &enable) < 0)
goto done;
if (!enable){
clicon_debug(1, "%s Autocli not enabled (clixon-autocli)", __FUNCTION__);
goto ok;
}
/* Init yang2cli */
if (yang2cli_init(h) < 0)
goto done;
yspec = clicon_dbspec_yang(h);
/* The actual generating call from yang to clispec for the complete yang spec */
if (yang2cli_yspec(h, yspec, AUTOCLI_TREENAME, printgen) < 0)
goto done;
/* Create backward compatible tree: @datamodel */ /* Create backward compatible tree: @datamodel */
if ((ph = cligen_ph_add(cli_cligen(h), "datamodel")) == NULL) if ((ph = cligen_ph_add(cli_cligen(h), "datamodel")) == NULL)
goto done; goto done;
@ -302,6 +270,7 @@ autocli_start(clicon_handle h,
if (cligen_ph_parsetree_set(ph, pt) < 0) if (cligen_ph_parsetree_set(ph, pt) < 0)
goto done; goto done;
/* Create backward compatible tree: @datamodelshow */ /* Create backward compatible tree: @datamodelshow */
if ((ph = cligen_ph_add(cli_cligen(h), "datamodelshow")) == NULL) if ((ph = cligen_ph_add(cli_cligen(h), "datamodelshow")) == NULL)
goto done; goto done;
@ -368,8 +337,6 @@ autocli_start(clicon_handle h,
goto done; goto done;
if (cligen_ph_parsetree_set(ph, pt) < 0) if (cligen_ph_parsetree_set(ph, pt) < 0)
goto done; goto done;
ok:
retval = 0; retval = 0;
done: done:
if (cb) if (cb)
@ -377,6 +344,55 @@ autocli_start(clicon_handle h,
return retval; return retval;
} }
/*! Generate autocli, ie if enabled, generate clispec from YANG and add to cligen parse-trees
*
* Generate clispec (basemodel) from YANG dataspec and add to the set of cligen trees
* This tree is referenced from the main CLI spec (CLICON_CLISPEC_DIR) using the
* "tree reference" syntax.
*
* @param[in] h Clixon handle
* @param[in] printgen Print CLI syntax generated from dbspec
* @retval 0 OK
* @retval -1 Error
*/
static int
autocli_start(clicon_handle h,
int printgen)
{
int retval = -1;
yang_stmt *yspec;
int enable = 0;
clicon_debug(1, "%s", __FUNCTION__);
/* There is no single "enable-autocli" flag,
* but set
* <module-default>false</module-default>
* with no rules:
* <rule><operation>enable</operation>
* is disable
*/
if (autocli_module(h, NULL, &enable) < 0)
goto done;
if (!enable){
clicon_debug(1, "%s Autocli not enabled (clixon-autocli)", __FUNCTION__);
goto ok;
}
/* Init yang2cli */
if (yang2cli_init(h) < 0)
goto done;
yspec = clicon_dbspec_yang(h);
/* The actual generating call from yang to clispec for the complete yang spec */
if (yang2cli_yspec(h, yspec, AUTOCLI_TREENAME, printgen) < 0)
goto done;
/* XXX Create pre-5.5 tree-refs for backward compatibility */
if (autocli_trees_default(h) < 0)
goto done;
ok:
retval = 0;
done:
return retval;
}
static void static void
usage(clicon_handle h, usage(clicon_handle h,
char *argv0) char *argv0)

View file

@ -393,6 +393,7 @@ done:
* CLI .so plugins have been loaded: syntax table in place. * CLI .so plugins have been loaded: syntax table in place.
* Now load cligen syntax files and create cligen pt trees. * Now load cligen syntax files and create cligen pt trees.
* @param[in] h Clicon handle * @param[in] h Clicon handle
* XXX The parsetree loading needs a rewrite for multiple parse-trees
*/ */
int int
cli_syntax_load(clicon_handle h) cli_syntax_load(clicon_handle h)

2
configure vendored
View file

@ -2267,7 +2267,7 @@ ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var.
CLIXON_VERSION_MAJOR="5" CLIXON_VERSION_MAJOR="5"
CLIXON_VERSION_MINOR="5" CLIXON_VERSION_MINOR="5"
CLIXON_VERSION_PATCH="0" CLIXON_VERSION_PATCH="0"
CLIXON_VERSION="\"${CLIXON_VERSION_MAJOR}.${CLIXON_VERSION_MINOR}.${CLIXON_VERSION_PATCH}.PRE\"" CLIXON_VERSION="\"${CLIXON_VERSION_MAJOR}.${CLIXON_VERSION_MINOR}.${CLIXON_VERSION_PATCH}\""
# Debug flag # Debug flag
# Check whether --enable-debug was given. # Check whether --enable-debug was given.

View file

@ -50,7 +50,7 @@ AC_CONFIG_AUX_DIR(config-aux)
CLIXON_VERSION_MAJOR="5" CLIXON_VERSION_MAJOR="5"
CLIXON_VERSION_MINOR="5" CLIXON_VERSION_MINOR="5"
CLIXON_VERSION_PATCH="0" CLIXON_VERSION_PATCH="0"
CLIXON_VERSION="\"${CLIXON_VERSION_MAJOR}.${CLIXON_VERSION_MINOR}.${CLIXON_VERSION_PATCH}.PRE\"" CLIXON_VERSION="\"${CLIXON_VERSION_MAJOR}.${CLIXON_VERSION_MINOR}.${CLIXON_VERSION_PATCH}\""
# Debug flag # Debug flag
AC_ARG_ENABLE(debug, AS_HELP_STRING([--enable-debug],[Build with debug symbols, default: no]),[ AC_ARG_ENABLE(debug, AS_HELP_STRING([--enable-debug],[Build with debug symbols, default: no]),[