I'm converting over some automation apps from perl to node. I've run into
what I'm sure is me making incorrect assumptions.
I have the following function. I load up a json config file that defines
a list of clusters and nodes (F5 ha pairs), then go out and query the
restapi on each nodes in a cluster to detemine their state.
The problem I'm having is the rest call seems to only happen for the last
item in the list.
Here's my rest config:
var client = require('node-rest-client').Client;
client = new client(options_auth);
function getActive() {
var clusters = require('../etc/clusters.json')
for (var cluster in clusters) {
console.log(cluster+':')
clusterlist += " "+cluster;
for (var index in clusters[cluster]) {
for (var node in clusters[cluster][index]) {
client.get("https://"+clusters[cluster][index][node]+"/mgmt/tm/cm/device",
function(data, response){
state = data["items"][1]["failoverState"];
console.log(state);
});
console.log("\t"+node.yellow+':
'+clusters[cluster][index][node].magenta+" state: "+state);
}
}
}
}
The client.get seems to happen asychronously, and after some debugging only
occurs to the against the last node in the list (I presently have 4 nodes
defined in the clusters.json).
I'm sure I'm doing this horribly wrong.
--
Job board: http://jobs.nodejs.org/
New group rules:
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/nodejs/249730c6-fdb6-401a-ada9-c8e77acf7d29%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.