mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +00:00
Adding introspection for package groups (in yum)
This commit is contained in:
parent
a5cf3210b5
commit
d3ddc67a6e
@ -582,6 +582,48 @@ def groupinfo(groupname):
|
||||
'description': group.description}
|
||||
|
||||
|
||||
def group_detail(groupname):
|
||||
'''
|
||||
Lists packages belonging to a certain group, and which are installed
|
||||
|
||||
CLI Example::
|
||||
|
||||
salt '*' pkg.group_detail 'Perl Support'
|
||||
'''
|
||||
ret = {
|
||||
'mandatory packages': {'installed': [], 'not installed': []},
|
||||
'optional packages': {'installed': [], 'not installed': []},
|
||||
'default packages': {'installed': [], 'not installed': []},
|
||||
'conditional packages': {'installed': [], 'not installed': []},
|
||||
}
|
||||
pkgs = list_pkgs()
|
||||
yumbase = yum.YumBase()
|
||||
(installed, available) = yumbase.doGroupLists()
|
||||
for group in installed:
|
||||
if group.name == groupname:
|
||||
for pkg in group.mandatory_packages:
|
||||
if pkg in pkgs:
|
||||
ret['mandatory packages']['installed'].append(pkg)
|
||||
else:
|
||||
ret['mandatory packages']['not installed'].append(pkg)
|
||||
for pkg in group.optional_packages:
|
||||
if pkg in pkgs:
|
||||
ret['optional packages']['installed'].append(pkg)
|
||||
else:
|
||||
ret['optional packages']['not installed'].append(pkg)
|
||||
for pkg in group.default_packages:
|
||||
if pkg in pkgs:
|
||||
ret['default packages']['installed'].append(pkg)
|
||||
else:
|
||||
ret['default packages']['not installed'].append(pkg)
|
||||
for pkg in group.conditional_packages:
|
||||
if pkg in pkgs:
|
||||
ret['conditional packages']['installed'].append(pkg)
|
||||
else:
|
||||
ret['conditional packages']['not installed'].append(pkg)
|
||||
return ret
|
||||
|
||||
|
||||
def list_repos(basedir='/etc/yum.repos.d'):
|
||||
'''
|
||||
Lists all repos in <basedir> (default: /etc/yum.repos.d/).
|
||||
|
Loading…
Reference in New Issue
Block a user