Metadata-Version: 2.4
Name: netboxlabs-netbox-branching
Version: 1.2.2
Summary: A git-like branching implementation for NetBox
Author-email: NetBox Labs <support@netboxlabs.com>
Maintainer-email: NetBox Labs <support@netboxlabs.com>
Project-URL: Homepage, https://github.com/netboxlabs/netbox-branching
Project-URL: Documentation, https://netboxlabs.github.io/netbox-branching/
Project-URL: Source, https://github.com/netboxlabs/netbox-branching
Project-URL: Issues, https://github.com/netboxlabs/netbox-branching/issues
Project-URL: Changelog, https://github.com/netboxlabs/netbox-branching/releases
Keywords: netbox,netbox-plugin
Classifier: Development Status :: 5 - Production/Stable
Classifier: Framework :: Django
Classifier: Framework :: Django :: 5.2
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: System Administrators
Classifier: Intended Audience :: Telecommunications Industry
Classifier: License :: Other/Proprietary License
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: System :: Networking
Requires-Python: >=3.12
Description-Content-Type: text/markdown
License-File: LICENSE.md
Provides-Extra: dev
Requires-Dist: build==1.2.2; extra == "dev"
Requires-Dist: twine==6.1.0; extra == "dev"
Provides-Extra: test
Requires-Dist: check-manifest==0.51; extra == "test"
Requires-Dist: coverage[toml]==7.6.10; extra == "test"
Provides-Extra: docs
Requires-Dist: mkdocs==1.6.1; extra == "docs"
Requires-Dist: mkdocs-material==9.7.6; extra == "docs"
Dynamic: license-file

# NetBox Branching

This [NetBox](http://netboxlabs.com/oss/netbox/) plugin introduces branching functionality. A branch is a discrete, static snapshot of the NetBox database which can be modified independently and later merged back into the main database. This enables users to make "offline" changes to objects within NetBox and avoid interfering with its integrity as the network source of truth. It also provides the opportunity to review changes in bulk prior to their application.

See the [compatibility matrix](COMPATIBILITY.md) for supported NetBox versions.

> [!TIP]
> To use NetBox Branching with NetBox Docker, click [here](./docs/netbox-docker.md)

## Installation

Brief installation instructions are provided below. For a complete installation guide, please refer to the included documentation.

1. Grant PostgreSQL permission for the NetBox database user to create schemas:

```postgresql
GRANT CREATE ON DATABASE $database TO $user;
```

2. Activate the NetBox virtual environment:

```
$ source /opt/netbox/venv/bin/activate
```

3. Install the plugin from [PyPI](https://pypi.org/project/netboxlabs-netbox-branching/):

```
$ pip install netboxlabs-netbox-branching
```

4. Add `netbox_branching` to `PLUGINS` in `configuration.py`.

```python
PLUGINS = [
    # ...
    'netbox_branching',
]
```

5. Configure the database and router in `configuration.py`:

```python
from netbox_branching.utilities import DynamicSchemaDict

DATABASES = DynamicSchemaDict({
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': 'netbox',               # Database name
        'USER': 'netbox',               # PostgreSQL username
        'PASSWORD': 'password',         # PostgreSQL password
        'HOST': 'localhost',            # Database server
        'PORT': '',                     # Database port (leave blank for default)
        'CONN_MAX_AGE': 300,            # Max database connection age
    }
})

DATABASE_ROUTERS = [
    'netbox_branching.database.BranchAwareRouter',
]
```

6. Run NetBox migrations:

```
$ ./manage.py migrate
```

## Running Tests

Plugin tests must be run from the NetBox application directory. Pass the `PYTHONPATH` environment variable to specify the `testing/` directory which holds the testing configuration.

```
cd $NETBOX_ROOT/netbox
PYTHONPATH=$PLUGIN_ROOT/testing \
NETBOX_CONFIGURATION=configuration \
python manage.py test netbox_branching.tests
```
