grpc/pygui: edit_link will now broadcast link changes, pygui now handles receiving this data
This commit is contained in:
parent
f921fa45c5
commit
f4a3fe6b7b
5 changed files with 34 additions and 6 deletions
|
@ -509,7 +509,7 @@ class CoreGrpcClient:
|
||||||
:param node_id: node id
|
:param node_id: node id
|
||||||
:param position: position to set node to
|
:param position: position to set node to
|
||||||
:param icon: path to icon for gui to use for node
|
:param icon: path to icon for gui to use for node
|
||||||
:param source: application source editing node
|
:param source: application source
|
||||||
:param geo: lon,lat,alt location for node
|
:param geo: lon,lat,alt location for node
|
||||||
:return: response with result of success or failure
|
:return: response with result of success or failure
|
||||||
:raises grpc.RpcError: when session or node doesn't exist
|
:raises grpc.RpcError: when session or node doesn't exist
|
||||||
|
@ -625,7 +625,7 @@ class CoreGrpcClient:
|
||||||
:param iface1: node one interface data
|
:param iface1: node one interface data
|
||||||
:param iface2: node two interface data
|
:param iface2: node two interface data
|
||||||
:param options: options for link (jitter, bandwidth, etc)
|
:param options: options for link (jitter, bandwidth, etc)
|
||||||
:param source: application source adding link
|
:param source: application source
|
||||||
:return: response with result of success or failure
|
:return: response with result of success or failure
|
||||||
:raises grpc.RpcError: when session or one of the nodes don't exist
|
:raises grpc.RpcError: when session or one of the nodes don't exist
|
||||||
"""
|
"""
|
||||||
|
@ -650,6 +650,7 @@ class CoreGrpcClient:
|
||||||
options: core_pb2.LinkOptions,
|
options: core_pb2.LinkOptions,
|
||||||
iface1_id: int = None,
|
iface1_id: int = None,
|
||||||
iface2_id: int = None,
|
iface2_id: int = None,
|
||||||
|
source: str = None,
|
||||||
) -> core_pb2.EditLinkResponse:
|
) -> core_pb2.EditLinkResponse:
|
||||||
"""
|
"""
|
||||||
Edit a link between nodes.
|
Edit a link between nodes.
|
||||||
|
@ -660,6 +661,7 @@ class CoreGrpcClient:
|
||||||
:param options: options for link (jitter, bandwidth, etc)
|
:param options: options for link (jitter, bandwidth, etc)
|
||||||
:param iface1_id: node one interface id
|
:param iface1_id: node one interface id
|
||||||
:param iface2_id: node two interface id
|
:param iface2_id: node two interface id
|
||||||
|
:param source: application source
|
||||||
:return: response with result of success or failure
|
:return: response with result of success or failure
|
||||||
:raises grpc.RpcError: when session or one of the nodes don't exist
|
:raises grpc.RpcError: when session or one of the nodes don't exist
|
||||||
"""
|
"""
|
||||||
|
@ -670,6 +672,7 @@ class CoreGrpcClient:
|
||||||
options=options,
|
options=options,
|
||||||
iface1_id=iface1_id,
|
iface1_id=iface1_id,
|
||||||
iface2_id=iface2_id,
|
iface2_id=iface2_id,
|
||||||
|
source=source,
|
||||||
)
|
)
|
||||||
return self.stub.EditLink(request)
|
return self.stub.EditLink(request)
|
||||||
|
|
||||||
|
@ -690,7 +693,7 @@ class CoreGrpcClient:
|
||||||
:param node2_id: node two id
|
:param node2_id: node two id
|
||||||
:param iface1_id: node one interface id
|
:param iface1_id: node one interface id
|
||||||
:param iface2_id: node two interface id
|
:param iface2_id: node two interface id
|
||||||
:param source: application source deleting link
|
:param source: application source
|
||||||
:return: response with result of success or failure
|
:return: response with result of success or failure
|
||||||
:raises grpc.RpcError: when session doesn't exist
|
:raises grpc.RpcError: when session doesn't exist
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -866,6 +866,7 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
||||||
node2_id=node2_id,
|
node2_id=node2_id,
|
||||||
iface1=iface1_data,
|
iface1=iface1_data,
|
||||||
iface2=iface2_data,
|
iface2=iface2_data,
|
||||||
|
options=options,
|
||||||
source=source,
|
source=source,
|
||||||
)
|
)
|
||||||
session.broadcast_link(link_data)
|
session.broadcast_link(link_data)
|
||||||
|
@ -909,6 +910,19 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
||||||
key=options_proto.key,
|
key=options_proto.key,
|
||||||
)
|
)
|
||||||
session.update_link(node1_id, node2_id, iface1_id, iface2_id, options)
|
session.update_link(node1_id, node2_id, iface1_id, iface2_id, options)
|
||||||
|
iface1 = InterfaceData(id=iface1_id)
|
||||||
|
iface2 = InterfaceData(id=iface2_id)
|
||||||
|
source = request.source if request.source else None
|
||||||
|
link_data = LinkData(
|
||||||
|
message_type=MessageFlags.NONE,
|
||||||
|
node1_id=node1_id,
|
||||||
|
node2_id=node2_id,
|
||||||
|
iface1=iface1,
|
||||||
|
iface2=iface2,
|
||||||
|
options=options,
|
||||||
|
source=source,
|
||||||
|
)
|
||||||
|
session.broadcast_link(link_data)
|
||||||
return core_pb2.EditLinkResponse(result=True)
|
return core_pb2.EditLinkResponse(result=True)
|
||||||
|
|
||||||
def DeleteLink(
|
def DeleteLink(
|
||||||
|
|
|
@ -216,6 +216,10 @@ class CoreClient:
|
||||||
self.app.canvas.organize()
|
self.app.canvas.organize()
|
||||||
elif event.message_type == MessageType.DELETE:
|
elif event.message_type == MessageType.DELETE:
|
||||||
self.app.canvas.delete_wired_edge(canvas_node1, canvas_node2)
|
self.app.canvas.delete_wired_edge(canvas_node1, canvas_node2)
|
||||||
|
elif event.message_type == MessageType.NONE:
|
||||||
|
self.app.canvas.update_wired_edge(
|
||||||
|
canvas_node1, canvas_node2, event.link
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
logging.warning("unknown link event: %s", event)
|
logging.warning("unknown link event: %s", event)
|
||||||
|
|
||||||
|
|
|
@ -262,6 +262,13 @@ class CanvasGraph(tk.Canvas):
|
||||||
return
|
return
|
||||||
self.delete_edge(edge)
|
self.delete_edge(edge)
|
||||||
|
|
||||||
|
def update_wired_edge(self, src: CanvasNode, dst: CanvasNode, link: Link) -> None:
|
||||||
|
token = create_edge_token(src.id, dst.id)
|
||||||
|
edge = self.edges.get(token)
|
||||||
|
if not edge:
|
||||||
|
return
|
||||||
|
edge.link.options.CopyFrom(link.options)
|
||||||
|
|
||||||
def add_wireless_edge(self, src: CanvasNode, dst: CanvasNode, link: Link) -> None:
|
def add_wireless_edge(self, src: CanvasNode, dst: CanvasNode, link: Link) -> None:
|
||||||
network_id = link.network_id if link.network_id else None
|
network_id = link.network_id if link.network_id else None
|
||||||
token = create_edge_token(src.id, dst.id, network_id)
|
token = create_edge_token(src.id, dst.id, network_id)
|
||||||
|
@ -350,9 +357,8 @@ class CanvasGraph(tk.Canvas):
|
||||||
dst_node.wireless_edges.remove(edge)
|
dst_node.wireless_edges.remove(edge)
|
||||||
self.wireless_edges.clear()
|
self.wireless_edges.clear()
|
||||||
|
|
||||||
# clear all middle edge labels
|
# clear throughputs
|
||||||
for edge in self.edges.values():
|
self.clear_throughputs()
|
||||||
edge.reset()
|
|
||||||
|
|
||||||
def canvas_xy(self, event: tk.Event) -> Tuple[float, float]:
|
def canvas_xy(self, event: tk.Event) -> Tuple[float, float]:
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -504,6 +504,7 @@ message EditLinkRequest {
|
||||||
int32 iface1_id = 4;
|
int32 iface1_id = 4;
|
||||||
int32 iface2_id = 5;
|
int32 iface2_id = 5;
|
||||||
LinkOptions options = 6;
|
LinkOptions options = 6;
|
||||||
|
string source = 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
message EditLinkResponse {
|
message EditLinkResponse {
|
||||||
|
|
Loading…
Add table
Reference in a new issue