cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2600
Views
0
Helpful
3
Replies

NETCONF RPC error

joeldoetsch
Level 1
Level 1

Hello, I'm running IOS XE 16.9.4 on a Catalyst 9300.  I'm trying to build a few NETCONF scripts to get a better understanding of it.  I've cobbled together a script from various examples just to test out pulling interface information, but I've hit a wall.  I'm getting an RPC error that I can't find a solution for, and was hoping someone could point me in the right direction.  Unfortunately, I have almost no experience with this, so I'm kind of treading water.

Error message:

Traceback (most recent call last):
File "C:\automate\Network\netconftest.py", line 35, in <module>
state_data = m.get(filter=interface_filter).xml
File "C:\automate\Network\network_automation\lib\site-packages\ncclient\manager.py", line 246, in execute
return cls(self._session,
File "C:\automate\Network\network_automation\lib\site-packages\ncclient\operations\retrieve.py", line 91, in request
return self._request(node)
File "C:\automate\Network\network_automation\lib\site-packages\ncclient\operations\rpc.py", line 375, in _request
raise self._reply.error
ncclient.operations.rpc.RPCError: {'type': 'protocol', 'tag': 'access-denied', 'app_tag': None, 'severity': 'error', 'info': None, 'path': None, 'message': None}

 

 

Here's the script

 

 

from ncclient import manager
from pprint import pprint
import xmltodict
import xml.dom.minidom


router = {
    'ip': '<redacted>',
    'port': '830',
    'username': '<redacted>',
    'password': '<redacted>'
}


m = manager.connect(host=router['ip'], port=router['port'], username=router['username'], password=router['password'], device_params={'name':'iosxe'}, hostkey_verify=False)

print(m.connected)

my_ints = ["1/0/15","2/0/23"]


for x in my_ints:
    interface_filter = '''
      <filter>
          <native xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-native">
              <interface>
                  <GigabitEthernet>
                      <name>'''+str(x)+'''</name>
                  </GigabitEthernet>
              </interface>
          </native>
      </filter>
    '''
    print (interface_filter)
    state_data = m.get(filter=interface_filter).xml
    print(xml.dom.minidom.parseString(state_data).toprettyxml())

#running_config = m.get_config('running', interface_filter).xml
#print(xml.dom.minidom.parseString(running_config).toprettyxml())



m.close_session()

 

 

Thanks in advance

 
1 Accepted Solution

Accepted Solutions

joeldoetsch
Level 1
Level 1

I finally figured it out.  It was silly.  It's because the user I was logging in with didn't have a high enough privilege level

View solution in original post

3 Replies 3

pieterh
VIP
VIP

I'm not a scripting guru but try changing the section

<interface>
  <GigabitEthernet>
     <name>'''+str(x)+'''</name>
  </GigabitEthernet>
</interface>

to

 

<interfaces>
  <interface>
     <name>'''+str(x)+'''</name>
  </interface>
</interfaces>

source: slides-edu-network-configuration-with-netconf-00.pdf (ietf.org)

Hello,

That was a good thought, but unfortunately, I still received the same error message.  Thanks for the reply, though!

joeldoetsch
Level 1
Level 1

I finally figured it out.  It was silly.  It's because the user I was logging in with didn't have a high enough privilege level

Review Cisco Networking for a $25 gift card