daemon/gui: adjustments to account for network node wired links having proper interface ids, which allow for unique configuration with the new linking semantics
This commit is contained in:
parent
b71272519d
commit
dc9b6adc98
7 changed files with 61 additions and 45 deletions
|
@ -275,7 +275,7 @@ class NodeConfigDialog(Dialog):
|
|||
ifaces_scroll.listbox.bind("<<ListboxSelect>>", self.iface_select)
|
||||
|
||||
# interfaces
|
||||
if self.canvas_node.ifaces:
|
||||
if nutils.is_container(self.node):
|
||||
self.draw_ifaces()
|
||||
|
||||
self.draw_spacer()
|
||||
|
|
|
@ -298,7 +298,10 @@ class CanvasNode:
|
|||
other_iface = edge.other_iface(self)
|
||||
label = other_node.core_node.name
|
||||
if other_iface:
|
||||
label = f"{label}:{other_iface.name}"
|
||||
iface_label = other_iface.id
|
||||
if other_iface.name:
|
||||
iface_label = other_iface.name
|
||||
label = f"{label}:{iface_label}"
|
||||
func_unlink = functools.partial(self.click_unlink, edge)
|
||||
unlink_menu.add_command(label=label, command=func_unlink)
|
||||
themes.style_menu(unlink_menu)
|
||||
|
|
|
@ -241,10 +241,10 @@ class InterfaceManager:
|
|||
dst_node = edge.dst.core_node
|
||||
self.determine_subnets(edge.src, edge.dst)
|
||||
src_iface = None
|
||||
if nutils.is_container(src_node):
|
||||
if nutils.is_iface_node(src_node):
|
||||
src_iface = self.create_iface(edge.src, edge.linked_wireless)
|
||||
dst_iface = None
|
||||
if nutils.is_container(dst_node):
|
||||
if nutils.is_iface_node(dst_node):
|
||||
dst_iface = self.create_iface(edge.dst, edge.linked_wireless)
|
||||
link = Link(
|
||||
type=LinkType.WIRED,
|
||||
|
@ -258,22 +258,26 @@ class InterfaceManager:
|
|||
|
||||
def create_iface(self, canvas_node: CanvasNode, wireless_link: bool) -> Interface:
|
||||
node = canvas_node.core_node
|
||||
ip4, ip6 = self.get_ips(node)
|
||||
if wireless_link:
|
||||
ip4_mask = WIRELESS_IP4_MASK
|
||||
ip6_mask = WIRELESS_IP6_MASK
|
||||
if nutils.is_bridge(node):
|
||||
iface_id = canvas_node.next_iface_id()
|
||||
iface = Interface(id=iface_id)
|
||||
else:
|
||||
ip4_mask = IP4_MASK
|
||||
ip6_mask = IP6_MASK
|
||||
iface_id = canvas_node.next_iface_id()
|
||||
name = f"eth{iface_id}"
|
||||
iface = Interface(
|
||||
id=iface_id,
|
||||
name=name,
|
||||
ip4=ip4,
|
||||
ip4_mask=ip4_mask,
|
||||
ip6=ip6,
|
||||
ip6_mask=ip6_mask,
|
||||
)
|
||||
ip4, ip6 = self.get_ips(node)
|
||||
if wireless_link:
|
||||
ip4_mask = WIRELESS_IP4_MASK
|
||||
ip6_mask = WIRELESS_IP6_MASK
|
||||
else:
|
||||
ip4_mask = IP4_MASK
|
||||
ip6_mask = IP6_MASK
|
||||
iface_id = canvas_node.next_iface_id()
|
||||
name = f"eth{iface_id}"
|
||||
iface = Interface(
|
||||
id=iface_id,
|
||||
name=name,
|
||||
ip4=ip4,
|
||||
ip4_mask=ip4_mask,
|
||||
ip6=ip6,
|
||||
ip6_mask=ip6_mask,
|
||||
)
|
||||
logger.info("create node(%s) interface(%s)", node.name, iface)
|
||||
return iface
|
||||
|
|
|
@ -97,6 +97,10 @@ def is_custom(node: Node) -> bool:
|
|||
return is_model(node) and node.model not in NODE_MODELS
|
||||
|
||||
|
||||
def is_iface_node(node: Node) -> bool:
|
||||
return is_container(node) or is_bridge(node)
|
||||
|
||||
|
||||
def get_custom_services(gui_config: GuiConfig, name: str) -> List[str]:
|
||||
for custom_node in gui_config.nodes:
|
||||
if custom_node.name == name:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue