Updated OTP Generate with new workflow

This commit is contained in:
2025-11-07 09:56:45 -05:00
parent 9dfdf8b9ee
commit 8a9b04cb7c
6 changed files with 524 additions and 50 deletions
+21 -14
View File
@@ -49,26 +49,26 @@ class PolicyTreeWidget(Widget):
node_map = {}
# Top-level policies
for _, policy in self.policies.iterrows():
if policy["parent"] == "global-policy-settings":
node = policy_tree.root.add(label=policy["name"], data=policy.to_dict())
node_map[policy["groupid"]] = node
for policy in self.policies:
if policy.parent == "global-policy-settings":
node = policy_tree.root.add(label=policy.name, data=policy)
node_map[policy.groupid] = node
# Child policies
for _, policy in self.policies.iterrows():
parent_id = policy["parent"]
for policy in self.policies:
parent_id = policy.parent
if parent_id in node_map:
parent_node = node_map[parent_id]
node = parent_node.add(label=policy["name"], data=policy.to_dict())
node_map[policy["groupid"]] = node
node = parent_node.add(label=policy.name, data=policy)
node_map[policy.groupid] = node
# Devices under policies
for _, device in self.devices.iterrows():
group_id = device["groupid"]
for device in self.devices:
group_id = device.groupid
if group_id in node_map:
parent_node = node_map[group_id]
label = device["hostname"]
parent_node.add(label=label, data=device.to_dict())
label = device.hostname
parent_node.add(label=label, data=device)
def _collect_tree_nodes(self, node, all_nodes):
"""Helper to recursively collect all nodes from a tree."""
@@ -110,7 +110,10 @@ class PolicyTreeWidget(Widget):
# Update details pane
if data:
details = "\n".join(f"{key}: {value}" for key, value in data.items())
# Work with dataclass objects using __dict__
details = "\n".join(
f"{key}: {value}" for key, value in data.__dict__.items()
)
else:
details = f"Selected: {node.label}"
details_pane.update(details)
@@ -135,7 +138,11 @@ class PolicyTreeWidget(Widget):
label_text = str(node.label).lower()
label_to_node[label_text] = node
if node.data:
for key, value in node.data.items():
# Use __dict__ for dataclass objects
data_dict = (
node.data.__dict__ if hasattr(node.data, "__dict__") else node.data
)
for key, value in data_dict.items():
if isinstance(value, str):
label_to_node[value.lower()] = node