03-28-2020 01:27 PM
I am using the Yang explorer with a Cisco catalyst 9300 and I am unable to find a Yang model that will return mac address table from the switch. Can anyone help me with find a Yang model that i can use to retrieve the mac address table from my catalyst 9300?
03-28-2020 02:01 PM
look at some example help you :
https://github.com/YangModels/yang/tree/master/vendor/cisco
If you have cisco live presenetation access look for BRKCRS-2004 to have some idea
03-28-2020 04:42 PM
I have looked at https://github.com/YangModels/yang/tree/master/vendor/cisco already I have been through many models. I don’t see any of them that say MAC address table.
Thanks for the reply.
03-29-2020 01:05 AM
03-30-2020 05:43 AM
I tried looking at it with pyang and I down get any output from this model. I am new to the yang model and I am unsure why I don't get the tree with this command (see below).
pyang -f tree openconfig-network-instance-l2.yang
Thanks.
03-31-2020 02:55 PM
This is expected outcome, because openconfig-network-instance-l2.yang is a submodule of openconfig-network-instance.yang. Try to run:
pyang -f tree openconfig-network-instance.yang
04-02-2020 06:59 AM - edited 04-02-2020 06:59 AM
Thanks for the replay yangorelik that worked but, I still don't see the mac address table. I sent the following Yang model to my cat 9300 and I don't see any mac address in the output. I am using the Yang explorer to test with.
<rpc message-id="101" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<get>
<filter>
<network-instances xmlns="http://openconfig.net/yang/network-instance">
<network-instance/>
</network-instances>
</filter>
</get>
</rpc>
Thanks for the reply
Chad Aiena
04-02-2020 10:42 PM
That is also expected result, because network-instance is an element of a list and key name must be specified. Try this:
<rpc message-id="101" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<get>
<filter>
<network-instances xmlns="http://openconfig.net/yang/network-instance">
<network-instance>
<name>default</name>
</network-instance>
</network-instances>
</filter>
</get>
</rpc>
I am not sure, how you send the RPC to device. Seems you are not using YDK. If you did, the built network instance object would not pass validation due to the above described error.
04-09-2020 07:44 AM
Thank you for your replay and I am sorry it to so long for me to check this but, I did not get the mac address table back. This is what I got. Am i missing something?
<rpc-reply message-id="urn:uuid:3581b412-f40c-4ebd-a22f-6e73f1a286a7" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
<data>
<network-instances xmlns="http://openconfig.net/yang/network-instance">
<network-instance>
<name>default</name>
<config>
<name>default</name>
<type xmlns:oc-ni-types="http://openconfig.net/yang/network-instance-types">oc-ni-types:DEFAULT_INSTANCE</type>
<description>default-vrf [read-only]</description>
</config>
<state>
<name>default</name>
<type xmlns:oc-ni-types="http://openconfig.net/yang/network-instance-types">oc-ni-types:DEFAULT_INSTANCE</type>
<description>default-vrf [read-only]</description>
</state>
<tables>
<table>
<protocol xmlns:oc-pol-types="http://openconfig.net/yang/policy-types">oc-pol-types:DIRECTLY_CONNECTED</protocol>
<address-family xmlns:oc-types="http://openconfig.net/yang/openconfig-types">oc-types:IPV4</address-family>
<config>
<protocol xmlns:oc-pol-types="http://openconfig.net/yang/policy-types">oc-pol-types:DIRECTLY_CONNECTED</protocol>
<address-family xmlns:oc-types="http://openconfig.net/yang/openconfig-types">oc-types:IPV4</address-family>
</config>
<state>
<protocol xmlns:oc-pol-types="http://openconfig.net/yang/policy-types">oc-pol-types:DIRECTLY_CONNECTED</protocol>
<address-family xmlns:oc-types="http://openconfig.net/yang/openconfig-types">oc-types:IPV4</address-family>
</state>
</table>
<table>
<protocol xmlns:oc-pol-types="http://openconfig.net/yang/policy-types">oc-pol-types:DIRECTLY_CONNECTED</protocol>
<address-family xmlns:oc-types="http://openconfig.net/yang/openconfig-types">oc-types:IPV6</address-family>
<config>
<protocol xmlns:oc-pol-types="http://openconfig.net/yang/policy-types">oc-pol-types:DIRECTLY_CONNECTED</protocol>
<address-family xmlns:oc-types="http://openconfig.net/yang/openconfig-types">oc-types:IPV6</address-family>
</config>
<state>
<protocol xmlns:oc-pol-types="http://openconfig.net/yang/policy-types">oc-pol-types:DIRECTLY_CONNECTED</protocol>
<address-family xmlns:oc-types="http://openconfig.net/yang/openconfig-types">oc-types:IPV6</address-family>
</state>
</table>
<table>
<protocol xmlns:oc-pol-types="http://openconfig.net/yang/policy-types">oc-pol-types:STATIC</protocol>
<address-family xmlns:oc-types="http://openconfig.net/yang/openconfig-types">oc-types:IPV4</address-family>
<config>
<protocol xmlns:oc-pol-types="http://openconfig.net/yang/policy-types">oc-pol-types:STATIC</protocol>
<address-family xmlns:oc-types="http://openconfig.net/yang/openconfig-types">oc-types:IPV4</address-family>
</config>
<state>
<protocol xmlns:oc-pol-types="http://openconfig.net/yang/policy-types">oc-pol-types:STATIC</protocol>
<address-family xmlns:oc-types="http://openconfig.net/yang/openconfig-types">oc-types:IPV4</address-family>
</state>
</table>
<table>
<protocol xmlns:oc-pol-types="http://openconfig.net/yang/policy-types">oc-pol-types:STATIC</protocol>
<address-family xmlns:oc-types="http://openconfig.net/yang/openconfig-types">oc-types:IPV6</address-family>
<config>
<protocol xmlns:oc-pol-types="http://openconfig.net/yang/policy-types">oc-pol-types:STATIC</protocol>
<address-family xmlns:oc-types="http://openconfig.net/yang/openconfig-types">oc-types:IPV6</address-family>
</config>
<state>
<protocol xmlns:oc-pol-types="http://openconfig.net/yang/policy-types">oc-pol-types:STATIC</protocol>
<address-family xmlns:oc-types="http://openconfig.net/yang/openconfig-types">oc-types:IPV6</address-family>
</state>
</table>
</tables>
<protocols>
<protocol>
<identifier xmlns:oc-pol-types="http://openconfig.net/yang/policy-types">oc-pol-types:STATIC</identifier>
<name>DEFAULT</name>
<config>
<identifier xmlns:oc-pol-types="http://openconfig.net/yang/policy-types">oc-pol-types:STATIC</identifier>
<name>DEFAULT</name>
</config>
</protocol>
<protocol>
<identifier xmlns:oc-pol-types="http://openconfig.net/yang/policy-types">oc-pol-types:DIRECTLY_CONNECTED</identifier>
<name>DEFAULT</name>
<config>
<identifier xmlns:oc-pol-types="http://openconfig.net/yang/policy-types">oc-pol-types:DIRECTLY_CONNECTED</identifier>
<name>DEFAULT</name>
</config>
</protocol>
</protocols>
</network-instance>
</network-instances>
</data>
</rpc-reply>
04-09-2020 11:08 AM
The openconfig models are implemented in Cisco devices with significant limitations. If you need specific information, I would suggest start looking at native models for your device and software version. The Cisco Catalyst 9300 is running IOS XE software (not sure what is the version running on your device). The corresponding YANG models described here. And YDK model that you can use for reference is here.
My simple YDK script to retrieve ARP table from sandbox running IOS XE 16.9.3:
#!/usr/bin/env python
#
from ydk.services import NetconfService
from ydk.providers import NetconfServiceProvider
from ydk.models.cisco_ios_xe import Cisco_IOS_XE_arp_oper as arp_oper
import logging
from getpass import getpass
def enable_logging(level):
log = logging.getLogger('ydk')
log.setLevel(logging.INFO)
handler = logging.StreamHandler()
formatter = logging.Formatter(
"%(asctime)s - %(name)s - %(levelname)s - %(message)s")
handler.setFormatter(formatter)
log.addHandler(handler)
if __name__ == '__main__':
enable_logging(logging.INFO)
password = getpass(prompt="SSH password: ")
nc = NetconfService()
nc_provider = NetconfServiceProvider(
address='ios-xe-mgmt.cisco.com',
port=10000,
username='developer',
password=password)
nc.get(nc_provider, arp_oper.ArpData())
I got the following that contains RPC and reply:
020-04-09 10:42:30,436 - ydk - INFO - Connected to ios-xe-mgmt.cisco.com on port 10000 using ssh with timeout of -1
2020-04-09 10:42:30,437 - ydk - INFO - Executing 'get' RPC on [Cisco-IOS-XE-arp-oper:arp-data]
2020-04-09 10:42:30,444 - ydk - INFO - ============= Sending RPC to device =============
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"><get xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<filter><arp-data xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-arp-oper"/></filter>
</get>
</rpc>
2020-04-09 10:42:30,964 - ydk - INFO - ============= Received RPC from device =============
<?xml version="1.0" encoding="UTF-8"?>
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="2">
<data>
<arp-data xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-arp-oper">
<arp-vrf>
<vrf>Default</vrf>
<arp-oper>
<address>10.10.20.48</address>
<enctype>ios-encaps-type-arpa</enctype>
<interface>GigabitEthernet1</interface>
<type>ios-linktype-ip</type>
<mode>ios-arp-mode-interface</mode>
<hwtype>ios-snpa-type-ieee48</hwtype>
<hardware>00:50:56:bb:e1:4e</hardware>
<time>2020-04-09T05:14:31.000586+00:00</time>
</arp-oper>
<arp-oper>
<address>10.10.20.253</address>
<enctype>ios-encaps-type-arpa</enctype>
<interface>GigabitEthernet1</interface>
<type>ios-linktype-ip</type>
<mode>ios-arp-mode-dynamic</mode>
<hwtype>ios-snpa-type-ieee48</hwtype>
<hardware>08:96:ad:9e:44:4c</hardware>
<time>2020-04-09T17:42:03.000956+00:00</time>
</arp-oper>
<arp-oper>
<address>10.10.20.254</address>
<enctype>ios-encaps-type-arpa</enctype>
<interface>GigabitEthernet1</interface>
<type>ios-linktype-ip</type>
<mode>ios-arp-mode-dynamic</mode>
<hwtype>ios-snpa-type-ieee48</hwtype>
<hardware>00:08:e3:ff:fd:90</hardware>
<time>2020-04-09T17:38:02.000194+00:00</time>
</arp-oper>
<arp-oper>
<address>10.255.255.1</address>
<enctype>ios-encaps-type-arpa</enctype>
<interface>GigabitEthernet2</interface>
<type>ios-linktype-ip</type>
<mode>ios-arp-mode-interface</mode>
<hwtype>ios-snpa-type-ieee48</hwtype>
<hardware>00:50:56:bb:10:5e</hardware>
<time>2020-04-09T15:48:52.000503+00:00</time>
</arp-oper>
<arp-oper>
<address>10.255.255.100</address>
<enctype>ios-encaps-type-arpa</enctype>
<interface>GigabitEthernet2</interface>
<type>ios-linktype-ip</type>
<mode>ios-arp-mode-app-alias</mode>
<hwtype>ios-snpa-type-ieee48</hwtype>
<hardware>00:07:b4:00:01:01</hardware>
<time>2020-04-09T15:49:03.000678+00:00</time>
</arp-oper>
<arp-oper>
<address>192.168.3.1</address>
<enctype>ios-encaps-type-arpa</enctype>
<interface>VirtualPortGroup0</interface>
<type>ios-linktype-ip</type>
<mode>ios-arp-mode-interface</mode>
<hwtype>ios-snpa-type-ieee48</hwtype>
<hardware>00:1e:7a:6f:41:bd</hardware>
<time>2020-04-09T17:03:55.000705+00:00</time>
</arp-oper>
</arp-vrf>
</arp-data>
</data>
</rpc-reply>
04-19-2023 11:45 PM
Hi, did anybody found such a module, I also struggle with it.
Marcel
04-20-2023 04:05 AM
I found it: Cisco-IOS-XE-matm-oper.yang
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide