import json


def get_host_daemon_map(cls):
    """
    Method to get the daemons deployed in each of the hosts
    Args:
        cls: cephadm instance object

    Returns:
        Dictionary with host names as keys and names of the daemons deployed as value list
    """
    out, _ = cls.shell(args=["ceph", "orch", "ps", "-f", "json"])
    daemon_obj = json.loads(out)
    daemon_dict = dict()
    for daemon in daemon_obj:
        daemon_name = daemon["daemon_type"] + "." + daemon["daemon_id"]
        if daemon["hostname"] in daemon_dict.keys():
            daemon_dict[daemon["hostname"]].append(daemon_name)
        else:
            daemon_dict[daemon["hostname"]] = [daemon_name]
    return daemon_dict