Skip to content

Commit 81357bf

Browse files
authored
21 migration fix (#22)
1 parent ea4c4de commit 81357bf

File tree

6 files changed

+29
-18
lines changed

6 files changed

+29
-18
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 0.1.6 (2023-09-08)
4+
5+
* Fix migrations NetBox 3.6.0
6+
37
## 0.1.5 (2023-09-08)
48

59
* Fix for NetBox 3.6.0

netbox_napalm_plugin/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
__author__ = """Arthur Hanson"""
44
__email__ = "[email protected]"
5-
__version__ = "0.1.5"
5+
__version__ = "0.1.6"
66

77

88
from extras.plugins import PluginConfig

netbox_napalm_plugin/migrations/0002_auto_20230215_1752.py

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,35 @@
11
# Generated by Django 4.1.5 on 2023-02-15 17:52
22

33
from django.db import migrations
4+
from django.core.exceptions import FieldError
45

56

67
def forwards_migrate_napalm(apps, schema_editor):
78
Platform = apps.get_model("dcim", "Platform")
8-
NapalmPlatformConfig = apps.get_model("netbox_napalm_plugin", "NapalmPlatformConfig")
9-
qs = Platform.objects.all().exclude(napalm_driver__exact="")
10-
for platform in qs:
11-
NapalmPlatformConfig.objects.create(
12-
platform=platform,
13-
napalm_driver=platform.napalm_driver,
14-
napalm_args=platform.napalm_args,
15-
)
9+
try:
10+
NapalmPlatformConfig = apps.get_model("netbox_napalm_plugin", "NapalmPlatformConfig")
11+
qs = Platform.objects.all().exclude(napalm_driver__exact="")
12+
for platform in qs:
13+
NapalmPlatformConfig.objects.create(
14+
platform=platform,
15+
napalm_driver=platform.napalm_driver,
16+
napalm_args=platform.napalm_args,
17+
)
18+
except FieldError:
19+
pass
1620

1721

1822
def reverse_migrate_napalm(apps, schema_editor):
1923
Platform = apps.get_model("dcim", "Platform")
20-
NapalmPlatformConfig = apps.get_model("netbox_napalm_plugin", "NapalmPlatformConfig")
21-
qs = Platform.objects.all().exclude(napalm_driver__exact="")
22-
for platform in qs:
23-
NapalmPlatformConfig.objects.delete(
24-
platform=platform,
25-
)
24+
try:
25+
NapalmPlatformConfig = apps.get_model("netbox_napalm_plugin", "NapalmPlatformConfig")
26+
qs = Platform.objects.all().exclude(napalm_driver__exact="")
27+
for platform in qs:
28+
NapalmPlatformConfig.objects.delete(
29+
platform=platform,
30+
)
31+
except FieldError:
32+
pass
2633

2734

2835
class Migration(migrations.Migration):

netbox_napalm_plugin/project-static/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "netbox_napalm_plugin",
3-
"version": "0.1.5",
3+
"version": "0.1.6",
44
"description": "Napalm Plugin for NetBox",
55
"main": "index.js",
66
"author": "Arthur Hanson",

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ python =
3030
3.8: py38, format, lint, build
3131

3232
[bumpversion]
33-
current_version = 0.1.5
33+
current_version = 0.1.6
3434
commit = True
3535
tag = True
3636

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@
3232
packages=find_packages(include=['netbox_napalm_plugin', 'netbox_napalm_plugin.*']),
3333
test_suite='tests',
3434
url='https://github.com/netbox-community/netbox-napalm',
35-
version='0.1.5',
35+
version='0.1.6',
3636
zip_safe=False,
3737
)

0 commit comments

Comments
 (0)