get rid of 2 unnecessary classes for service config

This commit is contained in:
Huy Pham 2019-11-22 10:32:25 -08:00
parent 3a73b10902
commit e39db4bd63
5 changed files with 4 additions and 76 deletions

View file

@ -9,8 +9,6 @@ from coretk.dialogs.sessions import SessionsDialog
from coretk.emaneodelnodeconfig import EmaneModelNodeConfig
from coretk.interface import InterfaceManager
from coretk.nodeutils import NodeDraw, NodeUtils
from coretk.servicefileconfig import ServiceFileConfig
from coretk.servicenodeconfig import ServiceNodeConfig
OBSERVERS = {
"processes": "ps",
@ -75,8 +73,6 @@ class CoreClient:
self.emane_model_configs = {}
self.emaneconfig_management = EmaneModelNodeConfig(app)
self.emane_config = None
self.serviceconfig_manager = ServiceNodeConfig(app)
self.servicefileconfig_manager = ServiceFileConfig()
self.created_nodes = set()
self.created_links = set()
@ -143,6 +139,8 @@ class CoreClient:
self.wlan_configs.clear()
self.mobility_configs.clear()
self.emane_config = None
self.service_configs.clear()
self.file_configs.clear()
# get session data
response = self.client.get_session(self.session_id)
@ -332,6 +330,7 @@ class CoreClient:
service_file_configs=file_configs,
)
logging.debug("Start session %s, result: %s", self.session_id, response.result)
print(self.client.get_session(self.session_id))
def stop_session(self):
response = self.client.stop_session(session_id=self.session_id)
@ -483,12 +482,6 @@ class CoreClient:
if node_type == core_pb2.NodeType.EMANE:
self.emaneconfig_management.set_default_config(node_id)
# set default service configurations
# if node_type == core_pb2.NodeType.DEFAULT:
# self.serviceconfig_manager.node_default_services_configuration(
# node_id=node_id, node_model=model
# )
logging.debug(
"adding node to core session: %s, coords: (%s, %s), name: %s",
self.session_id,
@ -648,22 +641,6 @@ class CoreClient:
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):
@ -675,16 +652,6 @@ class CoreClient:
node_id=node_id, service=service, file=file, data=data
)
configs.append(config_proto)
# for (
# node_id,
# service_file_configs,
# ) in self.servicefileconfig_manager.configurations.items():
# for service, file_configs in service_file_configs.items():
# for file, data in file_configs.items():
# config = core_pb2.ServiceFileConfig(
# node_id=node_id, service=service, file=file, data=data
# )
# configs.append(config)
return configs
def run(self, node_id):

View file

@ -18,10 +18,6 @@ class NodeService(Dialog):
self.groups = None
self.services = None
self.current = None
if services is None:
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
@ -31,8 +27,6 @@ class NodeService(Dialog):
services = set(services)
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):
@ -87,16 +81,9 @@ class NodeService(Dialog):
def service_clicked(self, name, var):
if var.get() and name not in self.current_services:
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))
self.current_services.add(name)
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)

View file

@ -15,7 +15,6 @@ class ServiceConfiguration(Dialog):
super().__init__(master, app, f"{service_name} service", modal=True)
self.app = app
self.core = app.core
self.service_manager = app.core.serviceconfig_manager
self.node_id = node_id
self.service_name = service_name
self.radiovar = tk.IntVar()
@ -64,19 +63,6 @@ class ServiceConfiguration(Dialog):
service_config = self.app.core.get_node_service(
self.node_id, self.service_name
)
# # load data from local memory
# 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:
# self.service_manager.node_custom_service_configuration(
# self.node_id, self.service_name
# )
# service_config = self.service_manager.configurations[self.node_id][
# self.service_name
# ]
self.dependencies = [x for x in service_config.dependencies]
self.executables = [x for x in service_config.executables]
self.metadata = service_config.meta
@ -93,7 +79,6 @@ 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
file_configs = self.app.core.file_configs
if (
self.node_id in file_configs
@ -393,18 +378,7 @@ 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
# self.service_manager.node_service_custom_configuration(
# self.node_id,
# self.service_name,
# startup_commands,
# validate_commands,
# 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]
# )
file_configs = self.app.core.file_configs
if self.node_id not in file_configs:
file_configs[self.node_id] = {}