From 67e6e5e5e1efd577b0b4a24059777f63ff84aed5 Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Tue, 29 Nov 2022 09:15:30 +0100 Subject: [PATCH] Preparations for Clixon 6.0 release Test: - netconf-monitoring using http-data disabled for restconf=fcgi - updated cicd.sh script with detail and change logfile --- CHANGELOG.md | 23 ++--- CONTRIBUTING.md | 100 ++++++++++--------- README.md | 6 +- doc/DEVELOP.md | 116 ----------------------- test/cicd/Makefile.in | 4 +- test/cicd/cicd.sh | 2 +- test/test_netconf_monitoring_location.sh | 9 +- 7 files changed, 82 insertions(+), 178 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d959c705..4d34cac5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,12 +42,6 @@ Expected: Nov 2022 ### New features -* Netconf monitoring - * First part: Capabilities and schema state and get-schema - * Remains: Datastore, sessions and statistics state - * Standards - * RFC 6022 "YANG Module for NETCONF Monitoring" - * See [Feature Request: Support RFC 6022 (NETCONF Monitoring)](https://github.com/clicon/clixon/issues/370) * Confirmed-commit capability * Standards * RFC 4741 "NETCONF Configuration Protocol": Section 8.4 @@ -58,6 +52,12 @@ Expected: Nov 2022 * Added support for relevant arguments to CLI commit * See [example_cli.cli](https://github.com/clicon/clixon/blob/master/example/main/example_cli.cli) * See [Netconf Confirmed Commit Capability](https://github.com/clicon/clixon/issues/255) +* Netconf monitoring, part 1 + * Capabilities and schema state and get-schema + * Remaining: Datastore, sessions and statistics state + * Standards + * RFC 6022 "YANG Module for NETCONF Monitoring" + * See [Feature Request: Support RFC 6022 (NETCONF Monitoring)](https://github.com/clicon/clixon/issues/370) ### API changes on existing protocol/config features @@ -67,7 +67,7 @@ Users may have to change how they access the system * Added option: * `CLICON_NETCONF_MONITORING` * `CLICON_NETCONF_MONITORING_LOCATION` -* Added `PRETTYPRINT_INDENT` compile-time option controlling indentation level for XML,JSON and TEXT +* Added `PRETTYPRINT_INDENT` compile-time option controlling indentation level for XML, JSON, TEXT and YANG * Default value is `3` * NETCONF: Removed `message-id` from hello protocol following RFC 6241 * See [message-id present on netconf app "hello"](https://github.com/clicon/clixon/issues/369) @@ -78,7 +78,7 @@ Developers may need to change their code * [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 -* C API changes +* C API changes: * Added `expanddefault` parameter to `xml_yang_validate_rpc()` * Added `defaults` parameter to `clicon_rpc_get_pageable_list()` * `clicon_rpc_commit()` and `cli_commit` @@ -91,9 +91,10 @@ Developers may need to change their code ### Minor features -* Removed `YANG_ORDERING_WHEN_LAST` compile-time option (obsolete since 5.4) - * See https://github.com/clicon/clixon/issues/287 -* Removed `JSON_CDATA_STRIP` compile-time option (obsolete since 5.4) +* Removed obsoleted compile-time options since 5.4: + * `YANG_ORDERING_WHEN_LAST` + * See https://github.com/clicon/clixon/issues/287 + * `JSON_CDATA_STRIP` * Added fuzz code for xpath * List-pagination: Follow ietf-draft 100%: Removed list-pagination "presence" * Main example: Removed dependency of external IETF RFCs diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index fcdf92d9..1953fce0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -13,24 +13,22 @@ Note especially, the contribution license agreement (CLA) is described in the CL ## C style -Clixon uses 4-char indentation, a la emacs "cc-mode". +Clixon uses 4-char space indentation. ### Function declarations Functions in C code are written as follows: ``` - static int - myfn(int par1, - my_structure *par2) - { - int retval = -1; - my_structure *ms; +static int +myfn(int par1, + my_structure *par2) +{ + int retval = -1; + my_structure *ms; - ms = NULL; + ms = NULL; ``` - Notes: - 1. The return type of the function and all qualifers on first line (`static int`) 2. Function name and first parameter on second line, thereafter each parameter on own line 3. Each parameter indented to match the "longest" (`my_structure`) @@ -41,7 +39,7 @@ Notes: Function signatures are declared in include files or in forward declaration using "one-line" syntax, unless very long: ``` - static int myfn(int par1, my_structure *par2); +static int myfn(int par1, my_structure *par2); ``` ### Errors @@ -57,32 +55,29 @@ Errors are typically declared as follows: All function returns that have return values must be checked Default return values form a function are: - - `0` OK - `-1` Fatal Error In some cases, Clixon uses three-value returns as follows: - - `1` OK -- `0` Invalid (and usually a cxobj* return value) +- `0` Invalid - `-1` Fatal error ### Return values -Clixon uses goto:s only to get a single point of exit functions as follows:: +Clixon uses goto:s only to get a single point of exit functions as follows: ``` - { - int retval = -1; - - ... - retval = 0; - done: - return retval - } +{ + int retval = -1; + + ... + retval = 0; + done: + return retval +} ``` Notes: - 1. Use only a single return statement in a function 2. Do not use of goto:s in other ways @@ -90,30 +85,47 @@ Notes: Use `/* */`. Use `//` only for temporal comments. -Do not use `======`, `>>>>>` or `<<<<<<` in comments since git merge conflict uses that. +Do not use "======", ">>>>>" or "<<<<<<" in comments since git merge conflict uses that. -## Documentation +### Format ints -How to document the code: +Use: + +- %zu for size_t +- PRIu64 for uint64 +- %p for pointers + +### Include files + +Avoid include statements in .h files, place them in .c files whenever possible. + +The reason is to avoid deep include chains where file dependencies are +difficult to analyze and understand. If include statements are only placed in .c +files, there is only a single level of include file dependencies. + +The drawback is that the same include file may need to be repeated in many .c files. + +### Structs + +Struct fields should have a prefix to distinguish them from other struct fields. The prefix should use an abbreviation of the struct name. + +Example: ``` - /*! This is a small comment on one line - * - * This is a detailed description - * spanning several lines. - * - * @param[in] src This is a description of the first parameter - * @param[in,out] dest This is a description of the second parameter - * @retval 0 This is a description of the return value - * @retval -1 This is a description of another return value - * - * Example usage: - * @code - * fn(a, &b); - * @endcode - * - * @see See also this function - */ + struct my_struct{ + int ms_foo; + char *ms_string[42]; + } ``` +where `ms_` is the prefix and is an abbreviation of `my_struct`. + +### Global variables + +Try to avoid global variables. + +If you absolutely need a global variable, try to contain it as static within a +single C-file, ie do not declare it extern and use it elsewhere. + +Also, always prepend a global variable with `_`, underscore. ## Testing diff --git a/README.md b/README.md index 333ed83d..530176c4 100644 --- a/README.md +++ b/README.md @@ -13,10 +13,10 @@ See [documentation](https://clixon-docs.readthedocs.io), [project page](https:// Clixon is open-source and dual licensed. Either Apache License, Version 2.0 or GNU General Public License Version 2; you choose, see [LICENSE.md](LICENSE.md). -Clixon has a master branch continuously tested with CI, but releases are made ca every second month. Latest 5.9.0 release is from September 2022. Next is planned for November 2022. See [CHANGELOG.md](CHANGELOG.md) release history. +Clixon has a master branch continuously tested with CI, but releases are made ca every second month. Latest 6.0.0 release is from November 2022. Next is planned for January 2023. See [CHANGELOG.md](CHANGELOG.md) release history. Clixon interaction is best done posting issues, pull requests, or joining the [slack channel](https://clixondev.slack.com). -[Slack invite](https://join.slack.com/t/clixondev/shared_invite/zt-1fz8at20n-KGNmKD7KH2j2jIFGU_EhMQ)(updated 15/9 2022, valid 30d) +[Slack invite](https://join.slack.com/t/clixondev/shared_invite/zt-1kl2nxe91-9vdsyYNjhU3ZP57nZq_2rw)(updated 29/11 2022, valid 30d) -Clixon is sponsored by [Rubicon Communications LLC(Netgate)](https://www.netgate.com/) and [Akamai Technologies, Inc.](https://www.akamai.com). \ No newline at end of file +Clixon is sponsored by [Rubicon Communications LLC(Netgate)](https://www.netgate.com/) and [Akamai Technologies, Inc.](https://www.akamai.com). diff --git a/doc/DEVELOP.md b/doc/DEVELOP.md index 3823d7cb..2514f33f 100644 --- a/doc/DEVELOP.md +++ b/doc/DEVELOP.md @@ -1,7 +1,6 @@ # README for Clixon developers * [Code documentation](#documentation) - * [C style](#c-style) * [How to work in git (how-to-work-in-git)](#how-to-work-in-git) * [How the meta-configure stuff works](#meta-configure) * [How to debug](#debug) @@ -29,121 +28,6 @@ How to document the code */ ``` -## C style - -Clixon uses 4-char indentation, a la emacs "cc-mode". - -### Function declarations - -Functions in C code are written as follows: -``` -static int -myfn(int par1, - my_structure *par2) -{ - int retval = -1; - my_structure *ms; - - ms = NULL; -``` -Notes: -1. The return type of the function and all qualifers on first line (`static int`) -2. Function name and first parameter on second line, thereafter each parameter on own line -3. Each parameter indented to match the "longest" (`my_structure`) -4. Pointer declarations written: `type *p`, not: `type* p`. -5. All local variables in a function declared at top of function, not inline with C-statements. -6. Local variables can be initialized with scalars or constants, not eg malloc or functions with return values that need to be checked for errors -7. There is a single empty line between local variable declarations and the first function statement. - -Function signatures are declared in include files or in forward declaration using "one-line" syntax, unless very long: -``` -static int myfn(int par1, my_structure *par2); -``` - -### Errors - -Errors are typically declared as follows: -``` - if (myfn(0) < 0){ - clicon_err(OE_UNIX, EINVAL, "myfn"); - goto done; - } -``` - -All function returns that have return values must be checked - -Default return values form a function are: -- `0` OK -- `-1` Fatal Error - -In some cases, Clixon uses three-value returns as follows: -- `1` OK -- `0` Invalid -- `-1` Fatal error - -### Return values - -Clixon uses goto:s only to get a single point of exit functions as follows: -``` -{ - int retval = -1; - - ... - retval = 0; - done: - return retval -} -``` - -Notes: -1. Use only a single return statement in a function -2. Do not use of goto:s in other ways - -### Comments - -Use `/* */`. Use `//` only for temporal comments. - -Do not use "======", ">>>>>" or "<<<<<<" in comments since git merge conflict uses that. - -### Format ints - -Use: -- %zu for size_t -- PRIu64 for uint64 -- %p for pointers - -### Include files - -Avoid include statements in .h files, place them in .c files whenever possible. - -The reason is to avoid deep include chains where file dependencies are -difficult to analyze and understand. If include statements are only placed in .c -files, there is only a single level of include file dependencies. - -The drawback is that the same include file may need to be repeated in many .c files. - -### Structs - -Struct fields should have a prefix to distinguish them from other struct fields. The prefix should use an abbreviation of the struct name. - -Example: -``` -struct my_struct{ - int ms_foo; - char *ms_string[42]; -} -``` -where `ms_` is the prefix and is an abbreviation of `my_struct`. - -### Global variables - -Try to avoid global variables. - -If you absolutely need one, try to contain it as static within a -single C-file, ie do not declare it extern and use it elsewhere. - -Also, always prepend a global variable with `_`, underscore. - ## How to work in git Clixon uses semantic versioning (https://semver.org). diff --git a/test/cicd/Makefile.in b/test/cicd/Makefile.in index f70a8a67..2b522668 100644 --- a/test/cicd/Makefile.in +++ b/test/cicd/Makefile.in @@ -58,9 +58,9 @@ all: $(HOSTS) # Real hosts reachable by ssh $(HOSTS): ifdef LOGDIR - ./cicd.sh $@ $(RESTCONF) 2>&1 > $(LOGDIR)/$@-$(RESTCONF).log + ./cicd.sh $@ $(RESTCONF) 2>&1 > $(LOGDIR)/host-$(RESTCONF)-$@.log else - ./cicd.sh $@ $(RESTCONF) 2>&1 | tee /$@-$(RESTCONF).log + ./cicd.sh $@ $(RESTCONF) 2>&1 | tee /host-$(RESTCONF)-$@.log endif clean: diff --git a/test/cicd/cicd.sh b/test/cicd/cicd.sh index 5b9095ad..40b11c05 100755 --- a/test/cicd/cicd.sh +++ b/test/cicd/cicd.sh @@ -54,5 +54,5 @@ if [ "$restconf" = "fcgi" ]; then else ssh -t $h sudo systemctl stop nginx fi -ssh -t $h "(cd src/clixon/test; ./sum.sh)" +ssh -t $h "(cd src/clixon/test; detail=true ./sum.sh)" exit 0 diff --git a/test/test_netconf_monitoring_location.sh b/test/test_netconf_monitoring_location.sh index 604b3526..ae387ca9 100755 --- a/test/test_netconf_monitoring_location.sh +++ b/test/test_netconf_monitoring_location.sh @@ -1,12 +1,19 @@ #!/usr/bin/env bash # Test for RFC6022 YANG Module for NETCONF Monitoring -# Tests the location scheme by using the clixon http-data feature +# Tests the location scheme by using the clixon http-data feature (only restconf=native) # Magic line must be first in script (see README.md) s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi APPNAME=example +# Does not work with fcgi +if [ "${WITH_RESTCONF}" = "fcgi" ]; then + echo "...skipped: Must run with --with-restconf=native" + rm -rf $dir + if [ "$s" = $0 ]; then exit 0; else return 0; fi +fi + cfg=$dir/conf_yang.xml fyang=$dir/clixon-example@2022-01-01.yang