diff options
author | Håkon Solbjørg <hakon@solbj.org> | 2023-03-29 22:38:05 +0200 |
---|---|---|
committer | Håkon Solbjørg <hakon@solbj.org> | 2023-03-29 22:38:05 +0200 |
commit | bfa92e35d394d30ffaaa3fe0d518c988e0ea931b (patch) | |
tree | b753c7758765f7cd6cf490af6e47210581191add /tools/netbox/scripts/netbox2gondul/netbox2gondul.py | |
parent | 0e06fd72696e711567f0af4ef4be9aa813f2f92e (diff) |
feat(netbox2gondul): Send traffic VLAN if one exists
Diffstat (limited to 'tools/netbox/scripts/netbox2gondul/netbox2gondul.py')
-rw-r--r-- | tools/netbox/scripts/netbox2gondul/netbox2gondul.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/tools/netbox/scripts/netbox2gondul/netbox2gondul.py b/tools/netbox/scripts/netbox2gondul/netbox2gondul.py index 26cda4b..833a35a 100644 --- a/tools/netbox/scripts/netbox2gondul/netbox2gondul.py +++ b/tools/netbox/scripts/netbox2gondul/netbox2gondul.py @@ -156,9 +156,19 @@ class Netbox2Gondul(Script): self.log_info(f'Overriding management vlan name with: {override} (was: {mgmt_vlan_name})') mgmt_vlan_name = override + traffic_vlan_name = None + try: + traffic_vlan = VLAN.objects.get(name=device.name) + traffic_prefix_v4 = Prefix.objects.get(vlan=traffic_vlan, family=4) + traffic_prefix_v6 = Prefix.objects.get(vlan=traffic_vlan, family=6) + + self.network_to_gondul(traffic_vlan, traffic_prefix_v4, traffic_prefix_v6) + except VLAN.DoesNotExist: + pass + switches = [{ # "community": "", # Not implemented - "tags": list(device.tags.all()), + "tags": [tag.slug for tag in list(device.tags.all())], "distro_name": distro.name, "distro_phy_port": distro_interface.name, # TODO: always .0 ? "mgmt_v4_addr": str(device.primary_ip4.address.ip) if device.primary_ip4 is not None else None, @@ -167,7 +177,7 @@ class Netbox2Gondul(Script): # "placement": "", # Not implemented # "poll_frequency": "", # Not implemented "sysname": device.name, - # "traffic_vlan": "", # Not implemented + "traffic_vlan": traffic_vlan_name, # Not implemented # "deleted": False, # Not implemented }] |