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)
| 2962 | |
| 2963 | |
| 2964 | def 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 |
no test coverage detected