CLI: Added meta format pipe-xml-default for cli commands inside pipes
This commit is contained in:
parent
c24c38dbb5
commit
2790d243e1
5 changed files with 21 additions and 294 deletions
|
|
@ -870,6 +870,13 @@ cli_show_option_format(clixon_handle h,
|
||||||
clixon_err(OE_PLUGIN, 0, "Not valid format: %s", formatstr);
|
clixon_err(OE_PLUGIN, 0, "Not valid format: %s", formatstr);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
/* Special pipe xml default handling */
|
||||||
|
if (format == FORMAT_PIPE_XML_DEFAULT){
|
||||||
|
if (cligen_spipe_get(cli_cligen(h)) != -1)
|
||||||
|
format = FORMAT_XML;
|
||||||
|
else
|
||||||
|
format = FORMAT_DEFAULT;
|
||||||
|
}
|
||||||
/* Special default format handling */
|
/* Special default format handling */
|
||||||
if (format == FORMAT_DEFAULT){
|
if (format == FORMAT_DEFAULT){
|
||||||
formatstr = clicon_option_str(h, "CLICON_CLI_OUTPUT_FORMAT");
|
formatstr = clicon_option_str(h, "CLICON_CLI_OUTPUT_FORMAT");
|
||||||
|
|
@ -877,6 +884,10 @@ cli_show_option_format(clixon_handle h,
|
||||||
clixon_err(OE_PLUGIN, 0, "Not valid format: %s", formatstr);
|
clixon_err(OE_PLUGIN, 0, "Not valid format: %s", formatstr);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
if (format > FORMAT_NETCONF){
|
||||||
|
clixon_err(OE_PLUGIN, 0, "Not concrete format: %d", format);
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
*formatp = format;
|
*formatp = format;
|
||||||
retval = 0;
|
retval = 0;
|
||||||
|
|
|
||||||
|
|
@ -189,8 +189,9 @@ enum format_enum{
|
||||||
FORMAT_JSON,
|
FORMAT_JSON,
|
||||||
FORMAT_TEXT,
|
FORMAT_TEXT,
|
||||||
FORMAT_CLI,
|
FORMAT_CLI,
|
||||||
FORMAT_NETCONF,
|
FORMAT_NETCONF, /* Last concrete format, used in code */
|
||||||
FORMAT_DEFAULT
|
FORMAT_DEFAULT, /* Indirect: actual value in CLICON_CLI_OUTPUT_FORMAT */
|
||||||
|
FORMAT_PIPE_XML_DEFAULT /* Meta: If pipe, xml, if not default */
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -131,12 +131,13 @@ static const map_str2int yang_regexp_map[] = {
|
||||||
* @see enum format_enum
|
* @see enum format_enum
|
||||||
*/
|
*/
|
||||||
static const map_str2int _FORMATS[] = {
|
static const map_str2int _FORMATS[] = {
|
||||||
{"xml", FORMAT_XML},
|
{"xml", FORMAT_XML},
|
||||||
{"text", FORMAT_TEXT},
|
{"text", FORMAT_TEXT},
|
||||||
{"json", FORMAT_JSON},
|
{"json", FORMAT_JSON},
|
||||||
{"cli", FORMAT_CLI},
|
{"cli", FORMAT_CLI},
|
||||||
{"netconf", FORMAT_NETCONF},
|
{"netconf", FORMAT_NETCONF},
|
||||||
{"default", FORMAT_DEFAULT},
|
{"default", FORMAT_DEFAULT},
|
||||||
|
{"pipe-xml-default", FORMAT_PIPE_XML_DEFAULT},
|
||||||
{NULL, -1}
|
{NULL, -1}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -937,7 +937,6 @@ yspec_new1(clixon_handle h,
|
||||||
* @param[in] h Clixon handle
|
* @param[in] h Clixon handle
|
||||||
* @param[in] xpath Mount xpath, saved in cvec
|
* @param[in] xpath Mount xpath, saved in cvec
|
||||||
* @param[in] domain YANG domain
|
* @param[in] domain YANG domain
|
||||||
* @param[in] domain YANG spec name
|
|
||||||
* @param[in] yspec0 Input NULL if no previous shared exist, otherwise a shared yspec but new name
|
* @param[in] yspec0 Input NULL if no previous shared exist, otherwise a shared yspec but new name
|
||||||
* @retval yspec1 New or (previously shared)
|
* @retval yspec1 New or (previously shared)
|
||||||
* @retval NULL Error
|
* @retval NULL Error
|
||||||
|
|
|
||||||
|
|
@ -1,285 +0,0 @@
|
||||||
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 2023-09-01 {
|
|
||||||
description
|
|
||||||
"Added argument to alias extension
|
|
||||||
Released in Clixon 6.3";
|
|
||||||
}
|
|
||||||
revision 2023-05-01 {
|
|
||||||
description
|
|
||||||
"Added extensions skip and alias
|
|
||||||
Added grouping-treeref
|
|
||||||
Released in Clixon 6.3";
|
|
||||||
}
|
|
||||||
revision 2022-02-11 {
|
|
||||||
description
|
|
||||||
"Released in Clixon 5.6";
|
|
||||||
}
|
|
||||||
revision 2021-12-05 {
|
|
||||||
description
|
|
||||||
"Initial version
|
|
||||||
Released in Clixon 5.5";
|
|
||||||
}
|
|
||||||
extension hide {
|
|
||||||
description
|
|
||||||
"Hide the command associated with a YANG node and its
|
|
||||||
sub-commands.
|
|
||||||
The command is active but not shown by ? or TAB. In other words, it hides the
|
|
||||||
auto-completion of commands";
|
|
||||||
}
|
|
||||||
extension hide-show {
|
|
||||||
description
|
|
||||||
"Hide the command associated with a YANG node and its
|
|
||||||
sub-commands in CLI show commands.";
|
|
||||||
}
|
|
||||||
extension skip {
|
|
||||||
description
|
|
||||||
"Skip the command associated with a YANG node and its sub-commands altogether.
|
|
||||||
The command is completely removed from the CLI, but still exists in NETCONF/
|
|
||||||
RESTCONF.";
|
|
||||||
}
|
|
||||||
extension strict-expand {
|
|
||||||
description
|
|
||||||
"Modify the autocli by only showing exactly the expanded values of a variable.
|
|
||||||
It should not be possible to add a new value that is not in the expanded list.";
|
|
||||||
}
|
|
||||||
extension alias {
|
|
||||||
description
|
|
||||||
"Replace the command name with a new value.
|
|
||||||
Instead of using the YANG argument name, use new argument instead.
|
|
||||||
Only implemented for YANG leafs";
|
|
||||||
argument new;
|
|
||||||
}
|
|
||||||
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";
|
|
||||||
}
|
|
||||||
enum edit-mode {
|
|
||||||
description
|
|
||||||
"Autocli CLI edit modes for YANG symbols.
|
|
||||||
For example,
|
|
||||||
edit interface eth0<CR>
|
|
||||||
enters a new mode with local context.";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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>";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
typedef yang-keywords {
|
|
||||||
type bits {
|
|
||||||
bit list;
|
|
||||||
bit listall{ /* NYI */
|
|
||||||
description
|
|
||||||
"Variant of list encompassing all list entries, not just an instance";
|
|
||||||
}
|
|
||||||
bit container;
|
|
||||||
bit leaf; /* Also leaf-list (NYI) */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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 edit-mode-default {
|
|
||||||
description
|
|
||||||
"Open automatic edit-modes for some YANG keywords and do not allow others.
|
|
||||||
A CLI edit mode opens a carriage-return option and changes the context to be
|
|
||||||
in that local context.
|
|
||||||
For example:
|
|
||||||
cli> interfaces interface e0<cr>
|
|
||||||
eth0>
|
|
||||||
Default is to generate edit-modes for all containers and lists.";
|
|
||||||
type yang-keywords;
|
|
||||||
default "list container";
|
|
||||||
}
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
leaf grouping-treeref {
|
|
||||||
description
|
|
||||||
"Controls the behaviour when generating CLISPEC of YANG 'uses' statements into the
|
|
||||||
corresponding 'grouping' definition: macro expansion.
|
|
||||||
For optimization of memory footprint.
|
|
||||||
If 'false', replace the uses definition with the grouping definition.
|
|
||||||
If 'true' use indirect tree reference '@treeref' to reference the grouping definition. This
|
|
||||||
saves memory for large YANGs.
|
|
||||||
|
|
||||||
See also AUTOCLI_GROUPING_TOPLEVEL_SKIP and AUTOCLI_GROUPING_AUGMENT_SKIP for
|
|
||||||
temporary disabled cornercases.
|
|
||||||
This option was introduced in Clixon 6.3";
|
|
||||||
type boolean;
|
|
||||||
default false;
|
|
||||||
}
|
|
||||||
/* 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue