grpc: changes to support nodes containing configuration data, allowing for node creation with configs and querying nodes with their configs

This commit is contained in:
Blake Harnden 2021-07-12 10:29:53 -07:00
parent 8678922c92
commit 54ac807a4f
11 changed files with 290 additions and 291 deletions

View file

@ -310,9 +310,9 @@ class ConfigServiceConfigDialog(Dialog):
current_listbox.itemconfig(current_listbox.curselection()[0], bg="")
self.destroy()
return
service_config = self.node.config_service_configs.get(self.service_name)
if not service_config:
service_config = ConfigServiceData()
service_config = self.node.config_service_configs.setdefault(
self.service_name, ConfigServiceData()
)
if self.config_frame:
self.config_frame.parse_config()
service_config.config = {x.name: x.value for x in self.config.values()}

View file

@ -31,6 +31,7 @@ class NodeConfigServiceDialog(Dialog):
if services is None:
services = set(node.config_services)
self.current_services: Set[str] = services
self.protocol("WM_DELETE_WINDOW", self.click_cancel)
self.draw()
def draw(self) -> None:
@ -131,13 +132,20 @@ class NodeConfigServiceDialog(Dialog):
if self.is_custom_service(name):
self.current.listbox.itemconfig(tk.END, bg="green")
def cleanup_custom_services(self) -> None:
for service in list(self.node.config_service_configs):
if service not in self.node.config_services:
self.node.config_service_configs.pop(service)
def click_save(self) -> None:
self.node.config_services = self.current_services.copy()
self.cleanup_custom_services()
logger.info("saved node config services: %s", self.node.config_services)
self.destroy()
def click_cancel(self) -> None:
self.current_services = None
self.cleanup_custom_services()
self.destroy()
def click_remove(self) -> None:

View file

@ -25,6 +25,7 @@ class NodeServiceDialog(Dialog):
self.current: Optional[ListboxScroll] = None
services = set(node.services)
self.current_services: Set[str] = services
self.protocol("WM_DELETE_WINDOW", self.click_cancel)
self.draw()
def draw(self) -> None:
@ -77,7 +78,7 @@ class NodeServiceDialog(Dialog):
button.grid(row=0, column=1, sticky=tk.EW, padx=PADX)
button = ttk.Button(frame, text="Remove", command=self.click_remove)
button.grid(row=0, column=2, sticky=tk.EW, padx=PADX)
button = ttk.Button(frame, text="Cancel", command=self.destroy)
button = ttk.Button(frame, text="Cancel", command=self.click_cancel)
button.grid(row=0, column=3, sticky=tk.EW)
# trigger group change
@ -125,8 +126,21 @@ class NodeServiceDialog(Dialog):
"Service Configuration", "Select a service to configure", parent=self
)
def cleanup_custom_services(self) -> None:
for service in list(self.node.service_configs):
if service not in self.node.services:
self.node.service_configs.pop(service)
for service in list(self.node.service_file_configs):
if service not in self.node.services:
self.node.service_file_configs.pop(service)
def click_cancel(self) -> None:
self.cleanup_custom_services()
self.destroy()
def click_save(self) -> None:
self.node.services = self.current_services.copy()
self.cleanup_custom_services()
self.destroy()
def click_remove(self) -> None: