Commit graph

158 commits

Author SHA1 Message Date
Olof hagsand
108f94cfad * Fixed: [Irregular ordering of cli command + help text when integer is a part of command #176](https://github.com/clicon/clixon/issues/176)
* Enabled by default `cligen_lexicalorder_set()` using strversmp instead of strcmp
2021-02-17 13:34:56 +01:00
Olof hagsand
96b50b88e8 Copyright 2021 2021-01-13 14:40:34 +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
9016dde319 Modify tests so they all work with evhtp and backend config, eg that CLICON_RESTCONF_CONFIG is default true.
Note that some tests are forced to CLICON_RESTCONF_CONFIG is false due to test complexities.
2020-11-18 13:57:25 +01:00
Olof hagsand
7a0838da3a * Restconf configuration has a new configure model: clixon-restconf.yang enabling restconf daemon configuration from datastore instead of from config file. 2020-11-03 21:26:34 +01:00
Olof hagsand
2d56c9674a * New YANG generated auto-cli feature with syntax modes
* The existing autocli does not support modes, complete paths must be given, eg: `set a b c d 42`.
  * In the new auto-cli, automatic modes are present at each YANG syntax node level, eg the above can be given as: `edit a b c; set d 4; top`
  * The existing CLI API remains, the new API is as follows: `cli_auto_edit()`, `cli_auto_up()`, `cli_auto_top()`, `cli_auto_show()`, `cli_auto_set()`, `cli_auto_merge()`, `cli_auto_create()`, `cli_auto_del()`.
  * See `test/test_cli_auto.sh` for an example of the new API, and `apps/cli/cli_auto.c` for the source code of the new callback API.
  * Documentation will be appear and full integration with the main example.
* Added inline state field to clixon-example.yang
* Added new clicon_data_cvec_*() API for generic cvec structs
2020-10-14 10:54:10 +02:00
Olof hagsand
6f2c4a076d * Configuration directory
* A new configuration option `CLICON_CONFIGDIR` has been added for loading of extra config files
  * If not given, only the main configfile is loaded.
  * If given, and if the directory exists, the files in this directory will be loaded alphabetically AFTER the main config file in the following way:
    * leaf values are overwritten
    * leaf-list values are appended
  * You can override file setting with `-E <dir>` command-line option.
* New clixon-config@2020-10-01.yang revision
  * Added option for configuration directory: `CLICON_CONFIGDIR`
2020-10-01 11:04:25 +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
b8955c81d8 * Changed CLI help strings behaviour on query (?) for long and multi-line help strings.
* If multiple strings (eg "\n" in text), indent before each new line
  * Primarily for auto-cli where long help strings are generated from YANG descriptions, but applies as well for manual long/multi-line help strings
  * New config option: `CLICON_CLI_HELPSTRING_TRUNCATE`: Truncate help string on right margin mode
  * New config option: `CLICON_CLI_HELPSTRING_LINES`: Limit of number of help strings to show
2020-09-04 13:15:53 +02:00
Olof hagsand
81fc7f742b * Netconf as default namespace has been disabled by default.
* Only requests on the form: `<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"><edit-config>...` will be accepted
  * All replies will be on the form: `<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">...`
  * Requests such as: `<rpc><edit-config>...` will not  be accepted.
  * You can revert this behaviour (to clixon pre-4.6 behaviour) by enabling `CLICON_NAMESPACE_NETCONF_DEFAULT`
  * This API change is a consequence of: [copy-config's RPC cxobj parameter does not contain namespace #131](https://github.com/clicon/clixon/issues/131)
2020-09-02 15:44:10 +02:00
Olof hagsand
ee29452d24 * New clixon-config@2020-06-17.yang revision
* Added CLICON_CLI_LINES_DEFAULT for setting window row size of raw terminals
  * Added  enum HIDE to CLICON_CLI_GENMODEL for auto-cli
2020-06-18 11:28:47 +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
ff5462ecac Replaced the global variable debug with access function: clicon_debug_get(). 2020-06-09 16:04:49 +02:00
Olof hagsand
8c1372d26a libhttp compile 2020-05-28 17:19:15 +02:00
Olof hagsand
7d0b245174 Adapt to CLIgen 4.6 API changes 2020-05-19 22:26:29 +02:00
Olof hagsand
132122c937 enabled and removed USE_CLIGEN44 2020-05-12 14:02:25 +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
dafc6d10e0 Added option to treat unknown XML (wrt YANG) as anydata. 2020-05-03 22:03:33 +02:00
Olof hagsand
772759e42f * Compile-time option: USE_CLIGEN44 for running clixon-45 with cligen-44.
* Temporary fix since cligen-45 have some non-backward compatible behaviour.
2020-05-01 00:42:54 +02:00
Olof hagsand
9a8c6cf3e6 * New clixon-lib@2020-04-23.yang revision
* Added: stats RPC for clixon XML and memory statistics.
  * Added: restart-plugin RPC for restarting individual plugins without restarting backend.
* xml-stats moved from clixon-config.yang as state data to an rpc `datastats` in clixon-lib.yang
* Experimental: restart_plugin
* Two new plugin callbacks added
  * ca_daemon: Called just after a server has "daemonized", ie put in background.
  * ca_trans_commit_done: Called when all plugin commits have been done.
    * Note: If you have used "end" callback and usign transaction data, you should probably use this instead.
2020-04-28 22:10:06 +02:00
Olof hagsand
65806f1ef2 Copyright change: LLC -> LLC(Netgate) 2020-04-23 16:55:56 +02:00
Olof hagsand
1dff0e681b Adapted to CLIgen 4.5 API changes, eg: and 2020-04-20 13:14:40 +02:00
Olof hagsand
6e2cb1b97d Adjust to cligen 4.5 update 2020-04-01 09:56:50 +02:00
Olof hagsand
8131bd1834 2020 copyright 2020-03-27 15:42:03 +01:00
Olof hagsand
4e578b77ee exit typo in test 2020-03-24 20:57:41 +01:00
Olof hagsand
a7e0a30938 Fixes for 4.4 release 2020-03-24 16:41:30 +01:00
Olof hagsand
0f54899ae4 * Added option: CLICON_CLI_BUF_START and CLICON_CLI_BUF_THRESHOLD so you can change the start and
threshold of quadratic and linear growth of CLIgen buffers (cbuf:s)
* Memory footprint
  * Do not autopopulate namespace cache, instead use on-demand, see `xml2ns()`.
  * Set CBUF start level to 256 (`CLICON_CLI_BUF_START` option)
  * Reduced xml child vector default size from 4 to 1 with quadratic growoth to 64K then linear
2020-03-04 11:27:43 +01:00
Olof hagsand
9fa5e216c4 * New "general-purpose" datastore upgrade callback added which i called once on startup, intended for lo
w-level general upgrades and as a complement to module-specific upgrade.
  * Called on startup after initial XML parsing, but before module-specific upgrades
  * Enabled by definign the `.ca_datastore_upgrade`
  * [General-purpose upgrade documentation](https://clixon-docs.readthedocs.io/en/latest/backend.html#ge
neral-purpose)
* JSON parse error messages change from ` on line x: syntax error,..` to `json_parse: line x: syntax err
or`
* Unknown-element error message is more descriptive, eg from `namespace is: urn:example:clixon` to: `Fai
led to find YANG spec of XML node: x with parent: xp in namespace urn:example:clixon`.
* C-API parse and validation API more capable
  * `xml_spec_populate` family of functions extended with three-value return values
    * -1: error, 0: parse OK, 1: parse and YANG binding OK.
  * `xml_parse` and `json_parse` API changes
    * Three value returns: -1: error, 0: parse OK, 1: parse and YANG binding OK.
    * Extended `xml_parse_file2` and `xml_parse_string2` extended API functions with all options available.
      * New concept called `yang_bind` that defines how XML symbols are bound to YANG after parsing
    * Existing API same except `xml_parse_file` `endtag` argument moved to `xml_parse_file2`
* C-API: Added instrumentation: `xml_size` and `xml_stats_get`.
* Fixed: Enabling modstate (CLICON_XMLDB_MODSTATE), changing a revision on a yang, and restarting made the backend daemon exit at start (thanks Matt)
  * Also: ensure to load `ietf-yang-library.yang ` if CLICON_XMLDB_MODSTATE is set
2020-02-20 14:00:01 +01:00
Olof hagsand
c7d6f69a85 * Session-id CLI functionality delayed: "lazy evaluation"
* From a cli perspective this is a revert to 4.1 behaviour, where the cli does not immediately exit on start if the backend is not running, but with the new session-id function
2020-02-05 15:37:25 +01: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
05ce6f38a3 test kill valgrind process after run 2019-12-09 21:12:39 +01:00
Olof hagsand
08b128f4d7 moved config yang spec from main functions to options_main function 2019-12-01 17:42:34 +01:00
Olof hagsand
c4954f5c43 memerror in uid-get. reinsert save config yang spec (removed for wrong reasons previously causing memleaks) 2019-12-01 16:48:45 +01:00
Olof hagsand
d0e97ee338 Removed obsolete config yang handler
Added base netconf as default namespace in canonical nsctx
2019-11-16 16:49:40 +01:00
Olof hagsand
52629d7b35 Added "canonical" global namespace context: nsctx_global 2019-11-15 17:04:13 +01:00
Olof hagsand
948e203a61 moved initial hello request from client to backend to immediate before first actual query 2019-10-27 10:24:13 +01:00
Olof hagsand
44138c0071 internal netconf hello mechanism to obtain session-id 2019-10-24 11:46:06 +02:00
Olof hagsand
b624e911b8 * Internal backend socket protocol changed: uint32_t session-id added, see clixon_proto.h
* * Changed session-id handing. Instead of using pid of peer process, a proper session id generated by the server is used, following RFC6241.
2019-10-19 19:52:09 +02:00
Olof hagsand
8b7b7b0f60 * RESTCONF "content" query parameter supported
* New clixon-lib@2019-08-13.yang revision
* Bugfix: If `ietf-netconf.yang` was imported from any yang module, client/backend communication stops working.
2019-08-13 13:21:11 +02:00
Olof hagsand
e7b60619da * Pushed tag to 4.0.1.PRE
* Restconf RFC 8040 increased feature compliance
  * Cache-Control: no-cache added in HTTP responses (RFC Section 5.5)
  * Restconf monitoring capabilities (RFC Section 9.1)
* Added support for Yang extensions
  * New plugin callback: ca_extension
  * Main backend example includes example code on how to implement a Yang extension in a plugin.
* JSON changes
  * Non-pretty-print output removed all extra spaces.
    * Example: `{"nacm-example:x": 42}` --> {"nacm-example:x":42}`
  * Empty JSON container changed from `null` to `{}`.
    * Empty list and leafs remain as `null`
* Removed unnecessary configure dependencies
  * libnsl, libcrypt, libm, if_vlan,...
* pseudo-plugin added, to enable callbacks also for main programs. Useful for extensions
* Yang Unique statements with multiple schema identifiers did not work on some platforms due to memory error.
2019-07-23 22:11:14 +02:00
Olof hagsand
d3c392b69d * New clixon-config@2019-06-05.yang revision
* Added: `CLICON_YANG_REGEXP, CLICON_CLI_TAB_MODE, CLICON_CLI_HIST_FILE, CLICON_CLI_HIST_SIZE, CLICON_XML_CHANGELOG, CLICON_XML_CHANGELOG_FILE`.
  * Renamed: `CLICON_XMLDB_CACHE` to `CLICON_DATASTORE_CACHE` and type changed.
  * Deleted: `CLICON_XMLDB_PLUGIN, CLICON_USE_STARTUP_CONFIG`;
* New clixon-lib@2019-06-05.yang revision
  * Added: ping rpc added (for liveness)
* Check cligen tab mode, dont start if CLICON_CLI_TAB_MODE is undefined
2019-06-05 10:58:02 +02:00
Olof hagsand
55f9b7cab0 Added CLIgen tab-modes in config option CLICON_CLI_TAB_MODE, which means you can control the behaviour of <tab> in the CLI. 2019-05-29 20:11:31 +02:00
Olof Hagsand
2ae9529a3e added regexp free routines, replaced regexp mode string with symbol 2019-05-29 14:17:30 +00:00
Olof hagsand
5b39b63698 Added --with-libxml2 to configure 2019-05-24 10:04:29 +02:00
Olof hagsand
e55a27bcac Check for libxml2 include files, not lib in code 2019-05-23 22:55:46 +02:00
Olof hagsand
a804e05375 * Added clicon_handle as parameter to all validate functions
* Added libxml2 XSD regexp mode as alternative to posix translation
* Added `CLICON_YANG_REGEXP` option with possible values libxml2 and posix
2019-05-23 22:48:33 +02:00
Olof hagsand
6bf2a74e24 * Restconf with startup feature will now copy all edit changes to startup db (as it should according to RFC 8040)
* See [Restconf does not handle startup datastore according to the RFC](https://github.com/clicon/clixon/issues/74)
* Netconf Startup feature is no longer hardcoded, you need to explicitly enable it (See RFC 6241, Section 8.7)
  * Enable in config file with: `<CLICON_FEATURE>ietf-netconf:startup</CLICON_FEATURE>`, or use `*:*`
2019-04-26 12:12:55 +02:00