From 26f0848cb43e725da8bc9447a47954027dd86595 Mon Sep 17 00:00:00 2001 From: Blake Harnden <32446120+bharnden@users.noreply.github.com> Date: Tue, 22 Mar 2022 21:08:31 -0700 Subject: [PATCH] daemon: update iface to use desired name when configuring, gui: dont assign mac to non container nodes --- daemon/core/gui/coreclient.py | 6 ++++-- daemon/core/nodes/base.py | 12 ++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/daemon/core/gui/coreclient.py b/daemon/core/gui/coreclient.py index 4905ac8a..b92dee79 100644 --- a/daemon/core/gui/coreclient.py +++ b/daemon/core/gui/coreclient.py @@ -404,9 +404,11 @@ class CoreClient: for edge in self.links.values(): link = edge.link if not definition: - if link.iface1 and not link.iface1.mac: + node1 = self.session.nodes[link.node1_id] + node2 = self.session.nodes[link.node2_id] + if nutils.is_container(node1) and link.iface1 and not link.iface1.mac: link.iface1.mac = self.ifaces_manager.next_mac() - if link.iface2 and not link.iface2.mac: + if nutils.is_container(node2) and link.iface2 and not link.iface2.mac: link.iface2.mac = self.ifaces_manager.next_mac() links.append(link) if edge.asymmetric_link: diff --git a/daemon/core/nodes/base.py b/daemon/core/nodes/base.py index 6fbfb612..818c700c 100644 --- a/daemon/core/nodes/base.py +++ b/daemon/core/nodes/base.py @@ -195,24 +195,24 @@ class NodeBase(abc.ABC): localname, self.session.use_ovs(), mtu, - node=self, - server=self.server, + self, + self.server, ) if iface_data: if iface_data.mac: iface.set_mac(iface_data.mac) for ip in iface_data.get_ips(): iface.add_ip(ip) + if iface_data.name: + name = iface_data.name if options: iface.options.update(options) self.ifaces[iface_id] = iface if self.up: iface.startup() - if iface_data and iface_data.name is not None: - name = iface_data.name - else: - name = iface.name self.adopt_iface(iface, name) + else: + iface.name = name return iface def delete_iface(self, iface_id: int) -> CoreInterface: