Skip to content

Commit 374ffde

Browse files
feature: multiple storage devices (#170)
Implemented changes to INFO response visualization and to DiskWriter node to accommodate for the multiple storage devices change to Synapse API.
1 parent 0851833 commit 374ffde

3 files changed

Lines changed: 22 additions & 14 deletions

File tree

synapse/cli/device_info_display.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,22 @@ def visualize_peripherals(info_dict):
9191
tree.add("No peripherals found")
9292
return tree
9393

94+
def visualize_storage_devices(status):
95+
tree = Tree("Storage Devices")
96+
storage_devices = status.get("storage", {}).get("storage_devices", [])
97+
if storage_devices:
98+
for storage_device in storage_devices:
99+
storage_devices_tree = tree.add(
100+
f"{storage_device.get('name', 'Unknown')}"
101+
)
102+
total = float(storage_device.get("total_gb", 0))
103+
used = float(storage_device.get("used_gb", 0))
104+
used_percent = (used / total * 100) if total > 0 else 0
105+
storage_devices_tree.add(f"ID: {storage_device.get('storage_device_id', 'Unknown')}")
106+
storage_devices_tree.add(f"Storage: {used_percent:.1f}% used ({used:.1f}GB / {total:.1f}GB)")
107+
else:
108+
tree.add("No storage devices found")
109+
return tree
94110

95111
class DeviceInfoDisplay:
96112
"""A class for displaying device information."""
@@ -135,15 +151,6 @@ def summary(self, device: Device):
135151
battery = status["power"].get("battery_level_percent", "N/A")
136152
self.console.print(f"Battery: {battery}%", highlight=False)
137153

138-
if "storage" in status:
139-
storage = status["storage"]
140-
total = float(storage.get("total_gb", 0))
141-
used = float(storage.get("used_gb", 0))
142-
used_percent = (used / total * 100) if total > 0 else 0
143-
self.console.print(
144-
f"Storage: {used_percent:.1f}% used ({used:.1f}GB / {total:.1f}GB)",
145-
highlight=False,
146-
)
147-
154+
self.console.print(visualize_storage_devices(status))
148155
self.console.print(visualize_peripherals(info_dict))
149156
self.console.print(visualize_configuration(info_dict, status))

synapse/client/nodes/disk_writer.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66
class DiskWriter(Node):
77
type = NodeType.kDiskWriter
88

9-
def __init__(self, filename: str):
9+
def __init__(self, filename: str, storage_device_id: int):
1010
self.filename = filename
11+
self.storage_device_id = storage_device_id
1112

1213
def _to_proto(self):
1314
n = NodeConfig()
14-
p = DiskWriterConfig(filename=self.filename)
15+
p = DiskWriterConfig(filename=self.filename, storage_device_id=self.storage_device_id)
1516
n.disk_writer.CopyFrom(p)
1617
return n
1718

@@ -22,4 +23,4 @@ def _from_proto(proto: DiskWriterConfig):
2223
if not isinstance(proto, DiskWriterConfig):
2324
raise ValueError("proto is not of type DiskWriterConfig")
2425

25-
return DiskWriter(filename=proto.filename)
26+
return DiskWriter(filename=proto.filename, storage_device_id=proto.storage_device_id)

0 commit comments

Comments
 (0)