MT#63514 Add sites support to get_all_ips_for_host script

Change-Id: I30cd9f99e1a63f5725aaecf2c084aac175f13543
(cherry picked from commit 04e6f0e567)
(cherry picked from commit 7979e69315)
mr12.5.1
Marco Capetta 5 months ago committed by Guillem Jover
parent 3f5c48250a
commit 5025f3e7af

@ -3,13 +3,18 @@
# Return an array of IPs for a given host.
#
# @param argv.site The site to use, default value: current.
# @param argv.host The host to get all IPs for.
# @param argv.type The interface type or empty string for all types.
# @param argv.status node status [ online, offline, inactive ]
# default value: ['online', 'inactive']
# @return out The array of IPs.
IF !hosts.${argv.host}.defined;
IF !argv.site.length;
argv.site = 'current';
END;
IF !sites.${argv.site}.hosts.${argv.host}.defined;
argv.host = 'self';
END;
@ -31,13 +36,13 @@ FOREACH val IN argv.status;
END;
out = [];
IF status.item(hosts.${argv.host}.status);
FOREACH iface IN hosts.${argv.host}.interfaces;
NEXT UNLESS hosts.${argv.host}.exists(iface);
NEXT UNLESS hosts.${argv.host}.$iface.type.grep('^' _ argv.type _ '$').size();
NEXT UNLESS hosts.${argv.host}.$iface.ip;
IF status.item(sites.${argv.site}.hosts.${argv.host}.status);
FOREACH iface IN sites.${argv.site}.hosts.${argv.host}.interfaces;
NEXT UNLESS sites.${argv.site}.hosts.${argv.host}.exists(iface);
NEXT UNLESS sites.${argv.site}.hosts.${argv.host}.$iface.type.grep('^' _ argv.type _ '$').size();
NEXT UNLESS sites.${argv.site}.hosts.${argv.host}.$iface.ip;
out.push(hosts.${argv.host}.$iface.ip);
out.push(sites.${argv.site}.hosts.${argv.host}.$iface.ip);
END;
END;
out = out.sort;

Loading…
Cancel
Save