code: def get_host_map(root):
    ''' Gets a mapping between CM hostId and Nagios host information
  
        The key is the CM hostId
        The value is an object containing the Nagios hostname and host address
    '''
    hosts_map = {}
    for host in root.get_all_hosts():
      hosts_map[host.hostId] = {"hostname": NAGIOS_HOSTNAME_FORMAT % (host.hostname,),
                                "address": host.ipAddress}
  
    ''' Also define "virtual hosts" for the CM clusters- they will be the hosts
        to which CM services are mapped
    '''
    for cluster in root.get_all_clusters():
      hosts_map[cluster.name] = {"hostname": cluster.name,
                                 "address": quote(cluster.name)}
    hosts_map[CM_DUMMY_HOST] = {"hostname": CM_DUMMY_HOST,
                                "address": CM_DUMMY_HOST}
    return hosts_maf get_host_map(root):
    ''' Gets a mapping between CM hostId and Nagios host information
  
        The key is the CM hostId
        The value is an object containing the Nagios hostname and host address
    '''
    hosts_map = {}
    for host in root.get_all_hosts():
      hosts_map[host.hostId] = {"hostname": NAGIOS_HOSTNAME_FORMAT % (host.hostname,),
                                "address": host.ipAddress}
  
    ''' Also define "virtual hosts" for the CM clusters- they will be the hosts
        to which CM services are mapped
    '''
    for cluster in root.get_all_clusters():
      hosts_map[cluster.name] = {"hostname": cluster.name,
                                 "address": quote(cluster.name)}
    hosts_map[CM_DUMMY_HOST] = {"hostname": CM_DUMMY_HOST,
                                "address": CM_DUMMY_HOST}
    return hosts_map
docs: Gets a mapping between CM hostId and Nagios host information
  
        The key is the CM hostId
        The value is an object containing the Nagios hostname and host address