Skip to content

Commit 9a15536

Browse files
committed
Make default (fallback) management interface name and prefix length configurable
1 parent 43a1c27 commit 9a15536

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

netbox_onboarding/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ class OnboardingConfig(PluginConfig):
3333
"create_device_type_if_missing": True,
3434
"create_device_role_if_missing": True,
3535
"default_device_role": "network",
36+
"default_management_interface": "PLACEHOLDER",
37+
"default_management_prefix_length": 0,
3638
}
3739
caching_config = {}
3840

netbox_onboarding/onboard.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,11 @@ def get_platform_object_from_netbox(platform_slug):
195195

196196
return platform
197197

198-
def get_required_info(self):
198+
def get_required_info(
199+
self,
200+
default_mgmt_if=PLUGIN_SETTINGS["default_management_interface"],
201+
default_mgmt_pfxlen=PLUGIN_SETTINGS["default_management_prefix_length"],
202+
):
199203
"""Gather information from the network device that is needed to onboard the device into the NetBox system.
200204
201205
Raises:
@@ -259,7 +263,7 @@ def get_mgmt_info():
259263
for if_addr, if_addr_data in if_data["ipv4"].items():
260264
if if_addr == mgmt_ipaddr:
261265
return (if_name, if_addr_data["prefix_length"])
262-
return ("PLACEHOLDER", 0)
266+
return (default_mgmt_if, default_mgmt_pfxlen)
263267

264268
mgmt_ifname, mgmt_pflen = get_mgmt_info()
265269

0 commit comments

Comments
 (0)