User and Group
Module for processing the user
and group
of Linux.
Parsers provided by this module include:
GroupInfo - command getent group <groupname>
- class insights.parsers.user_group.GroupInfo(context, extra_bad_lines=None)[source]
Bases:
CommandParser
,list
Class to parse the output of
getent group <groupname>
. The list of groupname is getting from the spec filters specified in rules.Typical output of the
getent group <groupname>
command is:wheel:x:10:admin,tester mem:x:8:
Examples:
>>> type(grp) <class 'insights.parsers.user_group.GroupInfo'> >>> grp[0]['id'] 10 >>> grp[0]['name'] 'wheel' >>> grp[0]['users'] ['admin', 'tester']
- search(**kwargs)[source]
Get the sub-list containing the keywords by searching the output of
getent group <groupname>
This uses the
insights.parsers.keyword_search()
function for searching, see its documentation for usage details. If no search parameters are given or does match the search, then nothing will be returned.- Returns:
- A list of dictionaries of the
getent group <groupname>
content that match the given search criteria.
- A list of dictionaries of the
- Return type:
list
Examples:
>>> grp.search(name='mem')[0] == grp[1] True >>> grp.search(users__contains='admin')[0] == grp[0] True