cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
762
Views
0
Helpful
5
Replies

Using NETCONF to add an SNMP server

ChrisNewnham_
Level 1
Level 1

Hello

I'm trying to use ncclient to add an SNMP server, after successfully getting the config. I really don't know where to put operation="create" or if I even need to do it.

This is just a lab environment, IOS-XE v 16.12.05

 

 

5 Replies 5

I don't think I'm trying to do that, I'm simply trying to change the SNMP server on the device using NETCONF.

Try

 

<config>
  <native xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-native">
    <snmp-server>
      <community>
        <name>public</name>
        <RO/>
      </community>
      <host>
        <version>2c</version>
        <ip>
          <hostip>4.4.4.4</hostip>
        </ip>
        <community>public</community>
      </host>
    </snmp-server>
  </native>
</config>
"""

 

Please mark this as helpful or solution accepted to help others
Connect with me https://bigevilbeard.github.io

No joy, said community is a bad element. Not sure where you got the above from, to be honest.

@ChrisNewnham_ test this on the DV sandbox version 17.09.02a. Works ok. HTH

 

from ncclient import manager
import xml.dom.minidom

RTR = manager.connect(
    host="sandbox-iosxe-latest-1.cisco.com",
    port="830",
    username="admin",
    password="C1sco12345",
    hostkey_verify=False)

snmp_server_xml = """
<config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
  <native xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-native">
    <snmp-server>
      <host-config xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-snmp">
        <ip-community>
          <ip-address>4.4.4.4</ip-address>
          <community-or-user>MOO</community-or-user>
        </ip-community>
      </host-config>
    </snmp-server>
  </native>
</config>
"""

edit_config_response = RTR.edit_config(target="running", config=snmp_server_xml)

 

Please mark this as helpful or solution accepted to help others
Connect with me https://bigevilbeard.github.io