Gnmi Protocol
Gnmi Protocol
This feature describes the model-driven configuration and retrieval of operational data using the gRPC Network
Management Interface (gNMI) CAPABILITIES, Get and Set remote procedure calls (RPCs). gNMI version
0.4.0 is supported.
• Restrictions for the gNMI Protocol, on page 1
• Information About the gNMI Protocol, on page 2
• How to Enable the gNMI Protocol, on page 15
• Configuration Examples for the gNMI Protocol, on page 20
• Additional References for the gNMI Protocol, on page 21
• Feature Information for the gNMI Protocol, on page 21
• GetResponse:
• Alias is not supported. It is a string that provides an alias for a prefix specified within the notification
message.
• Delete is not supported. It is a set of paths that are to be removed from a data tree.
gNMI Protocol
1
gNMI Protocol
Information About the gNMI Protocol
gNMI Protocol
2
gNMI Protocol
gNMI GET Request
gNMI Protocol
3
gNMI Protocol
gNMI GET Request
GetRequest GetResponse
The following is a path for the
openconfig-interfaces model
++++++++ Sending get request: ++++++++
path {
elem {
name: "interfaces"
}
elem {
name: "interface"
key {
key: "name"
value: "Loopback111"
}
}
}
gNMI Protocol
4
gNMI Protocol
gNMI GET Request
GetRequest GetResponse
encoding: JSON_IETF
++++++++ Received get response: ++++++++
notification {
timestamp: 1521699434792345469
update {
path {
elem {
name: "interfaces"
}
elem {
name: "interface"
key {
key: "name"
value: "\"Loopback111\""
}
}
}
val {
json_ietf_val:
"{\n\t\"openconfig-interfaces:name\":\t\
"Loopback111\",\n\t\
"openconfig-interfaces:config\":\t{\n\t\t\
"openconfig-interfaces:type\":\t\"ianaift:
softwareLoopback\",\n\t\t\
"openconfig-interfaces:name\":\t\"Loopback111\",\n\t\t\
"openconfig-interfaces:enabled\":\t\"true\"\n\t},\n\t\
"openconfig-interfaces:state\":\t{\n\t\t\
"openconfig-interfaces:type\":\t\"ianaift:
softwareLoopback\",\n\t\t\
"openconfig-interfaces:name\":\t\"Loopback111\",\n\t\t\
"openconfig-interfaces:enabled\":\t\"true\",\n\t\t\
"openconfig-interfaces:ifindex\":\t52,\n\t\t\
"openconfig-interfaces:admin-status\":\t\"UP\",\n\t\t\
"openconfig-interfaces:oper-status\":\t\"UP\",\n\t\t\
"openconfig-interfaces:last-change\":\t2018,\n\t\t\
"openconfig-interfaces:counters\":\t{\n\t\t\t\
gNMI Protocol
5
gNMI Protocol
gNMI GET Request
GetRequest GetResponse
"openconfig-interfaces:in-octets\":\t0,\n\t\t\t\
"openconfig-interfaces:in-unicast-pkts\":\t0,\n\t\t\t\
"openconfig-interfaces:in-broadcast-pkts\":\t0,\n\t\t\t\
"openconfig-interfaces:in-multicast-pkts\":\t0,\n\t\t\t\
"openconfig-interfaces:in-discards\":\t0,\n\t\t\t\
"openconfig-interfaces:in-errors\":\t0,\n\t\t\t\
"openconfig-interfaces:in-unknown-protos\":\t0,\n\t\t\t\
"openconfig-interfaces:out-octets\":\t0,\n\t\t\t\
"openconfig-interfaces:out-unicast-pkts\":\t0,\n\t\t\t\
"openconfig-interfaces:out-broadcast-pkts\":\t0,\n\t\t\t\
"openconfig-interfaces:out-multicast-pkts\":\t0,\n\t\t\t\
"openconfig-interfaces:out-discards\":\t0,\n\t\t\t\
"openconfig-interfaces:out-errors\":\t0,\n\t\t\t\
"openconfig-interfaces:last-clear\":\t2018\n\t\t},\n\t\t\
"openconfig-platform:hardware-port\":\t\
"Loopback111\"\n\t},\n\t\
"openconfig-interfaces:subinterfaces\":\t{\n\t\t\
"openconfig-interfaces:index\":\t0,\n\t\t\
"openconfig-interfaces:config\":\t{\n\t\t\t\
"openconfig-interfaces:index\":\t0,\n\t\t\t\
"openconfig-interfaces:name\":\t\"Loopback111\",\n\t\t\t\
"openconfig-interfaces:enabled\":\t\"true\"\n\t\t},\n\t\t\
gNMI Protocol
6
gNMI Protocol
gNMI GET Request
GetRequest GetResponse
"openconfig-interfaces:state\":\t{\n\t\t\t\
"openconfig-interfaces:index\":\t0,\n\t\t\t\
"openconfig-interfaces:name\":\t\"Loopback111.0\",\n\t\t\t\
"openconfig-interfaces:enabled\":\t\"true\",\n\t\t\t\
"openconfig-interfaces:admin-status\":\t\"UP\",\n\t\t\t\
"openconfig-interfaces:oper-status\":\t\"UP\",\n\t\t\t\
"openconfig-interfaces:last-change\":\t2018,\n\t\t\t\
"openconfig-interfaces:counters\":\t{\n\t\t\t\t\
"openconfig-interfaces:in-octets\":\t0,\n\t\t\t\t\
"openconfig-interfaces:in-unicast-pkts\":\t0,\n\t\t\t\t\
"openconfig-interfaces:in-broadcast-pkts\":\t0,\n\t\t\t\t\
"openconfig-interfaces:in-multicast-pkts\":\t0,\n\t\t\t\t\
"openconfig-interfaces:in-discards\":\t0,\n\t\t\t\t\
"openconfig-interfaces:in-errors\":\t0,\n\t\t\t\t\
"openconfig-interfaces:out-octets\":\t0,\n\t\t\t\t\
"openconfig-interfaces:out-unicast-pkts\":\t0,\n\t\t\t\t\
"openconfig-interfaces:out-broadcast-pkts\":\t0,\n\t\t\t\t\
"openconfig-interfaces:out-multicast-pkts\":\t0,\n\t\t\t\t\
"openconfig-interfaces:out-discards\":\t0,\n\t\t\t\t\
"openconfig-interfaces:out-errors\":\t0,\n\t\t\t\t\
"openconfig-interfaces:last-clear\":\
t2018\n\t\t\t}\n\t\t},\n\t\t\
"openconfig-if-ip:ipv6\":\t{\n\t\t\t\
gNMI Protocol
7
gNMI Protocol
gNMI SetRequest
GetRequest GetResponse
"openconfig-if-ip:config\":\t\"false\",\n\t\t\t\
"openconfig-if-ip:state\":\t\"false\"\n\t\t}\n\t}\n}"
}
}
}
GetRequest GetResponse
gNMI SetRequest
The Set RPC specifies how to set one or more configurable attributes associated with a supported model. A
SetRequest is sent from a client to a target to update the values in the data tree.
SetRequests also support JSON keys must contain a YANG-prefix, in which the namespace of the following
element differs from parent.
For example, the routed-vlan element derived from augmentation in openconfig-vlan.yang must be entered
as oc-vlan:routed-vlan, because it is different from the namespace of the parent node (The parent node prefix
is oc-if.).
gNMI Protocol
8
gNMI Protocol
gNMI SetRequest
The total set of deletes, replace, and updates contained in any one SetRequest is treated as a single transaction.
If any subordinate element of the transaction fails; the entire transaction will be disallowed and rolled back.
A SetResponse is sent back for a SetRequest.
SetRequest SetResponse
++++++++ Sending set request: ++++++++ ++++++++ Received set response: ++++++++
update { response {
path { path {
elem { elem {
name: "interfaces" name: "interfaces"
} }
elem { elem {
name: "interface" name: "interface"
key { key {
key: "name" key: "name"
value: "Loopback111" value: "Loopback111"
} }
} }
elem { elem {
name: "config" name: "config"
} }
} }
val { op: UPDATE
json_ietf_val: }
"{\"openconfig-interfaces:enabled\":\"false\"}" timestamp: 1521699342123890045
}
}
SetRequest SetResponse
++++++++ Sending set request: ++++++++ ++++++++ Received set response: ++++++++
update { response {
path { path {
elem { elem {
name: "interfaces" name: "interfaces"
} }
elem { elem {
name: "interface" name: "interface"
key { key {
key: "name" key: "name"
value: "Loopback111" value: "Loopback111"
} }
} }
elem { elem {
name: "config" name: "config"
} }
elem { elem {
name: "description" name: "description"
} }
} }
val { op: UPDATE
json_ietf_val: "\"UPDATE DESCRIPTION\"" }
} timestamp: 1521699342123890045
}
gNMI Protocol
9
gNMI Protocol
gNMI Namespace
gNMI Namespace
A namespace specifies the path prefixing to be used in the origin field of a message.
This section describes the namespaces used in Cisco IOS XE Gibraltar 16.10.1 and later releases:
• RFC 7951-specified namespaces: Path prefixes use the YANG module name as defined in RFC 7951.
The RFC 7951-specified value prefixing uses the YANG module name.
Value prefixing is not affected by the selected path prefix namespace. The following example shows an
RFC 7951-specified value prefix:
val {
json_ietf_val:"{
"openconfig-interfaces:config": {
“openconfig-interfaces:description":
“DESCRIPTION”
}
}"
}
An RFC 7951-specified namespace prefixing also uses the YANG module name. For example, the
openconfig path to a loopback interface will be
/openconfig-interfaces:interfaces/interface[name=Loopback111]/
• Openconfig: No path prefixes are used. These can only be used with a path to an openconfig model.
The behavior of the Openconfig namespace prefixing is the same when no origin or namespace is provided.
For example, the openconfig path to a loopback interface will be
/interfaces/interface[name=Loopback111]/
gNMI Protocol
10
gNMI Protocol
gNMI Wildcards
}
}
This section describes the path prefixing used in releases prior to Cisco IOS XE Gibraltar 16.10.1.
Here, path prefixing uses the YANG module prefix as defined in the YANG module definition. For example,
the openconfig path to a loopback interface will be
/oc-if:interfaces/interface[name=Loopback111]/
The following example shows a gNMI Path with with legacy namespacing:
path {
origin: “legacy"
elem {
name: "oc-if:interfaces"
}
elem {
name: "interface"
key {
key: "name"
value: "Loopback111"
}
}
}
gNMI Wildcards
The gNMI protocol supports wildcards for Get paths. This is the ability to use a wildcards in a path to match
multiple elements. These wildcards indicate all elements in a given subtree in the schema.
An elem is an element, and it is a value between / characters in an xpath. An elem is also available in a gNMI
path. For example, the position of a wildcard relative to elem names implies that the wildcard stands for an
interface, and is interpreted as all interfaces.
There are two types of wildcards; implicit and explicit, and both are supported. Get paths support all types
and combinations of path wildcards.
• Implicit wildcards: These expand a list of elements in an element tree. Implicit wildcard occurs when a
key value is not provided for elements of a list.
The following is a sample path implicit wildcard. This wildcard will return the descriptions of all interfaces
on a device:
gNMI Protocol
11
gNMI Protocol
gNMI Wildcards
path {
elem {
name: "interfaces"
}
elem {
name: "interface"
}
elem {
name: "config"
}
elem {
name: "description"
}
}
The following example shows a path asterisk wildcard as the path name. This wildcard will return
the description for all elements that are available in the Loopback111 interface.
path {
elem {
name: "interfaces"
}
elem {
name: "interface"
key {
key: "name"
value: "Loopback111"
}
}
elem {
name: "*"
}
elem {
name: "description"
}
}
gNMI Protocol
12
gNMI Protocol
gNMI Wildcards
• Specifying an ellipsis (...) or a blank entry as element names. These wildcards can expand to multiple
elements in a path.
The following example shows a path ellipsis wildcard. This wildcard will return all description
fields available under /interfaces.
path {
elem {
name: "interfaces"
}
elem {
name: "..."
}
elem {
name: "description"
}
}
The following is a sample GetRequest with an implicit wildcard. This GetRequest will return the oper-status
of all interfaces on a device.
path {
elem {
name: "interfaces"
}
elem {
name: "interface"
}
elem {
name: "state"
}
elem {
name: "oper-status"
}
},
type: 0,
encoding: 4
notification {
timestamp: 1520627877608777450
update {
path {
elem {
name: "interfaces"
}
elem {
name: "interface"
key {
key: "name"
value: "\"FortyGigabitEthernet1/1/1\""
}
}
elem {
name: "state"
}
elem {
name: "oper-status"
}
gNMI Protocol
13
gNMI Protocol
gNMI Error Messages
}
val {
json_ietf_val: "\"LOWER_LAYER_DOWN\""
}
},
<snip>
…
</snip>
update {
path {
elem {
name: "interfaces"
}
elem {
name: "interface"
key {
key: "name"
value: "\"Vlan1\""
}
}
elem {
name: "state"
}
elem {
name: "oper-status"
}
}
val {
json_ietf_val: "\"DOWN\""
}
}
}
The following sample error message is displayed when the data element is empty:
gNMI Protocol
14
gNMI Protocol
How to Enable the gNMI Protocol
2. Connect the gNMI client using client and root certificates configured in previous steps.
# Send:
Device# configure terminal
Device(config)# crypto pki import trustpoint1 pem terminal password password1
# Receive:
% Enter PEM-formatted CA certificate.
% End with a blank line or "quit" on a line by itself.
# Send:
# Contents of rootCA.pem, followed by newline + 'quit' + newline:
gNMI Protocol
15
gNMI Protocol
Enabling gNMI in Insecure Mode
-----BEGIN CERTIFICATE-----
<snip>
-----END CERTIFICATE-----
quit
# Receive:
% Enter PEM-formatted encrypted private General Purpose key.
% End with "quit" on a line by itself.
# Send:
# Contents of device.des3.key, followed by newline + 'quit' + newline:
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: DES-EDE3-CBC,D954FF9E43F1BA20
<snip>
-----END RSA PRIVATE KEY-----
quit
# Receive:
% Enter PEM-formatted General Purpose certificate.
% End with a blank line or "quit" on a line by itself.
# Send:
# Contents of device.crt, followed by newline + 'quit' + newline:
-----BEGIN CERTIFICATE-----
<snip>
-----END CERTIFICATE-----
quit
# Receive:
% PEM files import succeeded.
Device(config)#
# Send:
Device(config)# crypto pki trustpoint trustpoint1
Device(ca-trustpoint)# revocation-check none
Device(ca-trustpoint)# end
Device#
Note This task is applicable in Cisco IOS XE Fuji 16.8.1 through Amsterdam 17.2.x.
In a Day Zero setup, first enable the device in insecure mode, then disable it, and enable the secure mode. To
stop gNMI in insecure mode, use the no gnmi-yang server command.
SUMMARY STEPS
1. enable
2. configure terminal
3. gnmi-yang
gNMI Protocol
16
gNMI Protocol
Enabling gNMI in Insecure Mode
4. gnmi-yang server
5. gnmi-yang port port-number
6. end
7. show gnmi-yang state
DETAILED STEPS
Step 5 gnmi-yang port port-number Sets the gNMI port to listen to.
Example: • The default insecure gNMI port is 9339.
(Optional) Device(config)# gnmi-yang port 50000
Example
The following is sample output from the show gnmi-yang state command:
State Status
--------------------------------
Enabled Up
gNMI Protocol
17
gNMI Protocol
Enabling gNMI in Secure Mode
Note This task is applicable in Cisco IOS XE Fuji 16.8.1 through Amsterdam 17.2.x.
SUMMARY STEPS
1. enable
2. configure terminal
3. gnmi-yang
4. gnmi-yang secure-server
5. gnmi-yang secure-trustpoint trustpoint-name
6. gnmi-yang secure-client-auth
7. gnmi-yang secure-port
8. end
9. show gnmi-yang state
DETAILED STEPS
Step 5 gnmi-yang secure-trustpoint trustpoint-name Specifies the trustpoint and cert set that gNMI uses for
authentication.
Example:
Device(config)# gnmi-yang secure-trustpoint
trustpoint1
gNMI Protocol
18
gNMI Protocol
Connecting the gNMI Client
Step 7 gnmi-yang secure-port (Optional) Sets the gNMI port to listen to.
Example: • The default insecure gNMI port is 9339.
Device(config)# gnmi-yang secure-port
Example
The following is sample output from the show gnmi-yang state command:
State Status
--------------------------------
Enabled Up
gNMI Protocol
19
gNMI Protocol
Configuration Examples for the gNMI Protocol
Note This example is applicable in Cisco IOS XE Fuji 16.8.1 through Amsterdam 17.2.x.
gNMI Protocol
20
gNMI Protocol
Additional References for the gNMI Protocol
gNMI https://github.com/openconfig/reference/blob/master/rpc/gnmi/gnmi-specification.md
Standard/RFC Title
RFC 7951 JSON Encoding of Data Modeled with YANG
Technical Assistance
Description Link
The Cisco Support website provides extensive online resources, including http://www.cisco.com/support
documentation and tools for troubleshooting and resolving technical issues
with Cisco products and technologies.
To receive security and technical information about your products, you can
subscribe to various services, such as the Product Alert Tool (accessed from
Field Notices), the Cisco Technical Services Newsletter, and Really Simple
Syndication (RSS) Feeds.
Access to most tools on the Cisco Support website requires a Cisco.com user
ID and password.
gNMI Protocol
21
gNMI Protocol
Feature Information for the gNMI Protocol
gNMI Protocol Cisco IOS XE Fuji 16.8.1a This feature describes the model-driven
configuration and retrieval of operational data
using the gNMI capabilities, GET and SET
RPCs.
This feature was implemented on the
following platforms:
• Cisco Catalyst 9300 Series Switches
• Cisco Catalyst 9400 Series Switches
• Cisco Catalyst 9500 Series Switches
gNMI Protocol
22