Skip to content

Commit 09764a0

Browse files
authored
Merge pull request #81 from networktocode/develop
Release 1.3
2 parents d38343d + edb12af commit 09764a0

File tree

6 files changed

+24
-5
lines changed

6 files changed

+24
-5
lines changed

FAQ.md

+4
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,8 @@
4646

4747
> **No**, The plugin is leveraging the existing RQ Worker infrastructure already in place in NetBox, the only requirement is to ensure the plugin itself is installed in the Worker node.
4848
49+
## Why don't I see a webhook generated when a new device is onboarded successfully ?
50+
51+
> It's expected that any changes done asynchronously in NetBox currently (within a worker) will not generate a webhook.
52+
4953

development/Dockerfile

+3
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@ RUN pip install --upgrade pip\
1313
# -------------------------------------------------------------------------------------
1414
# Install NetBox
1515
# -------------------------------------------------------------------------------------
16+
# Remove redis==3.4.1 from the requirements.txt file as a workaround to #4910
17+
# https://github.com/netbox-community/netbox/issues/4910, required for version 2.8.8 and earlier
1618
RUN git clone --single-branch --branch ${netbox_ver} https://github.com/netbox-community/netbox.git /opt/netbox/ && \
1719
cd /opt/netbox/ && \
20+
sed -i '/^redis\=\=/d' /opt/netbox/requirements.txt && \
1821
pip install -r /opt/netbox/requirements.txt
1922

2023
# Make the django-debug-toolbar always visible when DEBUG is enabled,

netbox_onboarding/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
limitations under the License.
1313
"""
1414

15-
__version__ = "1.2.0"
15+
__version__ = "1.3.0"
1616

1717
from extras.plugins import PluginConfig
1818

netbox_onboarding/onboard.py

+13-2
Original file line numberDiff line numberDiff line change
@@ -552,10 +552,21 @@ def ensure_primary_ip(self):
552552
self.device.primary_ip4 = self.primary_ip
553553
self.device.save()
554554

555+
def check_if_device_already_exist(self):
556+
"""Check if a device with the same name / site already exist in the database."""
557+
try:
558+
Device.objects.get(name=self.netdev.hostname, site=self.netdev.ot.site)
559+
return True
560+
except Device.DoesNotExist:
561+
return False
562+
555563
def ensure_device(self):
556564
"""Ensure that the device represented by the DevNetKeeper exists in the NetBox system."""
557-
self.ensure_device_type()
558-
self.ensure_device_role()
565+
# Only check the device role and device type if the device do not exist already
566+
if not self.check_if_device_already_exist():
567+
self.ensure_device_type()
568+
self.ensure_device_role()
569+
559570
self.ensure_device_instance()
560571
if PLUGIN_SETTINGS["create_management_interface_if_missing"]:
561572
self.ensure_interface()

netbox_onboarding/worker.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ def onboard_device(task_id, credentials):
2929
"""Process a single OnboardingTask instance."""
3030
username = credentials.username
3131
password = credentials.password
32+
secret = credentials.secret
3233

3334
try:
3435
ot = OnboardingTask.objects.get(id=task_id)
@@ -43,7 +44,7 @@ def onboard_device(task_id, credentials):
4344
ot.status = OnboardingStatusChoices.STATUS_RUNNING
4445
ot.save()
4546

46-
netdev = NetdevKeeper(ot, username, password)
47+
netdev = NetdevKeeper(ot, username, password, secret)
4748
nbk = NetboxKeeper(netdev=netdev)
4849

4950
netdev.get_required_info()

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "ntc-netbox-plugin-onboarding"
3-
version = "1.2.0"
3+
version = "1.3.0"
44
description = "A plugin for NetBox to easily onboard new devices."
55
authors = ["Network to Code, LLC <[email protected]>"]
66
license = "Apache-2.0"

0 commit comments

Comments
 (0)