Menu

#1 Nested views

open
nobody
None
5
2010-04-05
2010-04-05
No

Hello.

Thanks for the usefull project!

I try to emulate Cisco CLI. But there is a problem. Cisco CLI has a nested views. For example:

voice service voip
allow-connections h323 to h323
allow-connections h323 to sip
allow-connections sip to h323
allow-connections sip to sip
redirect ip2ip
h323
ip circuit max-calls 1500
ip circuit carrier-id cisco2651 reserved-calls 200
sip

There are three nested command modes (views):
(config)#
(conf-voi-serv)#
(conf-serv-h323)#

When I'm in "conf-serv-h323" mode it possible to use commands from upper levels - "config" and "conf-voi-serv". But command "?" show help for current view only.
So I can't implement this behaviour using clish. There is the namespaces issue in documentation. It can solve my problem. I propose to use views as namespaces.
Code:
<VIEW name="fred"> <COMMAND> </VIEW> <VIEW name=" kdjkdj"...> <IMPORT namespace="fred"> <COMMAND ...> </VIEW>

The view "fred" can
be hidden. It means no one command change view field to "fred" value. But it define a namespace and can be included into another view. The inclusion can be done by special command like
<IMPORT ref="fred"> or <INCLUDE namespace="fred" prefix="do">
Or it can be done by modified COMMAND.
<COMMAND name="do" namespace="fred"> or <COMMAND namespace="fred" namespace_prefix="do">

I add command prefix "do" (like cisco's "do show...") to illustrate that namespaces can be included without any prefix (as is) or with prefix. It flexible and it's not necessary to implement really nested views. It's enough to include upper views namespaces into nested view.

Additionally it will be good to implement include options like "help=true/false", "completion=true/false". It will indicate to show (or not) the help on included namespace commands. And similar option for command completion. It seems I saw the issue like this in the documentation.

The namespace issue seems to be old. Do you plan to implement it (in any fashion)? If not, I'll try to implement it.

This request is duplication of forum topic (is forum alive?).

Discussion

  • Serj Kalichev

    Serj Kalichev - 2010-04-09

    Patch to implement NAMESPACE

     
  • Serj Kalichev

    Serj Kalichev - 2010-04-09

    I made a patch for clish (svn revision 6) to implement NAMESPACE directive.
    The patch is attached to this issue. To apply the patch:
    * Checkout revision 6 from clish svn repository.
    * Go to the clish dir
    * patch -p0 < patch_filename.patch

    The views is not really nested. The <NAMESPACE> directive allow to use commands from another views.
    Example:

    <VIEW name="additional">
    <COMMAND name="show"... >
    </VIEW>

    <VIEW name="configure">
    <COMMAND name="interface" ...>
    <NAMESPACE ref="additional" prefix="do" help="false" completion="true"/>
    </VIEW>

    If we are in the "configure" view, we can use commands "interface" (native command) and "do show" (command from "additional" view). There is a prefix option to indicate the prefix of imported commands. The prefix is not necessary. You can use NAMESPACE without prefix at all.

    The "help" indicate to show imported commands while help "?" or not. The same for the completion option.

     
  • Serj Kalichev

    Serj Kalichev - 2010-08-17

    The clish project was forked. See the klish project on googlecode http://code.google.com/p/klish/ .
    Several new features was implemented.

     

Log in to post a comment.