Commit graph

96 commits

Author SHA1 Message Date
Olof hagsand
d84c529ff1 [Code formatting: Change indentation style to space](https://github.com/clicon/clixon/issues/379)
* Applies to all c/h/y/l/sh files and .editorconfig
2022-10-27 14:21:17 +02:00
Olof hagsand
0c79298e76 Changed C-API for xml translation/print the internal cxobj tree data structure to other formats
New API is as follows:
  * `clixon_xml2file()` - Print internal tree as XML to file
  * `clixon_xml2cbuf()` - Print internal tree as XML to buffer
  * `clixon_json2file()` - Print internal tree as JSON to file
  * `clixon_json2cbuf()` - Print internal tree as JSON to buffer
  * `clixon_cli2file()` - Print internal tree as CLI format to file
  * `clixon_txt2file()` - Print internal tree as text format to file
2022-06-01 20:02:27 +02:00
Olof hagsand
0a593cd513 * [Strict auto completion for CLI argument expansion #163](https://github.com/clicon/clixon/issues/163)
* Fixed a bug with the extension API: different unknown statements were treated as same
2022-03-01 09:27:11 +01:00
Olof hagsand
95f6fe8b1a * Fixed: Autocli YANG patterns including " were not properly escaped: \" 2022-01-19 14:52:32 +01:00
Olof hagsand
77b4468eb3 Updated copyright statements to 2022 2022-01-18 16:36:00 +01:00
Olof hagsand
f922211212 * Changed autocli tree-labels using ac_ and act_ prefixes
* New automatic edit-mode design
   * Control which modes to use with `edit-mode-default`
     * Default is create edit-mode for all
   * New edit-mode tree: @datamodelmode
2022-01-18 12:17:47 +01:00
Olof hagsand
9b99d63411 - fix autocli modes error of empty type
- rename tests test_cli_auto -> test_autocli
2022-01-13 14:59:00 +01:00
Olof hagsand
e0bcca5405 * New clixon-lib@2021-12-05.yang revision
* Extension `autocli-op` obsoleted and no longer supported
  * 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-database` -> `autocli:hide-show`
    * `cl:autocli-op hide-database-auto-completion` -> `autocli:hide; autocli:hide-show`
2022-01-12 22:19:17 +01:00
Olof hagsand
081e6871b3 * Renamed clixon-clispec.yang to clixon-autocli.yang
* First version of clixon-autocli.yang semantics
   * Default rules for module exclusion, list-keywords, completion, treeref-state
   * Specialized rules for compress and exclusion of modules
   * See [autocli documentation](https://clixon-docs.readthedocs.io/en/latest/cli.html#autocli)
* Obsoleted and moved autocli config options from clixon-config.yang to clixon-autocli.yang as follows:
   * `CLICON_CLI_GENMODEL`, use: `autocli/module-default=false` instead
      * Removed `clicon_cli_genmodel()`
   * `CLICON_CLI_GENMODEL_TYPE`, use `autocli/list-keyword-default` and compress rules instead)
      * Removed `clicon_cli_genmodel_type()`
   * `CLICON_CLI_GENMODEL_COMPLETION`, use `autocli/completion-default` instead
      * Removed `clicon_cli_genmodel_completion()`
   * `CLICON_CLI_AUTOCLI_EXCLUDE`, use `autocli/rule/operation=exclude` instead
   * `CLICON_CLI_MODEL_TREENAME`, use constant `AUTOCLI_TREENAME` instead
     * Removed `clicon_cli_model_treename()`
* New YANG functions: yang_single_child_type, yang_find_namespace_by_prefix, yang_str2key
* Changed return values of yang_find_prefix_by_namespace
* Merged `cli_cli2xml()` into `cli2xml()`
2022-01-07 12:50:07 +01:00
Olof hagsand
f8f34e3571 * Replaced separate autocli trees with a single @basemodel tree by using filter labels
* Added lastkey argument to yang_key_match()
* Fixed segv in process-sigchld
* Added ietf-yang-library to CLICON_CLI_AUTOCLI_EXCLUDE default value
* Added yang_spec_print() function
2021-12-16 20:23:09 +01:00
Olof hagsand
5388aace12 Refactoring for better performance of large auto-cli specs
* Fixed: [very slow execution of load_set_file #288](https://github.com/clicon/clixon/issues/288)
* New `clixon-lib@2021-11-11.yang` revision
  * Modified option: RPC stats extended with YANG stats
* Modified `clixon-config@2021-11-11.yang` revision
  * Added option:
    * CLICON_PLUGIN_CALLBACK_CHECK
    * Enable to make plugin context check before and after all callbacks.
* Added statistics for YANG: number of objects and memory used
* Use the treeref no-copy option of CLIgen to reduce memory
* Refactored cli-generation/autocli-start code
* Refactored cligen glue functions to use cligen_eval directly (remove clicon_eval,clixon_cligen_eval)
2021-11-25 12:04:05 +01:00
Olof hagsand
7d9d0017a9 Fixed an issue with openconfig path compression: the compression was always done, not exclusively
for openconfig.
See [OpenConfig path compression](https://github.com/clicon/clixon/pull/276)
2021-11-14 17:54:58 +01:00
Olof Hagsand
9d8d9ac042
Merge branch 'master' into feature_openconfig_compress 2021-10-22 09:23:48 +02:00
Kristofer Hallin
b29387ce1d
Changes as per review. 2021-10-21 22:01:04 +02:00
Olof hagsand
063e6d6faa Added "exist" parameter to yang_extension_value() 2021-10-21 21:45:14 +02:00
Olof hagsand
448aa4c994 include signal.h 2021-10-21 16:29:43 +02:00
Kristofer Hallin
4ac1f0bad0
Implementation of OpenConfig path compression. 2021-10-15 13:55:31 +02:00
Olof hagsand
b70e22096e - Pagination: enabled LIST_PAGINATION and remobved constant
- Changed logic on how to find clixon_restconf in pseudo plugin
- Removed ==== in constants to avoid conflict with git merge
- Remove assert
- Added fuzzing for netconf
2021-09-23 13:33:26 +02:00
Olof hagsand
392e6679c5 * JSON errors are now labelled with JSON and not XML
* Fixed: [Performance issue when parsing large JSON param](https://github.com/clicon/clixon/issues/266)
* Moved strlen() from for end condition
* Fixed debugging of xpath parser
2021-09-20 21:35:01 +02:00
Olof hagsand
980718178a * YANG Leafref feature update
* Closer adherence to RFC 7950. Some of this is changed behavior, some is new feature.
  * Essentially instead of looking at the referring leaf, context is referred(target) node
  * Validation uses referred node
    * Validation changed to use type of referred node, instead of just "string"
  * Auto-cli
    * Changed to use type of referred node for typecheck
    * Completion uses referred node
  * Required instance / less strict validation
    * New: Leafrefs must refer to existing data leaf ONLY IF YANG `required-instance` is true
    * Previous: All leafrefs must refer to existing data leaf node
* Fixed: [Autocli does not offer completions for leafref to identityref #254](https://github.com/clicon/clixon/issues/254)
2021-08-16 17:14:27 +02:00
Olof hagsand
4d265d63bd Fixed: The auto-cli identityref did not expand identities in grouping/usecases properly. 2021-08-03 11:15:45 +02:00
Olof hagsand
1925ac68cd * Fixed: [RESTConf GET for a specific list instance retrieves data from other submodules that have same list name and key value #244](https://github.com/clicon/clixon/issues/244)
* Fixed: Double clixon error messages in yang2cli code
* Sanity checks for submodule belongs-to
2021-07-08 16:26:39 +02:00
Olof hagsand
5baf8642ea * Fixed union in XPATH [XPATH issues #219](https://github.com/clicon/clixon/issues/219) 2021-05-15 22:28:10 +02:00
shmuels
33ad428854 completing the function of hide for autocli-op in the yang files 2021-04-21 15:09:40 +03:00
shmuels
cede620a2a completing the function of hide for autocli-op in the yang files 2021-04-19 10:27:44 +03:00
shmuels
c370ac8706 completing the function of hide for autocli-op in the yang files 2021-04-18 16:58:18 +03:00
jxm
b938c0c40c yang container add support for cl:autocli-op 2021-04-09 15:27:37 +08:00
Olof hagsand
f536b1dc67 Added: CLICON_CLI_AUTOCLI_EXCLUDE
Added openconfig interfaces tests
2021-03-15 13:08:42 +01:00
Olof hagsand
f01efaf02a fixed fcgi notification, genmodel 2021-03-10 14:45:18 +01:00
Olof hagsand
96b50b88e8 Copyright 2021 2021-01-13 14:40:34 +01:00
Olof hagsand
b8641f30bd * More YANG extension functionality,
* See [Augment auto-cli for hiding/modifying cli syntax #156](https://github.com/clicon/clixon/issues/156) and [hiding auto-generated CLI entries #153](https://github.com/clicon/clixon/issues/153)
  * Extensions can be used in augmentations
  * Extension `autocli-op` has been added to add "hidden" commands in the autocli
  * Documentation: https://clixon-docs.readthedocs.io/en/latest/misc.html#extensions
2020-12-08 17:21:37 +01:00
Olof hagsand
75f85e0253 revert yang2cli sub code, use existing yang2cli solution 2020-11-27 15:31:27 +01:00
Olof hagsand
dda3244252 * Auto-cli changed singature of yang2cli()
* Auto-cli: create generated CLI for sub-parts of a YANG spec
2020-11-26 17:32:09 +01:00
Olof hagsand
101a8cb6e0 minor fixes 2020-09-27 17:15:36 +02:00
Olof hagsand
9a76899482 Fixed cli show conflicts for https://github.com/clicon/clixon/pull/137 2020-09-15 14:22:40 +02:00
Olof hagsand
5120409a56 Auto-cli updates and sync with clixon-docs 2020-06-15 16:07:04 +02:00
Olof hagsand
e898dda016 * Auto-CLI enhancements
* A generated clispec including state (default @datanodestate) also generated along with the config clispec tree (default @datanode)
  * New mode `GT_HIDE` set by option `CLICON_CLI_GENMODEL_TYPE` to collapse non-presence containers that only contain a single list
  * Added a prfix for cli_show_config/cli_show_auto so that it can produce parseable output
  * Thanks dcornejo@netgate.com for trying it out and suggestions
2020-06-13 12:05:26 +02:00
Olof hagsand
7d0b245174 Adapt to CLIgen 4.6 API changes 2020-05-19 22:26:29 +02:00
Olof hagsand
266e5581e4 Changed output of clixon_cli -G option to show generated CLI spec original text instead of resulting parse-tree, which gives better detail from a debugging perspective. 2020-05-09 16:20:50 +02:00
Olof hagsand
19e21be0bc Very large commit for upcoming 4.4 release
Major New features

* New and updated search functions using xpath, api-path and instance-id
  * New search functions using api-path and instance_id:
    * C search functions: `clixon_find_instance_id()` and `clixon_find_api_path()`
  * Binary search optimization in lists for indexed leafs in all three formats.
    * This improves search performance to O(logN) which is drastical improvements for large lists.
  * You can also register explicit indexes for making binary search (not only list keys)
  * For more info, see docs at [paths](https://clixon-docs.readthedocs.io/en/latest/paths.html) and
[search](https://clixon-docs.readthedocs.io/en/latest/xml.html#searching-in-xml)

API changes on existing features (you may need to change your code)
* On failed validation of leafrefs, error message changed from: `No such leaf` to `No leaf <name> matching path <path>`.
* CLI Error message (clicon_rpc_generate_error()) changed when backend returns netconf error to be more descriptive:
  * Original: `Config error: Validate failed. Edit and try again or discard changes: Invalid argument`
  * New (example): `Netconf error: application operation-failed Identityref validation failed, undefined not derived from acl-base . Validate failed. Edit and try again or discard changes"

Minor changes

* Test framework
  * Added `-- -S <file>` command-line to main example to be able to return any state to main example.
  * Added `test/cicd` test scripts for running on a set of other hosts
* C-code restructuring
  * clixon_yang.c partitioned and moved code into clixon_yang_parse_lib.c and clixon_yang_module.c and move back some code from clixon_yang_type.c.
    * partly to reduce size, but most important to limit code that accesses internal yang structures, only clixon_yang.c does this now.
2020-02-02 15:52:30 +01:00
Olof hagsand
7ad16bd84b * C-API: Added xpath_first_localonly() as an xpath function that skips prefix and namespace checks.
* Added experimental code for optizing XPath search using binary search.
  * Enable with XPATH_LIST_OPTIMIZE
* Changed `clicon_rpc_generate_error(msg, xerr)` to `clicon_rpc_generate_error(xerr, msg, arg)`
2019-12-20 18:21:46 +01:00
Olof hagsand
291f173505 libm needed in xpath 2019-07-24 09:46:08 +02:00
Olof hagsand
8b50695e1f misleading if indentation 2019-07-11 12:14:02 +02:00
Olof hagsand
6d46087109 Documented bug [Yang identityref XML encoding is not general #90](https://github.com/clicon/clixon/issues/90) 2019-07-11 12:11:45 +02:00
Olof hagsand
e44685a100 Replaced strchr with nodeid_split
Experimental code for replacing identityref lists with module:id instead of prefix:id
2019-07-10 17:18:34 +02:00
Olof hagsand
1f8c759f3d Merge branch 'master' of https://github.com/clicon/clixon.
Added new API function `xpath_parse()` to split parsing and xml evaluation.
2019-07-08 14:47:18 +02:00
Olof hagsand
67b8685bab The Clixon API has been extended with namespaces, or namespace contexts in the following cases:
* CLIspec functions have added namespace parameter:
    * `cli_show_config <db> <format> <xpath>` --> `cli_show_config <db> <format> <xpath> <namespace>`
    * `cli_copy_config <db> <xpath> ...` --> `cli_copy_config <db> <xpath> <namespace> ...`
  * Xpath API
    * `xpath_first(x, format, ...)` --> `xpath_first(x, nsc, format, ...)`
    * `xpath_vec(x, format, vec, veclen, ...)` --> `xpath_vec(x, nsc, format, vec, veclen, ...)`
    * `xpath_vec_flag(x, format, flags, vec, veclen, ...)` --> `xpath_vec_flag(x, format, flags, vec, veclen, ...)`
    * `xpath_vec_bool(x, format, ...)` --> `xpath_vec_bool(x, nsc, format, ...)`
    * `xpath_vec_ctx(x, xpath, xp)` --> `xpath_vec_ctx(x, nsc, xpath, xp)`
  * xmldb_get0 has an added `nsc` parameter:
    * `xmldb_get0(h, db, xpath, copy, xret, msd)` --> `xmldb_get0(h, db, nsc, xpath, copy, xret, msd)`
  * The plugin statedata callback (ca_statedata) has been extended with an nsc parameter:
    * `int example_statedata(clicon_handle h, cvec *nsc, char *xpath, cxobj *xstate);`
  * rpc get and get-config api function has an added namespace argument:
    * `clicon_rpc_get_config(clicon_handle h, char *db, char *xpath, char *namespace, cxobj **xt);`
    * `int clicon_rpc_get(clicon_handle h, char *xpath, char *namespace, cxobj **xt);`
2019-07-08 10:36:37 +02:00
Olof hagsand
b64dd678dc CLI ranges error shown instead of "Unknown command" 2019-06-21 17:44:52 +02:00
Olof hagsand
d12644a5ef Fixed [Wrong yang-generated cli code for typeref identityref combination #88](https://github.com/clicon/clixon/issues/88) 2019-06-20 19:00:22 +02:00
Olof Hagsand
2ae9529a3e added regexp free routines, replaced regexp mode string with symbol 2019-05-29 14:17:30 +00:00