service config, trying out some new icons

This commit is contained in:
Huy Pham 2019-11-20 16:52:02 -08:00
parent 695f5c3e66
commit 2e121a3344
30 changed files with 72 additions and 22 deletions

View file

@ -123,6 +123,9 @@ class CoreClient:
)
def join_session(self, session_id):
self.master.config(cursor="watch")
self.master.update()
# update session and title
self.session_id = session_id
self.master.title(f"CORE Session({self.session_id})")
@ -193,6 +196,7 @@ class CoreClient:
self.app.toolbar.runtime_frame.tkraise()
else:
self.app.toolbar.design_frame.tkraise()
self.master.config(cursor="")
def is_runtime(self):
return self.state == core_pb2.SessionState.RUNTIME
@ -296,7 +300,8 @@ class CoreClient:
mobility_configs = self.get_mobility_configs_proto()
emane_model_configs = self.get_emane_model_configs_proto()
hooks = list(self.hooks.values())
# service_configs = self.get_service_config_proto()
service_configs = self.get_service_config_proto()
print(service_configs)
# service_file_configs = self.get_service_file_config_proto()
self.created_links.clear()
self.created_nodes.clear()
@ -313,7 +318,7 @@ class CoreClient:
emane_config=emane_config,
emane_model_configs=emane_model_configs,
mobility_configs=mobility_configs,
# service_configs=service_configs
service_configs=service_configs,
)
logging.debug("Start session %s, result: %s", self.session_id, response.result)
@ -638,14 +643,15 @@ class CoreClient:
service_configs,
) in self.serviceconfig_manager.configurations.items():
for service, config in service_configs.items():
config = core_pb2.ServiceConfig(
node_id=node_id,
service=service,
startup=config.startup,
validate=config.validate,
shutdown=config.shutdown,
)
configs.append(config)
if service in self.serviceconfig_manager.current_services[node_id]:
config = core_pb2.ServiceConfig(
node_id=node_id,
service=service,
startup=config.startup,
validate=config.validate,
shutdown=config.shutdown,
)
configs.append(config)
return configs
def get_service_file_config_proto(self):

View file

@ -19,9 +19,11 @@ class NodeService(Dialog):
self.current = None
if services is None:
services = set(
app.core.serviceconfig_manager.configurations[self.node_id].keys()
app.core.serviceconfig_manager.current_services[self.node_id]
)
self.current_services = services
self.service_manager = self.app.core.serviceconfig_manager
self.service_file_manager = self.app.core.servicefileconfig_manager
self.draw()
def draw(self):
@ -76,9 +78,16 @@ class NodeService(Dialog):
def service_clicked(self, name, var):
if var.get() and name not in self.current_services:
self.current_services.add(name)
if self.service_manager.node_new_service_configuration(self.node_id, name):
self.current_services.add(name)
else:
for checkbutton in self.services.frame.winfo_children():
if name == checkbutton.cget("text"):
checkbutton.config(variable=tk.BooleanVar(value=False))
elif not var.get() and name in self.current_services:
self.current_services.remove(name)
self.service_manager.current_services[self.node_id].remove(name)
self.current.listbox.delete(0, tk.END)
for name in sorted(self.current_services):
self.current.listbox.insert(tk.END, name)
@ -90,7 +99,7 @@ class NodeService(Dialog):
master=self,
app=self.app,
service_name=self.current.listbox.get(current_selection[0]),
canvas_node=self.canvas_node,
node_id=self.node_id,
)
dialog.show()
else:

View file

@ -11,11 +11,11 @@ from coretk.widgets import ListboxScroll
class ServiceConfiguration(Dialog):
def __init__(self, master, app, service_name, canvas_node):
def __init__(self, master, app, service_name, node_id):
super().__init__(master, app, f"{service_name} service", modal=True)
self.app = app
self.canvas_node = canvas_node
self.node_id = canvas_node.core_node.id
self.service_manager = app.core.serviceconfig_manager
self.node_id = node_id
self.service_name = service_name
self.radiovar = tk.IntVar()
self.radiovar.set(2)
@ -51,16 +51,15 @@ class ServiceConfiguration(Dialog):
# create nodes and links in definition state for getting and setting service file
self.app.core.create_nodes_and_links()
# load data from local memory
serviceconfig_manager = self.app.core.serviceconfig_manager
if self.service_name in serviceconfig_manager.configurations[self.node_id]:
service_config = serviceconfig_manager.configurations[self.node_id][
if self.service_name in self.service_manager.configurations[self.node_id]:
service_config = self.service_manager.configurations[self.node_id][
self.service_name
]
else:
serviceconfig_manager.node_custom_service_configuration(
self.service_manager.node_custom_service_configuration(
self.node_id, self.service_name
)
service_config = serviceconfig_manager.configurations[self.node_id][
service_config = self.service_manager.configurations[self.node_id][
self.service_name
]
self.dependencies = [x for x in service_config.dependencies]
@ -363,7 +362,7 @@ class ServiceConfiguration(Dialog):
startup_commands = self.startup_commands_listbox.get(0, "end")
shutdown_commands = self.shutdown_commands_listbox.get(0, "end")
validate_commands = self.validate_commands_listbox.get(0, "end")
self.app.core.serviceconfig_manager.node_service_custom_configuration(
self.service_manager.node_service_custom_configuration(
self.node_id,
self.service_name,
startup_commands,

Binary file not shown.

After

Width:  |  Height:  |  Size: 642 B

BIN
coretk/coretk/icons/hub.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 669 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 667 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
coretk/coretk/icons/pc.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 517 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 696 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 348 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 588 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 145 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 146 B

View file

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View file

Before

Width:  |  Height:  |  Size: 719 B

After

Width:  |  Height:  |  Size: 719 B

View file

Before

Width:  |  Height:  |  Size: 744 B

After

Width:  |  Height:  |  Size: 744 B

View file

Before

Width:  |  Height:  |  Size: 174 B

After

Width:  |  Height:  |  Size: 174 B

View file

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View file

Before

Width:  |  Height:  |  Size: 160 B

After

Width:  |  Height:  |  Size: 160 B

View file

Before

Width:  |  Height:  |  Size: 755 B

After

Width:  |  Height:  |  Size: 755 B

View file

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View file

Before

Width:  |  Height:  |  Size: 925 B

After

Width:  |  Height:  |  Size: 925 B

View file

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View file

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View file

Before

Width:  |  Height:  |  Size: 127 B

After

Width:  |  Height:  |  Size: 127 B

View file

@ -2,15 +2,23 @@
service node configuration
"""
import logging
from tkinter import messagebox
import grpc
class ServiceNodeConfig:
def __init__(self, app):
self.app = app
# dict(node_id:dict(service:node_service_config_proto))
# maps node to all of its service configuration
self.configurations = {}
# dict(node_id:set(str))
# maps node to current configurations
self.current_services = {}
self.default_services = {}
# todo rewrite, no need self.default services
def node_default_services_configuration(self, node_id, node_model):
"""
set the default configurations for the default services of a node
@ -20,6 +28,7 @@ class ServiceNodeConfig:
"""
session_id = self.app.core.session_id
client = self.app.core.client
if len(self.default_services) == 0:
response = client.get_service_defaults(session_id)
logging.info("session default services: %s", response)
@ -28,6 +37,7 @@ class ServiceNodeConfig:
self.configurations[node_id] = {}
self.current_services[node_id] = set()
for default in self.default_services[node_model]:
response = client.get_node_service(session_id, node_id, default)
logging.info(
@ -36,6 +46,29 @@ class ServiceNodeConfig:
response,
)
self.configurations[node_id][default] = response.service
self.current_services[node_id].add(default)
def node_new_service_configuration(self, node_id, service_name):
"""
store node's configuration if a new service is added from the GUI
:param int node_id: node id
:param str service_name: service name
:return: nothing
"""
try:
config = self.app.core.get_node_service(node_id, service_name)
except grpc.RpcError:
messagebox.showerror("Service problem", "Service not found")
return False
if node_id not in self.configurations:
self.configurations[node_id] = {}
if node_id not in self.current_services:
self.current_services[node_id] = set()
if service_name not in self.configurations[node_id]:
self.configurations[node_id][service_name] = config
self.current_services[node_id].add(service_name)
return True
def node_custom_service_configuration(self, node_id, service_name):
self.configurations[node_id][service_name] = self.app.core.get_node_service(

View file

@ -196,9 +196,12 @@ class Toolbar(ttk.Frame):
:return: nothing
"""
logging.debug("clicked start button")
self.master.config(cursor="watch")
self.master.update()
self.app.canvas.mode = GraphMode.SELECT
self.app.core.start_session()
self.runtime_frame.tkraise()
self.master.config(cursor="")
def click_link(self):
logging.debug("Click LINK button")