def _translate_host_macros(self, cmd: str) -> str: attrs = core_config.get_host_attributes(self.hostname, self._config_cache) if self._host_config.is_cluster: parents_list = core_config.get_cluster_nodes_for_config(self._config_cache, self._host_config) attrs.setdefault("alias", "cluster of %s" % ", ".join(parents_list)) attrs.update( core_config.get_cluster_attributes(self._config_cache, self._host_config, parents_list)) macros = core_config.get_host_macros_from_attributes(self.hostname, attrs) return ensure_str(core_config.replace_macros(cmd, macros))
def _translate_host_macros(cmd: str, host_config: config.HostConfig) -> str: config_cache = config.get_config_cache() attrs = core_config.get_host_attributes(host_config.hostname, config_cache) if host_config.is_cluster: parents_list = core_config.get_cluster_nodes_for_config( config_cache, host_config, ) attrs.setdefault("alias", "cluster of %s" % ", ".join(parents_list)) attrs.update( core_config.get_cluster_attributes( config_cache, host_config, parents_list, )) macros = core_config.get_host_macros_from_attributes(host_config.hostname, attrs) return ensure_str(core_config.replace_macros(cmd, macros))