def get_networks(self): """Get the networks assoiated with the resource description. Returns list of tuple roles, network """ networks = self.c_resources["networks"] result = [] for net in networks: _c_network = net.get("_c_network") if _c_network is None: continue roles = utils.get_roles_as_list(net) result.append((roles, _c_network)) return result
def get_roles(self): """Get the roles associated with the hosts. Returns dict of role -> [host] """ machines = self.c_resources["machines"] result = {} for desc in machines: roles = utils.get_roles_as_list(desc) hosts = self._denormalize(desc) for role in roles: result.setdefault(role, []) result[role].extend(hosts) return result