cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
328
Views
2
Helpful
4
Replies

Catalyst Center/DNAC get IP pools via API

Alex D
Level 1
Level 1

Hi. Does anyone know some way to get IP pools via API? Not the global pool, but the subpools. I have found this in the API documentation:

 

https://developer.cisco.com/docs/dna-center/get-reserve-ip-subpool/

 

It supports GET request and requires siteId, but it doesn't work neither with providing site ID in the URL nor in the payload. It always answers:

 

{"status":false,"message":["Site id should not be empty."]}

 

I have a python function like this:

 

def catc_get_ippool():
    URI = '/dna/intent/api/v1/reserve-ip-subpool'#/39806d93-bab7-4749-819d-fb92bb0b637d
    HEADERS = {
        'X-Auth-Token': CATC_AUTH_TOKEN,
        'Content-Type': 'application/json', 
        'Accept': 'application/json'}
    DATA="""{'siteId':'39806d93-bab7-4749-819d-fb92bb0b637d'}"""
    RESPONE = requests.get(CATC_URL + URI, headers=HEADERS, verify=False, data=DATA)
    return RESPONE.text

 

As mentioned, I tried both the URL method and providing payload, neither works.

Maybe someone knows some other ways to retrieve IP pools information?

1 Accepted Solution

Accepted Solutions

Torbjørn
VIP
VIP

You must supply the siteId as a query parameter. In practice you append the query-string to your URL like this: https://{cat-c}/dna/intent/api/v1/reserve-ip-subpool?siteId={your-site-id} 

The following python code is working fine for me on 2.3.7.6:

 

import requests

url = "https://172.18.97.30/dna/intent/api/v1/reserve-ip-subpool"
params = { "siteId": "aedee3ec-a32e-4fa7-b21d-319636e61c60" }
headers = { 'X-Auth-Token': 'useYourOwnToken' }

response = requests.request("GET", url, headers=headers, params=params, verify=False)
print(response.text)

 

 

Happy to help! Please mark as helpful/solution if applicable.
Get in touch: https://torbjorn.dev

View solution in original post

4 Replies 4

I also tried "/dna/intent/api/v1/ippool" BAPI path which is supposed to work on its own and give back all IP pools as well as "/dna/intent/api/v1/ippool/site/{site_id}" to give back IP Pool for a specific site ID. Neither works with error {'error': 'BAPI not found with technicalName /v1/ippool/ and restMethod GET'}

Torbjørn
VIP
VIP

You must supply the siteId as a query parameter. In practice you append the query-string to your URL like this: https://{cat-c}/dna/intent/api/v1/reserve-ip-subpool?siteId={your-site-id} 

The following python code is working fine for me on 2.3.7.6:

 

import requests

url = "https://172.18.97.30/dna/intent/api/v1/reserve-ip-subpool"
params = { "siteId": "aedee3ec-a32e-4fa7-b21d-319636e61c60" }
headers = { 'X-Auth-Token': 'useYourOwnToken' }

response = requests.request("GET", url, headers=headers, params=params, verify=False)
print(response.text)

 

 

Happy to help! Please mark as helpful/solution if applicable.
Get in touch: https://torbjorn.dev

Indeed, after checking the API docs closely yesterday on reserve-ip-subpool, I found that either siteId or ignoreInheritedGroups parameter is necessary. So it worked for me too with the reserved ones. Thanks for reconfirming.

---------

siteId string

site id of site from which to retrieve associated reserve pools. Either siteId (per site queries) or ignoreInheritedGroups must be used. They can also be used together.

ignoreInheritedGroups string

 

Ignores pools inherited from parent site. Either siteId or ignoreInheritedGroups must be passed. They can also be used together.

--------------

But still a puzzle on ippool API. 

Thanks, it works! Didn't realize it should be supplied as a query parameter.