cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1360
Views
0
Helpful
2
Replies

Change MGMT ip in Dnac via API

ybkthedev
Level 1
Level 1

I have noticed an inconsistency between the IP addresses of devices in my inventory file and the IP addresses used by Cisco DNA Center to monitor these devices. This is causing communication issues as DNA Center is unable to reach the devices due to incorrect IP addresses. I am seeking a way to update the IP addresses in DNA Center to match those in my master inventory file, which has the correct IP addresses and device names. However, I have not found an API endpoint that allows me to do this in the DNA Center API documentation. The "Sync Devices" section appears to only allow for changing the IP addresses on the actual devices, but not in DNA Center. Can anyone help me identify the appropriate API endpoint or provide any alternative solutions to achieve what I want to do? 
BTW i am using ansible

2 Replies 2

TahirAli12881
Level 1
Level 1

Hi, i want to do something similar. I want to change/update netconf port of a device.

iam using dnacentersdk

from dnacentersdk import api 

 

def UpdateDeviceParameters(DevId):
    dev = dnac.devices.sync_devices(
        ipAddress=["10.26.68.253"],
        netconfPort='830',
        type="NETWORK_DEVICE")
    print (dev)
    pass

 

I get a response back 

 

{'response': {'taskId': '84f1ba0f-86b0-485c-9793-0183d6deb70d', 'url': '/api/v1/task/84f1ba0f-86b0-485c-9793-0183d6deb70d'}, 'version': '1.0'}

 

But the device is not updating the port to 830. I have tired to add device ID in to the call as shown below. That did not help either.

Can someone help plz

 

def UpdateDeviceParameters(DevId):
    dev = dnac.devices.sync_devices(
        ipAddress=["10.26.68.253"],
        id=DevId,
        netconfPort='830',
        type="NETWORK_DEVICE")
    print (dev)
    pass

 

 

 

 

 

Found the solution.

You need to have all these in the json body

def ChangeNetconf(DeviceIP,newIP):
    resp = dnac.devices.sync_devices(
        type="NETWORK_DEVICE",
        computeDevice=False,
        snmpVersion="v3",
        snmpMode="AUTHPRIV",
        snmpAuthProtocol="SHA",
        snmpAuthPassphrase="xxx",
        snmpPrivProtocol="AES128",
        snmpPrivPassphrase="xxx",
        snmpUserName="snmpv",
        snmpROCommunity="NO!$DATA!$",
        snmpRWCommunity="NO!$DATA!$",
        snmpRetry=-1,
        snmpTimeout= -1,
        cliTransport="NO!$DATA!$",
        userName="NO!$DATA!$",
        password="NO!$DATA!$",
        enablePassword="NO!$DATA!$",
        netconfPort="830",
        ipAddress=[DeviceIP],
        updateMgmtIPaddressList=[{"existMgmtIpAddress":DeviceIP,"newMgmtIpAddress":newIP}]
    )
###########
These are required to make any changes to netconf or management ip

cliTransport (string, required)
enablePassword (string, required)
ipAddress (array<string>, required)
password (string, required)
snmpAuthPassphrase (string, required)
snmpAuthProtocol (string, required)
snmpMode (string, required)
snmpPrivPassphrase (string, required)
snmpPrivProtocol (string, required)
snmpROCommunity (string, required)
snmpRWCommunity (string, required)
snmpRetry (integer, required)
snmpTimeout (integer, required)
snmpUserName (string, required)
username (string, required)