cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2913
Views
1
Helpful
11
Replies

I am looking for a Yang Model that will return me the mac address table

Caiena
Level 1
Level 1

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?

11 Replies 11

balaji.bandi
Hall of Fame
Hall of Fame

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

BB

***** Rate All Helpful Responses *****

How to Ask The Cisco Community for Help

Caiena
Level 1
Level 1

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.

omz
VIP Alumni
VIP Alumni

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.

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 

 

Yan Gorelik
YDK Solutions

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

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. 

Yan Gorelik
YDK Solutions

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>

 

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>

 

Yan Gorelik
YDK Solutions

Marcel Zehnder
Spotlight
Spotlight

Hi, did anybody found such a module, I also struggle with it.

Marcel

I found it: Cisco-IOS-XE-matm-oper.yang