Environment Commands

The environment configuration for the MD-CLI is available in both the classic CLI and in the MD-CLI, but the configuration applies only to MD-CLI sessions.

In the MD-CLI, environment variables are found under the context configure system management-interface cli md-cli:

[ex:/configure system management-interface cli md-cli environment]
A:admin@node-2# ?

 command-alias         + Enter the command-alias context
 command-completion    + Enter the command-completion context
 console               + Enter the console context
 message-severity-     + Enter the message-severity-level context
  level
 more                  - Prompt to continue or stop when output text fills page
 progress-indicator    + Enter the progress-indicator context
 prompt                + Enter the prompt context
 time-display          - Time zone to display time
 time-format           - Time format to display date and time

Changes made to the environment configuration apply only to new sessions and do not affect current sessions.

See the 7450 ESS, 7750 SR, 7950 XRS, and VSR MD-CLI Command Reference Guide for information about the environment commands in the MD-CLI.

Command Aliases

The MD-CLI can be customized to provide an enhanced user experience through the use of command aliases.

Aliases can be configured to execute a user-defined command name that performs a specific action. Supported actions include:

Creating Aliases

Newly created or modified command aliases apply to new sessions and do not affect the current session.

Aliases created in the system-wide MD-CLI environment context configure system management-interface cli md-cli environment command-alias are copied into the local environment context when a new CLI session begins.

Aliases can be created and modified in the local user environment context or the global configuration context. Aliases (or elements of the aliases) that are deleted in the local environment context return to their defaults (usually to the state of the global environment alias defined in the configuration context).

When an alias is configured, the alias acts as a substitute for a command or set of commands that can then be executed. Nokia recommends defining alias names that are meaningful to the operator. Alias names must not use any string that is an MD-CLI root element, such as admin, or that is an MD-CLI global command, such as insert. Aliases are displayed in command completion and ? help, where applicable.

The MD-CLI command history displays what was entered in the CLI. Instead of recording the resultant operation, the history records the alias name and any arguments.

Typical use cases for MD-CLI command aliases include:

  • shortcuts for navigating MD-CLI contexts
  • creating new MD-CLI output commands
  • aliasing existing MD-CLI commands

Mounting an Alias

Aliases are mounted at specific points in the MD-CLI contexts. Aliases may be mounted globally using the mount-point global option. A globally mounted alias may be executed from any MD-CLI context.

The following example shows the execution of a globally mounted alias that creates the alias up for the back command.

[ex:/configure system management-interface cli md-cli environment command-alias alias "hello"]
A:admin@node-2# info
    command-alias {
        alias "up" {
            cli-command "back"
            mount-point global { }
        }
    }

[ex:/configure router "Base" bgp]
A:admin@node-2# up  # Moved back one level by typing “up”


[ex:/configure router "Base"]
A:admin@node-2# uPress Tab  # Integrated into MD-CLI command completion

 up

 update

[ex:/configure router "Base"]
A:admin@node-2# up ?  # Accepts parameters and displays ? help for aliased command

 [[levels] <number>]
 <number>  - <1..4294967295>
 Default   - 1

    Number of levels to move up

Alternatively, an alias may be mounted at one or more specific locations, which limits the contexts from which the alias may be executed. The execution of such an alias can be considered equivalent to executing the resultant operation from the present working context of the mount point.

The following example shows the execution of an alias mounted in the /show and /tools perform contexts.

(ex)[/configure system management-interface cli md-cli environment command-alias]
A:admin@node-2# info
    alias "hello-from-some-places-only" {
        python-script "hello"
        mount-point "/show" { }
        mount-point "/tools perform" { }
    }

[/]
A:admin@node-2# /show hello-from-some-places-only
Hi

[/]
A:admin@node-2# /tools perform hello-from-some-places-only
Hi

[/show]
A:admin@node-2# hello-from-some-places-only
Hi

[/tools]
A:admin@node-2# hello-from-some-places-only
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
MINOR: MGMT_CORE #2201: Unknown element - 'hello-from-some-places-only'

Mount points may contain lists. Where lists are provisioned, the keys must be provided. If lists have default keys, these may be omitted. List keys do not need to be present in the current configuration.

The following example shows an alias using a nonexistent list key in a mount point. The key vpn3 does not exist as a current VPRN service. When vpn3 is entered on the command line, the resultant configuration shows the string vpn3 enclosed in quotation marks, escaped by the backslash (\) character.

(ex)[/configure system management-interface cli md-cli environment command-alias]
A:admin@node-2# info /state service vprn <tab>

 <service-name>
 "vpn1"
 "vpn2"

*(ex)[/configure system management-interface cli md-cli environment command-alias alias "list-keys-in-mount-point-example"]
A:admin@node-2# mount-point "/state service vprn vpn3"

*(ex)[/configure system management-interface cli md-cli environment command-alias alias "list-keys-in-mount-point-example"]
A:admin@node-2# info
    python-script "hello"
    mount-point "/state service vprn \"vpn3\"" { }

When the list key is created, the alias automatically becomes available in the context, as shown in the following example.

[/]
A:admin@node-2# /state service vprn "vpn3" list-keys-in-mount-point-example
                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
MINOR: MGMT_CORE #2201: Unknown element - 'list-keys-in-mount-point-example'

[/]
A:admin@node-2# edit-config exclusive
INFO: CLI #2060: Entering exclusive configuration mode
INFO: CLI #2061: Uncommitted changes are discarded on configuration mode exit

(ex)[/]
A:admin@node-2# configure service vprn vpn3

*(ex)[/configure service vprn "vpn3"]
A:admin@node-2# customer "1"

*(ex)[/configure service vprn "vpn3"]
A:admin@node-2# commit

(ex)[/configure service vprn "vpn3"]
A:admin@node-2# /state service vprn vpn3 list-keys-in-mount-point-example
Hi

Configuring Aliases to Execute Python Applications

An alias can execute a configured Python application. The alias python-script command can reference a Python application configured in the /configure python python-script context.

See Accounting and Authorization of Aliases for information about authorizing Python application execution using the alias command.

Configuring Aliases to Execute MD-CLI Commands

An alias may execute an MD-CLI command by using the alias cli-command command. The command is configured using a string that contains the MD-CLI command to execute. The string must be syntactically correct and quotation marks (single or double quotes) must be escaped using the backslash character. If the string contains a list, the list key must be provided, except in the following cases:
  • the list key has a default entry
  • the list key is the last element of the CLI command

The following example configuration shows a simplified navigation within the MD-CLI.

*(ex)[/configure system management-interface cli md-cli environment command-alias]
A:admin@node-2# info
    alias "go-to-alias" {
        cli-command "configure system management-interface cli md-cli environment command-alias"
        mount-point global { }
    }

(ex)[/configure router "Base" bgp]
A:admin@node-2# go-to-alias

(ex)[/configure system management-interface cli md-cli environment command-alias]
A:admin@node-2#

The following example configuration is a list (router) with a default list key ("Base").

*(ex)[/configure system management-interface cli md-cli environment command-alias alias "router-auth-stats"]
A:admin@node-2# info
    cli-command "show router authentication statistics"
    mount-point "/show" { }

[/state system]
A:admin@node-2# /show router-auth-stats

====================================================================
Authentication Global Statistics
====================================================================
Client Packets Authenticate Fail     : 0
Client Packets Authenticate Ok       : 0
====================================================================

A list key can be omitted if the last element of the CLI command string is a list. This allows the key to be provided as a parameter when executing the alias, as shown in the following example.

(ex)[/configure system management-interface cli md-cli environment command-alias]
A:admin@node-2# info
    alias "vprn-state" {
        cli-command "info candidate /state service vprn"
        mount-point "/show" { }
    }

[/]
A:admin@node-2# /show vprn-state
                                     ^
MINOR: CLI #2001: Missing element value - 'service-name'

[/]
A:admin@node-2# /show vprn-state vpn1
    oper-service-id 1
    oper-state up
    sap-count 2
    sdp-bind-count 0
    template-used ""
    creation-origin manual
    vrtr-id 2
    oper-router-id 255.0.0.0
    oper-route-distinguisher-type auto

...snip...

Aliases can also accept arguments, allowing extra parameters to be executed, as shown in the following example.

[/]
A:admin@node-2# /show vprn-state vpn1 interface "test1" ipv4 icmp
    statistics {
        icmp-in-msgs 0
        icmp-in-errors 0
        icmp-in-dest-unreachables 0
        icmp-in-redirects 0
        icmp-in-echos 0
        icmp-in-echo-replies 0
        icmp-in-time-exceeds 0
        icmp-in-src-quenches 0
        icmp-in-timestamps 0
        icmp-in-timestamp-replies 0
        icmp-in-address-masks 0
        icmp-in-address-mask-replies 0
        icmp-in-parm-problems 0
        icmp-out-msgs 0
        icmp-out-errors 0
        icmp-out-dest-unreachables 0
        icmp-out-redirects 0
        icmp-out-echos 0
        icmp-out-echo-replies 0
        icmp-out-time-exceeds 0
        icmp-out-src-quenches 0
        icmp-out-timestamps 0
        icmp-out-timestamp-replies 0
        icmp-out-address-masks 0
        icmp-out-address-mask-replies 0
        icmp-out-parm-problems 0
        icmp-out-discards 0
    }

Aliases that execute CLI commands may also include output modifiers in the definitions. In the following example, the alias bgp-top-line outputs the line from show router bgp summary that uses the output match modifier to select a specific string.

(ex)[/configure system management-interface cli md-cli environment command-alias]
A:admin@node-2# info
    alias "bgp-top-line" {
        cli-command "show router bgp summary | match \"AS:\""
        mount-point global { }
    }

[/]
A:admin@node-2# bgp-top-line
 BGP Router ID:255.0.0.0        AS:65535       Local AS:65535

Accounting and Authorization of Aliases

Aliases have specific accounting and authorization rules, as shown in the following configuration example.

(ex)[/configure system management-interface cli md-cli environment command-alias]
A:admin@node-2# info
    alias "my-python-alias" {
        python-script "hello"
        mount-point global { }
    }
    alias "my-cli-alias" {
        cli-command "info running /state service vprn"
        mount-point global { }
    }
    alias "my-cli-python-alias" {
        cli-command "pyexec cf3:\hello.py"
        mount-point global { }
    }

The command entered by the operator on the MD-CLI command line is sent to the accounting system, including all arguments supplied to the alias.

For example, if the operator enters my-cli-alias vpn1, the string my-cli-alias vpn1 is sent to the accounting system. If the operator enters my-python-alias, the string my-python-alias is sent to the accounting system.

The string sent to the authorization system depends on whether cli-command or python-script is configured in the alias context.

When an alias uses a CLI command, the resulting MD-CLI command is sent to the authorization system. For example, if the operator enters my-cli-alias vpn1, the string sent to the authorization system is info running /state service vprn vpn1. If the operator enters my-cli-python-alias, the string sent to the authorization system is pyexec cf3:\hello.py

If the alias is configured with the python-script option, the string sent to the authorization server is the referenced Python application name prefaced by the string python-script. This allows Python applications initiated with the pyexec command to be authorized independently of those initiated from within MD-CLI command aliases. Administrators can predefine approved Python applications that may be executed by users who otherwise have no access to run the pyexec command.

For example, if the operator enters my-python-alias, the string sent to the authorization server is python-script \”hello\”.

Customizing Per-Session Environment Settings

The environment can be customized for all sessions in the configuration under the configure system management-interface cli md-cli environment context, or per session using the environment command. When a new MD-CLI session is started, the per-session environment configuration is copied from the global environment configuration. Changes made to the global environment configuration after the session begins apply only to new sessions and do not affect current sessions. Changes made to the environment parameters for a session apply only for that session.

The per-session environment is accessed by entering environment at the operational root or with /environment from any other mode or context. Changes made in the per-session environment are immediate.

The info command displays the difference between the per-session environment and the configured global environment parameters. Therefore, for a new MD-CLI session, the info command has no output, as the per-session environment is the same as the global environment. The info detail command displays the current values in the global environment for all parameters.

Customizing the Session Prompt

Customizing the Uncommitted Changes Indicator

As the default setting of the environment configuration, the uncommitted changes indicator is displayed as part of the command prompt. This setting can be modified per session or it can be changed for all MD-CLI sessions by changing the environment configuration.

The uncommitted-changes-indicator command under the environment prompt context suppresses or displays the change indicator for an MD-CLI session. Environment changes are applied immediately and are lost when the session disconnects.

*[/environment prompt]
A:admin@node-2# uncommitted-changes-indicator false

[/environment prompt]
A:admin@node-2#

[/environment prompt]
A:admin@node-2# uncommitted-changes-indicator true

*[/environment prompt]
A:admin@node-2#

Customizing the Line Preceding the Command Prompt

By default, a blank line precedes the command prompt. This setting can be modified for each MD-CLI session.

The newline command under the environment prompt context suppresses or displays a new line before the prompt.


[/]
A:admin@node-2# environment prompt

[/environment prompt]
A:admin@node-2# newline false
[/environment prompt]
A:admin@node-2# newline true

[/environment prompt]
A:admin@node-2#

Customizing the Context Information in the Command Prompt

By default, the context is displayed in the command prompt. This setting can be modified for each MD-CLI session.

The context command under the environment prompt context suppresses or displays the current context.

[/environment prompt]
A:admin@node-2# context false

[]
A:admin@node-2# context true

[/environment prompt]
A:admin@node-2#

Customizing the Date and Time Output

By default, the timestamp is not displayed before the command prompt. This setting can be modified for each MD-CLI session.

The timestamp command under the environment prompt context suppresses or displays the timestamp.

[/environment prompt]
A:admin@node-2# timestamp true

Tue, 16 Feb 2021 16:37:26 UTC
[/environment prompt]
A:admin@node-2# timestamp false

[/environment prompt]
A:admin@node-2#

The environment time-display command configures the time zone display to UTC or local time (as configured in configure system time).

[/environment]
A:admin@node-2# time-display ?

 time-display <keyword>
 <keyword>  - (local|utc)
 Default    - local

    Time zone displayed before the prompt

The environment time-format command specifies the format for the time display.

[/environment]
A:admin@node-2# time-format ?

 time-format <keyword>
 <keyword>  - (iso-8601|rfc-1123|rfc-3339)
 Default    - rfc-3339

    Time format to display date and time

The following shows the time in the format as defined by ISO 8601:

[/state cpm "a" hardware-data]
A:admin@node-2# software-last-boot-time
    software-last-boot-time "2020-09-01 23:27:17 UTC"

The following shows the time in the format as defined by RFC 1123:

[/state cpm "a" hardware-data]
A:admin@node-2# software-last-boot-time
    software-last-boot-time "Tue, 01 Sep 2020 23:27:17 UTC"

The following shows the time in the format as defined by RFC 3339:

[/state cpm "a" hardware-data]
A:admin@node-2# software-last-boot-time
    software-last-boot-time 2020-09-01T23:27:17.0+00:00

Customizing the Progress Indicator

The progress indicator appears on the line immediately following the command and disappears when the MD-CLI command completes or when output is available to display. The indicator is a display of dynamically changing dots.

(ex)[/configure]
A:admin@node-2# compare
...                    # progress indicator displays here as dots 

The delay interval can be configured with the delay command or the indicator can be disabled with the admin-state disable command under the environment progress-indicator context. For example, the user can disable the progress indicator for logged sessions.

[/environment progress-indicator]
A:admin@node-2# ?

 admin-state          - Administrative state of the progress indicator
 delay                - Delay before progress indicator is displayed
 type                 - Progress indicator output style

Customizing the Pagination Setting

The environment more command enables pagination when configured to true and disables pagination when configured to falseenter

[/]
A:admin@node-2# environment more true
[/]
A:admin@node-2# show system security management

===============================================================================
Server Global
===============================================================================
Telnet:
Administrative State         : Enabled
Operational State            : Up
Telnet6:
Administrative State         : Disabled
Operational State            : Down
FTP:
Administrative State         : Disabled
Operational State            : Down
SSH:
Administrative State         : Enabled
Operational State            : Up
NETCONF:
Administrative State         : Disabled
Operational State            : Down
GRPC:
Administrative State         : Disabled
Operational State            : Down

Press Q to quit, Enter to print next line or any other key to print next page.

The pagination setting can be overridden by using | no-more for a single command. As with pagination disabled, the output is displayed completely without any prompts to continue.

[/]
A:admin@node-2# show system security management | no-more

Customizing the Console Settings

The default size for a console window is 24 lines long by 80 characters wide. The environment console command can be used to change these settings.

(ex)[/environment]
A:admin@node-2# console ?

 console

 length               - Number of lines displayed on the screen
 width                - Number of columns displayed on the screen

Customizing the Message Level Security Settings

The INFO: CLI messages are displayed by default. The environment message-security-level command suppresses the INFO messages by changing the setting to warning.

[/environment message-severity-level]
A:admin@node-2# cli ?

 cli <keyword>
 <keyword> - (warning|info)
 Default   - info

    Message severity threshold for CLI messages

Following are examples of INFO: CLI messages that are suppressed when the setting is changed to warning.

INFO: CLI #2051: Switching to the classic CLI engine
INFO: CLI #2052: Switching to the MD-CLI engine
INFO: CLI #2054: Entering global configuration mode
INFO: CLI #2056: Exiting global configuration mode 
INFO: CLI #2055: Uncommitted changes are present in the candidate configuration
INFO: CLI #2057: Uncommitted changes are kept in the candidate configuration

Preventing Changes to Environment Settings

The environment datastore is subject to AAA command authorization. A user can be prevented from modifying the global environment settings or the per-session environment settings, or both.

In the following configuration output, entry 113 blocks user ‟tstuser” from modifying the global environment settings. In addition, entry 114 prevents the user from changing the per-session environment settings.

(ro)[/configure system security aaa local-profiles profile "tstuser"]
A:admin@node-2# info
    default-action permit-all
    entry 113 {
        action deny
        match "configure system management-interface cli md-cli environment"
    }
    entry 114 {
        action deny
        match "environment"
    }
(ex)[/configure system management-interface cli md-cli environment]
A:tstuser@node-2# prompt timestamp
MINOR: MGMT_CORE #2020: Permission denied

(ex)[configure system management-interface cli md-cli environment]
A:tstuser@node-2# /environment
MINOR: MGMT_CORE #2020: Permission denied

(ex)[/configure system management-interface cli md-cli environment]
A:tstuser@node-2#