10-28-2021 06:57 AM
Greetings
dnac version 2.2.2.5
we have huge site where we have to assign pools statically, obviously its a cumbersome task due to slow GUI and many pools. Hence we thought of using " /dna/intent/api/v1/business/sda/hostonboarding/user-device". Unfortunately we are ending up with an error while trying more than one port at a time. I am really a newbie in python, appreciate your support.
I tried to follow @Aninda Chatterjee 's code achieve the ports assignment, however that ending with another error mentioning "Device not found" - however i really like his logic, appreciate the efforts.
Every time when we run the code, a dnac event generated as follows " Service request processing has failed with error: This intent (with name 'edge-1.company.com') is outdated as the controller has a newer intent. Resubmit the intent based on the current state of controller.
my code attached below for your reference
#Import required libraries import requests import json from requests.auth import HTTPBasicAuth # GET the AUTH TOKEN token = requests.post("https://<DNAC-IP>/dna/system/api/v1/auth/token",auth=HTTPBasicAuth(username="<username>",password="<password>”), headers={'content-type': 'application/json'},verify=False,) data = token.json() # Assign Token to a variable token=data['Token'] ports=['4','5'] print (ports) for i in ports: payload={ "siteNameHierarchy": "<SiteHierarchy>", "deviceManagementIpAddress": "<deviceIP>", "interfaceName": "GigabitEthernet1/0/"+i, "dataIpAddressPoolName": "IP_Pool", "authenticateTemplateName": "Closed Authentication" } print (payload) response = requests.post ('https://<DNAC-IP>/dna/intent/api/v1/business/sda/hostonboarding/user-device',json=payload,headers={ 'X-Auth-Token': '{}'.format(token), 'Content-type': 'application/json', }, verify=False ) print (response)
Thanks in advance.
Solved! Go to Solution.