From b7b9fdaea749469fb102a50184f2b41aa0077e16 Mon Sep 17 00:00:00 2001 From: Daan Selen Date: Thu, 13 Feb 2025 12:29:06 +0100 Subject: [PATCH] Added minor changes (documentation) and indentation for readability. Readme correct referencing to new docs directory its file. couple comments and indentations to improve readability. Added a dummy Ubuntu 22 and MacOS categories as an example. --- README.md | 10 +++------- meshbook.py | 2 ++ os_categories.json | 3 +++ 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 5f6d788..42e6b52 100644 --- a/README.md +++ b/README.md @@ -102,14 +102,10 @@ The tasks you want to run should be contained under the `tasks:` with two fields The name field is for the user of meshbook, to clarify what the following command does in a summary.
The command field actually gets executed on the end-point.
-### Granual Operating System control: +### Granual Operating System filtering: -I have made the program so it can have a basic filter with the Operating systems. If you have a mixed group, then you need to match the image below like this: - -MeshCentral Operating System Version
-MeshBook yaml example - -This will filter the nodes/machines in the MeshCentral group to the ones matching this. Very basic and open for feedback. This must match the full string, not case sensitive. +I have made the program so it can have a filter with the Operating systems. If you have a mixed group, please read: +[This explanation](./docs/operating_system_filtering.md) # Example: diff --git a/meshbook.py b/meshbook.py index 3f1bd52..f84a9e7 100644 --- a/meshbook.py +++ b/meshbook.py @@ -101,6 +101,7 @@ async def filter_targets(devices: list[dict], os_categories: dict, target_os: st def get_os_variants(category: str, os_map: dict) -> set: """Extracts all OS names under a given category if it exists.""" + for key, value in os_map.items(): if key == category: if isinstance(value, dict): # Expand nested categories @@ -124,6 +125,7 @@ async def filter_targets(devices: list[dict], os_categories: dict, target_os: st allowed_os = get_os_variants(target_os, os_categories[key]) break # Stop searching once a match is found + # Filter out unreachable devices for device in devices: if not device["reachable"]: continue # Skip unreachable devices. diff --git a/os_categories.json b/os_categories.json index 4eaefe9..9070307 100644 --- a/os_categories.json +++ b/os_categories.json @@ -6,6 +6,9 @@ ], "Ubuntu": [ "Ubuntu 24.04.1 LTS" + ], + "Ubuntu 22": [ + "Ubuntu 22.04.1 LTS" ] }, "MacOS": {