Skip to content

Release 1.3 #81

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Aug 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,8 @@

> **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.

## Why don't I see a webhook generated when a new device is onboarded successfully ?

> It's expected that any changes done asynchronously in NetBox currently (within a worker) will not generate a webhook.


3 changes: 3 additions & 0 deletions development/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ RUN pip install --upgrade pip\
# -------------------------------------------------------------------------------------
# Install NetBox
# -------------------------------------------------------------------------------------
# Remove redis==3.4.1 from the requirements.txt file as a workaround to #4910
# https://github.com/netbox-community/netbox/issues/4910, required for version 2.8.8 and earlier
RUN git clone --single-branch --branch ${netbox_ver} https://github.com/netbox-community/netbox.git /opt/netbox/ && \
cd /opt/netbox/ && \
sed -i '/^redis\=\=/d' /opt/netbox/requirements.txt && \
pip install -r /opt/netbox/requirements.txt

# Make the django-debug-toolbar always visible when DEBUG is enabled,
Expand Down
2 changes: 1 addition & 1 deletion netbox_onboarding/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
limitations under the License.
"""

__version__ = "1.2.0"
__version__ = "1.3.0"

from extras.plugins import PluginConfig

Expand Down
15 changes: 13 additions & 2 deletions netbox_onboarding/onboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,10 +552,21 @@ def ensure_primary_ip(self):
self.device.primary_ip4 = self.primary_ip
self.device.save()

def check_if_device_already_exist(self):
"""Check if a device with the same name / site already exist in the database."""
try:
Device.objects.get(name=self.netdev.hostname, site=self.netdev.ot.site)
return True
except Device.DoesNotExist:
return False

def ensure_device(self):
"""Ensure that the device represented by the DevNetKeeper exists in the NetBox system."""
self.ensure_device_type()
self.ensure_device_role()
# Only check the device role and device type if the device do not exist already
if not self.check_if_device_already_exist():
self.ensure_device_type()
self.ensure_device_role()

self.ensure_device_instance()
if PLUGIN_SETTINGS["create_management_interface_if_missing"]:
self.ensure_interface()
Expand Down
3 changes: 2 additions & 1 deletion netbox_onboarding/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def onboard_device(task_id, credentials):
"""Process a single OnboardingTask instance."""
username = credentials.username
password = credentials.password
secret = credentials.secret

try:
ot = OnboardingTask.objects.get(id=task_id)
Expand All @@ -43,7 +44,7 @@ def onboard_device(task_id, credentials):
ot.status = OnboardingStatusChoices.STATUS_RUNNING
ot.save()

netdev = NetdevKeeper(ot, username, password)
netdev = NetdevKeeper(ot, username, password, secret)
nbk = NetboxKeeper(netdev=netdev)

netdev.get_required_info()
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "ntc-netbox-plugin-onboarding"
version = "1.2.0"
version = "1.3.0"
description = "A plugin for NetBox to easily onboard new devices."
authors = ["Network to Code, LLC <info@networktocode.com>"]
license = "Apache-2.0"
Expand Down