List groups

    CLI Example:

    .. code-block:: bash

        salt '*' keystoneng.group_list
        salt '*' keystoneng.group_list domain_id=b62e76fbeeff4e8fb77073f591cf211e
421735
def group_list(auth=None, **kwargs):
    '''
    
    '''
    cloud = get_operator_cloud(auth)
    kwargs = _clean_kwargs(**kwargs)
    return cloud.list_groups(**kwargs)
1316706
def build_command_groups(self, block):
        
        text = block['text']

        commands = sorted(self.build_commands(block))
        grouped = groupby(commands, Command.key)
        listed = list(groupby(commands, Command.key))
        sliced = []

        i = 0
        for start_index, commands in grouped:
            if i < len(listed) - 1:
                stop_index = listed[i + 1][0]
                sliced.append((text[start_index:stop_index], list(commands)))
            else:
                sliced.append((text[start_index:start_index], list(commands)))
            i += 1

        return sliced
1192806
def GetAll(root_group_id,alias=None,session=None):
		
		if not alias:  alias = clc.v2.Account.GetAlias(session=session)

		groups = []
		for r in clc.v2.API.Call('GET','groups/%s/%s' % (alias,root_group_id),{}, session=session)['groups']:
			groups.append(Group(id=r['id'],alias=alias,group_obj=r,session=session))

		return(groups)
123385
def list_groups(self, **kwargs):
        
        response = self._do_request('GET', '/v2/groups')
        groups = self._parse_response(
            response, MarathonGroup, is_list=True, resource_name='groups')
        for k, v in kwargs.items():
            groups = [o for o in groups if getattr(o, k) == v]
        return groups
1296556
def xgroup_setid(self, name, groupname, id):
        
        return self.execute_command('XGROUP SETID', name, groupname, id)
331113
def list_security_groups(call=None):
    '''
    
    '''
    if call == 'action':
        raise SaltCloudSystemExit(
            'The list_security_groups function must be called with -f or --function.'
        )

    server, user, password = _get_xml_rpc()
    auth = ':'.join([user, password])
    secgroup_pool = server.one.secgrouppool.info(auth, -2, -1, -1)[1]

    groups = {}
    for group in _get_xml(secgroup_pool):
        groups[group.find('NAME').text] = _xml_to_dict(group)

    return groups
98599
def example_list(a, args):
    

    if len(args) == 0:
        what = "all"
    else:
        what = args[0]

    md = a.list_topics(timeout=10)

    print("Cluster {} metadata (response from broker {}):".format(md.cluster_id, md.orig_broker_name))

    if what in ("all", "brokers"):
        print(" {} brokers:".format(len(md.brokers)))
        for b in iter(md.brokers.values()):
            if b.id == md.controller_id:
                print("  {}  (controller)".format(b))
            else:
                print("  {}".format(b))

    if what not in ("all", "topics"):
        return

    print(" {} topics:".format(len(md.topics)))
    for t in iter(md.topics.values()):
        if t.error is not None:
            errstr = ": {}".format(t.error)
        else:
            errstr = ""

        print("  \"{}\" with {} partition(s){}".format(t, len(t.partitions), errstr))

        for p in iter(t.partitions.values()):
            if p.error is not None:
                errstr = ": {}".format(p.error)
            else:
                errstr = ""

            print("    partition {} leader: {}, replicas: {}, isrs: {}".format(
                p.id, p.leader, p.replicas, p.isrs, errstr))
831286
def _parse_group(self, group_name, group):
        
        if type(group) == dict:
            # Example:
            #     {
            #       "mgmt": {
            #         "hosts": [ "mgmt01", "mgmt02" ],
            #         "vars": {
            #           "eth0": {
            #             "onboot": "yes",
            #             "nm_controlled": "no"
            #           }
            #         }
            #       }
            #     }
            #
            hostnames_in_group = set()

            # Group member with hosts and variable definitions.
            for hostname in group.get('hosts', []):
                self._get_host(hostname)['groups'].add(group_name)
                hostnames_in_group.add(hostname)
            # Apply variables to all hosts in group
            for var_key, var_val in group.get('vars', {}).items():
                for hostname in hostnames_in_group:
                    self._get_host(hostname)['hostvars'][var_key] = var_val
        elif type(group) == list:
            # List of hostnames for this group
            for hostname in group:
                self._get_host(hostname)['groups'].add(group_name)
        else:
            self.log.warning("Invalid element found in dynamic inventory output: {0}".format(type(group)))
475306
def group(self, *args, **kwargs):
        
        def decorator(f):
            cmd = group(*args, **kwargs)(f)
            self.add_command(cmd)
            return cmd
        return decorator
1117522
def list_by_instance(self, instance_id):
        
        ports = port_list(self.request, device_id=instance_id)
        sg_ids = []
        for p in ports:
            sg_ids += p.security_groups
        return self._list(id=set(sg_ids)) if sg_ids else []
445439
def group2commdct(commdct, glist):
    """"""
    for (gname, objname), commitem in zip(glist, commdct):
        commitem[0]['group'] = gname
        commitem[0]['idfobj'] = objname
    return commdct
62053
def commandline_to_list(self, cmdline_str, trigger_string):
        '''
        
        '''
        cmdline = salt.utils.args.shlex_split(cmdline_str[len(trigger_string):])
        # Remove slack url parsing
        #  Translate target=<http://host.domain.net|host.domain.net>
        #  to target=host.domain.net
        cmdlist = []
        for cmditem in cmdline:
            pattern = r'(?P<begin>.*)(<.*\|)(?P<url>.*)(>)(?P<remainder>.*)'
            mtch = re.match(pattern, cmditem)
            if mtch:
                origtext = mtch.group('begin') + mtch.group('url') + mtch.group('remainder')
                cmdlist.append(origtext)
            else:
                cmdlist.append(cmditem)
        return cmdlist
17456
def list_subnets(call=None, kwargs=None):
    '''
    
    '''
    if kwargs is None:
        kwargs = {}

    if call == 'action':
        raise SaltCloudSystemExit(
            'The avail_sizes function must be called with '
            '-f or --function'
        )

    netconn = get_conn(client_type='network')

    resource_group = kwargs.get('resource_group') or config.get_cloud_config_value(
                         'resource_group',
                         get_configured_provider(), __opts__, search_global=False
                     )

    if not resource_group and 'group' in kwargs and 'resource_group' not in kwargs:
        resource_group = kwargs['group']

    if not resource_group:
        raise SaltCloudSystemExit(
            'A resource group must be specified'
        )

    if kwargs.get('network') is None:
        kwargs['network'] = config.get_cloud_config_value(
            'network', get_configured_provider(), __opts__, search_global=False
        )

    if 'network' not in kwargs or kwargs['network'] is None:
        raise SaltCloudSystemExit(
            'A "network" must be specified'
        )

    ret = {}
    subnets = netconn.subnets.list(resource_group, kwargs['network'])
    for subnet in subnets:
        ret[subnet.name] = subnet.as_dict()
        ret[subnet.name]['ip_configurations'] = {}
        for ip_ in subnet.ip_configurations:
            comps = ip_.id.split('/')
            name = comps[-1]
            ret[subnet.name]['ip_configurations'][name] = ip_.as_dict()
            ret[subnet.name]['ip_configurations'][name]['subnet'] = subnet.name
        ret[subnet.name]['resource_group'] = resource_group
    return ret
821981
def get_group_list(user, include_default=True):
    '''
    
    '''
    if HAS_GRP is False or HAS_PWD is False:
        return []
    group_names = None
    ugroups = set()
    if hasattr(os, 'getgrouplist'):
        # Try os.getgrouplist, available in python >= 3.3
        log.trace('Trying os.getgrouplist for \'%s\'', user)
        try:
            group_names = [
                grp.getgrgid(grpid).gr_name for grpid in
                os.getgrouplist(user, pwd.getpwnam(user).pw_gid)
            ]
        except Exception:
            pass
    elif HAS_PYSSS:
        # Try pysss.getgrouplist
        log.trace('Trying pysss.getgrouplist for \'%s\'', user)
        try:
            group_names = list(pysss.getgrouplist(user))
        except Exception:
            pass

    if group_names is None:
        # Fall back to generic code
        # Include the user's default group to match behavior of
        # os.getgrouplist() and pysss.getgrouplist()
        log.trace('Trying generic group list for \'%s\'', user)
        group_names = [g.gr_name for g in grp.getgrall() if user in g.gr_mem]
        try:
            default_group = get_default_group(user)
            if default_group not in group_names:
                group_names.append(default_group)
        except KeyError:
            # If for some reason the user does not have a default group
            pass

    if group_names is not None:
        ugroups.update(group_names)

    if include_default is False:
        # Historically, saltstack code for getting group lists did not
        # include the default group. Some things may only want
        # supplemental groups, so include_default=False omits the users
        # default group.
        try:
            default_group = grp.getgrgid(pwd.getpwnam(user).pw_gid).gr_name
            ugroups.remove(default_group)
        except KeyError:
            # If for some reason the user does not have a default group
            pass
    log.trace('Group list for user \'%s\': %s', user, sorted(ugroups))
    return sorted(ugroups)
967665
def convert_to_group_ids(groups, vpc_id=None, vpc_name=None, region=None, key=None,
                         keyid=None, profile=None):
    '''
    
    '''
    log.debug('security group contents %s pre-conversion', groups)
    group_ids = []
    for group in groups:
        group_id = get_group_id(name=group, vpc_id=vpc_id,
                                vpc_name=vpc_name, region=region,
                                key=key, keyid=keyid, profile=profile)
        if not group_id:
            # Security groups are a big deal - need to fail if any can't be resolved...
            raise CommandExecutionError('Could not resolve Security Group name '
                                        '{0} to a Group ID'.format(group))
        else:
            group_ids.append(six.text_type(group_id))
    log.debug('security group contents %s post-conversion', group_ids)
    return group_ids
867167
def list_domains(container_id=None):
    '''
    
    '''
    if container_id:
        url = '{0}/domain?{1}'.format(_base_url(), container_id)
    else:
        url = '{0}/domain'.format(_base_url())

    orgs = _paginate(url,
                     "domains",
                     method='GET',
                     decode=True,
                     decode_type='json',
                     header_dict={
                         'X-DC-DEVKEY': _api_key(),
                         'Content-Type': 'application/json',
                     }
    )

    ret = {'domains': orgs}
    return ret
627584
def list_affinity_groups(kwargs=None, conn=None, call=None):
    '''
    
    '''
    if call != 'function':
        raise SaltCloudSystemExit(
            'The list_affinity_groups function must be called with -f or --function.'
        )

    if not conn:
        conn = get_conn()

    data = conn.list_affinity_groups()
    ret = {}
    for item in data.affinity_groups:
        ret[item.name] = object_to_dict(item)
    return ret