Test error handling for itf creation.
This commit is contained in:
parent
b71db1af19
commit
74af9e31b6
1 changed files with 29 additions and 29 deletions
|
|
@ -291,37 +291,37 @@ class Network(object):
|
||||||
name=nic['name'], mac=nic['mac'], device=self.device.name
|
name=nic['name'], mac=nic['mac'], device=self.device.name
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
nic['vlan'] = None
|
|
||||||
|
|
||||||
|
|
||||||
if nic['vlan']:
|
if interface:
|
||||||
nb_vlan = self.get_or_create_vlan(nic['vlan'])
|
if nic['vlan']:
|
||||||
interface.mode = self.dcim_choices['interface:mode']['Tagged']
|
nb_vlan = self.get_or_create_vlan(nic['vlan'])
|
||||||
interface.tagged_vlans = [nb_vlan.id]
|
interface.mode = self.dcim_choices['interface:mode']['Tagged']
|
||||||
interface.save()
|
interface.tagged_vlans = [nb_vlan.id]
|
||||||
elif config.network.lldp and self.lldp.get_switch_vlan(nic['name']) is not None:
|
interface.save()
|
||||||
# if lldp reports a vlan on an interface, tag the interface in access and set the vlan
|
elif config.network.lldp and self.lldp.get_switch_vlan(nic['name']) is not None:
|
||||||
# report only the interface which has `pvid=yes` (ie: lldp.eth3.vlan.pvid=yes)
|
# if lldp reports a vlan on an interface, tag the interface in access and set the vlan
|
||||||
# if pvid is not present, it'll be processed as a vlan tagged interface
|
# report only the interface which has `pvid=yes` (ie: lldp.eth3.vlan.pvid=yes)
|
||||||
vlans = self.lldp.get_switch_vlan(nic['name'])
|
# if pvid is not present, it'll be processed as a vlan tagged interface
|
||||||
for vid, vlan_infos in vlans.items():
|
vlans = self.lldp.get_switch_vlan(nic['name'])
|
||||||
nb_vlan = self.get_or_create_vlan(vid)
|
for vid, vlan_infos in vlans.items():
|
||||||
if vlan_infos.get('vid'):
|
nb_vlan = self.get_or_create_vlan(vid)
|
||||||
interface.mode = self.dcim_choices['interface:mode']['Access']
|
if vlan_infos.get('vid'):
|
||||||
interface.untagged_vlan = nb_vlan.id
|
interface.mode = self.dcim_choices['interface:mode']['Access']
|
||||||
interface.save()
|
interface.untagged_vlan = nb_vlan.id
|
||||||
|
interface.save()
|
||||||
|
|
||||||
# cable the interface
|
# cable the interface
|
||||||
if config.network.lldp:
|
if config.network.lldp:
|
||||||
switch_ip = self.lldp.get_switch_ip(interface.name)
|
switch_ip = self.lldp.get_switch_ip(interface.name)
|
||||||
switch_interface = self.lldp.get_switch_port(interface.name)
|
switch_interface = self.lldp.get_switch_port(interface.name)
|
||||||
|
|
||||||
if switch_ip and switch_interface:
|
if switch_ip and switch_interface:
|
||||||
nic_update, interface = self.create_or_update_cable(
|
nic_update, interface = self.create_or_update_cable(
|
||||||
switch_ip, switch_interface, interface
|
switch_ip, switch_interface, interface
|
||||||
)
|
)
|
||||||
if nic_update:
|
if nic_update:
|
||||||
interface.save()
|
interface.save()
|
||||||
return interface
|
return interface
|
||||||
|
|
||||||
def create_or_update_netbox_ip_on_interface(self, ip, interface):
|
def create_or_update_netbox_ip_on_interface(self, ip, interface):
|
||||||
|
|
|
||||||
Loading…
Add table
editor.link_modal.header
Reference in a new issue