Skip to content

Commit

Permalink
Check if it's a VM before running lldp related actions
Browse files Browse the repository at this point in the history
  • Loading branch information
obeone authored and clbu committed Dec 11, 2024
1 parent 0e37e6a commit e7fb233
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions netbox_agent/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def get_or_create_vlan(self, vlan_id):
def reset_vlan_on_interface(self, nic, interface):
update = False
vlan_id = nic['vlan']
lldp_vlan = self.lldp.get_switch_vlan(nic['name']) if config.network.lldp else None
lldp_vlan = self.lldp.get_switch_vlan(nic['name']) if config.network.lldp and isinstance(self, ServerNetwork) else None
# For strange reason, we need to get the object from scratch
# The object returned by pynetbox's save isn't always working (since pynetbox 6)
interface = self.nb_net.interfaces.get(id=interface.id)
Expand Down Expand Up @@ -301,7 +301,7 @@ def create_netbox_nic(self, nic, mgmt=False):
interface.save()

# cable the interface
if config.network.lldp:
if config.network.lldp and isinstance(self, ServerNetwork):
switch_ip = self.lldp.get_switch_ip(interface.name)
switch_interface = self.lldp.get_switch_port(interface.name)

Expand Down Expand Up @@ -478,7 +478,7 @@ def batched(it, n):
interface.lag = None

# cable the interface
if config.network.lldp:
if config.network.lldp and isinstance(self, ServerNetwork):
switch_ip = self.lldp.get_switch_ip(interface.name)
switch_interface = self.lldp.get_switch_port(interface.name)
if switch_ip and switch_interface:
Expand Down

0 comments on commit e7fb233

Please sign in to comment.