Model-Driven CLI to Display Data Model Structure
Feature Name |
Release Information |
Description |
---|---|---|
Model-driven CLI to Show YANG Operational Data |
Release 7.3.2 |
This feature enables you to use a traditional CLI command to display YANG data model structures on the router console and also obtain operational data from the router in JSON or XML formats. The functionality helps you transition smoothly between CLI and YANG models, easing data retrieval from your router and network. This feature introduces the show yang operational command. |
Cisco IOS XR Software provides a rich set of show commands and data models to access data from the router and network. The show commands present unstructured data, whereas data models are structured data that can be encoded in XML or JSON formats. However, both the access points do not always present the same view. Network operators who work on show commands face challenges with adopting the data models when transitioning to programmatic interfaces.
With this feature, these adoption challenges are overcome using show yang operational command that is driven by data models. The command uses the data model as the base to display the structured data using traditional CLI command. Using this command, you can simplify parsing scripts via XML and JSON formats.
ietf-interfaces.yang
data model:ietf-interfaces.yang
module: ietf-interfaces
+--rw interfaces
| +--rw interface* [name]
| +--rw name string
| +--rw description? string
| +--rw type identityref
| +--rw enabled? boolean
| +--rw link-up-down-trap-enable? enumeration {if-mib}?
+--ro interfaces-state
+--ro interface* [name]
+--ro name string
+--ro type identityref
+--ro admin-status enumeration {if-mib}
In the example, the hierarchy of the data model is as follows:-
Model—ietf-interfaces.yang
-
Module—ietf-interfaces
-
Container—interfaces, interface-state
-
Node—interface* [name]
-
Leaf—name, description, type, enabled, link-up-down-trap-enable, admin-status
You can use the show yang operational command to navigate to the leaf level as you do in a data model.
The image show a mapping between CLI and data model, and how the structured data is displayed on the console.
The table shows various queries that can be used to navigate through the hierarchy of a data model using the CLI command.
The queries are demonstrated using Cisco-IOS-XR-interfaces-oper.yang
data model as an example.
Operational Query |
Description |
---|---|
Search specific top-level nodes |
Search and produce the output of keywords from top-level nodes.
|
All the instances of the container |
Lists all the models at the root level container and its container name.
mpls- displays all the containers with mpls :
|
All the nodes of the container |
|
Navigate until the last leaf level |
read only (ro) leaves in a YANG model are considered as the state data (operational).
|