Get the roles associated with the hosts.

        Returns
            dict of role -> [host]
173962
def get_roles(self):
        

        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
657760
def get_accessibles(request, roles=None):
        
        results = []
        for role_name, organizations in six.iteritems(request.session.get(
                'roles', {})):
            if roles is None or role_name in roles:
                results += organizations
        return results
829170
def connection(self):
        
        return {'host': self.host, 'namespace': self.namespace, 'username': self.username, 'password': self.password}
1094816
def get_user_roles(user):
    """"""
    if user:
        groups = user.groups.all()   # Important! all() query may be cached on User with prefetch_related.
        roles = (RolesManager.retrieve_role(group.name) for group in groups if group.name in RolesManager.get_roles_names())
        return sorted(roles, key=lambda r: r.get_name() )
    else:
        return []
870258
def get_dict(self):
        
        return {'hostname': self.get_name(),
                'address':  self.get_address(),
                'protocol': self.get_protocol(),
                'port':     self.get_tcp_port()}
120898
def hosts(self, **kwargs):
        
        kwargs['channelID'] = self.id
        return self.connection.listHosts(**kwargs)
64995
def _get_roles(self, username):
        
        groups = self._get_groups(username)
        user_roles = self.roles.get_roles(groups)
        cherrypy.log.error(
            msg="user '" + username + "' roles: " + str(user_roles),
            severity=logging.DEBUG,
        )
        return user_roles
913359
def get_all_role_config_groups(self):
    
    return role_config_groups.get_all_role_config_groups(
        self._get_resource_root(), self.name, self._get_cluster_name())
1298788
def get_role(resource_root, service_name, name, cluster_name="default"):
  
  return _get_role(resource_root, _get_role_path(cluster_name, service_name, name))
742343
def local_bind_hosts(self):
        
        self._check_is_started()
        return [_server.local_host for _server in self._server_list if
                _server.local_host is not None]
965654
def get_host(self, host):
        '''  '''

        if len(self.index) == 0:
            # Need to load index from cache
            self.load_index_from_cache()

        if not host in self.index:
            # try updating the cache
            self.do_api_calls_update_cache()
            if not host in self.index:
                # host might not exist anymore
                return {}

        (region, instance_id) = self.index[host]

        instance = self.get_instance(region, instance_id)
        return self.get_host_info_dict_from_instance(instance)
486819
def for_host(parent, host):
        
        account = AccountProxy(parent)
        account.host = host
        if account.acquire():
            return account
        return None
781027
def peers(self):
        

        resp = self.call('peers')

        result = {}
        peers = resp.get('peers') or {}

        for host, version in peers.items():
            result[host] = int(version)

        return result
1291114
def _get_role_arn():
    
    role_arn = bottle.request.headers.get('X-Role-ARN')
    if not role_arn:
        role_arn = _lookup_ip_role_arn(bottle.request.environ.get('REMOTE_ADDR'))
    if not role_arn:
        role_arn = _role_arn
    return role_arn
833296
def list_roles(self):
        """"""

        json_resp = self.get_roles()
        temp_dict = {}
        for item in json_resp:
            temp_dict[item["name"]] = item["id"]
        return temp_dict
886830
def _get_hosts(self, host):
        
        try:
            return shlex.split(host)
        except ValueError:
            raise Exception("Unparsable host {}".format(host))
1263816
def children_of_group(self, group: Union[str, Group]) -> Set[Host]:
        
        hosts: List[Host] = set()
        for host in self.hosts.values():
            if host.has_parent_group(group):
                hosts.add(host)
        return hosts