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

How to automate Port Assignment?

Aleksandr Serov
Level 1
Level 1

Hello, 

Is there any way to automate port assignment by python? 

When I add new switches to the fabric I have to click on hundreds of ports and assign them to appropriate data ip pool, voice ip pool and authentication template. It isn't look like a convenient way (. Are there any other way? There is even no option to find the port by the name(.

 

I found this tool https://github.com/CiscoDevNet/dnacenter-host-onboarding

but I not sure that it is compatible with fabric host onboarding to an approriate ip pools and authentication template.

 

I also found function add_port_assignment_for_user_device in api but can not find well enough explanation how to use it.

 

Thank you in advance for any idea.

1 Accepted Solution

Accepted Solutions

Preston Chilcote
Cisco Employee
Cisco Employee

Hi Aleksandr,

Have you looked at "api/v1/business/sda/hostonboarding/user-device".   add_port_assignment_for_user_device is a wrapper for that API, so if you populate the payload to look like what you see when you "GET" that api, then it should do the update.  I can't find any sample code for that function precisely, but the docs will show you how to use the SDK in general:

 

https://dnacentersdk.readthedocs.io/en/latest/api/quickstart.html#making-api-calls

 

Body:
[
    {
        "siteNameHierarchy": "Global/Belgium/Diegem/Peg3",
        "deviceManagementIpAddress": "172.16.1.3",
        "interfaceName": "TenGigabitEthernet1/0/15",
        "dataIpAddressPoolName": "Employees",
        "voiceIpAddressPoolName": "VoicePool",
        "authenticateTemplateName": "DefaultWiredDot1xClosedAuth",
    }
]


Be sure to run 1.3.3.6 or later to have the fix for CSCvu29574 (Cisco DNA Center - Cannot set port Authentication Template in SD-Access through API )

View solution in original post

2 Replies 2

Preston Chilcote
Cisco Employee
Cisco Employee

Hi Aleksandr,

Have you looked at "api/v1/business/sda/hostonboarding/user-device".   add_port_assignment_for_user_device is a wrapper for that API, so if you populate the payload to look like what you see when you "GET" that api, then it should do the update.  I can't find any sample code for that function precisely, but the docs will show you how to use the SDK in general:

 

https://dnacentersdk.readthedocs.io/en/latest/api/quickstart.html#making-api-calls

 

Body:
[
    {
        "siteNameHierarchy": "Global/Belgium/Diegem/Peg3",
        "deviceManagementIpAddress": "172.16.1.3",
        "interfaceName": "TenGigabitEthernet1/0/15",
        "dataIpAddressPoolName": "Employees",
        "voiceIpAddressPoolName": "VoicePool",
        "authenticateTemplateName": "DefaultWiredDot1xClosedAuth",
    }
]


Be sure to run 1.3.3.6 or later to have the fix for CSCvu29574 (Cisco DNA Center - Cannot set port Authentication Template in SD-Access through API )

Thank you very much for your response and the solution. 

I made a couple of experiments on my 1.3.3.7 and found a lot of difficulties.

1) API do not work until restarts it by Platform/Bundles/DNA Center REST API Disable/Enable  (I suppose it is well known bug)

2) There is a rate limiter, which allows me to do only 5 requests per minute, no matter GET or POST.

3) There is no way to define static SGT on port as in GUI ((((

4)  If the authentication template was defined by GUI then the API return empty value for "authenticateTemplateName". API allows to define the value for "authenticateTemplateName" but not as "DefaultWiredDot1xClosedAuth", it have to be defined as "Closed authentication". But after that GUI do not show this value on port )

 

I decided not to use API for configuring ports on new switches in the fabric. I tried to configure ports by the cli and found that it is surprisingly most convenient way )). DNAC do not remove my port configurations during provisioning.

 

Any way,  it was interesting experience. I suppose the API will be improved in following versions.

 

 

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: