dnf facts¶
- class reemote.facts.dnf.get_packages.Get_packages[source]¶
Bases:
objectGets a list of installed DNF packages from a remote server.
This reemote operation executes dnf list installed on the target host to retrieve a list of all installed packages. It then parses the command’s output into a structured list of dictionaries.
The final result is stored in the stdout attribute of the completed process object returned by the operation.
- Returns:
- A list of dictionaries, where each dictionary
represents a package and contains ‘name’ and ‘version’ keys.
- Return type:
list[dict]
Examples
# To be used within a reemote execution plan. The parsed # list will be in the `stdout` of the result. result = yield Get_packages() packages = result.stdout
- reemote.facts.dnf.get_packages.parse_dnf_list_installed(output)[source]¶
Parses the output of the ‘dnf list installed’ command.
This function processes the raw string output from dnf list installed and converts it into a structured list of packages. It is designed to handle the specific format of the DNF command’s output.
Key transformations include:
Skipping the header lines (e.g., “Installed Packages”).
Correctly parsing lines where package names may contain spaces.
Identifying the package name and version by working backward from the repository field, which is expected to start with an ‘@’ symbol.
- Parameters:
output (str) – The raw string stdout from a dnf list installed command.
- Returns:
- A list of dictionaries, where each dictionary represents
an installed package and contains ‘name’ and ‘version’ keys.
- Return type:
list[dict]