-
Notifications
You must be signed in to change notification settings - Fork 11
05. Openconfig demo using cli on Juniper devices
The Openconfig modules and the corresponding translation scripts are already installed on the two devices.
lab@fabric-01> show system yang package
Package ID :junos-openconfig
YANG Module(s) :iana-if-type.yang ietf-inet-types.yang ietf-interfaces.yang ietf-yang-types.yang jnx-aug-openconfig-bgp.yang jnx-aug-openconfig-if-ip.yang jnx-aug-openconfig-interfaces.yang jnx-aug-openconfig-lacp.yang jnx-aug-openconfig-lldp.yang jnx-aug-openconfig-local-routing.yang jnx-aug-openconfig-mpls.yang jnx-openconfig-dev.yang openconfig-bgp-multiprotocol.yang openconfig-bgp-operational.yang openconfig-bgp-policy.yang openconfig-bgp-types.yang openconfig-bgp.yang openconfig-extensions.yang openconfig-if-aggregate.yang openconfig-if-ethernet.yang openconfig-if-ip-ext.yang openconfig-if-ip.yang openconfig-interfaces.yang openconfig-lacp.yang openconfig-lldp-types.yang openconfig-lldp.yang openconfig-local-routing.yang openconfig-mpls-igp.yang openconfig-mpls-ldp.yang openconfig-mpls-rsvp.yang openconfig-mpls-sr.yang openconfig-mpls-static.yang openconfig-mpls-te.yang openconfig-mpls-types.yang openconfig-mpls.yang openconfig-platform-types.yang openconfig-platform.yang openconfig-policy-types.yang openconfig-rib-bgp-ext.yang openconfig-rib-bgp-types.yang openconfig-rib-bgp.yang openconfig-routing-policy.yang openconfig-terminal-device.yang openconfig-transport-types.yang openconfig-types.yang openconfig-vlan-types.yang openconfig-vlan.yang
Translation Script(s) :openconfig-bgp.slax openconfig-interface.slax openconfig-local-routing.slax openconfig-mpls.slax openconfig-policy.slax
Translation script status is enabled
The YANG modules, the equivalent YIN modules, and the translation scripts are stored into these directories:
lab@fabric-01> file list /opt/yang-pkg/junos-openconfig/yang
lab@fabric-01> file list /opt/yang-pkg/junos-openconfig/yin
lab@fabric-01> file list /opt/yang-pkg/junos-openconfig/translation/
lab@fabric-01> file list /var/db/scripts/translation
Here's an example (working Openconfig BGP configuration on Juniper routers):
OpenConfig BGP data models:
lab@fabric-02> show configuration openconfig-bgp:bgp | display set
set openconfig-bgp:bgp neighbors neighbor 192.168.1.1 config peer-as 104
set openconfig-bgp:bgp neighbors neighbor 192.168.1.1 config peer-group OC
set openconfig-bgp:bgp peer-groups peer-group OC config local-as 110
set openconfig-bgp:bgp peer-groups peer-group OC config peer-type EXTERNAL
set openconfig-bgp:bgp peer-groups peer-group OC apply-policy config import-policy bgp-in
set openconfig-bgp:bgp peer-groups peer-group OC apply-policy config export-policy bgp-out
Interface configuration (I am using the Junos model):
lab@fabric-02> show configuration interfaces xe-0/0/0 | display set
set interfaces xe-0/0/0 unit 0 family inet address 192.168.1.2/24
Routing policies configuration (I am using the Junos model):
lab@fabric-02> show configuration policy-options policy-statement bgp-in | display set
set policy-options policy-statement bgp-in then accept
lab@fabric-02> show configuration policy-options policy-statement bgp-out | display set
set policy-options policy-statement bgp-out then accept
OpenConfig BGP data models:
lab@fabric-01> show configuration openconfig-bgp:bgp
neighbors {
neighbor 192.168.1.2 {
config {
peer-as 110;
peer-group OC;
}
}
}
peer-groups {
peer-group OC {
config {
local-as 104;
peer-type EXTERNAL;
}
apply-policy {
config {
import-policy bgp-in;
export-policy bgp-out;
}
}
}
}
To display the json representation, include | display json
lab@fabric-01> show configuration openconfig-bgp:bgp | display json
{
"openconfig-bgp:bgp" : {
"neighbors" : {
"neighbor" : [
{
"neighbor-address" : "192.168.1.2",
"config" : {
"peer-as" : 110,
"peer-group" : "OC"
}
}
]
},
"peer-groups" : {
"peer-group" : [
{
"peer-group-name" : "OC",
"config" : {
"local-as" : 104,
"peer-type" : "EXTERNAL"
},
"apply-policy" : {
"config" : {
"import-policy" : ["bgp-in"],
"export-policy" : ["bgp-out"]
}
}
}
]
}
}
}
To display the XML representation, include | display xml
Please note the xmlns (xml name space) in the below example.
lab@fabric-01> show configuration openconfig-bgp:bgp | display xml
<rpc-reply xmlns:junos="http://xml.juniper.net/junos/16.1I0/junos">
<bgp xmlns="http://openconfig.net/yang/bgp">
<neighbors>
<neighbor>
<neighbor-address>192.168.1.2</neighbor-address>
<config>
<peer-as>110</peer-as>
<peer-group>OC</peer-group>
</config>
</neighbor>
</neighbors>
<peer-groups>
<peer-group>
<peer-group-name>OC</peer-group-name>
<config>
<local-as>104</local-as>
<peer-type>EXTERNAL</peer-type>
</config>
<apply-policy>
<config>
<import-policy>bgp-in</import-policy>
<export-policy>bgp-out</export-policy>
</config>
</apply-policy>
</peer-group>
</peer-groups>
</bgp>
<cli>
<banner></banner>
</cli>
</rpc-reply>
Interface configuration (I am using the Junos model):
lab@fabric-01> show configuration interfaces xe-0/0/0
unit 0 {
family inet {
address 192.168.1.1/24;
}
}
Routing policies configuration (I am using the Junos model):
lab@fabric-01> show configuration policy-options policy-statement bgp-in
then accept;
lab@fabric-01> show configuration policy-options policy-statement bgp-out
then accept;
To display only the Junos configuration emitted by the translation scripts:
lab@fabric-01> show configuration | display translation-scripts translated-config
protocols {
bgp {
group OC {
type external;
import bgp-in;
export bgp-out;
local-as 104;
neighbor 192.168.1.2 {
peer-as 110;
}
}
}
}
To display the whole configuration in junos data model after translation scripts have been applied:
lab@fabric-01> show configuration | display translation-scripts
lab@fabric-01> show bgp neighbor 192.168.1.2
Peer: 192.168.1.2+57620 AS 110 Local: 192.168.1.1+179 AS 104
Group: OC Routing-Instance: master
Forwarding routing-instance: master
Type: External State: Established Flags: <Sync>
Last State: OpenConfirm Last Event: RecvKeepAlive
Last Error: None
Export: [ bgp-out ] Import: [ bgp-in ]
Options: <Preference LogUpDown PeerAS LocalAS Refresh>
Holdtime: 90 Preference: 170 Local AS: 104 Local System AS: 200
Number of flaps: 0
Peer ID: 100.0.0.2 Local ID: 100.0.0.1 Active Holdtime: 90
Keepalive Interval: 30 Group index: 3 Peer index: 0
I/O Session Thread: bgpio-0 State: Enabled
BFD: disabled, down
Local Interface: xe-0/0/0.0
NLRI for restart configured on peer: inet-unicast
NLRI advertised by peer: inet-unicast
NLRI for this session: inet-unicast
Peer supports Refresh capability (2)
Stale routes from peer are kept for: 300
Peer does not support Restarter functionality
Restart flag received from the peer: Notification
NLRI that restart is negotiated for: inet-unicast
NLRI of received end-of-rib markers: inet-unicast
NLRI of all end-of-rib markers sent: inet-unicast
Peer does not support LLGR Restarter functionality
Peer supports 4 byte AS extension (peer-as 110)
Peer does not support Addpath
Table inet.0 Bit: 40001
RIB State: BGP restart is complete
Send state: in sync
Active prefixes: 2
Received prefixes: 15
Accepted prefixes: 14
Suppressed due to damping: 0
Advertised prefixes: 14
Last traffic (seconds): Received 1560640 Sent 282 Checked 1560640
Input messages: Total 23 Updates 7 Refreshes 0 Octets 789
Output messages: Total 14 Updates 7 Refreshes 0 Octets 753
Output Queue[3]: 0 (inet.0, inet-unicast)
To display the Junos RPC for an operational mode command, include the | display xml rpc
The equivalent RPC for the Junos command "show bgp neighbor| display xml" is get-bgp-neighbor-information
lab@fabric-01> show bgp neighbor | display xml rpc
<rpc-reply xmlns:junos="http://xml.juniper.net/junos/16.1I0/junos">
<rpc>
<get-bgp-neighbor-information>
</get-bgp-neighbor-information>
</rpc>
<cli>
<banner></banner>
</cli>
</rpc-reply>
lab@fabric-01> show bgp neighbor 192.168.1.2 | display xml rpc
<rpc-reply xmlns:junos="http://xml.juniper.net/junos/16.1I0/junos">
<rpc>
<get-bgp-neighbor-information>
<neighbor-address>192.168.1.2</neighbor-address>
</get-bgp-neighbor-information>
</rpc>
<cli>
<banner></banner>
</cli>
</rpc-reply>
lab@spine-02# set openconfig-interfaces:interfaces interface et-0/0/12 config type iso88025TokenRing mtu 9192 description "* to leaf-01"
lab@spine-02# set openconfig-interfaces:interfaces interface et-0/0/12 subinterfaces subinterface 0 openconfig-if-ip:ipv4 addresses address 172.16.0.4/31 config ip 172.16.0.4 prefix-length 31
lab@spine-02# show | compare
[edit]
+ openconfig-interfaces:interfaces {
+ interface et-0/0/12 {
+ config {
+ type iso88025TokenRing;
+ mtu 9192;
+ description "* to leaf-01";
+ }
+ subinterfaces {
+ subinterface 0 {
+ openconfig-if-ip:ipv4 {
+ addresses {
+ address 172.16.0.4/31 {
+ config {
+ ip 172.16.0.4;
+ prefix-length 31;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
lab@spine-02# commit
configuration check succeeds
commit complete
lab@spine-02# show openconfig-interfaces:interfaces
interface et-0/0/12 {
config {
type iso88025TokenRing;
mtu 9192;
description "* to leaf-01";
}
subinterfaces {
subinterface 0 {
openconfig-if-ip:ipv4 {
addresses {
address 172.16.0.4/31 {
config {
ip 172.16.0.4;
prefix-length 31;
}
}
}
}
}
}
}
openconfig configuration translated into junos:
lab@spine-02# show | display translation-scripts translated-config
chassis {
aggregated-devices {
ethernet {
device-count 100;
}
}
}
interfaces {
et-0/0/12 {
description "* to leaf-01";
mtu 9192;
unit 0 {
family inet {
address 172.16.0.4/31;
}
}
}
}
lab@spine-02#set openconfig-routing-policy:routing-policy defined-sets prefix-sets prefix-set "100.0.0.0/16 or longer" config prefix-set-name "100.0.0.0/16 or longer"
lab@spine-02#set openconfig-routing-policy:routing-policy defined-sets prefix-sets prefix-set "100.0.0.0/16 or longer" prefixes prefix 100.0.0.0/16 16..32
lab@spine-02#set openconfig-routing-policy:routing-policy policy-definitions policy-definition bgp-ipclos-in config name "100.0.0.0/16 or longer"
lab@spine-02#set openconfig-routing-policy:routing-policy policy-definitions policy-definition bgp-ipclos-in statements statement loopbacks conditions lab@spine-02#match-prefix-set config prefix-set "100.0.0.0/16 or longer"
lab@spine-02#set openconfig-routing-policy:routing-policy policy-definitions policy-definition bgp-ipclos-in statements statement loopbacks actions config accept-route
lab@spine-02# show openconfig-routing-policy:routing-policy defined-sets { prefix-sets { prefix-set "100.0.0.0/16 or longer" { config { prefix-set-name "100.0.0.0/16 or longer"; } prefixes { prefix 100.0.0.0/16 16..32; } } } } policy-definitions { policy-definition bgp-ipclos-in { config { name "100.0.0.0/16 or longer"; } statements { statement loopbacks { conditions { match-prefix-set { config { prefix-set "100.0.0.0/16 or longer"; } } } actions { config { accept-route; } } } } } }
lab@spine-02# commit configuration check succeeds commit complete
openconfig configuration translated into junos:
lab@spine-02# show | display translation-scripts translated-config policy-options { route-filter-list "100.0.0.0/16 or longer" { 100.0.0.0/16 prefix-length-range /16-/32; } policy-statement bgp-ipclos-in { term loopbacks { from { route-filter-list "100.0.0.0/16 or longer"; } then accept; } } }