MCPcopy Create free account
hub / github.com/saltstack/salt / get_selections

Function get_selections

salt/modules/aptpkg.py:2964–2998  ·  view source on GitHub ↗

View package state from the dpkg database. Returns a dict of dicts containing the state, and package names: .. code-block:: python {' ': {' ': ['pkg1', ... ] }, ... }

(pattern=None, state=None)

Source from the content-addressed store, hash-verified

2962
2963
2964def get_selections(pattern=None, state=None):
2965 """
2966 View package state from the dpkg database.
2967
2968 Returns a dict of dicts containing the state, and package names:
2969
2970 .. code-block:: python
2971
2972 {'<host>':
2973 {'<state>': ['pkg1',
2974 ...
2975 ]
2976 },
2977 ...
2978 }
2979
2980 CLI Example:
2981
2982 .. code-block:: bash
2983
2984 salt '*' pkg.get_selections
2985 salt '*' pkg.get_selections 'python-*'
2986 salt '*' pkg.get_selections state=hold
2987 salt '*' pkg.get_selections 'openssh*' state=hold
2988 """
2989 ret = {}
2990 cmd = ["dpkg", "--get-selections"]
2991 cmd.append(pattern if pattern else "*")
2992 stdout = __salt__["cmd.run_stdout"](
2993 cmd, output_loglevel="trace", python_shell=False
2994 )
2995 ret = _parse_selections(stdout)
2996 if state:
2997 return {state: ret.get(state, [])}
2998 return ret
2999
3000
3001# TODO: allow state=None to be set, and that *args will be set to that state

Callers 4

installFunction · 0.70
holdFunction · 0.70
unholdFunction · 0.70
set_selectionsFunction · 0.70

Calls 3

_parse_selectionsFunction · 0.85
appendMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected