service file config

This commit is contained in:
Huy Pham 2019-11-21 16:59:55 -08:00
parent 741477c043
commit c21f060797
3 changed files with 55 additions and 23 deletions

View file

@ -312,7 +312,6 @@ class CoreClient:
emane_model_configs = self.get_emane_model_configs_proto()
hooks = list(self.hooks.values())
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()
@ -397,9 +396,9 @@ class CoreClient:
:return: nothing
"""
node_protos = [x.core_node for x in self.canvas_nodes.values()]
link_protos = list(self.links.values())
print(node_protos)
if self.get_session_state() != core_pb2.SessionState.DEFINITION:
self.client.set_session_state(
self.session_id, core_pb2.SessionState.DEFINITION
@ -426,6 +425,7 @@ class CoreClient:
self.created_links.add(
tuple([link_proto.node_one_id, link_proto.node_two_id])
)
print(self.app.core.client.get_session(self.app.core.session_id))
def close(self):
"""
@ -638,20 +638,32 @@ class CoreClient:
def get_service_config_proto(self):
configs = []
for (
node_id,
service_configs,
) in self.serviceconfig_manager.configurations.items():
for service, config in service_configs.items():
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)
for node_id, services in self.service_configs.items():
for name, config in services.items():
config_proto = core_pb2.ServiceConfig(
node_id=node_id,
service=name,
startup=config.startup,
validate=config.validate,
shutdown=config.shutdown,
)
configs.append(config_proto)
# configs = []
# for (
# node_id,
# service_configs,
# ) in self.serviceconfig_manager.configurations.items():
# for service, config in service_configs.items():
# 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

@ -22,6 +22,14 @@ class NodeService(Dialog):
services = set(
app.core.serviceconfig_manager.current_services[self.node_id]
)
if services is None:
services = canvas_node.core_node.services
model = canvas_node.core_node.model
if len(services) == 0:
services = set(self.app.core.default_services[model])
else:
services = set(services)
self.current_services = services
self.service_manager = self.app.core.serviceconfig_manager
self.service_file_manager = self.app.core.servicefileconfig_manager

View file

@ -93,9 +93,13 @@ class ServiceConfiguration(Dialog):
self.temp_service_files = {
x: self.original_service_files[x] for x in self.original_service_files
}
configs = self.app.core.servicefileconfig_manager.configurations
if self.node_id in configs and self.service_name in configs[self.node_id]:
for file, data in configs[self.node_id][self.service_name].items():
# configs = self.app.core.servicefileconfig_manager.configurations
file_configs = self.app.core.file_configs
if (
self.node_id in file_configs
and self.service_name in file_configs[self.node_id]
):
for file, data in file_configs[self.node_id][self.service_name].items():
self.temp_service_files[file] = data
def draw(self):
@ -389,7 +393,6 @@ class ServiceConfiguration(Dialog):
service_configs[self.node_id] = {}
if self.service_name not in service_configs[self.node_id]:
self.app.core.service_configs[self.node_id][self.service_name] = config
print(self.app.core.client.get_session(self.app.core.session_id))
# self.service_manager.node_service_custom_configuration(
# self.node_id,
@ -399,9 +402,18 @@ class ServiceConfiguration(Dialog):
# shutdown_commands,
# )
for file in self.modified_files:
self.app.core.servicefileconfig_manager.set_custom_service_file_config(
self.node_id, self.service_name, file, self.temp_service_files[file]
)
# self.app.core.servicefileconfig_manager.set_custom_service_file_config(
# self.node_id, self.service_name, file, self.temp_service_files[file]
# )
file_configs = self.app.core.file_configs
if self.node_id not in file_configs:
file_configs[self.node_id] = {}
if self.service_name not in file_configs[self.node_id]:
file_configs[self.node_id][self.service_name] = {}
file_configs[self.node_id][self.service_name][
file
] = self.temp_service_files[file]
self.app.core.set_node_service_file(
self.node_id, self.service_name, file, self.temp_service_files[file]
)