How to implement this kind of command: show interfaces [interface-id] counters

58 views
Skip to first unread message

Gavin Xu

unread,
May 12, 2022, 3:25:07 AM5/12/22
to klish-dev
Hi
    I want to implement this command:
    show interfaces [interface-id] counters

The xml content I edited is as follows, but the effect is not as expected

    <COMMAND name="show interface" help="Show Interface info">
      <PARAM name="if-subcommands" help="Interface subcommands" mode="switch" ptype="SUBCOMMAND">
        <PARAM name="interface-id" help="Physical interface(Multiples of 4)" ptype="UINT" mode="subcommand" optional="true">
          <PARAM name="counters" help="Counters for Physical Interfaces" ptype="SUBCOMMAND" mode="subcommand"> </PARAM>
        </PARAM>
        <PARAM name="Ethernet" help="Physical Interface" ptype="SUBCOMMAND" mode="subcommand">
          <PARAM name="phy-if-id" help="Physical interface(Multiples of 4)" ptype="UINT" optional="true"> </PARAM>
        </PARAM>
        <PARAM name="status" help="Physical interfaces status" ptype="SUBCOMMAND" mode="subcommand"> </PARAM>
      </PARAM>
      <ACTION>
       .......
      </ACTION>
      <xi:include href="include/pipe.xml"/>
    </COMMAND>

Shawn Qiu

unread,
May 12, 2022, 4:19:17 AM5/12/22
to klish-dev
Hello, I think firstly, there exists a problem in your xml that PARAM interface-id has the attribute mode="subcommand".
And if you want to make interface-id an optional param, you could try like this:
COMMAND  show interface
        PARAM  mode=switch
                PARAM  interface-id
                        PARAM  counters
                PARAM  counters
                PARAM  Ethernet
                ……

Gavin Xu

unread,
May 12, 2022, 5:21:05 AM5/12/22
to klish-dev
Hi Shawn:
    thank you for your reply.
I modified as follows:
112.jpg
The result is as follows, not as expected:
113.jpg

any other suggestions?

Shawn Qiu

unread,
May 12, 2022, 6:14:57 AM5/12/22
to klish-dev
I'm sorry for my expression ahead. What I mean is that:
(1) remove optional="true" of PARAM interface-id
(2) add a PARAM tag named counters at the same level as PARAM interface-id

And let me explain why can't you execute "show interface counters". That's because PARAM counters is in PARAM interface-id, or we could say PARAM counters is the child of PARAM interface-id(image xml as a tree). So if you don't input interface-id, you can't input counters, too.
Reply all
Reply to author
Forward
Message has been deleted
Message has been deleted
0 new messages