aboutsummaryrefslogtreecommitdiffstats
path: root/tools/netbox/scripts/create-switch/create-switch.py
diff options
context:
space:
mode:
authorHåkon Solbjørg <hakon@solbj.org>2023-03-06 23:27:29 +0100
committerHåkon Solbjørg <hakon@solbj.org>2023-03-06 23:42:02 +0100
commit3aff25d7f35518153987c47a8740eece30addfa6 (patch)
treed026a68f4f3be6e9cc1a8cc57cd7ace1d99dfc72 /tools/netbox/scripts/create-switch/create-switch.py
parentbd7ee18b11a4d0baca0d6f0e333474680d12a168 (diff)
feat(create-switch): Set primary ip address
Diffstat (limited to 'tools/netbox/scripts/create-switch/create-switch.py')
-rw-r--r--tools/netbox/scripts/create-switch/create-switch.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/tools/netbox/scripts/create-switch/create-switch.py b/tools/netbox/scripts/create-switch/create-switch.py
index 23b7250..36477a2 100644
--- a/tools/netbox/scripts/create-switch/create-switch.py
+++ b/tools/netbox/scripts/create-switch/create-switch.py
@@ -164,6 +164,9 @@ class CreateSwitch(Script):
)
mgmt_vlan_interface.ip_addresses.add(v4_mgmt_addr)
mgmt_vlan_interface.ip_addresses.add(v6_mgmt_addr)
+ switch.primary_ip4 = v4_mgmt_addr
+ switch.primary_ip6 = v6_mgmt_addr
+ switch.save()
num_uplinks = len(data['destination_interfaces'])
interfaces = list(Interface.objects.filter(device=switch).exclude(type=InterfaceTypeChoices.TYPE_VIRTUAL).exclude(type=InterfaceTypeChoices.TYPE_LAG))