[Fix] Invalid network config silently fails

- Gracefully handle when a node interface is attached
  to a network that does not exist in MaaS.

Change-Id: I454016dc74a5d78bcd271ca35fda774dccd316a2
This commit is contained in:
Scott Hussey 2018-03-08 16:21:33 -06:00
parent 6e044b6b5f
commit 7fe70bd2b3
2 changed files with 17 additions and 5 deletions

View File

@ -1126,8 +1126,19 @@ class ApplyNodeNetworking(BaseMaasAction):
% (dd_net.vlan_id, n.name, % (dd_net.vlan_id, n.name,
i.device_name)) i.device_name))
link_iface = machine.interfaces.create_vlan( try:
**vlan_options) link_iface = machine.interfaces.create_vlan(
**vlan_options)
except errors.DriverError as ex:
msg = "Error creating interface: %s" % str(ex)
self.logger.info(msg)
self.task.add_status_msg(
msg=msg,
error=True,
ctx=n.name,
ctx_type='node')
self.task.failure(focus=n.name)
continue
link_options = {} link_options = {}
link_options[ link_options[

View File

@ -319,9 +319,10 @@ class Interfaces(model_base.ResourceCollectionBase):
vlan = vlans.singleton({'vid': vlan_tag}) vlan = vlans.singleton({'vid': vlan_tag})
if vlan is None: if vlan is None:
self.logger.error( msg = ("Cannot locate VLAN %s on fabric %s to attach interface" %
"Cannot locate VLAN %s on fabric %s to attach interface" % (vlan_tag, parent_iface.fabric_id))
(vlan_tag, parent_iface.fabric_id)) self.logger.warning(msg)
raise errors.DriverError(msg)
exists = self.singleton({'vlan': vlan.resource_id}) exists = self.singleton({'vlan': vlan.resource_id})