Skip to content

Commit

Permalink
21 migration fix (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
arthanson authored Sep 14, 2023
1 parent ea4c4de commit 81357bf
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 18 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.1.6 (2023-09-08)

* Fix migrations NetBox 3.6.0

## 0.1.5 (2023-09-08)

* Fix for NetBox 3.6.0
Expand Down
2 changes: 1 addition & 1 deletion netbox_napalm_plugin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

__author__ = """Arthur Hanson"""
__email__ = "[email protected]"
__version__ = "0.1.5"
__version__ = "0.1.6"


from extras.plugins import PluginConfig
Expand Down
35 changes: 21 additions & 14 deletions netbox_napalm_plugin/migrations/0002_auto_20230215_1752.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,35 @@
# Generated by Django 4.1.5 on 2023-02-15 17:52

from django.db import migrations
from django.core.exceptions import FieldError


def forwards_migrate_napalm(apps, schema_editor):
Platform = apps.get_model("dcim", "Platform")
NapalmPlatformConfig = apps.get_model("netbox_napalm_plugin", "NapalmPlatformConfig")
qs = Platform.objects.all().exclude(napalm_driver__exact="")
for platform in qs:
NapalmPlatformConfig.objects.create(
platform=platform,
napalm_driver=platform.napalm_driver,
napalm_args=platform.napalm_args,
)
try:
NapalmPlatformConfig = apps.get_model("netbox_napalm_plugin", "NapalmPlatformConfig")
qs = Platform.objects.all().exclude(napalm_driver__exact="")
for platform in qs:
NapalmPlatformConfig.objects.create(
platform=platform,
napalm_driver=platform.napalm_driver,
napalm_args=platform.napalm_args,
)
except FieldError:
pass


def reverse_migrate_napalm(apps, schema_editor):
Platform = apps.get_model("dcim", "Platform")
NapalmPlatformConfig = apps.get_model("netbox_napalm_plugin", "NapalmPlatformConfig")
qs = Platform.objects.all().exclude(napalm_driver__exact="")
for platform in qs:
NapalmPlatformConfig.objects.delete(
platform=platform,
)
try:
NapalmPlatformConfig = apps.get_model("netbox_napalm_plugin", "NapalmPlatformConfig")
qs = Platform.objects.all().exclude(napalm_driver__exact="")
for platform in qs:
NapalmPlatformConfig.objects.delete(
platform=platform,
)
except FieldError:
pass


class Migration(migrations.Migration):
Expand Down
2 changes: 1 addition & 1 deletion netbox_napalm_plugin/project-static/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "netbox_napalm_plugin",
"version": "0.1.5",
"version": "0.1.6",
"description": "Napalm Plugin for NetBox",
"main": "index.js",
"author": "Arthur Hanson",
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ python =
3.8: py38, format, lint, build

[bumpversion]
current_version = 0.1.5
current_version = 0.1.6
commit = True
tag = True

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@
packages=find_packages(include=['netbox_napalm_plugin', 'netbox_napalm_plugin.*']),
test_suite='tests',
url='https://github.com/netbox-community/netbox-napalm',
version='0.1.5',
version='0.1.6',
zip_safe=False,
)

0 comments on commit 81357bf

Please sign in to comment.