Switching between the classic CLI and the MD-CLI engines

A single CLI command is available in both the classic CLI and MD-CLI engines to switch between the two engines in a user session. When authorized (cli-engine list contains both classic-cli and md-cli), the CLI engine switch command (‟//”, the double slash) can be executed from any CLI context in both engines to switch to the other CLI engine.

Switching engines

A:node-2# //
INFO: CLI #2052: Switching to the MD-CLI engine

[/]
A:admin@node-2# //
INFO: CLI #2051: Switching to the classic CLI engine
A:node-2#

Context saved when toggling

The context in which the CLI engine switch command is executed is saved when toggling between CLI engines and returns to the same context when toggling back.

[/]
A:admin@node-2# edit-config read-only
INFO: CLI #2066: Entering read-only configuration mode

(ro)[/]
A:admin@node-2# configure router

(ro)[/configure router "Base"]
A:admin@node-2# //
INFO: CLI #2051: Switching to the classic CLI engine
A:node-2# configure system management-interface
A:node-2>config>system>management-interface# //
INFO: CLI #2052: Switching to the MD-CLI engine

(ro)[/configure router "Base"]
A:admin@node-2# //
INFO: CLI #2051: Switching to the classic CLI engine
A:node-2>config>system>management-interface#

When switching is not authorized

If switching engines is not authorized (when cli-engine is only [classic-cli] or [md-cli]), the command is rejected.

A:node-2# //
MINOR: CLI #2053 Switching CLI engine is not authorized
A:node-2#

Executing classic CLI commands from the MD-CLI engine

When switching engines is authorized, all classic CLI engine commands can be executed from the MD-CLI engine. Entering a classic CLI engine command preceded by the ‟//” command executes the command in the classic CLI engine and returns immediately to the MD-CLI engine. The MD-CLI context is preserved before the switch to the classic CLI engine, and the context is restored when the session returns to the MD-CLI engine.

In the following example, the classic CLI command is executed from the configure system context in the MD-CLI. When the session returns to the MD-CLI engine, it is returned to the same context.
[ex:/configure system]
A:admin@node-2# //show debug
INFO: CLI #2051: Switching to the classic CLI engine
A:admin-node-2# /show debug
debug
    router "Base"
        bgp
            open
        exit
    exit
exit
INFO: CLI #2052: Switching to the MD-CLI engine

[ex:/configure system]
A:admin@node-2#

It is acceptable to include a space between ‟//” and the CLI command. For example, //show debug and // show debug are equivalent commands.

User interactions, such as pagination, confirmation, or control characters (for example, Ctrl-C to stop an ongoing command execution), are supported during CLI command execution. The CLI engine is switched back to the MD-CLI engine just before the CLI command prompt would normally appear.

Executing MD-CLI commands from the classic CLI engine works in the same way as described for executing classic CLI commands from the MD-CLI engine.

MD-CLI and classic CLI engine interactions

The following describes MD-CLI engine interactions with the classic CLI when using the ‟//” command:

  • Uncommitted changes in the MD-CLI are kept when switching to the classic CLI.

  • ‟//” appears in the history of the CLI engine where it is executed.

[/]
A:admin@node-2# //
INFO: CLI #2051: Switching to the classic CLI engine
A:node-2# history
   1 history
A:node-2# //
INFO: CLI #2052: Switching to the MD-CLI engine
[/]
A:admin@node-2# history
       1 //
[/]
A:admin@node-2#
  • ‟//command” appears in the history of both CLI engines.

[ex:/configure system]
A:admin@node-2# //show debug
INFO: CLI #2051: Switching to the classic CLI engine
A:admin-node-2# /show debug
debug
    router "Base"
        bgp
            open
        exit
    exit
exit
INFO: CLI #2052: Switching to the MD-CLI engine

[/]
A:admin@node-2# history
       1 //show debug 

[/]
A:admin@node-2# //
INFO: CLI #2052: Switching to the classic CLI engine
A:admin@node-2# history
       1 /show debug 
       2 history  
A:admin@node-2# 
  • Command completion, ? help, and redirection are not supported for the command following the ‟//”.

  • All control characters added on the same line when entering a ‟//” command have an effect on the CLI engine where they are entered.

[/]
A:admin@node-2# //show debug   Press Ctrl-W   # stay in the MD-CLI engine
                                              # delete word
[/]
A:admin@node-2# //show debug   Press Ctrl-C   # stay in the MD-CLI engine
                                              # stop current command
[/]
A:admin@node-2#

Switching explicitly to the classic CLI engine

The /!classic-cli command is available in both the classic CLI and MD-CLI engines to explicitly switch to the classic CLI engine in a session, as long as classic-cli is an authorized CLI engine. If switching to the classic CLI engine is not authorized, the command is rejected. Issuing the/!classic-cli command in the classic CLI engine has no effect.

The /!classic-cli switch command can be executed from any CLI context in both engines and the context is preserved for both engines. When the command is executed, the session enters the last saved working context of the classic CLI engine.

Executing the /!classic-cli switch command

A:node-2>config>system>management-interface# //
INFO: CLI #2052: Switching to the MD-CLI engine

[ex:/configure router "Base" bgp]
A:admin@node-2# /!classic-cli
INFO: CLI #2051: Switching to the classic CLI engine
A:node-2>config>system>management-interface#

Switching explicitly to the MD-CLI engine

The /!md-cli command is available in both the classic CLI and MD-CLI engines to explicitly switch to the MD-CLI engine in a session, as long as md-cli is an authorized CLI engine. If switching to the MD-CLI engine is not authorized, the command is rejected. Issuing the /!md-cli command in the MD-CLI engine has no effect.

The /!md-cli switch command can be executed from any CLI context in both engines and the context is preserved for both engines. When the command is executed, the session enters the last saved working context of the MD-CLI engine.

Executing the /!md-cli switch command

[ex:/configure router "Base" bgp]
A:admin@node-2# /!classic-cli
INFO: CLI #2051: Switching to the classic CLI engine
A:node-2>config>system>management-interface# /!md-cli
INFO: CLI #2052: Switching to the MD-CLI engine

[ex:/configure router "Base" bgp]
A:admin@node-2#

The /!md-cli and /!classic-cli commands can be useful when executing commands from a file, allowing the file to be executed in either CLI engine and ensuring the commands are run in the intended CLI engine.