copy over wlan config, emane, mobility config, service config, service file config

This commit is contained in:
Huy Pham 2019-12-20 09:55:30 -08:00
parent 9dd42e0359
commit 086e3316eb
3 changed files with 34 additions and 3 deletions

View file

@ -909,3 +909,33 @@ class CoreClient:
def set_emane_model_config(self, node_id, model, config, interface=None):
logging.info("setting emane model config: %s %s %s", node_id, model, interface)
self.emane_model_configs[(node_id, model, interface)] = config
def copy_node_service(self, _from, _to):
services = self.canvas_nodes[_from].core_node.services
self.canvas_nodes[_to].core_node.services[:] = services
def copy_node_config(self, _from, _to):
node_type = self.canvas_nodes[_from].core_node.type
if node_type == core_pb2.NodeType.DEFAULT:
services = self.canvas_nodes[_from].core_node.services
self.canvas_nodes[_to].core_node.services[:] = services
config = self.service_configs.get(_from)
if config:
self.service_configs[_to] = config
file_configs = self.file_configs.get(_from)
if file_configs:
for key, value in file_configs.items():
if _to not in self.file_configs:
self.file_configs[_to] = {}
self.file_configs[_to][key] = value
elif node_type == core_pb2.NodeType.WIRELESS_LAN:
config = self.wlan_configs.get(_from)
if config:
self.wlan_configs[_to] = config
config = self.mobility_configs.get(_from)
if config:
self.mobility_configs[_to] = config
elif node_type == core_pb2.NodeType.EMANE:
config = self.emane_model_configs.get(_from)
if config:
self.emane_model_configs[_to] = config

View file

@ -870,6 +870,7 @@ class CanvasGraph(tk.Canvas):
copy_map[canvas_nid] = node.id
self.core.canvas_nodes[copy.id] = node
self.nodes[node.id] = node
self.core.copy_node_config(core_node.id, copy.id)
edges = self.nodes[canvas_nid].edges
for edge in edges:

View file

@ -19,8 +19,8 @@ INT_TYPES = {
}
def file_button_click(value):
file_path = filedialog.askopenfilename(title="Select File")
def file_button_click(value, parent):
file_path = filedialog.askopenfilename(title="Select File", parent=parent)
if file_path:
value.set(file_path)
@ -111,7 +111,7 @@ class ConfigFrame(ttk.Notebook):
file_frame.columnconfigure(0, weight=1)
entry = ttk.Entry(file_frame, textvariable=value)
entry.grid(row=0, column=0, sticky="ew", padx=PADX)
func = partial(file_button_click, value)
func = partial(file_button_click, value, self)
button = ttk.Button(file_frame, text="...", command=func)
button.grid(row=0, column=1)
else: