Command alias using ref attribute reference command in nested view with viewid vars

36 views
Skip to first unread message

Cuong Bang

unread,
May 9, 2025, 3:27:40 AMMay 9
to klish
Dear all,

I am defining a command alias for a series of commands that go into nested views with different viewid vars. Is there any way that I can provide values for such viewid vars? In my example, they are if_name and vrid.

<VIEW name="alias-view" prompt="$(alias)# ">
  <COMMAND name="config-vrrp-test" help="configure terminal -> interface -> vrrp -> test-cmd"
         ref="test-cmd@configure-if-vrrp-view@configure-if-view@configure-view">
  <ACTION builtin="clish_nop"/>
  </COMMAND>
</VIEW>

<VIEW name="configure-view">
  <COMMAND name="interface" help="configure interface" view="configure-if-view" viewid="if_name=${if_name}">
    <PARAM name="if_name" help="interface name" ptype="STRING"/>
    <ACTION builtin="clish_nop"/>
  </COMMAND>
</VIEW>

<VIEW name="configure-if-view" prompt="(config-if-${if_name})# " depth="2">
  <COMMAND name="vrrp" help="Configure VRRP" view="configure-if-vrrp-view" viewid="if_name=${if_name};vrid=${vrid}">
    <PARAM name="vrid" help="Virtual router ID" ptype="INTEGER"></PARAM>
  <ACTION builtin="clish_nop"/>
</COMMAND>
</VIEW>

<VIEW name="configure-if-vrrp-view" prompt="(config-if-${if_name}-vrrp-${vrid})# " depth="3">
  <COMMAND name="test-cmd" help="A test command">
    <ACTION>echo "A test command: interface=${if_name}, vrid=${vrid}"</ACTION>
  </COMMAND>
</VIEW>

Best regards,
Cuong Bang.

Serj Kalichev

unread,
May 12, 2025, 4:26:17 AMMay 12
to kl...@googlegroups.com
Hi
I don't understand where does engine get "if_name", "vrid" in a case of alias using. In a case of nested views it gets values from "viewid". You can add if_name and vrid PARAMs for config-vrrp-test COMMAND and don't define it as a "ref" but just set target "view" and "viewid".

09.05.2025 10:27, Cuong Bang пишет:
--
You received this message because you are subscribed to the Google Groups "klish" group.
To unsubscribe from this group and stop receiving emails from it, send an email to klish+un...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/klish/8d939768-6a73-432a-b914-d87a7b9df71cn%40googlegroups.com.


Message has been deleted

Cuong Bang

unread,
May 13, 2025, 3:52:49 AMMay 13
to klish
Thanks Serj Kalichev! By defining "config-vrrp-test" as a regular command and set target "view" and "viewid", I can only reach "configure-if-vrrp-view", not running the command "test-cmd" inside "configure-if-vrrp-view" after executing "config-vrrp-test" command.
Reply all
Reply to author
Forward
0 new messages