- Working with the api of the cisco prime and would need to get the number of a port-channel that a physical interface is on.
interface GigabitEthernet1/1
switchport
switchport trunk encapsulation dot1q
switchport trunk allowed vlan 11,99,254,425-427,500,600
switchport mode trunk
channel-group 10 mode active
end
- Looking the cisco prime api documentation haven't found any way to get this information.
The port channel exists on the switch, not in Prime.
go to the switch and run the following
sh interface description (if it was labeled with description)
sh etherchannel summary (to see what port channel the interfaces belong to ad what the port channel number is.
Also the API has a resource that returns this information unfortunately. I've forwarded your feature request to our product management team
One way of getting that port-channel number would be to extract the switch config and parse the info yourself, using regex to match that config line. If you want to do it that way, use the ConfigVersions API with the deviceName of the switch (or whatever other identifier) to get the config ID.
https://<primeUrl>/webacs/api/v1/data/ConfigVersions?deviceName=<deviceName>&isLast=true&.full=true
The "isLast=true" part will get the most recently collected config in the instance there are multiple stored configs. If your configs are being saved by Prime, your returned tree data should include fileInfos like the below.
<fileInfos>
<fileInfo>
<fileId>4742337804</fileId>
<fileState>STARTUPCONFIG</fileState>
<fileType>TEXT</fileType>
</fileInfo>
<fileInfo>
<fileId>4742337803</fileId>
<fileState>RUNNINGCONFIG</fileState>
<fileType>TEXT</fileType>
</fileInfo>
</fileInfos>
The "fileInfos" contain the fileIds of the running and startup configs. Grab the number of whichever you'd prefer and then use that with the extractSanitizedFile API.
https://<primeUrl>/webacs/api/v1/op/configArchiveService/extractSanitizedFile?fileId=4742337804
The returned fileData is a straight text dump of the device's config. You can download it yourself as XML by default or JSON if you add ".json" to the url's path.
So https://<primeUrl>/webacs/api/v1/op/configArchiveService/extractSanitizedFile.json?fileId=4742337804
Comments
0 comments
Please sign in to leave a comment.