mirror of
https://github.com/DaanSelen/meshbook.git
synced 2026-02-20 08:22:11 +00:00
Added OS filtering doc and supported (1 level deep) nested definition.
This commit is contained in:
65
docs/operating_system_filtering.md
Normal file
65
docs/operating_system_filtering.md
Normal file
@@ -0,0 +1,65 @@
|
||||
# **Understanding the OS Filtering Mechanism**
|
||||
|
||||
## **Overview**
|
||||
This function filters devices based on their **reachability** and an optional **OS category filter**. It supports:
|
||||
|
||||
- **Broad OS categories** (e.g., `"Linux"` includes all OS versions under `"Linux"`)
|
||||
- **Specific OS categories** (e.g., `"Debian"` only includes OS versions under `"Linux" -> "Debian"`)
|
||||
- **Single category selection** (Only `target_os="Linux"` OR `target_os="Debian"` is used, never both at once)
|
||||
|
||||
---
|
||||
|
||||
## **How It Works (Simplified)**
|
||||
|
||||
### **1. OS Category Expansion**
|
||||
The function first expands the `target_os` category by retrieving all valid OS names under it.
|
||||
|
||||
#### **Example OS Category Structure:**
|
||||
```json
|
||||
{
|
||||
"Linux": {
|
||||
"Debian": [
|
||||
"Debian GNU/Linux 12 (bookworm)",
|
||||
"Debian GNU/Linux 11 (bullseye)"
|
||||
],
|
||||
"Ubuntu": [
|
||||
"Ubuntu 24.04.1 LTS"
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### **Expanding Different `target_os` Values:**
|
||||
|
||||
| `target_os` | Expanded OS Versions |
|
||||
|--------------|---------------------------------------------------|
|
||||
| `"Linux"` | `{ "Debian GNU/Linux 12 (bookworm)", "Debian GNU/Linux 11 (bullseye)", "Ubuntu 24.04.1 LTS" }` |
|
||||
| `"Debian"` | `{ "Debian GNU/Linux 12 (bookworm)", "Debian GNU/Linux 11 (bullseye)" }` |
|
||||
|
||||
---
|
||||
|
||||
### **2. Device Filtering**
|
||||
Once the function has the allowed OS versions, it checks each device:
|
||||
|
||||
#### **Example Device List:**
|
||||
```json
|
||||
[
|
||||
{"device_id": "A1", "device_os": "Debian GNU/Linux 12 (bookworm)", "reachable": true},
|
||||
{"device_id": "A2", "device_os": "Ubuntu 24.04.1 LTS", "reachable": true},
|
||||
{"device_id": "A3", "device_os": "Windows 11", "reachable": true},
|
||||
{"device_id": "A4", "device_os": "Debian GNU/Linux 11 (bullseye)", "reachable": false}
|
||||
]
|
||||
```
|
||||
|
||||
#### **Filtering Behavior:**
|
||||
| Device ID | Device OS | Reachable | Matches `target_os="Linux"` | Matches `target_os="Debian"` |
|
||||
|-----------|----------------------------------|-----------|-------------------------------|-------------------------------|
|
||||
| A1 | Debian GNU/Linux 12 (bookworm) | ✅ | ✅ | ✅ |
|
||||
| A2 | Ubuntu 24.04.1 LTS | ✅ | ✅ | ❌ |
|
||||
| A3 | Windows 11 | ✅ | ❌ | ❌ |
|
||||
| A4 | Debian GNU/Linux 11 (bullseye) | ❌ | ❌ (Unreachable) | ❌ (Unreachable) |
|
||||
|
||||
#### **Final Output:**
|
||||
- If `target_os="Linux"`: `["A1", "A2"]`
|
||||
- If `target_os="Debian"`: `["A1"]`
|
||||
- If `target_os=None`: `["A1", "A2", "A3"]` or `target_os` is undefined
|
||||
Reference in New Issue
Block a user