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:
parent
8678922c92
commit
54ac807a4f
11 changed files with 290 additions and 291 deletions
|
@ -439,7 +439,7 @@ class CoreClient:
|
|||
def get_links(self, definition: bool = False) -> Tuple[List[Link], List[Link]]:
|
||||
if not definition:
|
||||
self.ifaces_manager.set_macs([x.link for x in self.links.values()])
|
||||
links, asym_links = [], []
|
||||
links = []
|
||||
for edge in self.links.values():
|
||||
link = edge.link
|
||||
if not definition:
|
||||
|
@ -449,12 +449,11 @@ class CoreClient:
|
|||
link.iface2.mac = self.ifaces_manager.next_mac()
|
||||
links.append(link)
|
||||
if edge.asymmetric_link:
|
||||
asym_links.append(edge.asymmetric_link)
|
||||
return links, asym_links
|
||||
links.append(edge.asymmetric_link)
|
||||
return links
|
||||
|
||||
def start_session(self, definition: bool = False) -> Tuple[bool, List[str]]:
|
||||
links, asym_links = self.get_links(definition)
|
||||
self.session.links = links
|
||||
self.session.links = self.get_links(definition)
|
||||
self.session.metadata = self.get_metadata()
|
||||
self.session.servers.clear()
|
||||
for server in self.servers.values():
|
||||
|
@ -462,9 +461,7 @@ class CoreClient:
|
|||
result = False
|
||||
exceptions = []
|
||||
try:
|
||||
result, exceptions = self.client.start_session(
|
||||
self.session, asym_links, definition
|
||||
)
|
||||
result, exceptions = self.client.start_session(self.session, definition)
|
||||
logger.info(
|
||||
"start session(%s) definition(%s), result: %s",
|
||||
self.session.id,
|
||||
|
|
|
@ -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()}
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue