You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+11-6Lines changed: 11 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ This [NetBox](http://netboxlabs.com/oss/netbox/) plugin introduces branching fun
4
4
5
5
## Requirements
6
6
7
-
* NetBox v4.1 or later
7
+
* NetBox v4.3 or later
8
8
* PostgreSQL 12 or later
9
9
10
10
## Installation
@@ -38,18 +38,23 @@ PLUGINS = [
38
38
]
39
39
```
40
40
41
-
5.Create `local_settings.py` (in the same directory as `settings.py`) to override the `DATABASES` & `DATABASE_ROUTERS` settings. This enables dynamic schema support.
41
+
5.Configure the database and router in `configuration.py`:
42
42
43
43
```python
44
44
from netbox_branching.utilities import DynamicSchemaDict
45
-
from .configuration importDATABASE
46
45
47
-
# Wrap DATABASES with DynamicSchemaDict for dynamic schema support
48
46
DATABASES= DynamicSchemaDict({
49
-
'default': DATABASE,
47
+
'default': {
48
+
'ENGINE': 'django.db.backends.postgresql',
49
+
'NAME': 'netbox', # Database name
50
+
'USER': 'netbox', # PostgreSQL username
51
+
'PASSWORD': 'password', # PostgreSQL password
52
+
'HOST': 'localhost', # Database server
53
+
'PORT': '', # Database port (leave blank for default)
54
+
'CONN_MAX_AGE': 300, # Max database connection age
Copy file name to clipboardExpand all lines: docs/index.md
+39-11Lines changed: 39 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -72,19 +72,17 @@ sequenceDiagram
72
72
Branch->>Main: Merge branch
73
73
```
74
74
75
-
## Getting Started
75
+
## Plugin Installation
76
76
77
-
### Database Preparation
77
+
### 1. Database Preparation
78
78
79
79
Before installing this plugin, ensure that the PostgreSQL user as which NetBox authenticates has permission to create new schemas in the database. This can be achieved by issuing the following command in the PostgreSQL shell (substituting `$database` and `$user` with their respective values):
80
80
81
81
```postgresql
82
82
GRANT CREATE ON DATABASE $database TO $user;
83
83
```
84
84
85
-
### Plugin Installation
86
-
87
-
#### 1. Virtual Environment
85
+
### 2. Virtual Environment
88
86
89
87
The plugin can be installed from [PyPI](https://pypi.org/project/netboxlabs-netbox-branching/). First, activate the Python virtual environment used by NetBox (which is typically located at `/opt/netbox/venv/`):
You may need to modify the `source` command above if your virtual environment has been installed in a different location.
97
95
98
-
#### 2. Python Package
96
+
###3. Python Package
99
97
100
98
Use `pip` to install the Python package:
101
99
102
100
```
103
101
pip install netboxlabs-netbox-branching
104
102
```
105
103
106
-
#### 3. Enable Plugin
104
+
###4. Enable Plugin
107
105
108
106
Add `netbox_branching` to **the end** of the `PLUGINS` list in `configuration.py`.
109
107
@@ -120,12 +118,42 @@ PLUGINS = [
120
118
!!! note
121
119
If there are no plugins already installed, you might need to create this parameter. If so, be sure to define `PLUGINS` as a list _containing_ the plugin name as above, rather than just the name.
122
120
123
-
#### 4. Configuration
121
+
### 5. Configuration
122
+
123
+
#### NetBox v4.3 and Later
124
+
125
+
Wrap your `DATABASES` configuration parameter with `DynamicSchemaDict` in `configuration.py`, as shown below.
126
+
127
+
!!! note
128
+
If upgrading from an earlier version of NetBox, you may need to replace the legacy `DATABASE` (singular) parameter with `DATABASES` (plural).
129
+
130
+
```python
131
+
from netbox_branching.utilities import DynamicSchemaDict
132
+
133
+
DATABASES= DynamicSchemaDict({
134
+
'default': {
135
+
'ENGINE': 'django.db.backends.postgresql',
136
+
'NAME': 'netbox',
137
+
'USER': 'netbox',
138
+
...
139
+
}
140
+
})
141
+
```
142
+
143
+
Additionally, declare `DATABASE_ROUTERS` to employ the plugin's custom database router to support branching.
144
+
145
+
```python
146
+
DATABASE_ROUTERS= [
147
+
'netbox_branching.database.BranchAwareRouter',
148
+
]
149
+
```
124
150
125
-
This plugin employs dynamic schema resolution, which requires that we override two low-level Django settings. First, we'll wrap NetBox's configured `DATABASE` parameter with `DynamicSchemaDict` to support dynamic schemas. Second, we'll employ the plugin's custom database router.
151
+
#### NetBox v4.2 and Earlier
126
152
127
-
Create a new file named `local_settings.py` in the same directory as `settings.py`, and add the content below.
153
+
If using NetBox v4.2 or earlier, these changes must be made in `local_settings.py`, as the `DATABASES` and `DATABASE_ROUTERS` configuration parameters were not introduced until NetBox v4.3.
128
154
155
+
Create a file named `local_settings.py` in the same directory as `configuration.py`, and add the following content.
156
+
129
157
```python
130
158
from netbox_branching.utilities import DynamicSchemaDict
0 commit comments