Files
infix/src/klinfix/xml/infix.xml
T
Joachim WibergandTobias Waldekranz 30a28fe874 klinfix: modify show datetime, add optional [iso] flag
By default, output human-friendly RFC2822 format rather than NETCONF:ish
ISO-8601 format.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-08-08 16:35:18 +02:00

366 lines
11 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<KLISH
xmlns="https://klish.libcode.org/klish3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://src.libcode.org/pkun/klish/src/master/klish.xsd">
<PLUGIN name="klish"/>
<PLUGIN name="klinfix"/>
<PLUGIN name="script"/>
<PLUGIN name="sysrepo">
ShowBrackets = y
ShowSemicolons = y
FirstKeyWithStatement = n
MultiKeysWithStatement = y
Colorize = y
Indent = 2
HidePasswords = y
DefaultKeys = n
EnableNACM = y
</PLUGIN>
<PTYPE name="DATASTORE">
<COMPL>
<ACTION sym="printl">factory-config</ACTION>
<ACTION sym="printl">startup-config</ACTION>
<ACTION sym="printl">running-config</ACTION>
</COMPL>
<ACTION sym="STRING"/>
</PTYPE>
<PTYPE name="RW_DATASTORE">
<COMPL>
<ACTION sym="printl">startup-config</ACTION>
<ACTION sym="printl">running-config</ACTION>
</COMPL>
<ACTION sym="STRING"/>
</PTYPE>
<PTYPE name="PLINE_SET">
<COMPL>
<ACTION sym="srp_compl@sysrepo"/>
</COMPL>
<HELP>
<ACTION sym="srp_help@sysrepo"/>
</HELP>
<ACTION sym="PLINE_SET@sysrepo"/>
</PTYPE>
<PTYPE name="PLINE_DEL">
<COMPL>
<ACTION sym="srp_compl@sysrepo"/>
</COMPL>
<HELP>
<ACTION sym="srp_help@sysrepo"/>
</HELP>
<ACTION sym="PLINE_DEL@sysrepo"/>
</PTYPE>
<PTYPE name="PLINE_EDIT">
<COMPL>
<ACTION sym="srp_compl@sysrepo"/>
</COMPL>
<HELP>
<ACTION sym="srp_help@sysrepo"/>
</HELP>
<ACTION sym="PLINE_EDIT@sysrepo"/>
</PTYPE>
<PTYPE name="PLINE_INSERT_FROM">
<COMPL>
<ACTION sym="srp_compl@sysrepo"/>
</COMPL>
<HELP>
<ACTION sym="srp_help@sysrepo"/>
</HELP>
<ACTION sym="PLINE_INSERT_FROM@sysrepo"/>
</PTYPE>
<PTYPE name="PLINE_INSERT_TO">
<COMPL>
<ACTION sym="srp_compl_insert_to@sysrepo"/>
</COMPL>
<HELP>
<ACTION sym="srp_help_insert_to@sysrepo"/>
</HELP>
<ACTION sym="PLINE_INSERT_TO@sysrepo"/>
</PTYPE>
<PTYPE name="LOGFILES">
<COMPL>
<ACTION sym="klix_files@klinfix">/var/log</ACTION>
</COMPL>
<ACTION sym="STRING"/>
</PTYPE>
<VIEW name="main">
<HOTKEY key="^D" cmd="exit"/>
<PROMPT>
<ACTION sym="prompt" exec_on="always">%u@%h:exec> </ACTION>
</PROMPT>
<COMMAND name="poweroff" help="Poweroff system (system policy may yield reboot)">
<ACTION sym="klix_rpc@klinfix" ptype="STRING">/ietf-system:system-shutdown</ACTION>
</COMMAND>
<COMMAND name="reboot" help="Reboot system">
<ACTION sym="klix_rpc@klinfix" ptype="STRING">/ietf-system:system-restart</ACTION>
</COMMAND>
<COMMAND name="shell" help="Enter system shell">
<ACTION sym="script" interactive="true">/bin/sh -l</ACTION>
</COMMAND>
<COMMAND name="exit" help="Exit">
<ACTION sym="nav">pop</ACTION>
</COMMAND>
<COMMAND name="logout" help="Alias for exit">
<ACTION sym="nav">pop</ACTION>
</COMMAND>
<COMMAND name="configure" help="Create new candidate-config based on running-config">
<ACTION sym="nav">replace configure</ACTION>
</COMMAND>
<COMMAND name="copy" help="Copy">
<PARAM name="src" ptype="/DATASTORE" help="Source datastore"/>
<PARAM name="dst" ptype="/RW_DATASTORE" help="Destination datastore"/>
<ACTION sym="klix_copy@klinfix"/>
</COMMAND>
<COMMAND name="password" help="Password tools" mode="switch">
<COMMAND name="generate" help="Generate random passwords using pwgen">
<ACTION sym="script">pwgen -c -n -B -C</ACTION>
</COMMAND>
<COMMAND name="encrypt" help="Encrypt a password string">
<COMMAND name="salt" min="0" help="Random data to salt with before hashing.">
<PARAM name="pwsalt" ptype="/STRING" help="Must not use prefix like $1$"/>
</COMMAND>
<COMMAND name="type" min="0" help="Optional hash algorithm type.">
<PARAM name="pwhash" ptype="/STRING" help="Hash algorithm.">
<COMPL>
<ACTION sym="printl">md5</ACTION>
<ACTION sym="printl">sha256</ACTION>
<ACTION sym="printl">sha512</ACTION>
</COMPL>
</PARAM>
</COMMAND>
<PARAM name="pwpass" min="0" ptype="/STRING" help="Optional clear text password (no spaces)"/>
<ACTION sym="script" interactive="true">
type=${KLISH_PARAM_pwhash:-md5}
salt=${KLISH_PARAM_pwsalt:+-S $KLISH_PARAM_pwsalt}
mkpasswd -m $type $salt $KLISH_PARAM_pwpass
</ACTION>
</COMMAND>
</COMMAND>
<COMMAND name="set" help="Set" mode="switch">
<COMMAND name="datetime" help="Set current date and time, ISO-8601 format">
<PARAM name="current-datetime" ptype="/STRING" help="yyyy-mm-ddThh:mm:ss(Z|+/-hh:mm)"/>
<ACTION sym="klix_rpc@klinfix">/ietf-system:set-current-datetime</ACTION>
</COMMAND>
</COMMAND>
<COMMAND name="show" help="Show" mode="switch">
<COMMAND name="bridge" help="Show bridge (ports/fdb/mdb/vlans)">
<ACTION sym="script">bridge -color link</ACTION>
<SWITCH name="optional" min="0">
<COMMAND name="fdb" help="Show unicast forwarding database">
<ACTION sym="script">bridge -color fdb</ACTION>
</COMMAND>
<COMMAND name="mdb" help="Show mulficast forwarding database">
<ACTION sym="script">bridge -color mdb</ACTION>
<SWITCH name="optional" min="0">
<COMMAND name="detailed" help="Detailed (full) output">
<ACTION sym="script">bridge -color -d mdb</ACTION>
</COMMAND>
</SWITCH>
</COMMAND>
<COMMAND name="detailed" help="Show VLAN table">
<ACTION sym="script">bridge -color vlan</ACTION>
<SWITCH name="optional" min="0">
<COMMAND name="detailed" help="Detailed (full) output">
<ACTION sym="script">bridge -color -d vlan</ACTION>
</COMMAND>
</SWITCH>
</COMMAND>
</SWITCH>
</COMMAND>
<COMMAND name="datetime" help="Show current date and time, default RFC2822 format">
<ACTION sym="script">date -R</ACTION>
<COMMAND name="iso" min="0" help="NETCONF/ISO-8601 format">
<ACTION sym="script">date -Isec</ACTION>
</COMMAND>
</COMMAND>
<!-- https://www.cisco.com/c/en/us/td/docs/wireless/access_point/mob_exp/83/cmd-ref/me_cr_book/me_ports_and_interfaces_cli.html -->
<COMMAND name="interfaces" help="Show link layer interfaces">
<ACTION sym="script">ip -color link</ACTION>
<SWITCH name="optional" min="0">
<COMMAND name="brief" help="Simplified (human-readable) output" mode="switch">
<ACTION sym="script">ip -color -br link</ACTION>
</COMMAND>
<COMMAND name="detailed" help="Detailed (full) output" mode="switch">
<ACTION sym="script">ip -color -d link</ACTION>
</COMMAND>
</SWITCH>
</COMMAND>
<COMMAND name="ip" help="Show IP level status (Layer-3)">
<ACTION sym="script">ip -color addr</ACTION>
<SWITCH name="optional" min="0">
<COMMAND name="brief" help="Simplified (human-readable) output" mode="switch">
<ACTION sym="script">ip -color -br addr</ACTION>
</COMMAND>
<COMMAND name="detailed" help="Detailed (full) output" mode="switch">
<ACTION sym="script">ip -color -d addr</ACTION>
</COMMAND>
</SWITCH>
</COMMAND>
<COMMAND name="log" help="Show log file, default: syslog">
<PARAM name="fn" ptype="/LOGFILES" min="0" help="Optional log file to show"/>
<SWITCH name="optional" min="0">
<COMMAND name="tail" help="Show log tail, last N lines only">
<PARAM name="lines" ptype="/UINT" help="Last number of lines to show"/>
</COMMAND>
</SWITCH>
<ACTION sym="script">
file=${KLISH_PARAM_fn:-syslog}
if [ -n "$KLISH_PARAM_lines" ]; then
tail -n $KLISH_PARAM_lines /log/$file
else
cat /log/$file
fi
</ACTION>
</COMMAND>
<COMMAND name="factory-config" help="Show factory-config">
<ACTION sym="script">cat /cfg/factory-config.cfg | jq .</ACTION>
</COMMAND>
<COMMAND name="running-config" help="Show running-config">
<!-- TODO: add PARAM for xml/json output, and coloring like factory -->
<ACTION sym="srp_show_running@sysrepo"/>
</COMMAND>
<COMMAND name="startup-config" help="Show startup-config">
<ACTION sym="script">cat /cfg/startup-config.cfg | jq .</ACTION>
</COMMAND>
</COMMAND>
<COMMAND name="follow" help="Monitor a log file, use Ctrl-C to abort">
<PARAM name="fn" ptype="/LOGFILES" help="Optional log file to monitor, default: syslog"/>
<ACTION sym="script" interactive="true">
file=${KLISH_PARAM_fn:-syslog}
echo -e "\e[1mPress Ctrl-C to abort ────────────────────────────────────────────\e[0m"
tail -F /log/$file
</ACTION>
</COMMAND>
</VIEW>
<VIEW name="configure">
<PROMPT>
<ACTION sym="srp_prompt_edit_path@sysrepo"/>
<ACTION sym="prompt" exec_on="always">%u@%h:configure> </ACTION>
</PROMPT>
<HOTKEY key="^C" cmd="up"/>
<HOTKEY key="^D" cmd="abort"/>
<HOTKEY key="^Z" cmd="leave"/>
<!-- Move -->
<COMMAND name="abort" help="Abandon changes made candidate">
<ACTION sym="srp_reset@sysrepo"/>
<ACTION sym="nav">replace main</ACTION>
</COMMAND>
<COMMAND name="leave" help="Finalize candidate and apply to running-config">
<ACTION sym="klix_commit@klinfix"/>
<ACTION sym="nav" exec_on="success">replace main</ACTION>
</COMMAND>
<COMMAND name="exit" help="Ascend to the parent configuration node, or abort (from top)">
<ACTION sym="srp_up@sysrepo"/>
<ACTION sym="klix_commit@klinfix" exec_on="fail"/>
<ACTION sym="nav" exec_on="success">replace main</ACTION>
</COMMAND>
<COMMAND name="up" help="Ascend to the parent configuration node">
<ACTION sym="srp_up@sysrepo"/>
</COMMAND>
<COMMAND name="top" help="Ascend to the configuration root">
<ACTION sym="srp_top@sysrepo"/>
</COMMAND>
<COMMAND name="edit" help="Descend to the specified configuration node">
<PARAM name="path" ptype="/PLINE_EDIT" max="100"/>
<ACTION sym="srp_edit@sysrepo"/>
</COMMAND>
<!-- Edit -->
<COMMAND name="set" help="Set configuration setting">
<PARAM name="path" ptype="/PLINE_SET" max="100"/>
<ACTION sym="srp_set@sysrepo"/>
</COMMAND>
<COMMAND name="delete" help="Delete configuration setting(s)">
<PARAM name="path" ptype="/PLINE_DEL" max="100"/>
<ACTION sym="srp_del@sysrepo"/>
</COMMAND>
<COMMAND name="no" help="Alias for delete">
<PARAM name="path" ptype="/PLINE_DEL" max="100"/>
<ACTION sym="srp_del@sysrepo"/>
</COMMAND>
<COMMAND name="commit" help="Commit current candidate to running-config">
<ACTION sym="klix_commit@klinfix"/>
</COMMAND>
<COMMAND name="reset" help="Reset candidate to running-config">
<ACTION sym="srp_reset@sysrepo"/>
</COMMAND>
<!-- Display -->
<COMMAND name="check" help="Validate candidate">
<ACTION sym="srp_verify@sysrepo"/>
</COMMAND>
<COMMAND name="show" help="Show configuration">
<PARAM name="path" ptype="/PLINE_EDIT" min="0" max="100"/>
<ACTION sym="srp_show@sysrepo"/>
</COMMAND>
<COMMAND name="diff" help="Summarize uncommitted changes">
<PARAM name="path" ptype="/PLINE_EDIT" min="0" max="100"/>
<ACTION sym="srp_diff@sysrepo"/>
</COMMAND>
<!-- Misc -->
<COMMAND name="do" help="Execute operational mode command">
<VIEW name="operational" ref="/main"/>
</COMMAND>
</VIEW>
</KLISH>