Skip to content

Commit c395860

Browse files
committed
fixes from issues #1, #2, #3, #4
1 parent 3308cac commit c395860

File tree

3 files changed

+52
-8
lines changed

3 files changed

+52
-8
lines changed

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ include README.md
55
recursive-include tests *
66
recursive-exclude * __pycache__
77
recursive-exclude * *.py[co]
8+
recursive-include netbox_napalm_plugin/templates *
89

910
recursive-include docs *.rst conf.py Makefile make.bat *.jpg *.png *.gif

README.md

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,31 +19,38 @@ The features the plugin provides should be listed here.
1919
|----------------|----------------|
2020
| 3.5 | 0.1.0 |
2121

22-
## Installing
22+
### Installation
2323

2424
For adding to a NetBox Docker setup see
2525
[the general instructions for using netbox-docker with plugins](https://github.com/netbox-community/netbox-docker/wiki/Using-Netbox-Plugins).
2626

2727
While this is still in development and not yet on pypi you can install with pip:
2828

29-
```bash
30-
pip install git+https://github.com/netbox-community/netbox-napalm
29+
```no-highlight
30+
$ source /opt/netbox/venv/bin/activate
31+
(venv) pip install git+https://github.com/netbox-community/netbox-napalm
3132
```
3233

3334
or by adding to your `local_requirements.txt` or `plugin_requirements.txt` (netbox-docker):
3435

35-
```bash
36-
git+https://github.com/netbox-community/netbox-napalm
36+
```no-highlight
37+
(venv) git+https://github.com/netbox-community/netbox-napalm
3738
```
3839

40+
### Enable the Plugin
41+
3942
Enable the plugin in `/opt/netbox/netbox/netbox/configuration.py`,
4043
or if you use netbox-docker, your `/configuration/plugins.py` file :
4144

4245
```python
4346
PLUGINS = [
44-
'Napalm'
47+
'netbox_napalm_plugin'
4548
]
4649

50+
### Configure Plugin
51+
52+
Configure the plugin in `configuration.py` under the `PLUGINS_CONFIG` parameter.
53+
4754
PLUGINS_CONFIG = {
4855
'netbox_napalm_plugin': {
4956
'NAPALM_USERNAME': 'xxx',
@@ -52,6 +59,32 @@ PLUGINS_CONFIG = {
5259
}
5360
```
5461

62+
### Run Database Migrations
63+
64+
Run the provided schema migrations:
65+
66+
```no-highlight
67+
(venv) $ cd /opt/netbox/netbox/
68+
(venv) $ python3 manage.py migrate
69+
```
70+
71+
### Collect Static Files
72+
73+
Ensure the static files are copied to the static root directory with the `collectstatic` management command:
74+
75+
```no-highlight
76+
(venv) $ cd /opt/netbox/netbox/
77+
(venv) $ python3 manage.py collectstatic
78+
```
79+
80+
### Restart WSGI Service
81+
82+
Restart the WSGI service to load the new plugin:
83+
84+
```no-highlight
85+
# sudo systemctl restart netbox
86+
```
87+
5588
## Credits
5689

5790
Based on the NetBox plugin tutorial:

netbox_napalm_plugin/migrations/0002_auto_20230215_1752.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from django.db import migrations
44

55

6-
def migrate_napalm(apps, schema_editor):
6+
def forwards_migrate_napalm(apps, schema_editor):
77
Platform = apps.get_model("dcim", "Platform")
88
NapalmPlatformConfig = apps.get_model("netbox_napalm_plugin", "NapalmPlatformConfig")
99
qs = Platform.objects.all().exclude(napalm_driver__exact="")
@@ -15,11 +15,21 @@ def migrate_napalm(apps, schema_editor):
1515
)
1616

1717

18+
def reverse_migrate_napalm(apps, schema_editor):
19+
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+
)
26+
27+
1828
class Migration(migrations.Migration):
1929
dependencies = [
2030
("netbox_napalm_plugin", "0001_initial"),
2131
]
2232

2333
operations = [
24-
migrations.RunPython(migrate_napalm),
34+
migrations.RunPython(forwards_migrate_napalm, reverse_migrate_napalm),
2535
]

0 commit comments

Comments
 (0)