* 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()`
This commit is contained in:
parent
dec05e2cae
commit
081e6871b3
45 changed files with 1804 additions and 900 deletions
|
|
@ -47,7 +47,7 @@ YANGSPECS += clixon-lib@2021-11-11.yang # 5.4
|
|||
YANGSPECS += clixon-rfc5277@2008-07-01.yang
|
||||
YANGSPECS += clixon-xml-changelog@2019-03-21.yang
|
||||
YANGSPECS += clixon-restconf@2021-05-20.yang # 5.2
|
||||
YANGSPECS += clixon-clispec@2021-12-05.yang # 5.5
|
||||
YANGSPECS += clixon-autocli@2021-12-05.yang # 5.5
|
||||
|
||||
all:
|
||||
|
||||
|
|
|
|||
202
yang/clixon/clixon-autocli@2021-12-05.yang
Normal file
202
yang/clixon/clixon-autocli@2021-12-05.yang
Normal file
|
|
@ -0,0 +1,202 @@
|
|||
module clixon-autocli{
|
||||
yang-version 1.1;
|
||||
namespace "http://clicon.org/autocli";
|
||||
prefix autocli;
|
||||
|
||||
organization
|
||||
"Clicon / Clixon";
|
||||
|
||||
contact
|
||||
"Olof Hagsand <olof@hagsand.se>";
|
||||
|
||||
description
|
||||
"Clixon CLIgen specification declarations, including autocli.
|
||||
Design inspired by ietf-netconf-acm.yang
|
||||
|
||||
***** BEGIN LICENSE BLOCK *****
|
||||
Copyright (C) 2020-2021 Olof Hagsand and Rubicon Communications, LLC(Netgate)
|
||||
|
||||
This file is part of CLIXON
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the \"License\");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an \"AS IS\" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
Alternatively, the contents of this file may be used under the terms of
|
||||
the GNU General Public License Version 3 or later (the \"GPL\"),
|
||||
in which case the provisions of the GPL are applicable instead
|
||||
of those above. If you wish to allow use of your version of this file only
|
||||
under the terms of the GPL, and not to allow others to
|
||||
use your version of this file under the terms of Apache License version 2,
|
||||
indicate your decision by deleting the provisions above and replace them with
|
||||
the notice and other provisions required by the GPL. If you do not delete
|
||||
the provisions above, a recipient may use your version of this file under
|
||||
the terms of any one of the Apache License version 2 or the GPL.
|
||||
|
||||
***** END LICENSE BLOCK *****";
|
||||
|
||||
revision 2021-12-05 {
|
||||
description
|
||||
"Initial version";
|
||||
}
|
||||
typedef autocli-op {
|
||||
description
|
||||
"Autocli rule-type operation, each rule use different fields as
|
||||
described in the individual enums below.";
|
||||
type enumeration {
|
||||
enum enable {
|
||||
description
|
||||
"Include a complete subtree to rendering of autocli.
|
||||
Example:
|
||||
<module-default>false</module-default>
|
||||
<rule>
|
||||
<name>wifi</name>
|
||||
<operation>enable</operation>
|
||||
<module-name>openconfig-wifi</module-name>
|
||||
</rule>
|
||||
Only on module-level and if module-default is false,
|
||||
Rule fields used: module-name";
|
||||
}
|
||||
enum compress {
|
||||
description
|
||||
"Skip a keyword from a command.
|
||||
Keep the command, only make it shorter by omitting a part.
|
||||
Example: compress containers if single list child
|
||||
<rule>
|
||||
<name>container compress</name>
|
||||
<operation>compress</operation>
|
||||
<yang-keyword>container</yang-keyword>
|
||||
<yang-keyword-child>list</yang-keyword-child>
|
||||
</rule>
|
||||
Rule fields used:
|
||||
module-name, yang-keyword, schema-nodeid, yang-keyword-child, extension";
|
||||
}
|
||||
/*--- NYI ----
|
||||
enum hide {
|
||||
description
|
||||
"A complete command (not just single keyword) is hidden from CLI query,
|
||||
help and completion, ie a user must type it manually.
|
||||
Example: 'start shell'";
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
typedef list-keyword-type {
|
||||
description
|
||||
"Autocli CLI keyword behaviour in YANG lists.
|
||||
With 'keyword' is meant CLIgen 'constants' rather than 'variables'.
|
||||
Assume a YANG LIST: list a{ key x; leaf x; leaf y;} and how to generate
|
||||
the autocli";
|
||||
type enumeration {
|
||||
enum kw-none{
|
||||
description "No extra keywords, only variables: a <x> <y>";
|
||||
}
|
||||
enum kw-nokey{
|
||||
description "Keywords on non-key variables: a <x> y <y>";
|
||||
}
|
||||
enum kw-all{
|
||||
description "Keywords on all variables: a x <x> y <y>";
|
||||
}
|
||||
}
|
||||
}
|
||||
grouping clixon-autocli{
|
||||
/* options */
|
||||
leaf module-default {
|
||||
description
|
||||
"Include YANG modules for generation of autocli.
|
||||
If true, all modules with a top-level datanode are generated, ie
|
||||
they get a top-level entry in the @basemodel tree.
|
||||
If false, you need to explicitly enable modules for autocli generation
|
||||
using 'enable' rules";
|
||||
type boolean;
|
||||
default true;
|
||||
}
|
||||
leaf list-keyword-default {
|
||||
description
|
||||
"Autocli CLI keyword behaviour in YANG lists.";
|
||||
type list-keyword-type;
|
||||
default kw-nokey;
|
||||
}
|
||||
leaf treeref-state-default {
|
||||
description
|
||||
"If 'true', generate CLI from YANG state/non-config statements as well, not only config data.
|
||||
Many specs have very large state parts, for example openconfig has ca 10 times
|
||||
larger state than config parts, see for example openconfig-isis.yang.";
|
||||
type boolean;
|
||||
default false;
|
||||
}
|
||||
leaf completion-default {
|
||||
description
|
||||
"Generate code for CLI completion of existing db symbols.
|
||||
That is, check existing configure database for completion options.
|
||||
This is normally always enabled.";
|
||||
type boolean;
|
||||
default true;
|
||||
}
|
||||
/* rules */
|
||||
list rule {
|
||||
description
|
||||
"Represents a modification rule of a clixon clispec.";
|
||||
key name;
|
||||
leaf name {
|
||||
description
|
||||
"Arbitrary name assigned for the rule, must be unique";
|
||||
type string;
|
||||
}
|
||||
leaf description {
|
||||
description
|
||||
"Rule description";
|
||||
type string;
|
||||
}
|
||||
leaf operation {
|
||||
description "Rule operation";
|
||||
type autocli-op;
|
||||
}
|
||||
leaf module-name {
|
||||
description
|
||||
"Name of the module associated with this rule.
|
||||
Wildchars '*' and '?' can be used (glob pattern).
|
||||
Revision and yang suffix are omitted
|
||||
Example: 'openconfig-*'";
|
||||
type string;
|
||||
}
|
||||
leaf yang-keyword {
|
||||
description
|
||||
"If present identifes a YANG keyword which the rule applies to
|
||||
Example: 'container'
|
||||
";
|
||||
type string;
|
||||
}
|
||||
leaf schema-nodeid {
|
||||
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 yang-keyword-child {
|
||||
description
|
||||
"The YANG statement has a single child, and the yang type of the child is the
|
||||
value of this option
|
||||
A (maybe too) specific property to cover openconfig compressions
|
||||
as defined here:
|
||||
https://github.com/openconfig/ygot/blob/master/docs/design.md#openconfig-path-compression";
|
||||
type string;
|
||||
}
|
||||
leaf extension {
|
||||
/* Consider making this a container with name/module/value instead */
|
||||
description
|
||||
"The extension is set either in the node itself, or in this module
|
||||
Extension prefix must be set
|
||||
Example: oc-ext:openconfig-version";
|
||||
type string;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,115 +0,0 @@
|
|||
module clixon-clispec{
|
||||
yang-version 1.1;
|
||||
namespace "http://clicon.org/clispec";
|
||||
prefix ccli;
|
||||
|
||||
organization
|
||||
"Clicon / Clixon";
|
||||
|
||||
contact
|
||||
"Olof Hagsand <olof@hagsand.se>";
|
||||
|
||||
description
|
||||
"Clixon CLIgen specification declarations, including autocli.
|
||||
|
||||
***** BEGIN LICENSE BLOCK *****
|
||||
Copyright (C) 2020-2021 Olof Hagsand and Rubicon Communications, LLC(Netgate)
|
||||
|
||||
This file is part of CLIXON
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the \"License\");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an \"AS IS\" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
Alternatively, the contents of this file may be used under the terms of
|
||||
the GNU General Public License Version 3 or later (the \"GPL\"),
|
||||
in which case the provisions of the GPL are applicable instead
|
||||
of those above. If you wish to allow use of your version of this file only
|
||||
under the terms of the GPL, and not to allow others to
|
||||
use your version of this file under the terms of Apache License version 2,
|
||||
indicate your decision by deleting the provisions above and replace them with
|
||||
the notice and other provisions required by the GPL. If you do not delete
|
||||
the provisions above, a recipient may use your version of this file under
|
||||
the terms of any one of the Apache License version 2 or the GPL.
|
||||
|
||||
***** END LICENSE BLOCK *****";
|
||||
|
||||
revision 2021-12-05 {
|
||||
description
|
||||
"Initial version";
|
||||
}
|
||||
|
||||
grouping clixon-clispec{
|
||||
list rule {
|
||||
description
|
||||
"Represents a modification rule of a clixon clispec.";
|
||||
ordered-by user; /* eg modules: omit * */
|
||||
key id;
|
||||
|
||||
leaf id {
|
||||
description
|
||||
"Arbitrary string index for the rule";
|
||||
type string;
|
||||
}
|
||||
leaf description {
|
||||
description
|
||||
"Rule description";
|
||||
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 {
|
||||
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 {
|
||||
description
|
||||
"A complete command (not just single keyword) is hidden from CLI query,
|
||||
help and completion, ie a user must type it manually.
|
||||
Example: 'start shell'";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -6,8 +6,8 @@ module clixon-config {
|
|||
import clixon-restconf {
|
||||
prefix clrc;
|
||||
}
|
||||
import clixon-clispec {
|
||||
prefix ccli;
|
||||
import clixon-autocli {
|
||||
prefix autocli;
|
||||
}
|
||||
organization
|
||||
"Clicon / Clixon";
|
||||
|
|
@ -48,11 +48,16 @@ module clixon-config {
|
|||
|
||||
revision 2021-12-05 {
|
||||
description
|
||||
"Added option:
|
||||
Imported sub-spec:
|
||||
clixon-clispec.yang
|
||||
Removed obsolete options:
|
||||
"Imported
|
||||
clixon-autocli.yang
|
||||
Removed (previosly marked) obsolete options:
|
||||
CLICON_YANG_LIST_CHECK
|
||||
Marked as obsolete:
|
||||
CLICON_CLI_GENMODEL (use autocli/enable-autocli instead)
|
||||
CLICON_CLI_GENMODEL_TYPE (use autocli/list-keyword-default and compress rules instead)
|
||||
CLICON_CLI_GENMODEL_COMPLETION (use autocli/completion-default instead)
|
||||
CLICON_CLI_AUTOCLI_EXCLUDE (use autocli/exclude logic instead)
|
||||
CLICON_CLI_MODEL_TREENAME (use constant AUTOCLI_TREENAME instead)
|
||||
Released in Clixon 5.5";
|
||||
}
|
||||
revision 2021-11-11 {
|
||||
|
|
@ -375,8 +380,8 @@ module clixon-config {
|
|||
container restconf {
|
||||
uses clrc:clixon-restconf;
|
||||
}
|
||||
container clispec {
|
||||
uses ccli:clixon-clispec;
|
||||
container autocli {
|
||||
uses autocli:clixon-autocli;
|
||||
}
|
||||
leaf-list CLICON_FEATURE {
|
||||
description
|
||||
|
|
@ -639,7 +644,9 @@ module clixon-config {
|
|||
This CLI tree can be accessed in CLI-spec files using the tree reference syntax (eg
|
||||
@datamodel).
|
||||
2: Same including state syntax in a tree called @datamodelstate and @datamodelshow
|
||||
See also CLICON_CLI_MODEL_TREENAME.";
|
||||
See also CLICON_CLI_MODEL_TREENAME.
|
||||
Obsolete, use clixon-autocli.yang enable-autocli instead";
|
||||
status obsolete;
|
||||
}
|
||||
leaf CLICON_CLI_MODEL_TREENAME {
|
||||
type string;
|
||||
|
|
@ -654,18 +661,21 @@ module clixon-config {
|
|||
Example: set @datamodel, cli_set();
|
||||
show @datamodelshow, cli_show_auto();
|
||||
show state @datamodelstate, cli_show_auto_state();
|
||||
Obsolete, use constant AUTOCLI_TREENAME instead;
|
||||
";
|
||||
status obsolete;
|
||||
}
|
||||
leaf CLICON_CLI_GENMODEL_COMPLETION {
|
||||
type int32;
|
||||
default 1;
|
||||
description "Generate code for CLI completion of existing db symbols.
|
||||
(consider boolean)";
|
||||
Obsolete, use autocli/completion-default instead";
|
||||
status obsolete;
|
||||
}
|
||||
leaf CLICON_CLI_GENMODEL_TYPE {
|
||||
type cli_genmodel_type;
|
||||
default "VARS";
|
||||
description "How to generate and show auto CLI syntax: VARS|ALL|HIDE";
|
||||
description "How to generate and show auto CLI syntax: VARS|ALL|HIDE|OC_COMPRESS";
|
||||
}
|
||||
leaf CLICON_CLI_AUTOCLI_EXCLUDE {
|
||||
type string;
|
||||
|
|
@ -674,8 +684,9 @@ module clixon-config {
|
|||
Example:
|
||||
<CLICON_CLI_AUTOCLI_EXCLUDE>clixon-restconf</CLICON_CLI_AUTOCLI_EXCLUDE>
|
||||
means generate autocli for all models except clixon-restconf.yang
|
||||
The value can be a list of space separated module names";
|
||||
default "clixon-restconf ietf-yang-library";
|
||||
The value can be a list of space separated module names
|
||||
Obsolete, use autocli/exclude logic instead";
|
||||
status obsolete;
|
||||
}
|
||||
leaf CLICON_CLI_VARONLY {
|
||||
type int32;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue