daemon: fix for deleting an interface from rj45 node, better error messaging when trying to add an interface to a node that already exists

This commit is contained in:
Blake Harnden 2020-12-15 09:34:42 -08:00
parent 4a9d16c78c
commit 4b6afe4db7
2 changed files with 19 additions and 5 deletions

View file

@ -837,7 +837,12 @@ class CoreNode(CoreNodeBase):
if net.has_custom_iface:
return net.custom_iface(self, iface_data)
else:
iface_id = self.newveth(iface_data.id, iface_data.name)
iface_id = iface_data.id
if iface_id is not None and iface_id in self.ifaces:
raise CoreError(
f"node({self.name}) already has interface({iface_id})"
)
iface_id = self.newveth(iface_id, iface_data.name)
self.attachnet(iface_id, net)
if iface_data.mac:
self.set_mac(iface_id, iface_data.mac)