Netconf monitoring:
- Announce module capability - Return origin Yang file in get-schema
This commit is contained in:
parent
981d6f3797
commit
a38c54e4cc
8 changed files with 108 additions and 32 deletions
10
CHANGELOG.md
10
CHANGELOG.md
|
|
@ -1,5 +1,6 @@
|
|||
# Clixon Changelog
|
||||
|
||||
* [6.1.0](#610) Expected: beginning of 2023
|
||||
* [6.0.0](#600) 29 Nov 2022
|
||||
* [5.9.0](#590) 24 September 2022
|
||||
* [5.8.0](#580) 28 July 2022
|
||||
|
|
@ -37,6 +38,15 @@
|
|||
* [3.3.2](#332) Aug 27 2017
|
||||
* [3.3.1](#331) June 7 2017
|
||||
|
||||
## 6.1.0
|
||||
Expected: beginning of 2023
|
||||
|
||||
### Corrected Bugs
|
||||
|
||||
* Fixed [Netconf monitoring](https://github.com/clicon/clixon/issues/370)
|
||||
- Announce module capability
|
||||
- Return origin Yang file in get-schema
|
||||
|
||||
## 6.0.0
|
||||
29 Nov 2022
|
||||
|
||||
|
|
|
|||
|
|
@ -1075,6 +1075,8 @@ from_client_get_schema(clicon_handle h,
|
|||
yang_stmt *ymatch;
|
||||
yang_stmt *yrev;
|
||||
cbuf *cbyang = NULL;
|
||||
cbuf *cbmsg = NULL;
|
||||
const char *filename;
|
||||
|
||||
if ((yspec = clicon_dbspec_yang(h)) == NULL){
|
||||
clicon_err(OE_YANG, ENOENT, "No yang spec");
|
||||
|
|
@ -1121,12 +1123,25 @@ from_client_get_schema(clicon_handle h,
|
|||
ymatch = ymod;
|
||||
}
|
||||
if (ymatch == NULL){
|
||||
if (netconf_invalid_value(cbret, "protocol", "No such schema") < 0)
|
||||
if ((cbmsg = cbuf_new()) == NULL){
|
||||
clicon_err(OE_XML, errno, "cbuf_new");
|
||||
goto done;
|
||||
}
|
||||
if (version)
|
||||
cprintf(cbmsg, "No schema matching: %s@%s", identifier, version);
|
||||
else
|
||||
cprintf(cbmsg, "No schema matching: %s", identifier);
|
||||
if (netconf_invalid_value(cbret, "protocol", cbuf_get(cbmsg)) < 0)
|
||||
goto done;
|
||||
goto ok;
|
||||
}
|
||||
if (format && strcmp(format, "yang") != 0){
|
||||
if (netconf_invalid_value(cbret, "protocol", "Format not supported") < 0)
|
||||
if ((cbmsg = cbuf_new()) == NULL){
|
||||
clicon_err(OE_XML, errno, "cbuf_new");
|
||||
goto done;
|
||||
}
|
||||
cprintf(cbmsg, "Format not supported: %s", format);
|
||||
if (netconf_invalid_value(cbret, "protocol", cbuf_get(cbmsg)) < 0)
|
||||
goto done;
|
||||
goto ok;
|
||||
}
|
||||
|
|
@ -1136,12 +1151,17 @@ from_client_get_schema(clicon_handle h,
|
|||
clicon_err(OE_UNIX, errno, "cbuf_new");
|
||||
goto done;
|
||||
}
|
||||
yang_print_cbuf(cbyang, ymatch, 0, 0);
|
||||
if ((filename = yang_filename_get(ymatch)) != NULL){
|
||||
if (clicon_file_cbuf(filename, cbyang) < 0)
|
||||
goto done;
|
||||
}
|
||||
xml_chardata_cbuf_append(cbret, cbuf_get(cbyang));
|
||||
cprintf(cbret, "</data></rpc-reply>");
|
||||
ok:
|
||||
retval = 0;
|
||||
done:
|
||||
if (cbmsg)
|
||||
cbuf_free(cbmsg);
|
||||
if (cbyang)
|
||||
cbuf_free(cbyang);
|
||||
if (nsc)
|
||||
|
|
|
|||
|
|
@ -42,9 +42,8 @@
|
|||
|
||||
int clicon_file_dirent(const char *dir, struct dirent **ent,
|
||||
const char *regexp, mode_t type);
|
||||
|
||||
int clicon_files_recursive(const char *dir, const char *regexp, cvec *cvv);
|
||||
|
||||
int clicon_file_copy(char *src, char *target);
|
||||
int clicon_file_cbuf(const char *filename, cbuf *cb);
|
||||
|
||||
#endif /* _CLIXON_FILE_H_ */
|
||||
|
|
|
|||
|
|
@ -160,9 +160,9 @@ clicon_files_recursive(const char *dir,
|
|||
}
|
||||
|
||||
/*! Return alphabetically sorted files from a directory matching regexp
|
||||
*
|
||||
* @param[in] dir Directory path
|
||||
* @param[out] ent Entries pointer, will be filled in with dir entries. Free
|
||||
* after use
|
||||
* @param[in] regexp Regexp filename matching
|
||||
* @param[in] type File type matching, see stat(2)
|
||||
*
|
||||
|
|
@ -262,6 +262,9 @@ quit:
|
|||
}
|
||||
|
||||
/*! Make a copy of file src. Overwrite existing
|
||||
*
|
||||
* @param[in] src Source filename
|
||||
* @param[out] target Destination filename
|
||||
* @retval 0 OK
|
||||
* @retval -1 Error
|
||||
*/
|
||||
|
|
@ -304,3 +307,43 @@ clicon_file_copy(char *src,
|
|||
errno = err;
|
||||
return retval;
|
||||
}
|
||||
|
||||
/*! Read content of file into cbuf
|
||||
*
|
||||
* @param[in] filename
|
||||
* @param[out] cb
|
||||
* @retval 0 OK
|
||||
* @retval -1 Error
|
||||
*/
|
||||
int
|
||||
clicon_file_cbuf(const char *filename,
|
||||
cbuf *cb)
|
||||
{
|
||||
int retval = -1;
|
||||
int fd = 0;
|
||||
int err = 0;
|
||||
char line[512];
|
||||
int bytes;
|
||||
struct stat st;
|
||||
|
||||
if (stat(filename, &st) != 0){
|
||||
clicon_err(OE_UNIX, errno, "stat");
|
||||
return -1;
|
||||
}
|
||||
if ((fd = open(filename, O_RDONLY)) == -1) {
|
||||
clicon_err(OE_UNIX, errno, "open(%s) for read", filename);
|
||||
return -1;
|
||||
}
|
||||
while((bytes = read(fd, line, sizeof(line))) > 0)
|
||||
if (cbuf_append_buf(cb, line, bytes) < 0){
|
||||
clicon_err(OE_UNIX, errno, "cbuf_append_buf(%s)", filename);
|
||||
err = errno;
|
||||
goto error;
|
||||
}
|
||||
retval = 0;
|
||||
error:
|
||||
close(fd);
|
||||
if (retval < 0)
|
||||
errno = err;
|
||||
return retval;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1815,6 +1815,11 @@ netconf_capabilites(clicon_handle h,
|
|||
cprintf(cb, "</capability>");
|
||||
/* RFC5277 Notification Capability */
|
||||
cprintf(cb, "<capability>%s</capability>", NETCONF_NOTIFICATION_CAPABILITY);
|
||||
/* RFC6022 YANG Module for NETCONF Monitoring
|
||||
* This seems non-standard but necessary for most existing boxes and software
|
||||
*/
|
||||
if (clicon_option_bool(h, "CLICON_NETCONF_MONITORING"))
|
||||
cprintf(cb, "<capability>%s</capability>", NETCONF_MONITORING_NAMESPACE);
|
||||
|
||||
/* It is somewhat arbitrary why some features/capabilities are hardocded and why some are not
|
||||
* rfc 6241 Sec 8.4 confirmed-commit capabilities */
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ new "wait backend"
|
|||
wait_backend
|
||||
|
||||
new "Retrieving all state via <get> operation"
|
||||
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><get/></rpc>" "<rpc-reply $DEFAULTNS><data><netconf-state xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring\"><capabilities><capability>urn:ietf:params:netconf:base:1.0</capability><capability>urn:ietf:params:netconf:base:1.1</capability>.*</capabilities><schemas>.*</schemas></netconf-state></data></rpc-reply>" ""
|
||||
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><get/></rpc>" "<rpc-reply $DEFAULTNS><data><netconf-state xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring\"><capabilities><capability>urn:ietf:params:netconf:base:1.0</capability><capability>urn:ietf:params:netconf:base:1.1</capability>.*<capability>urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring</capability>.*</capabilities><schemas>.*</schemas></netconf-state></data></rpc-reply>"
|
||||
|
||||
# 4.1. Retrieving Schema List via <get> Operation
|
||||
new "Retrieving Schema List via <get> Operation"
|
||||
|
|
@ -63,30 +63,29 @@ expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS>
|
|||
# 4.2. Retrieving Schema Instances
|
||||
# From 2b. bar, version 2008-06-1 in YANG format, via get-schema
|
||||
new "Retrieving clixon-example schema instance using id, version, format"
|
||||
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><get-schema xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring\"><identifier>clixon-example</identifier><version>2022-01-01</version><format>yang</format></get-schema></rpc>" "<rpc-reply $DEFAULTNS><data xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring\">module clixon-example {yang-version 1.1;namespace urn:example:clixon;prefix ex;revision 2022-01-01;}</data></rpc-reply>"
|
||||
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><get-schema xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring\"><identifier>clixon-example</identifier><version>2022-01-01</version><format>yang</format></get-schema></rpc>" "<rpc-reply $DEFAULTNS><data xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring\">module clixon-example{"
|
||||
|
||||
new "Retrieving clixon-example schema instance using id, version only"
|
||||
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><get-schema xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring\"><identifier>clixon-example</identifier><version>2022-01-01</version></get-schema></rpc>" "<rpc-reply $DEFAULTNS><data xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring\">module clixon-example {yang-version 1.1;namespace urn:example:clixon;prefix ex;revision 2022-01-01;}</data></rpc-reply>"
|
||||
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><get-schema xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring\"><identifier>clixon-example</identifier><version>2022-01-01</version></get-schema></rpc>" "<rpc-reply $DEFAULTNS><data xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring\">module clixon-example{"
|
||||
|
||||
new "Retrieving clixon-example schema instance using id only"
|
||||
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><get-schema xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring\"><identifier>clixon-example</identifier></get-schema></rpc>" "<rpc-reply $DEFAULTNS><data xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring\">module clixon-example {yang-version 1.1;namespace urn:example:clixon;prefix ex;revision 2022-01-01;}</data></rpc-reply>"
|
||||
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><get-schema xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring\"><identifier>clixon-example</identifier></get-schema></rpc>" "<rpc-reply $DEFAULTNS><data xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring\">module clixon-example{"
|
||||
|
||||
new "Retrieving ietf-inet-types schema"
|
||||
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><get-schema xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring\"><identifier>ietf-inet-types</identifier></get-schema></rpc>" "<rpc-reply $DEFAULTNS><data xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring\">module ietf-inet-types {namespace urn:ietf:params:xml:ns:yang:ietf-
|
||||
inet-types;prefix inet"
|
||||
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><get-schema xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring\"><identifier>ietf-inet-types</identifier></get-schema></rpc>" "<rpc-reply $DEFAULTNS><data xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring\">module ietf-inet-types {"
|
||||
|
||||
# Negative tests
|
||||
new "get-schema: no id"
|
||||
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><get-schema xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring\"></get-schema></rpc>" "<rpc-reply $DEFAULTNS><rpc-error><error-type>application</error-type><error-tag>missing-element</error-tag><error-info><bad-element>identifier</bad-element></error-info><error-severity>error</error-severity><error-message>Mandatory variable of get-schema in module ietf-netconf-monitoring</error-message></rpc-error></rpc-reply>"
|
||||
|
||||
new "get-schema: non-existing schema"
|
||||
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><get-schema xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring\"><identifier>not-found</identifier></get-schema></rpc>" "<rpc-reply $DEFAULTNS><rpc-error><error-type>protocol</error-type><error-tag>invalid-value</error-tag><error-severity>error</error-severity><error-message>No such schema</error-message></rpc-error></rpc-reply>"
|
||||
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><get-schema xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring\"><identifier>not-found</identifier></get-schema></rpc>" "<rpc-reply $DEFAULTNS><rpc-error><error-type>protocol</error-type><error-tag>invalid-value</error-tag><error-severity>error</error-severity><error-message>No schema matching: not-found</error-message></rpc-error></rpc-reply>"
|
||||
|
||||
new "get-schema: non-existing format"
|
||||
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><get-schema xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring\"><identifier>clixon-example</identifier><version>2022-01-01</version><format>xsd</format></get-schema></rpc>" "<rpc-reply $DEFAULTNS><rpc-error><error-type>protocol</error-type><error-tag>invalid-value</error-tag><error-severity>error</error-severity><error-message>Format not supported</error-message></rpc-error></rpc-reply>"
|
||||
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><get-schema xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring\"><identifier>clixon-example</identifier><version>2022-01-01</version><format>xsd</format></get-schema></rpc>" "<rpc-reply $DEFAULTNS><rpc-error><error-type>protocol</error-type><error-tag>invalid-value</error-tag><error-severity>error</error-severity><error-message>Format not supported: xsd</error-message></rpc-error></rpc-reply>"
|
||||
|
||||
new "get-schema: non-existing date"
|
||||
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><get-schema xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring\"><identifier>clixon-example</identifier><version>2013-01-01</version><format>yang</format></get-schema></rpc>" "<rpc-reply $DEFAULTNS><rpc-error><error-type>protocol</error-type><error-tag>invalid-value</error-tag><error-severity>error</error-severity><error-message>No such schema</error-message></rpc-error></rpc-reply>"
|
||||
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><get-schema xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring\"><identifier>clixon-example</identifier><version>2013-01-01</version><format>yang</format></get-schema></rpc>" "<rpc-reply $DEFAULTNS><rpc-error><error-type>protocol</error-type><error-tag>invalid-value</error-tag><error-severity>error</error-severity><error-message>No schema matching: clixon-example@2013-01-01</error-message></rpc-error></rpc-reply>"
|
||||
|
||||
if [ $BE -ne 0 ]; then
|
||||
new "Kill backend"
|
||||
|
|
|
|||
|
|
@ -87,10 +87,10 @@ new "get-schema: multiple schemas, fail"
|
|||
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><get-schema xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring\"><identifier>clixon-example</identifier></get-schema></rpc>" "<rpc-reply $DEFAULTNS><rpc-error><error-type>application</error-type><error-tag>operation-failed</error-tag><error-app-tag>data-not-unique</error-app-tag><error-severity>error</error-severity></rpc-error></rpc-reply>"
|
||||
|
||||
new "get-schema: multiple schemas 2000-01-01"
|
||||
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><get-schema xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring\"><identifier>clixon-example</identifier><version>2000-01-01</version></get-schema></rpc>" "<rpc-reply $DEFAULTNS><data xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring\">module clixon-example {yang-version 1.1;namespace urn:example:clixon;prefix ex;revision 2000-01-01;}</data></rpc-reply>"
|
||||
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><get-schema xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring\"><identifier>clixon-example</identifier><version>2000-01-01</version></get-schema></rpc>" "<rpc-reply $DEFAULTNS><data xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring\">module clixon-example{"
|
||||
|
||||
new "get-schema: multiple schemas 2022-01-01"
|
||||
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><get-schema xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring\"><identifier>clixon-example</identifier><version>2022-01-01</version></get-schema></rpc>" "<rpc-reply $DEFAULTNS><data xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring\">module clixon-example {yang-version 1.1;namespace urn:example:clixon;prefix ex;revision 2022-01-01;}</data></rpc-reply>"
|
||||
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><get-schema xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring\"><identifier>clixon-example</identifier><version>2022-01-01</version></get-schema></rpc>" "<rpc-reply $DEFAULTNS><data xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring\">module clixon-example{"
|
||||
|
||||
if [ $BE -ne 0 ]; then
|
||||
new "Kill backend"
|
||||
|
|
|
|||
|
|
@ -144,7 +144,7 @@ EOF
|
|||
new "Start Listener client"
|
||||
echo "ssh -s -F $sshcfg -v -i $key -o ProxyUseFdpass=yes -o ProxyCommand=\"clixon_netconf_ssh_callhome_client -a 127.0.0.1\" . netconf"
|
||||
#-F $sshcfg
|
||||
expectpart "$(ssh -s -F $sshcfg -v -i $key -o ProxyUseFdpass=yes -o ProxyCommand="${clixon_netconf_ssh_callhome_client} -a 127.0.0.1" . netconf < $rpccmd)" 0 "<hello $DEFAULTONLY><capabilities><capability>urn:ietf:params:netconf:base:1.1</capability><capability>urn:ietf:params:netconf:base:1.0</capability><capability>urn:ietf:params:netconf:capability:yang-library:1.0?revision=2019-01-04&module-set-id=42</capability><capability>urn:ietf:params:netconf:capability:candidate:1.0</capability><capability>urn:ietf:params:netconf:capability:validate:1.1</capability><capability>urn:ietf:params:netconf:capability:xpath:1.0</capability><capability>urn:ietf:params:netconf:capability:with-defaults:1.0?basic-mode=explicit&also-supported=report-all,trim,report-all-tagged</capability><capability>urn:ietf:params:netconf:capability:notification:1.0</capability></capabilities><session-id>2</session-id></hello>" "<rpc-reply $DEFAULTNS><data/></rpc-reply>"
|
||||
expectpart "$(ssh -s -F $sshcfg -v -i $key -o ProxyUseFdpass=yes -o ProxyCommand="${clixon_netconf_ssh_callhome_client} -a 127.0.0.1" . netconf < $rpccmd)" 0 "<hello $DEFAULTONLY><capabilities><capability>urn:ietf:params:netconf:base:1.1</capability>.*</capabilities><session-id>2</session-id></hello>" "<rpc-reply $DEFAULTNS><data/></rpc-reply>"
|
||||
|
||||
# Wait
|
||||
wait
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue