From 9bceee55c8c1aa04b545b878e5e7c8187f2fdc11 Mon Sep 17 00:00:00 2001 From: Edin Sarajlic Date: Thu, 19 Sep 2019 12:17:55 +1000 Subject: [PATCH] Add function that returns a map of unit names -> hostnames --- zaza/openstack/utilities/generic.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/zaza/openstack/utilities/generic.py b/zaza/openstack/utilities/generic.py index 7eb175c..b2f7354 100644 --- a/zaza/openstack/utilities/generic.py +++ b/zaza/openstack/utilities/generic.py @@ -75,6 +75,16 @@ def get_network_config(net_topology, ignore_env_vars=False, return net_info +def get_unit_hostnames(units): + """Return a dict of juju unit names to hostnames.""" + host_names = {} + for unit in units: + output = model.run_on_unit(unit.entity_id, 'hostname') + hostname = output['Stdout'].strip() + host_names[unit.entity_id] = hostname + return host_names + + def get_pkg_version(application, pkg): """Return package version.