07-18-2024 10:41 AM
Is there an API call that can retrieve the CSV data for the device specific variable/values? The equivalent of going to vmanage > Configure > Devices > {device} > Change Device Values > Download CSV
We're migrating several dozen sites in the near future and would like to be able to obtain the current CSV data in code so I can automate updating the path values to what they are for the new devices generating a new CSV files with the new values.
Solved! Go to Solution.
07-19-2024 11:25 AM
07-19-2024 12:53 PM
The spacing looks off in your payload. should look like this if using python before applying json.dumps
payload = {"templateId":templateId,"deviceIds":[uuid],"isEdited":False,"isMasterEdited":False}
I have used this on 20.6, 20.9 and 20.12 code.
[root@Raggedtooth cat8kv]# python templateInput.py 4f68d795-21e8-4d55-bdd5-ff4c55be8344 C8K-B5698608-998C-92DA-CFF4-EA1E77E83C3A
200
https://192.168.0.156:443/dataservice/template/device/config/input/
+-----------------------+------------------------------------------+
| key | value |
+-----------------------+------------------------------------------+
| ipv6_strict_control | false |
| metroeIntf | GigabitEthernet7.100 |
| metroeIpv6 | 2001:0172:0027:0003:0000:0000:0000:002 |
| vbond | vbond2.local.net |
| hostName | cat8kv40_1 |
| inetShaperBps | 500000000 |
| advertiseNetwork | 169.1.1.0/24 |
| ntpLogTac | 192.168.16.254 |
| metroePeIp | 172.27.3.1 |
| lanv6Network | 2001:40::0 |
| mplsVlan | 100 |
| csv-host-name | cat8kv40_1 |
| mplsPeIp | 172.27.1.1 |
| mplsIpv6 | 2001:0172:0027:0001:0000:0000:0000:002 |
| mplsPeIpv6 | 2001:0172:0027:0001:0000:0000:0000:001 |
| metroePeIpv6 | 2001:0172:0027:0003:0000:0000:0000:001 |
| metroShaperBps | 100000000 |
| csv-deviceId | C8K-B5698608-998C-92DA-CFF4-EA1E77E83C3A |
| lanIp | 10.0.40.1 |
| multicastGroupAddress | 225.1.1.1 |
| lanIpv6 | 2001:40::1 |
| metroeTunnel | 100007 |
| metroeVlan | 100 |
| vbond1ipv6 | 2001:10:64:32::1 |
| siteId | 40 |
| routerNum | 1 |
| vbond2ipv6 | 2001:10:64:64::1 |
| systemIp | 11.1.40.1 |
| lanNetwork | 10.0.40.0 |
| mplsIp | 172.27.1.2 |
| mplsIntf | GigabitEthernet3.100 |
| csv-deviceIP | 11.1.40.1 |
| csv-status | complete |
| tunnelIntf | 100003 |
| mplsShaperBps | 200000000 |
| vbond1ip | 10.100.1.1 |
| vbond2ip | 10.200.1.1 |
| metroeIp | 172.27.3.2 |
+-----------------------+------------------------------------------+
200
https://192.168.0.156:443/dataservice/template/device/config/input/
07-19-2024 07:03 AM
The API to get the variable list returned as JSON and can be converted to csv on the client end.
payload = {"templateId":templateId,"deviceIds":[uuid],"isEdited":False,"isMasterEdited":False}
api_url = "/template/device/config/input/"
url = base_url + api_url
response = requests.post(url=url, headers=headers, data=json.dumps(payload), verify=False)
07-19-2024 07:31 AM
Thanks! I'll try this out in a bit and update.
07-19-2024 11:05 AM
So I tried forming the request in postman and keep getting a 500 internal server error response. I've tried different combinations of forming my request body in json format but I'm not having much luck. This is not a multitenant environment, if that matters at all.
07-19-2024 11:25 AM
07-19-2024 11:55 AM - edited 07-19-2024 12:44 PM
For security purposes on a public forum, I need to redact my base url and the specific deviceId and templateId, but they are in the proper format, as other requests leveraging them work and I know the base URL is correct because I have made several dozen different calls successfully. This is the first one I'm running into an issue with
POST: https://{BASE-URL}/dataservice/template/device/config/input/
Request body put into body field in postman as raw, format: JSON
07-19-2024 12:53 PM
The spacing looks off in your payload. should look like this if using python before applying json.dumps
payload = {"templateId":templateId,"deviceIds":[uuid],"isEdited":False,"isMasterEdited":False}
I have used this on 20.6, 20.9 and 20.12 code.
[root@Raggedtooth cat8kv]# python templateInput.py 4f68d795-21e8-4d55-bdd5-ff4c55be8344 C8K-B5698608-998C-92DA-CFF4-EA1E77E83C3A
200
https://192.168.0.156:443/dataservice/template/device/config/input/
+-----------------------+------------------------------------------+
| key | value |
+-----------------------+------------------------------------------+
| ipv6_strict_control | false |
| metroeIntf | GigabitEthernet7.100 |
| metroeIpv6 | 2001:0172:0027:0003:0000:0000:0000:002 |
| vbond | vbond2.local.net |
| hostName | cat8kv40_1 |
| inetShaperBps | 500000000 |
| advertiseNetwork | 169.1.1.0/24 |
| ntpLogTac | 192.168.16.254 |
| metroePeIp | 172.27.3.1 |
| lanv6Network | 2001:40::0 |
| mplsVlan | 100 |
| csv-host-name | cat8kv40_1 |
| mplsPeIp | 172.27.1.1 |
| mplsIpv6 | 2001:0172:0027:0001:0000:0000:0000:002 |
| mplsPeIpv6 | 2001:0172:0027:0001:0000:0000:0000:001 |
| metroePeIpv6 | 2001:0172:0027:0003:0000:0000:0000:001 |
| metroShaperBps | 100000000 |
| csv-deviceId | C8K-B5698608-998C-92DA-CFF4-EA1E77E83C3A |
| lanIp | 10.0.40.1 |
| multicastGroupAddress | 225.1.1.1 |
| lanIpv6 | 2001:40::1 |
| metroeTunnel | 100007 |
| metroeVlan | 100 |
| vbond1ipv6 | 2001:10:64:32::1 |
| siteId | 40 |
| routerNum | 1 |
| vbond2ipv6 | 2001:10:64:64::1 |
| systemIp | 11.1.40.1 |
| lanNetwork | 10.0.40.0 |
| mplsIp | 172.27.1.2 |
| mplsIntf | GigabitEthernet3.100 |
| csv-deviceIP | 11.1.40.1 |
| csv-status | complete |
| tunnelIntf | 100003 |
| mplsShaperBps | 200000000 |
| vbond1ip | 10.100.1.1 |
| vbond2ip | 10.200.1.1 |
| metroeIp | 172.27.3.2 |
+-----------------------+------------------------------------------+
200
https://192.168.0.156:443/dataservice/template/device/config/input/
07-19-2024 01:04 PM - edited 07-19-2024 01:04 PM
Oh wow, getting rid of all the whitepsace fixed it in Postman. 3 hours of my day spent on whitespace. Thank you!
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide