updated coretk to working order for configuring config services from coretk
This commit is contained in:
parent
da107cc1d9
commit
80a4955bd4
4 changed files with 28 additions and 7 deletions
|
@ -182,9 +182,10 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
# config service configs
|
||||
for config in request.config_service_configs:
|
||||
node = self.get_node(session, config.node_id, context)
|
||||
service = node.config_services[request.name]
|
||||
service.set_config(config.config)
|
||||
for name, template in config.templates.values():
|
||||
service = node.config_services[config.name]
|
||||
if config.config:
|
||||
service.set_config(config.config)
|
||||
for name, template in config.templates.items():
|
||||
service.custom_template(name, template)
|
||||
|
||||
# service file configs
|
||||
|
|
|
@ -730,6 +730,7 @@ class Session:
|
|||
self.services.add_services(node, node.type, options.services)
|
||||
|
||||
# add config services
|
||||
logging.info("setting node config services: %s", options.config_services)
|
||||
for name in options.config_services:
|
||||
service_class = self.service_manager.get_service(name)
|
||||
node.add_config_service(service_class)
|
||||
|
|
|
@ -9,7 +9,7 @@ from typing import TYPE_CHECKING, Dict, List
|
|||
|
||||
import grpc
|
||||
|
||||
from core.api.grpc import client, common_pb2, core_pb2
|
||||
from core.api.grpc import client, common_pb2, configservices_pb2, core_pb2
|
||||
from core.gui import appconfig
|
||||
from core.gui.dialogs.mobilityplayer import MobilityPlayer
|
||||
from core.gui.dialogs.sessions import SessionsDialog
|
||||
|
@ -462,6 +462,7 @@ class CoreClient:
|
|||
asymmetric_links = [
|
||||
x.asymmetric_link for x in self.links.values() if x.asymmetric_link
|
||||
]
|
||||
config_service_configs = self.get_config_service_configs_proto()
|
||||
if self.emane_config:
|
||||
emane_config = {x: self.emane_config[x].value for x in self.emane_config}
|
||||
else:
|
||||
|
@ -482,6 +483,7 @@ class CoreClient:
|
|||
service_configs,
|
||||
file_configs,
|
||||
asymmetric_links,
|
||||
config_service_configs,
|
||||
)
|
||||
logging.debug(
|
||||
"start session(%s), result: %s", self.session_id, response.result
|
||||
|
@ -871,6 +873,21 @@ class CoreClient:
|
|||
configs.append(config_proto)
|
||||
return configs
|
||||
|
||||
def get_config_service_configs_proto(
|
||||
self
|
||||
) -> List[configservices_pb2.ConfigServiceConfig]:
|
||||
config_service_protos = []
|
||||
for node_id, node_config in self.config_service_configs.items():
|
||||
for name, service_config in node_config.items():
|
||||
config_proto = configservices_pb2.ConfigServiceConfig(
|
||||
node_id=node_id,
|
||||
name=name,
|
||||
templates=service_config["templates"],
|
||||
config=service_config.get("config"),
|
||||
)
|
||||
config_service_protos.append(config_proto)
|
||||
return config_service_protos
|
||||
|
||||
def run(self, node_id: int) -> str:
|
||||
logging.info("running node(%s) cmd: %s", node_id, self.observer)
|
||||
return self.client.node_command(self.session_id, node_id, self.observer).output
|
||||
|
|
|
@ -297,8 +297,9 @@ class ConfigServiceConfigDialog(Dialog):
|
|||
try:
|
||||
node_config = self.service_configs.setdefault(self.node_id, {})
|
||||
service_config = node_config.setdefault(self.service_name, {})
|
||||
self.config_frame.parse_config()
|
||||
service_config["config"] = self.config
|
||||
if self.config_frame:
|
||||
self.config_frame.parse_config()
|
||||
service_config["config"] = self.config
|
||||
templates_config = service_config.setdefault("templates", {})
|
||||
for file in self.modified_files:
|
||||
templates_config[file] = self.temp_service_files[file]
|
||||
|
@ -343,7 +344,8 @@ class ConfigServiceConfigDialog(Dialog):
|
|||
filename = self.templates_combobox.get()
|
||||
self.template_text.text.delete(1.0, "end")
|
||||
self.template_text.text.insert("end", self.temp_service_files[filename])
|
||||
self.config_frame.set_values(self.default_config)
|
||||
if self.config_frame:
|
||||
self.config_frame.set_values(self.default_config)
|
||||
self.startup_commands_listbox.delete(0, tk.END)
|
||||
self.validate_commands_listbox.delete(0, tk.END)
|
||||
self.shutdown_commands_listbox.delete(0, tk.END)
|
||||
|
|
Loading…
Reference in a new issue