Skip to content

Commit 6d8ae4a

Browse files
committed
core-cli: add geo position to node output for query session and node
1 parent 2df8aa4 commit 6d8ae4a

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

daemon/scripts/core-cli

+7-7
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,11 @@ def query_session(core: CoreGrpcClient, args: Namespace) -> None:
212212
print_json(session)
213213
else:
214214
print("Nodes")
215-
print("Node ID | Node Name | Node Type")
215+
print("ID | Name | Type | XY | Geo")
216216
for node in session.nodes.values():
217-
print(f"{node.id:<7} | {node.name:<9} | {node.type.name}")
217+
xy_pos = f"{int(node.position.x)},{int(node.position.y)}"
218+
geo_pos = f"{node.geo.lon:.7f},{node.geo.lat:.7f},{node.geo.alt:f}"
219+
print(f"{node.id:<7} | {node.name[:7]:<7} | {node.type.name[:7]:<7} | {xy_pos:<9} | {geo_pos}")
218220
print("\nLinks")
219221
for link in session.links:
220222
n1 = session.nodes[link.node1_id].name
@@ -243,12 +245,10 @@ def query_node(core: CoreGrpcClient, args: Namespace) -> None:
243245
ifaces = [protobuf_to_json(x.to_proto()) for x in ifaces]
244246
print_json(dict(node=node, ifaces=ifaces))
245247
else:
246-
print("ID | Name | Type | XY")
248+
print("ID | Name | Type | XY | Geo")
247249
xy_pos = f"{int(node.position.x)},{int(node.position.y)}"
248-
print(f"{node.id:<4} | {node.name[:7]:<7} | {node.type.name[:7]:<7} | {xy_pos}")
249-
if node.geo:
250-
print("Geo")
251-
print(f"{node.geo.lon:.7f},{node.geo.lat:.7f},{node.geo.alt:f}")
250+
geo_pos = f"{node.geo.lon:.7f},{node.geo.lat:.7f},{node.geo.alt:f}"
251+
print(f"{node.id:<7} | {node.name[:7]:<7} | {node.type.name[:7]:<7} | {xy_pos:<9} | {geo_pos}")
252252
if ifaces:
253253
print("Interfaces")
254254
print("Connected To | ", end="")

0 commit comments

Comments
 (0)