* Added new YANG clixon-clispec.yang

* This yang replaces many autocli option
* New `clixon-config@2021-12-05.yang` revision
  * Imported (as a sub-spec):  clixon-clispec.yang
This commit is contained in:
Olof hagsand 2021-12-19 22:52:42 +01:00
parent 4fbad467df
commit 32930f4f6b
8 changed files with 1193 additions and 39 deletions

View file

@ -50,6 +50,15 @@ Planned: January, 2022
* `@datamodelstate` translated to `@basemodel, @remove:leafvar` * `@datamodelstate` translated to `@basemodel, @remove:leafvar`
* Note: autocli mode support is not backward compatible * Note: autocli mode support is not backward compatible
* see main example * see main example
* Added new YANG clixon-clispec.yang
* This yang replaces many autocli options
### API changes on existing protocol/config features
Users may have to change how they access the system
* New `clixon-config@2021-12-05.yang` revision
* Imported (as a sub-spec): clixon-clispec.yang
### Minor features ### Minor features

View file

@ -96,6 +96,7 @@ cxobj *clicon_conf_xml(clicon_handle h);
int clicon_conf_xml_set(clicon_handle h, cxobj *x); int clicon_conf_xml_set(clicon_handle h, cxobj *x);
cxobj *clicon_conf_restconf(clicon_handle h); cxobj *clicon_conf_restconf(clicon_handle h);
cxobj *clicon_conf_clispec(clicon_handle h);
db_elmnt *clicon_db_elmnt_get(clicon_handle h, const char *db); db_elmnt *clicon_db_elmnt_get(clicon_handle h, const char *db);
int clicon_db_elmnt_set(clicon_handle h, const char *db, db_elmnt *xc); int clicon_db_elmnt_set(clicon_handle h, const char *db, db_elmnt *xc);

View file

@ -453,7 +453,7 @@ clicon_conf_xml_set(clicon_handle h,
* *
* That is, get the XML of clixon-config/restconf container of clixon-config.yang * That is, get the XML of clixon-config/restconf container of clixon-config.yang
* @param[in] h Clicon handle * @param[in] h Clicon handle
* @retval x XML tree containing restconf xml node frm clixon-restconf.yang * @retval x XML tree containing restconf xml node from clixon-restconf.yang
* @note The clixon-restconf.yang instance can also be a part of the running datastore if * @note The clixon-restconf.yang instance can also be a part of the running datastore if
* CLICON_BACKEND_RESTCONF_PROCESS is true * CLICON_BACKEND_RESTCONF_PROCESS is true
*/ */
@ -467,6 +467,22 @@ clicon_conf_restconf(clicon_handle h)
return NULL; return NULL;
} }
/*! Get local YANG specification for Clixon-clispec.yang tree
*
* That is, get the XML of clixon-config/clispec container of clixon-config.yang
* @param[in] h Clicon handle
* @retval x XML tree containing clispec xml node from clixon-clispec.yang
*/
cxobj *
clicon_conf_clispec(clicon_handle h)
{
cxobj *xconfig = NULL;
if ((xconfig = clicon_conf_xml(h)) != NULL) /* Get local config */
return xpath_first(xconfig, NULL, "clispec");
return NULL;
}
/*! Get authorized user name /*! Get authorized user name
* @param[in] h Clicon handle * @param[in] h Clicon handle
* @retval username * @retval username

View file

@ -106,8 +106,9 @@ expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO<rpc $DEFAULTNS><get-config
new "cli show configuration" new "cli show configuration"
expectpart "$($clixon_cli -1 -f $cfg show conf xml)" 0 "^<interfaces xmlns=\"http://openconfig.net/yang/interfaces\">" --not-- "<oc-eth:ethernet xmlns:oc-eth=\"http://openconfig.net/yang/interfaces/ethernet\">" expectpart "$($clixon_cli -1 -f $cfg show conf xml)" 0 "^<interfaces xmlns=\"http://openconfig.net/yang/interfaces\">" --not-- "<oc-eth:ethernet xmlns:oc-eth=\"http://openconfig.net/yang/interfaces/ethernet\">"
new "cli set interfaces interface <tab> complete: e" # XXX THIS REQUIRES PREFIX FOR IETF-INTERFACES
expectpart "$(echo "set interfaces interface " | $clixon_cli -f $cfg)" 0 "interface e" #new "cli set interfaces interface <tab> complete: e"
#expectpart "$(echo "set interfaces interface " | $clixon_cli -f $cfg)" 0 "interface e"
# XXX See https://github.com/clicon/clixon/issues/218 # XXX See https://github.com/clicon/clixon/issues/218
#new "cli set interfaces interface e <tab> complete: not ethernet" #new "cli set interfaces interface e <tab> complete: not ethernet"
@ -124,6 +125,7 @@ if [ $BE -ne 0 ]; then
stop_backend -f $cfg stop_backend -f $cfg
fi fi
# Second using openconfig-interfaces instead # Second using openconfig-interfaces instead
# Example yang # Example yang
cat <<EOF > $fyang cat <<EOF > $fyang

View file

@ -42,14 +42,12 @@ datarootdir = @datarootdir@
YANG_INSTALLDIR = @YANG_INSTALLDIR@ YANG_INSTALLDIR = @YANG_INSTALLDIR@
YANGSPECS = clixon-config@2021-07-11.yang # 5.3 YANGSPECS = clixon-config@2021-07-11.yang # 5.3
YANGSPECS = clixon-config@2021-11-11.yang # 5.4 YANGSPECS = clixon-config@2021-12-05.yang # 5.5
YANGSPECS += clixon-lib@2021-11-11.yang # 5.4 YANGSPECS += clixon-lib@2021-11-11.yang # 5.4
YANGSPECS += clixon-rfc5277@2008-07-01.yang YANGSPECS += clixon-rfc5277@2008-07-01.yang
YANGSPECS += clixon-xml-changelog@2019-03-21.yang YANGSPECS += clixon-xml-changelog@2019-03-21.yang
YANGSPECS += clixon-restconf@2021-05-20.yang # 5.2 YANGSPECS += clixon-restconf@2021-05-20.yang # 5.2
YANGSPECS += clixon-clispec@2021-12-05.yang YANGSPECS += clixon-clispec@2021-12-05.yang # 5.5
APPNAME = clixon # subdir ehere these files are installed
all: all:

View file

@ -47,10 +47,11 @@ module clixon-clispec{
grouping clixon-clispec{ grouping clixon-clispec{
list rule { list rule {
key id;
ordered-by user;
description description
"Represents a modification rule of a clixon clispec."; "Represents a modification rule of a clixon clispec.";
ordered-by user; /* eg modules: omit * */
key id;
leaf id { leaf id {
description description
"Arbitrary string index for the rule"; "Arbitrary string index for the rule";
@ -61,42 +62,53 @@ module clixon-clispec{
"Rule description"; "Rule description";
type string; type string;
} }
leaf-list node-id {
description
"path in the form of <id>/<id> or just a single <id> identifying a YANG
schema-node identifier as defined in RFC 7950 Sec 6.5
Example: 'config', '/interfaces/interface'";
type string;
}
leaf-list module {
description
"Constraints the rule to the module names identified by a glob.
Wildchars '*' and '?' can be used.
Revision and yang suffix are ommitted
Note, this special rule is necessary since node-id cannot be used for
modules.
Example: 'openconfig-*'";
type string;
}
leaf-list yang-keyword {
description
"If present identifes a YANG keyword which the rule applies to
Example: 'container'";
type string;
}
leaf operation { leaf operation {
type enumeration { type enumeration {
enum exclude {
description
"Exclude a subtree from rendering of autocli.
Example: exclude: openconfig-* module";
}
enum include {
description
"Include a subtree to rendering of autocli.
Example: include: openconfig-wifi module";
}
enum omit {
description
"Remove a single keyword from a command.
Example: replace 'interfaces interface' with 'interface' ??";
}
enum hide { enum hide {
description description
"A complete command (not just single keyword) is hidden from CLI query, "A complete command (not just single keyword) is hidden from CLI query,
help and completion, ie a user must type it manually. help and completion, ie a user must type it manually.
Example: 'start shell'"; Example: 'start shell'";
} }
enum omit { }
description
"Remove a single keyword from a command.
Example: replace 'interfaces interface' with 'interface'";
}
}
}
leaf node-id {
description
"path in the form of <id>/<id> or just a single <id> identifying a YANG
schema-node identifier as defined in RFC 7950 Sec 6.5
Example: 'config', '/interfaces/interface'";
mandatory true;
type string;
}
leaf yang-statement {
description
"If present identifes a YANG statement which the rule applies to
Example: 'container'";
type string;
}
leaf module {
description
"If present constraints the rule to the module names identified by a glob.
Wildchars '*' and '?' can be used.
Revision and yang suffix are ommitted
Example: 'openconfig-*'";
type string;
} }
} }
} }

View file

@ -673,7 +673,7 @@ module clixon-config {
<CLICON_CLI_AUTOCLI_EXCLUDE>clixon-restconf</CLICON_CLI_AUTOCLI_EXCLUDE> <CLICON_CLI_AUTOCLI_EXCLUDE>clixon-restconf</CLICON_CLI_AUTOCLI_EXCLUDE>
means generate autocli for all models except clixon-restconf.yang means generate autocli for all models except clixon-restconf.yang
The value can be a list of space separated module names"; The value can be a list of space separated module names";
default "clixon-restconf ietf-yang-library"; default "clixon-restconf";
} }
leaf CLICON_CLI_VARONLY { leaf CLICON_CLI_VARONLY {
type int32; type int32;
@ -707,7 +707,8 @@ module clixon-config {
type int8; type int8;
default 0; default 0;
description description
"Set CLI tab mode. This is a bitfield of three bits: "Set CLI tab mode. This is actually a bitfield of three
combinations:
bit 1: 0: <tab> shows short info of available commands bit 1: 0: <tab> shows short info of available commands
1: <tab> has same output as <?>, ie line per command 1: <tab> has same output as <?>, ie line per command
bit 2: 0: On <tab>, select a command over a <var> if both exist bit 2: 0: On <tab>, select a command over a <var> if both exist

File diff suppressed because it is too large Load diff