Nokia SR OS MD-CLI: Model-Driven CLI Basics - 夜莺博客

Nokia SR OS MD-CLI: Model-Driven CLI Basics

The MD-CLI on Nokia SR OS is not a cosmetic rewrite of the classic CLI - it is a YANG-modelled tree whose every branch maps to a gNMI path, which is why the same knowledge serves both interactive configuration and streaming telemetry. Engineers arriving from SR OS classic mode trip over the context-based tree, the explicit commit, and the way state is read with show while configuration lives in the edit tree. This walkthrough covers navigation, the commit and rollback workflow, comparing configurations, and the practical conventions that make MD-CLI configs reproducible.

The context tree model

MD-CLI replaces flat command paths with a navigable hierarchy. You enter contexts, configure leaves, and then commit explicitly - meaning changes are staged rather than applied as you type.

A:admin@node-2# configure
A:admin@node-2> edit
*[ex:configure]
A:admin@node-2# ...

The prompt tells you where you are and whether there are uncommitted changes: a leading * means the candidate configuration differs from the running one. Context names appear in brackets, for example [ex:configure router "Base"], and ? lists everything available at the current node.

Navigation commands worth memorising

  • edit <context> - descend into a context by name.
  • back and back 2 - move up one or more levels.
  • ... - jump straight to the root of the edit tree.
  • tree and info - print the full tree or just the changed leaves, the MD-CLI equivalent of eyeballing a diff.
  • flat mode - swaps the edit tree for a full-path command style, valuable when copying configuration between nodes.
A:admin@node-2# configure
A:admin@node-2> edit router "Base" interface "to-peer"
A:admin@node-2> info
A:admin@node-2> flush

Commit, compare and rollback

A:admin@node-2> info compare
A:admin@node-2> commit
A:admin@node-2> discard
  • info compare shows the delta between candidate and running configuration before anything is applied.
  • commit applies the candidate and becomes the rollback checkpoint.
  • discard throws the candidate away without touching the service.
  • compare rollback, rollback <n> and rollback 0 let you inspect and revert to earlier states - the operational reason to prefer MD-CLI for change windows.

State reads are separate from the edit tree

Configuration changes need edit context; operational data is read outside it. show commands remain available at the top level, and the same data is exposed as YANG paths for gNMI. This separation is deliberate and is what makes the platform automation-friendly: the same leaf an engineer types in the edit tree is the leaf a collector subscribes to.

A:admin@node-2# show router interface
A:admin@node-2# show router bgp summary
A:admin@node-2# show system session

Aliases, environment and repeatability

MD-CLI supports command aliases so that frequently typed tooling shortcuts survive upgrades, and it records configuration history so that the info output at any rollback point can be re-applied. For cross-vendor consistency, keep the operational conventions you already use elsewhere - Nokia SR OS IS-IS configuration with MD-CLI shows the tree in a protocol context, and YANG and OpenConfig model workflows explains how to explore the models behind the commands.

原文链接:https://infocenter.nokia.com/public/7750SR207R1A/topic/com.sr.mdcli/html/navigatinginmdcli.html