netbox-docker-plugin


Namenetbox-docker-plugin JSON
Version 3.1.0 PyPI version JSON
download
home_pageNone
SummaryManage Docker with Netbox & style.
upload_time2024-10-21 14:53:15
maintainerNone
docs_urlNone
authorNone
requires_python>=3.11
licenseNone
keywords netbox netbox-plugin docker
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Netbox Docker Plugin

[![Testing Report](https://github.com/SaaShup/netbox-docker-plugin/actions/workflows/main_ci.yml/badge.svg)](https://github.com/SaaShup/netbox-docker-plugin/actions/workflows/main_ci.yml)

Manage Docker with Netbox & style. Made to work with [netbox-docker-agent](https://github.com/SaaShup/netbox-docker-agent).

![UI Container view with dependencies](/docs/assets/screenshot.png)

## How does it work?

```mermaid
sequenceDiagram
    Netbox->>Agent: Change (Webhook)
    Agent->>Docker API: Request (HTTP)
    Docker API->>Agent: Response (HTTP)
    Agent->>Netbox: Feedback (Callback)
```

Once the plugin and webhooks are installed, you can:

1. Create hosts that point to
   [agents](https://github.com/SaaShup/netbox-docker-agent) you had installed
2. Retrieve informations from Docker API with the help of the agent
3. Create containers on host with an image, expose ports, add env variables and
   labels, mount volumes, set networks.
4. Manage the container status, start, stop, restart.

## Installation

Below the compatibility list of the Netbox Docker PLugin and Netbox. Please chose the right version of the plugin depending of the Netbox version you use:

| Netbox Version | Netbox Docker Plugin Version |
| -------------- | ---------------------------- |
| 3.\*           | 1.\*                         |
| 4.0.\*         | 2.\*                         |
| 4.1.\*         | 3.\*                         |

You can follow [the official plugins installation
instructions](https://docs.netbox.dev/en/stable/plugins/#installing-plugins).

If needed, source your Netbox's virtual environment and install the plugin like
a package. We assume [you have already installed
Netbox](https://docs.netbox.dev/en/stable/installation/) and its source code are
in `/opt/netbox`:

```bash
cd /opt/netbox
python3 -m venv venv # if virtual env was not created before
source /opt/netbox/venv/bin/activate
pip install netbox-docker-plugin
```

Enable the plugin in the `/opt/netbox/netbox/netbox/configuration.py` file:

```python
PLUGINS = [
    'netbox_docker_plugin',
]
```

Then, run migrations:

```bash
cd /opt/netbox
python3 netbox/manage.py migrate
```

> [!IMPORTANT]
> In order to the communication between your Netbox instance and [the Agent](https://github.com/SaaShup/netbox-docker-agent)
> works, the plugin will check if webhooks to agents are
> presents on each migration phase.
> If not, then the plugin will automatically install webhooks configuration in
> your Netbox instance.

### Alternative

Another way to install Netbox is to use the [Official netbox-docker
project](https://github.com/netbox-community/netbox-docker).

With this alternate way, you can [customize your Netbox image](https://github.com/netbox-community/netbox-docker/wiki/Using-Netbox-Plugins) and migrations will be
automatically execute each time you restart the container.

## Contribute

### Install our development environment

Requirements:
* Python 3.11
* PostgreSQL 15 [Official Netbox doc](https://github.com/netbox-community/netbox/blob/master/docs/installation/1-postgresql.md)
  - user: netbox (with database creation right)
  - password: secret
  - database: netbox
  - port: 5432
* Redis 7.2
  - port: 6379

Set a PROJECT variable :

```
PROJECT="/project/netbox"
```

Create a project directory `$PROJECT`:

```bash
mkdir $PROJECT
```

Go inside your project directory, clone this repository and the Netbox repository:

```bash
cd $PROJECT
git clone git@github.com:SaaShup/netbox-docker-plugin.git
git clone git@github.com:netbox-community/netbox.git
```

Create your venv and activate it:

```bash
python -m venv venv
source venv/bin/activate
```

Install netbox-docker-plugin dependencies:

```bash
cd $PROJECT/netbox-docker-plugin
pip install -e .
```

Configure Netbox and install Netbox dependencies:

```bash
cd $PROJECT/netbox
cp $PROJECT/netbox-docker-plugin/netbox_configuration/configuration_dev.py $PROJECT/netbox/netbox/netbox/configuration.py
pip install -r requirements.txt
```

Run database migrations:

```bash
cd $PROJECT/netbox
python3 netbox/manage.py migrate
```

Create a Netbox super user:

```bash
cd $PROJECT/netbox
python3 netbox/manage.py createsuperuser
```

Start Netbox instance:

```bash
cd $PROJECT/netbox
python3 netbox/manage.py runserver 0.0.0.0:8000 --insecure
```

Visit http://localhost:8000/

### Run tests

After installing your development environment, you can run the tests plugin
(you don't need to start the Netbox instance):

```bash
cd $PROJECT/netbox
python3 -m pip install requests_mock
python3 netbox/manage.py test netbox_docker_plugin.tests --keepdb -v 2
```

With code coverage, install [coverage.py](https://coverage.readthedocs.io/en/7.3.2/) and use it:

```bash
cd $PROJECT/netbox
python3 -m pip install coverage
```

Then run the test with coverage.py and print the report:

```bash
cd $PROJECT/netbox
coverage run --include='*/netbox_docker_plugin/*' netbox/manage.py test netbox_docker_plugin.tests --keepdb -v 2
coverage report -m
```

# Hosting

Check https://saashup.com for more information.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "netbox-docker-plugin",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.11",
    "maintainer_email": null,
    "keywords": "netbox, netbox-plugin, docker",
    "author": null,
    "author_email": "Vincent Simonin <vincent@saashup.com>, David Delassus <david.jose.delassus@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/aa/1f/9b37737d1aa217d40d8eee54a55a6de4557e9d3a7ca8940074199fbe4426/netbox_docker_plugin-3.1.0.tar.gz",
    "platform": null,
    "description": "# Netbox Docker Plugin\n\n[![Testing Report](https://github.com/SaaShup/netbox-docker-plugin/actions/workflows/main_ci.yml/badge.svg)](https://github.com/SaaShup/netbox-docker-plugin/actions/workflows/main_ci.yml)\n\nManage Docker with Netbox & style. Made to work with [netbox-docker-agent](https://github.com/SaaShup/netbox-docker-agent).\n\n![UI Container view with dependencies](/docs/assets/screenshot.png)\n\n## How does it work?\n\n```mermaid\nsequenceDiagram\n    Netbox->>Agent: Change (Webhook)\n    Agent->>Docker API: Request (HTTP)\n    Docker API->>Agent: Response (HTTP)\n    Agent->>Netbox: Feedback (Callback)\n```\n\nOnce the plugin and webhooks are installed, you can:\n\n1. Create hosts that point to\n   [agents](https://github.com/SaaShup/netbox-docker-agent) you had installed\n2. Retrieve informations from Docker API with the help of the agent\n3. Create containers on host with an image, expose ports, add env variables and\n   labels, mount volumes, set networks.\n4. Manage the container status, start, stop, restart.\n\n## Installation\n\nBelow the compatibility list of the Netbox Docker PLugin and Netbox. Please chose the right version of the plugin depending of the Netbox version you use:\n\n| Netbox Version | Netbox Docker Plugin Version |\n| -------------- | ---------------------------- |\n| 3.\\*           | 1.\\*                         |\n| 4.0.\\*         | 2.\\*                         |\n| 4.1.\\*         | 3.\\*                         |\n\nYou can follow [the official plugins installation\ninstructions](https://docs.netbox.dev/en/stable/plugins/#installing-plugins).\n\nIf needed, source your Netbox's virtual environment and install the plugin like\na package. We assume [you have already installed\nNetbox](https://docs.netbox.dev/en/stable/installation/) and its source code are\nin `/opt/netbox`:\n\n```bash\ncd /opt/netbox\npython3 -m venv venv # if virtual env was not created before\nsource /opt/netbox/venv/bin/activate\npip install netbox-docker-plugin\n```\n\nEnable the plugin in the `/opt/netbox/netbox/netbox/configuration.py` file:\n\n```python\nPLUGINS = [\n    'netbox_docker_plugin',\n]\n```\n\nThen, run migrations:\n\n```bash\ncd /opt/netbox\npython3 netbox/manage.py migrate\n```\n\n> [!IMPORTANT]\n> In order to the communication between your Netbox instance and [the Agent](https://github.com/SaaShup/netbox-docker-agent)\n> works, the plugin will check if webhooks to agents are\n> presents on each migration phase.\n> If not, then the plugin will automatically install webhooks configuration in\n> your Netbox instance.\n\n### Alternative\n\nAnother way to install Netbox is to use the [Official netbox-docker\nproject](https://github.com/netbox-community/netbox-docker).\n\nWith this alternate way, you can [customize your Netbox image](https://github.com/netbox-community/netbox-docker/wiki/Using-Netbox-Plugins) and migrations will be\nautomatically execute each time you restart the container.\n\n## Contribute\n\n### Install our development environment\n\nRequirements:\n* Python 3.11\n* PostgreSQL 15 [Official Netbox doc](https://github.com/netbox-community/netbox/blob/master/docs/installation/1-postgresql.md)\n  - user: netbox (with database creation right)\n  - password: secret\n  - database: netbox\n  - port: 5432\n* Redis 7.2\n  - port: 6379\n\nSet a PROJECT variable :\n\n```\nPROJECT=\"/project/netbox\"\n```\n\nCreate a project directory `$PROJECT`:\n\n```bash\nmkdir $PROJECT\n```\n\nGo inside your project directory, clone this repository and the Netbox repository:\n\n```bash\ncd $PROJECT\ngit clone git@github.com:SaaShup/netbox-docker-plugin.git\ngit clone git@github.com:netbox-community/netbox.git\n```\n\nCreate your venv and activate it:\n\n```bash\npython -m venv venv\nsource venv/bin/activate\n```\n\nInstall netbox-docker-plugin dependencies:\n\n```bash\ncd $PROJECT/netbox-docker-plugin\npip install -e .\n```\n\nConfigure Netbox and install Netbox dependencies:\n\n```bash\ncd $PROJECT/netbox\ncp $PROJECT/netbox-docker-plugin/netbox_configuration/configuration_dev.py $PROJECT/netbox/netbox/netbox/configuration.py\npip install -r requirements.txt\n```\n\nRun database migrations:\n\n```bash\ncd $PROJECT/netbox\npython3 netbox/manage.py migrate\n```\n\nCreate a Netbox super user:\n\n```bash\ncd $PROJECT/netbox\npython3 netbox/manage.py createsuperuser\n```\n\nStart Netbox instance:\n\n```bash\ncd $PROJECT/netbox\npython3 netbox/manage.py runserver 0.0.0.0:8000 --insecure\n```\n\nVisit http://localhost:8000/\n\n### Run tests\n\nAfter installing your development environment, you can run the tests plugin\n(you don't need to start the Netbox instance):\n\n```bash\ncd $PROJECT/netbox\npython3 -m pip install requests_mock\npython3 netbox/manage.py test netbox_docker_plugin.tests --keepdb -v 2\n```\n\nWith code coverage, install [coverage.py](https://coverage.readthedocs.io/en/7.3.2/) and use it:\n\n```bash\ncd $PROJECT/netbox\npython3 -m pip install coverage\n```\n\nThen run the test with coverage.py and print the report:\n\n```bash\ncd $PROJECT/netbox\ncoverage run --include='*/netbox_docker_plugin/*' netbox/manage.py test netbox_docker_plugin.tests --keepdb -v 2\ncoverage report -m\n```\n\n# Hosting\n\nCheck https://saashup.com for more information.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Manage Docker with Netbox & style.",
    "version": "3.1.0",
    "project_urls": {
        "Bug Tracker": "https://github.com/SaaShup/netbox-docker-plugin/issues",
        "Homepage": "https://github.com/SaaShup/netbox-docker-plugin"
    },
    "split_keywords": [
        "netbox",
        " netbox-plugin",
        " docker"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ff0ad3409cd0e404bce3896db0fabe6dd175f49fa749deb03211b176cb4fc476",
                "md5": "0645d86aef829680dacb94fdae5edbb7",
                "sha256": "d647919f7034a3cecfe7a0322a473a179aa30f4b878163a03a3cbc56356bb042"
            },
            "downloads": -1,
            "filename": "netbox_docker_plugin-3.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0645d86aef829680dacb94fdae5edbb7",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11",
            "size": 98215,
            "upload_time": "2024-10-21T14:53:13",
            "upload_time_iso_8601": "2024-10-21T14:53:13.894017Z",
            "url": "https://files.pythonhosted.org/packages/ff/0a/d3409cd0e404bce3896db0fabe6dd175f49fa749deb03211b176cb4fc476/netbox_docker_plugin-3.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "aa1f9b37737d1aa217d40d8eee54a55a6de4557e9d3a7ca8940074199fbe4426",
                "md5": "968f10c847706dfca5aa329838eb3554",
                "sha256": "4a79076ba89c97862ef9f939e01cf3517290346c332f3d9f6acb17a238cef3dd"
            },
            "downloads": -1,
            "filename": "netbox_docker_plugin-3.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "968f10c847706dfca5aa329838eb3554",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11",
            "size": 47621,
            "upload_time": "2024-10-21T14:53:15",
            "upload_time_iso_8601": "2024-10-21T14:53:15.299146Z",
            "url": "https://files.pythonhosted.org/packages/aa/1f/9b37737d1aa217d40d8eee54a55a6de4557e9d3a7ca8940074199fbe4426/netbox_docker_plugin-3.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-21 14:53:15",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "SaaShup",
    "github_project": "netbox-docker-plugin",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "netbox-docker-plugin"
}
        
Elapsed time: 0.34853s