code: def linkify_h_by_realms(self, realms):
          
          default_realm = realms.get_default()
          for host in self:
              if not getattr(host, 'realm', None):
                  # Applying default realm to an host
                  host.realm = default_realm.uuid if default_realm else ''
                  host.realm_name = default_realm.get_name() if default_realm else ''
                  host.got_default_realm = True
  
              if host.realm not in realms:
                  realm = realms.find_by_name(host.realm)
                  if not realm:
                      continue
                  host.realm = realm.uuid
              else:
                  realm = realms[host.realm]
docs: Link hosts with realms
  
          :param realms: realms object to link with
          :type realms: alignak.objects.realm.Realms
          :return: None