updated wlan/mobility configs to be directly associated with a node and allow them to be copied
This commit is contained in:
parent
bd30d0d9ff
commit
85b4a81f8a
7 changed files with 52 additions and 52 deletions
|
@ -90,8 +90,6 @@ class CoreClient:
|
||||||
self.location = None
|
self.location = None
|
||||||
self.links = {}
|
self.links = {}
|
||||||
self.hooks = {}
|
self.hooks = {}
|
||||||
self.wlan_configs = {}
|
|
||||||
self.mobility_configs = {}
|
|
||||||
self.emane_config = None
|
self.emane_config = None
|
||||||
self.service_configs = {}
|
self.service_configs = {}
|
||||||
self.config_service_configs = {}
|
self.config_service_configs = {}
|
||||||
|
@ -127,8 +125,6 @@ class CoreClient:
|
||||||
self.canvas_nodes.clear()
|
self.canvas_nodes.clear()
|
||||||
self.links.clear()
|
self.links.clear()
|
||||||
self.hooks.clear()
|
self.hooks.clear()
|
||||||
self.wlan_configs.clear()
|
|
||||||
self.mobility_configs.clear()
|
|
||||||
self.emane_config = None
|
self.emane_config = None
|
||||||
self.service_configs.clear()
|
self.service_configs.clear()
|
||||||
self.file_configs.clear()
|
self.file_configs.clear()
|
||||||
|
@ -311,8 +307,9 @@ class CoreClient:
|
||||||
# get mobility configs
|
# get mobility configs
|
||||||
response = self.client.get_mobility_configs(self.session_id)
|
response = self.client.get_mobility_configs(self.session_id)
|
||||||
for node_id in response.configs:
|
for node_id in response.configs:
|
||||||
node_config = response.configs[node_id].config
|
config = response.configs[node_id].config
|
||||||
self.mobility_configs[node_id] = node_config
|
canvas_node = self.canvas_nodes[node_id]
|
||||||
|
canvas_node.mobility_config = dict(config)
|
||||||
|
|
||||||
# get emane model config
|
# get emane model config
|
||||||
response = self.client.get_emane_model_configs(self.session_id)
|
response = self.client.get_emane_model_configs(self.session_id)
|
||||||
|
@ -321,15 +318,16 @@ class CoreClient:
|
||||||
if config.interface != -1:
|
if config.interface != -1:
|
||||||
interface = config.interface
|
interface = config.interface
|
||||||
canvas_node = self.canvas_nodes[config.node_id]
|
canvas_node = self.canvas_nodes[config.node_id]
|
||||||
canvas_node.emane_model_configs[
|
canvas_node.emane_model_configs[(config.model, interface)] = dict(
|
||||||
(config.model, interface)
|
config.config
|
||||||
] = config.config
|
)
|
||||||
|
|
||||||
# get wlan configurations
|
# get wlan configurations
|
||||||
response = self.client.get_wlan_configs(self.session_id)
|
response = self.client.get_wlan_configs(self.session_id)
|
||||||
for _id in response.configs:
|
for _id in response.configs:
|
||||||
mapped_config = response.configs[_id]
|
mapped_config = response.configs[_id]
|
||||||
self.wlan_configs[_id] = mapped_config.config
|
canvas_node = self.canvas_nodes[_id]
|
||||||
|
canvas_node.wlan_config = dict(mapped_config.config)
|
||||||
|
|
||||||
# get service configurations
|
# get service configurations
|
||||||
response = self.client.get_node_service_configs(self.session_id)
|
response = self.client.get_node_service_configs(self.session_id)
|
||||||
|
@ -554,11 +552,16 @@ class CoreClient:
|
||||||
return response
|
return response
|
||||||
|
|
||||||
def show_mobility_players(self):
|
def show_mobility_players(self):
|
||||||
for node_id, config in self.mobility_configs.items():
|
for canvas_node in self.canvas_nodes.values():
|
||||||
canvas_node = self.canvas_nodes[node_id]
|
if canvas_node.core_node.type != core_pb2.NodeType.WIRELESS_LAN:
|
||||||
mobility_player = MobilityPlayer(self.app, self.app, canvas_node, config)
|
continue
|
||||||
mobility_player.show()
|
if canvas_node.mobility_config:
|
||||||
self.mobility_players[node_id] = mobility_player
|
mobility_player = MobilityPlayer(
|
||||||
|
self.app, self.app, canvas_node, canvas_node.mobility_config
|
||||||
|
)
|
||||||
|
node_id = canvas_node.core_node.id
|
||||||
|
self.mobility_players[node_id] = mobility_player
|
||||||
|
mobility_player.show()
|
||||||
|
|
||||||
def set_metadata(self):
|
def set_metadata(self):
|
||||||
# create canvas data
|
# create canvas data
|
||||||
|
@ -839,14 +842,7 @@ class CoreClient:
|
||||||
logging.error("unknown node: %s", node_id)
|
logging.error("unknown node: %s", node_id)
|
||||||
continue
|
continue
|
||||||
del self.canvas_nodes[node_id]
|
del self.canvas_nodes[node_id]
|
||||||
|
|
||||||
self.modified_service_nodes.discard(node_id)
|
self.modified_service_nodes.discard(node_id)
|
||||||
|
|
||||||
if node_id in self.mobility_configs:
|
|
||||||
del self.mobility_configs[node_id]
|
|
||||||
if node_id in self.wlan_configs:
|
|
||||||
del self.wlan_configs[node_id]
|
|
||||||
|
|
||||||
for edge in canvas_node.edges:
|
for edge in canvas_node.edges:
|
||||||
if edge in edges:
|
if edge in edges:
|
||||||
continue
|
continue
|
||||||
|
@ -916,16 +912,24 @@ class CoreClient:
|
||||||
|
|
||||||
def get_wlan_configs_proto(self) -> List[WlanConfig]:
|
def get_wlan_configs_proto(self) -> List[WlanConfig]:
|
||||||
configs = []
|
configs = []
|
||||||
for node_id, config in self.wlan_configs.items():
|
for canvas_node in self.canvas_nodes.values():
|
||||||
|
if canvas_node.core_node.type != core_pb2.NodeType.WIRELESS_LAN:
|
||||||
|
continue
|
||||||
|
config = canvas_node.wlan_config
|
||||||
config = {x: config[x].value for x in config}
|
config = {x: config[x].value for x in config}
|
||||||
|
node_id = canvas_node.core_node.id
|
||||||
wlan_config = WlanConfig(node_id=node_id, config=config)
|
wlan_config = WlanConfig(node_id=node_id, config=config)
|
||||||
configs.append(wlan_config)
|
configs.append(wlan_config)
|
||||||
return configs
|
return configs
|
||||||
|
|
||||||
def get_mobility_configs_proto(self) -> List[MobilityConfig]:
|
def get_mobility_configs_proto(self) -> List[MobilityConfig]:
|
||||||
configs = []
|
configs = []
|
||||||
for node_id, config in self.mobility_configs.items():
|
for canvas_node in self.canvas_nodes.values():
|
||||||
|
if canvas_node.core_node.type != core_pb2.NodeType.WIRELESS_LAN:
|
||||||
|
continue
|
||||||
|
config = canvas_node.mobility_config
|
||||||
config = {x: config[x].value for x in config}
|
config = {x: config[x].value for x in config}
|
||||||
|
node_id = canvas_node.core_node.id
|
||||||
mobility_config = MobilityConfig(node_id=node_id, config=config)
|
mobility_config = MobilityConfig(node_id=node_id, config=config)
|
||||||
configs.append(mobility_config)
|
configs.append(mobility_config)
|
||||||
return configs
|
return configs
|
||||||
|
@ -995,28 +999,24 @@ class CoreClient:
|
||||||
return self.client.node_command(self.session_id, node_id, self.observer).output
|
return self.client.node_command(self.session_id, node_id, self.observer).output
|
||||||
|
|
||||||
def get_wlan_config(self, node_id: int) -> Dict[str, common_pb2.ConfigOption]:
|
def get_wlan_config(self, node_id: int) -> Dict[str, common_pb2.ConfigOption]:
|
||||||
config = self.wlan_configs.get(node_id)
|
response = self.client.get_wlan_config(self.session_id, node_id)
|
||||||
if not config:
|
config = response.config
|
||||||
response = self.client.get_wlan_config(self.session_id, node_id)
|
|
||||||
config = response.config
|
|
||||||
logging.debug(
|
logging.debug(
|
||||||
"get wlan configuration from node %s, result configuration: %s",
|
"get wlan configuration from node %s, result configuration: %s",
|
||||||
node_id,
|
node_id,
|
||||||
config,
|
config,
|
||||||
)
|
)
|
||||||
return config
|
return dict(config)
|
||||||
|
|
||||||
def get_mobility_config(self, node_id: int) -> Dict[str, common_pb2.ConfigOption]:
|
def get_mobility_config(self, node_id: int) -> Dict[str, common_pb2.ConfigOption]:
|
||||||
config = self.mobility_configs.get(node_id)
|
response = self.client.get_mobility_config(self.session_id, node_id)
|
||||||
if not config:
|
config = response.config
|
||||||
response = self.client.get_mobility_config(self.session_id, node_id)
|
|
||||||
config = response.config
|
|
||||||
logging.debug(
|
logging.debug(
|
||||||
"get mobility config from node %s, result configuration: %s",
|
"get mobility config from node %s, result configuration: %s",
|
||||||
node_id,
|
node_id,
|
||||||
config,
|
config,
|
||||||
)
|
)
|
||||||
return config
|
return dict(config)
|
||||||
|
|
||||||
def get_emane_model_config(
|
def get_emane_model_config(
|
||||||
self, node_id: int, model: str, interface: int = None
|
self, node_id: int, model: str, interface: int = None
|
||||||
|
@ -1056,13 +1056,6 @@ class CoreClient:
|
||||||
if dst_id not in self.file_configs:
|
if dst_id not in self.file_configs:
|
||||||
self.file_configs[dst_id] = {}
|
self.file_configs[dst_id] = {}
|
||||||
self.file_configs[dst_id][key] = value
|
self.file_configs[dst_id][key] = value
|
||||||
elif node_type == core_pb2.NodeType.WIRELESS_LAN:
|
|
||||||
config = self.wlan_configs.get(src_node.id)
|
|
||||||
if config:
|
|
||||||
self.wlan_configs[dst_id] = config
|
|
||||||
config = self.mobility_configs.get(src_node.id)
|
|
||||||
if config:
|
|
||||||
self.mobility_configs[dst_id] = config
|
|
||||||
|
|
||||||
def service_been_modified(self, node_id: int) -> bool:
|
def service_been_modified(self, node_id: int) -> bool:
|
||||||
return node_id in self.modified_service_nodes
|
return node_id in self.modified_service_nodes
|
||||||
|
|
|
@ -108,7 +108,7 @@ class EmaneModelDialog(Dialog):
|
||||||
def click_apply(self):
|
def click_apply(self):
|
||||||
self.config_frame.parse_config()
|
self.config_frame.parse_config()
|
||||||
key = (self.model, self.interface)
|
key = (self.model, self.interface)
|
||||||
self.canvas_node.emane_model_configs[key] = dict(self.config)
|
self.canvas_node.emane_model_configs[key] = self.config
|
||||||
self.destroy()
|
self.destroy()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,9 @@ class MobilityConfigDialog(Dialog):
|
||||||
self.config_frame = None
|
self.config_frame = None
|
||||||
self.has_error = False
|
self.has_error = False
|
||||||
try:
|
try:
|
||||||
self.config = self.app.core.get_mobility_config(self.node.id)
|
self.config = self.canvas_node.mobility_config
|
||||||
|
if not self.config:
|
||||||
|
self.config = self.app.core.get_mobility_config(self.node.id)
|
||||||
self.draw()
|
self.draw()
|
||||||
except grpc.RpcError as e:
|
except grpc.RpcError as e:
|
||||||
self.has_error = True
|
self.has_error = True
|
||||||
|
@ -60,5 +62,5 @@ class MobilityConfigDialog(Dialog):
|
||||||
|
|
||||||
def click_apply(self):
|
def click_apply(self):
|
||||||
self.config_frame.parse_config()
|
self.config_frame.parse_config()
|
||||||
self.app.core.mobility_configs[self.node.id] = self.config
|
self.canvas_node.mobility_config = self.config
|
||||||
self.destroy()
|
self.destroy()
|
||||||
|
|
|
@ -48,8 +48,9 @@ class MobilityPlayer:
|
||||||
self.dialog.show()
|
self.dialog.show()
|
||||||
|
|
||||||
def handle_close(self):
|
def handle_close(self):
|
||||||
self.dialog.destroy()
|
if self.dialog:
|
||||||
self.dialog = None
|
self.dialog.destroy()
|
||||||
|
self.dialog = None
|
||||||
|
|
||||||
def set_play(self):
|
def set_play(self):
|
||||||
self.state = MobilityAction.START
|
self.state = MobilityAction.START
|
||||||
|
|
|
@ -32,7 +32,9 @@ class WlanConfigDialog(Dialog):
|
||||||
self.ranges = {}
|
self.ranges = {}
|
||||||
self.positive_int = self.app.master.register(self.validate_and_update)
|
self.positive_int = self.app.master.register(self.validate_and_update)
|
||||||
try:
|
try:
|
||||||
self.config = self.app.core.get_wlan_config(self.node.id)
|
self.config = self.canvas_node.wlan_config
|
||||||
|
if not self.config:
|
||||||
|
self.config = self.app.core.get_wlan_config(self.node.id)
|
||||||
self.init_draw_range()
|
self.init_draw_range()
|
||||||
self.draw()
|
self.draw()
|
||||||
except grpc.RpcError as e:
|
except grpc.RpcError as e:
|
||||||
|
@ -83,7 +85,7 @@ class WlanConfigDialog(Dialog):
|
||||||
retrieve user's wlan configuration and store the new configuration values
|
retrieve user's wlan configuration and store the new configuration values
|
||||||
"""
|
"""
|
||||||
config = self.config_frame.parse_config()
|
config = self.config_frame.parse_config()
|
||||||
self.app.core.wlan_configs[self.node.id] = self.config
|
self.canvas_node.wlan_config = self.config
|
||||||
if self.app.core.is_runtime():
|
if self.app.core.is_runtime():
|
||||||
session_id = self.app.core.session_id
|
session_id = self.app.core.session_id
|
||||||
self.app.core.client.set_wlan_config(session_id, self.node.id, config)
|
self.app.core.client.set_wlan_config(session_id, self.node.id, config)
|
||||||
|
|
|
@ -305,7 +305,7 @@ class CanvasGraph(tk.Canvas):
|
||||||
token = create_edge_token(canvas_node_one.id, canvas_node_two.id)
|
token = create_edge_token(canvas_node_one.id, canvas_node_two.id)
|
||||||
|
|
||||||
if link.type == core_pb2.LinkType.WIRELESS:
|
if link.type == core_pb2.LinkType.WIRELESS:
|
||||||
self.add_wireless_edge(canvas_node_one, canvas_node_two)
|
self.add_wireless_edge(canvas_node_one, canvas_node_two, link)
|
||||||
else:
|
else:
|
||||||
if token not in self.edges:
|
if token not in self.edges:
|
||||||
src_pos = (node_one.position.x, node_one.position.y)
|
src_pos = (node_one.position.x, node_one.position.y)
|
||||||
|
@ -352,6 +352,7 @@ class CanvasGraph(tk.Canvas):
|
||||||
"""
|
"""
|
||||||
Convert window coordinate to canvas coordinate
|
Convert window coordinate to canvas coordinate
|
||||||
"""
|
"""
|
||||||
|
logging.info("event type: %s", type(event))
|
||||||
x = self.canvasx(event.x)
|
x = self.canvasx(event.x)
|
||||||
y = self.canvasy(event.y)
|
y = self.canvasy(event.y)
|
||||||
return x, y
|
return x, y
|
||||||
|
@ -421,7 +422,7 @@ class CanvasGraph(tk.Canvas):
|
||||||
self.mode = GraphMode.NODE
|
self.mode = GraphMode.NODE
|
||||||
self.selected = None
|
self.selected = None
|
||||||
|
|
||||||
def handle_edge_release(self, event: tk.Event):
|
def handle_edge_release(self, _event: tk.Event):
|
||||||
edge = self.drawing_edge
|
edge = self.drawing_edge
|
||||||
self.drawing_edge = None
|
self.drawing_edge = None
|
||||||
|
|
||||||
|
@ -702,7 +703,7 @@ class CanvasGraph(tk.Canvas):
|
||||||
else:
|
else:
|
||||||
self.hide_context()
|
self.hide_context()
|
||||||
|
|
||||||
def press_delete(self, event: tk.Event):
|
def press_delete(self, _event: tk.Event):
|
||||||
"""
|
"""
|
||||||
delete selected nodes and any data that relates to it
|
delete selected nodes and any data that relates to it
|
||||||
"""
|
"""
|
||||||
|
@ -925,6 +926,8 @@ class CanvasGraph(tk.Canvas):
|
||||||
|
|
||||||
# copy configurations
|
# copy configurations
|
||||||
node.emane_model_configs = deepcopy(canvas_node.emane_model_configs)
|
node.emane_model_configs = deepcopy(canvas_node.emane_model_configs)
|
||||||
|
node.wlan_config = deepcopy(canvas_node.wlan_config)
|
||||||
|
node.mobility_config = deepcopy(canvas_node.mobility_config)
|
||||||
|
|
||||||
# add new node to modified_service_nodes set if that set contains the
|
# add new node to modified_service_nodes set if that set contains the
|
||||||
# to_copy node
|
# to_copy node
|
||||||
|
|
|
@ -181,7 +181,6 @@ class ConfigFrame(ttk.Notebook):
|
||||||
option.value = "0"
|
option.value = "0"
|
||||||
else:
|
else:
|
||||||
option.value = config_value
|
option.value = config_value
|
||||||
|
|
||||||
return {x: self.config[x].value for x in self.config}
|
return {x: self.config[x].value for x in self.config}
|
||||||
|
|
||||||
def set_values(self, config: Dict[str, str]) -> None:
|
def set_values(self, config: Dict[str, str]) -> None:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue