Merge branch 'develop' into enhancement/pygui-address-creation
This commit is contained in:
commit
6ba065e8b6
6 changed files with 23 additions and 64 deletions
|
@ -493,7 +493,6 @@ class CoreGrpcClient:
|
|||
"""
|
||||
request = core_pb2.EventsRequest(session_id=session_id, events=events)
|
||||
stream = self.stub.Events(request)
|
||||
logging.info("STREAM TYPE: %s", type(stream))
|
||||
start_streamer(stream, handler)
|
||||
return stream
|
||||
|
||||
|
|
|
@ -128,5 +128,4 @@ class CoreEmu:
|
|||
result = True
|
||||
else:
|
||||
logging.error("session to delete did not exist: %s", _id)
|
||||
|
||||
return result
|
||||
|
|
|
@ -85,7 +85,6 @@ class CoreClient:
|
|||
self.handling_events = None
|
||||
self.xml_dir = None
|
||||
self.xml_file = None
|
||||
self.modified_service_nodes = set()
|
||||
|
||||
@property
|
||||
def client(self):
|
||||
|
@ -112,7 +111,6 @@ class CoreClient:
|
|||
self.links.clear()
|
||||
self.hooks.clear()
|
||||
self.emane_config = None
|
||||
self.modified_service_nodes.clear()
|
||||
for mobility_player in self.mobility_players.values():
|
||||
mobility_player.handle_close()
|
||||
self.mobility_players.clear()
|
||||
|
@ -616,7 +614,7 @@ class CoreClient:
|
|||
Open core xml
|
||||
"""
|
||||
try:
|
||||
response = self.client.open_xml(file_path)
|
||||
response = self._client.open_xml(file_path)
|
||||
logging.info("open xml file %s, response: %s", file_path, response)
|
||||
self.join_session(response.session_id)
|
||||
except grpc.RpcError as e:
|
||||
|
@ -815,6 +813,11 @@ class CoreClient:
|
|||
if NodeUtils.is_custom(node_type, model):
|
||||
services = NodeUtils.get_custom_node_services(self.app.guiconfig, model)
|
||||
node.services[:] = services
|
||||
# assign default services to CORE node
|
||||
else:
|
||||
services = self.default_services.get(model, None)
|
||||
if services:
|
||||
node.services[:] = services
|
||||
logging.info(
|
||||
"add node(%s) to session(%s), coordinates(%s, %s)",
|
||||
node.name,
|
||||
|
@ -837,7 +840,6 @@ class CoreClient:
|
|||
logging.error("unknown node: %s", node_id)
|
||||
continue
|
||||
del self.canvas_nodes[node_id]
|
||||
self.modified_service_nodes.discard(node_id)
|
||||
for edge in canvas_node.edges:
|
||||
if edge in edges:
|
||||
continue
|
||||
|
@ -1056,9 +1058,6 @@ class CoreClient:
|
|||
)
|
||||
return dict(config)
|
||||
|
||||
def service_been_modified(self, node_id: int) -> bool:
|
||||
return node_id in self.modified_service_nodes
|
||||
|
||||
def execute_script(self, script):
|
||||
response = self.client.execute_script(script)
|
||||
logging.info("execute python script %s", response)
|
||||
|
|
|
@ -3,11 +3,10 @@ core node services
|
|||
"""
|
||||
import tkinter as tk
|
||||
from tkinter import messagebox, ttk
|
||||
from typing import TYPE_CHECKING, Any, Set
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from core.gui.dialogs.dialog import Dialog
|
||||
from core.gui.dialogs.serviceconfig import ServiceConfigDialog
|
||||
from core.gui.nodeutils import NodeUtils
|
||||
from core.gui.themes import FRAME_PAD, PADX, PADY
|
||||
from core.gui.widgets import CheckboxList, ListboxScroll
|
||||
|
||||
|
@ -17,13 +16,7 @@ if TYPE_CHECKING:
|
|||
|
||||
|
||||
class NodeServiceDialog(Dialog):
|
||||
def __init__(
|
||||
self,
|
||||
master: Any,
|
||||
app: "Application",
|
||||
canvas_node: "CanvasNode",
|
||||
services: Set[str] = None,
|
||||
):
|
||||
def __init__(self, master: Any, app: "Application", canvas_node: "CanvasNode"):
|
||||
title = f"{canvas_node.core_node.name} Services"
|
||||
super().__init__(master, app, title, modal=True)
|
||||
self.app = app
|
||||
|
@ -32,24 +25,7 @@ class NodeServiceDialog(Dialog):
|
|||
self.groups = None
|
||||
self.services = None
|
||||
self.current = None
|
||||
if services is None:
|
||||
services = canvas_node.core_node.services
|
||||
model = canvas_node.core_node.model
|
||||
if len(services) == 0:
|
||||
# not custom node type and node's services haven't been modified before
|
||||
if not NodeUtils.is_custom(
|
||||
canvas_node.core_node.type, canvas_node.core_node.model
|
||||
) and not self.app.core.service_been_modified(self.node_id):
|
||||
services = set(self.app.core.default_services[model])
|
||||
# services of default type nodes were modified to be empty
|
||||
elif canvas_node.core_node.id in self.app.core.modified_service_nodes:
|
||||
services = set()
|
||||
else:
|
||||
services = set(
|
||||
NodeUtils.get_custom_node_services(self.app.guiconfig, model)
|
||||
)
|
||||
else:
|
||||
services = set(services)
|
||||
services = set(canvas_node.core_node.services)
|
||||
self.current_services = services
|
||||
self.draw()
|
||||
|
||||
|
@ -103,7 +79,7 @@ class NodeServiceDialog(Dialog):
|
|||
button.grid(row=0, column=1, sticky="ew", padx=PADX)
|
||||
button = ttk.Button(frame, text="Remove", command=self.click_remove)
|
||||
button.grid(row=0, column=2, sticky="ew", padx=PADX)
|
||||
button = ttk.Button(frame, text="Cancel", command=self.click_cancel)
|
||||
button = ttk.Button(frame, text="Cancel", command=self.destroy)
|
||||
button.grid(row=0, column=3, sticky="ew")
|
||||
|
||||
# trigger group change
|
||||
|
@ -153,22 +129,8 @@ class NodeServiceDialog(Dialog):
|
|||
)
|
||||
|
||||
def click_save(self):
|
||||
# if node is custom type or current services are not the default services then
|
||||
# set core node services and add node to modified services node set
|
||||
if (
|
||||
self.canvas_node.core_node.model not in self.app.core.default_services
|
||||
or self.current_services
|
||||
!= self.app.core.default_services[self.canvas_node.core_node.model]
|
||||
):
|
||||
self.canvas_node.core_node.services[:] = self.current_services
|
||||
self.app.core.modified_service_nodes.add(self.canvas_node.core_node.id)
|
||||
else:
|
||||
if len(self.canvas_node.core_node.services) > 0:
|
||||
self.canvas_node.core_node.services[:] = []
|
||||
self.destroy()
|
||||
|
||||
def click_cancel(self):
|
||||
self.current_services = None
|
||||
core_node = self.canvas_node.core_node
|
||||
core_node.services[:] = self.current_services
|
||||
self.destroy()
|
||||
|
||||
def click_remove(self):
|
||||
|
|
|
@ -133,6 +133,15 @@ class CanvasGraph(tk.Canvas):
|
|||
# hide context
|
||||
self.hide_context()
|
||||
|
||||
# reset view options to default state
|
||||
self.show_node_labels.set(True)
|
||||
self.show_link_labels.set(True)
|
||||
self.show_grid.set(True)
|
||||
self.show_annotations.set(True)
|
||||
self.show_interface_names.set(False)
|
||||
self.show_ip4s.set(True)
|
||||
self.show_ip6s.set(True)
|
||||
|
||||
# delete any existing drawn items
|
||||
for tag in tags.COMPONENT_TAGS:
|
||||
self.delete(tag)
|
||||
|
@ -936,11 +945,6 @@ class CanvasGraph(tk.Canvas):
|
|||
node.service_file_configs = deepcopy(canvas_node.service_file_configs)
|
||||
node.config_service_configs = deepcopy(canvas_node.config_service_configs)
|
||||
|
||||
# add new node to modified_service_nodes set if that set contains the
|
||||
# to_copy node
|
||||
if self.core.service_been_modified(core_node.id):
|
||||
self.core.modified_service_nodes.add(copy.id)
|
||||
|
||||
copy_map[canvas_node.id] = node.id
|
||||
self.core.canvas_nodes[copy.id] = node
|
||||
self.nodes[node.id] = node
|
||||
|
|
|
@ -387,12 +387,8 @@ class Menubar(tk.Menu):
|
|||
if self.core.is_runtime():
|
||||
result = messagebox.askyesnocancel("Exit", "Stop the running session?")
|
||||
if result:
|
||||
callback = None
|
||||
if quit_app:
|
||||
callback = self.app.quit
|
||||
task = BackgroundTask(self.app, self.core.delete_session, callback)
|
||||
task.start()
|
||||
elif quit_app:
|
||||
self.core.delete_session()
|
||||
if quit_app:
|
||||
self.app.quit()
|
||||
|
||||
def click_new(self) -> None:
|
||||
|
|
Loading…
Reference in a new issue