- type: javascript
name: resolve_replica_hostnames
script: |
const ips = REPLICA_IP_LIST.stdout.trim().split(/\s+/);
let hostnameList = [];
let pending = ips.length;
if (pending === 0) {
fail("❌ No replica IPs found.");
}
for (const ip of ips) {
const cmd = `nslookup ${ip} | grep "name =" | sed 's/.*name = //g' | sed -r 's/\\.$//'`;
Amelia.host.runCommand(cmd, function(result) {
if (result.code === 0 && result.stdout.trim()) {
hostnameList.push(result.stdout.trim());
} else {
hostnameList.push(`⚠️ lookup_failed_for_${ip}`);
}
pending--;
if (pending === 0) {
const joined = hostnameList.join(" ");
proceed({
message: `🧭 Replica hostnames resolved:\n${joined}`,
REPLICA_LIST: joined
});
}
});
}





0 comments:
Post a Comment