05-09-2022 01:33 PM
ACII have a JSON list of APIC FQDNs:
[
"apic1.fabric1.somewhere.net",
"apic2.fabric1.somewhere.net",
"apic3.fabric1.somewhere.net",
"apic1.fabric2.somewhere.net",
...
]
I can step through that list and login to each APIC and get the list of APICs in that fabric's controller cluster. By comparing cluster members, I can then figure out which APICs belong to which fabric.
What I can't seem to find is an API call to tell me what the serial number is of the APIC I am currently connected to.
I am using Javascript, so I cannot lookup hostnames or IP addresses. The hostname doesn't necessarily match the name given to the APIC in MIT, so I can't assume that, either.
Anyone got any ideas?
05-10-2022 07:58 PM
Hi
If you know on which node id you are, you can execute a GET on the url https://x.x.x.x/api/node/mo/topology/pod-1/node-1.json
This will give you the serial number:
"fabricNode": { "attributes": { "adSt": "on", "address": "x.x.x.x", "annotation": "", "apicType": "apic", "childAction": "", "delayedHeartbeat": "no", "dn": "topology/pod-1/node-1", "extMngdBy": "", "fabricSt": "unknown", "id": "1", "lastStateModTs": "1969-12-31T19:00:00.000-05:00", "lcOwn": "local", "modTs": "2022-01-11T17:17:06.723-05:00", "model": "APIC-SERVER-L3", "monPolDn": "uni/fabric/monfab-default", "name": "TEST", "nameAlias": "", "nodeType": "unspecified", "role": "controller", "serial": "XXXXXXXXXXXX", "status": "", "uid": "0", "userdom": "all", "vendor": "Cisco Systems, Inc", "version": "5.2(3g)"
Hope this answers your question
05-11-2022 04:47 AM - edited 05-11-2022 05:03 AM
Ah, so there's the rub! I have no way of knowing which APIC in the cluster (and therefore the node ID) I am connected to. That's why I am looking for some API call to essentially ask, "Hey you that is servicing this API call: what's your node ID/Serial number/IP?"
05-11-2022 11:28 AM
Never tested this because you usually send API requests to the primary node so not sure if there's whoami api call.
When you said to know which one you're on, you're accessing it through an API call so you have the hostname or IP in the url right?
Or are you connecting through other method?
05-11-2022 11:38 AM - edited 05-11-2022 01:28 PM
API requests can be sent to any node in the cluster. As I said in the first post, I only have a list of APIC fully qualified domain names to iterate through. There is no guarantee that those FQDNs match the APIC nodes' node names. And since I am using Javascript, there is no way for me to programmatically do a DNS lookup to find the IP addresses associated with the FQDNs.
05-11-2022 12:48 PM
Hi @bmckibben
I am just curious, why do you need the SN of the specific APIC you send API calls to? In the end, regardless of which one you are connected to the APIs will return the same info.
And since you only want to get the SNs of the APICs part of the same cluster, you can do that from any APIC from the cluster.
I hope I expressed my thoughts in an understandable way. ^_^
Stay safe,
Sergiu
05-11-2022 01:23 PM - edited 05-11-2022 01:29 PM
I can build a picture of each "cluster as seen by node" as I iterate through the list of APIC FQDNs. However, it would be easier/faster to follow this logic:
// apicList = [ that list of APICs in the first post ]
// clusterList = []
// for each APIC in apicList
// Login to APIC
// If clusterList.length > 0
// Get this APIC's S/N
// if clusterList doesn't yet contain that S/N
// Get the cluster-as-seen-by-node of the current APIC
// Add that cluster to the clusterList
// else
// Get the cluster-as-seen-by-node of the current APIC
// Add that cluster to the clusterList
That's why I want to know how to identify which node I am connected to when I send an API call. I guess I assumed something like this would be easy....
05-11-2022 02:48 PM
In your pseudocode I see one flaw - the following section will never be executed simply because you will always get the clusterList with all APICs at the first iteration (the else statement):
// if clusterList doesn't yet contain that S/N // Get the cluster-as-seen-by-node of the current APIC // Add that cluster to the clusterList
Cheers,
Sergiu
05-11-2022 02:52 PM
The "fabric1" versus "fabric2" implies that the "cluster-as-seen-by-node" values will be different for the two fabrics. So the logic will work.
05-11-2022 10:22 PM
I am a bit confused. You want to have a list with all SNs or a list of SNs per cluster?
04-11-2025 01:01 AM
ACI have a JSON list of APIC FQDNs: [ "apic1.fabric1.test.net", "apic2.fabric1.test.net", "apic3.fabric1.test.net", "apic1.fabric2.test.net", ... ] I can step through that list and login to each APIC and get the list of APICs in that fabric's controller cluster. By comparing cluster members, I can then figure out which APICs belong to which fabric. What I can't seem to find is an API call to tell me what the serial number is of the APIC I am currently connected to. Anyone got any ideas?
04-16-2025 01:01 AM
I can capture that via ansible
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