daemon: update iface to use desired name when configuring, gui: dont assign mac to non container nodes

This commit is contained in:
Blake Harnden 2022-03-22 21:08:31 -07:00
parent 346364d705
commit 26f0848cb4
2 changed files with 10 additions and 8 deletions

View file

@ -404,9 +404,11 @@ class CoreClient:
for edge in self.links.values(): for edge in self.links.values():
link = edge.link link = edge.link
if not definition: 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() 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() link.iface2.mac = self.ifaces_manager.next_mac()
links.append(link) links.append(link)
if edge.asymmetric_link: if edge.asymmetric_link:

View file

@ -195,24 +195,24 @@ class NodeBase(abc.ABC):
localname, localname,
self.session.use_ovs(), self.session.use_ovs(),
mtu, mtu,
node=self, self,
server=self.server, self.server,
) )
if iface_data: if iface_data:
if iface_data.mac: if iface_data.mac:
iface.set_mac(iface_data.mac) iface.set_mac(iface_data.mac)
for ip in iface_data.get_ips(): for ip in iface_data.get_ips():
iface.add_ip(ip) iface.add_ip(ip)
if iface_data.name:
name = iface_data.name
if options: if options:
iface.options.update(options) iface.options.update(options)
self.ifaces[iface_id] = iface self.ifaces[iface_id] = iface
if self.up: if self.up:
iface.startup() 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) self.adopt_iface(iface, name)
else:
iface.name = name
return iface return iface
def delete_iface(self, iface_id: int) -> CoreInterface: def delete_iface(self, iface_id: int) -> CoreInterface: