Git Product home page Git Product logo

netbox_slm's Introduction

NetBox SLM

NetBox SLM is a plugin for lifecycle management of software components, including versions and installations.

PyPi Stars Badge Forks Badge Pull Requests Badge Issues Badge GitHub contributors License Badge

Known Issues

  • WARNING: This plugin is only tested with a single NetBox version at this time.
  • CSV/Bulk imports for SoftwareProduct, Version and Installation are currently broken (WIP)

Installation Guide

When using the Docker version of NetBox, first follow the netbox-docker quickstart instructions to clone the netbox-docker repo and set up the docker-compose.override.yml.

Next, follow these instructions (based on the NetBox docker variant instructions) to install the NetBox SLM plugin:

  1. Add netbox_slm to the PLUGINS list in configuration/plugins.py.

  2. Create a plugin_requirements.txt with netbox-slm as contents.

  3. Create a Dockerfile-SLM with contents:

    FROM netboxcommunity/netbox:vX.Y.Z
    
    COPY ./plugin_requirements.txt /
    RUN /opt/netbox/venv/bin/pip install --no-warn-script-location -r /plugin_requirements.txt
    
  4. Create a docker-compose.override.yml with contents:

    version: '3.7'
    services:
      netbox:
        ports:
          - 8000:8080
        build:
          context: .
          dockerfile: Dockerfile-SLM
        image: netbox:slm
      netbox-worker:
        image: netbox:slm
      netbox-housekeeping:
        image: netbox:slm
    

Now, build the image: docker compose build --no-cache

And finally, run NetBox with the SLM plugin: docker compose up

Releasing Guide

To draft a release;

update the netbox_slm/__init__.py file to reflect the new version, then from the src directory run

$ python -m build
$ twine upload dist/*

On Github.com create a similar tag and version. These steps could be automated with a github workflow.

Developer Guide (local installation)

Follow the steps below on your local system to run netbox and the netbox_slm plugin in developer mode

Setup

The goal below is to run all NetBox components in Docker and run a local NetBox Django copy with auto-reload to develop the plugin pointing to the Dockerized postgres and redis instances, basically ignoring the netbox docker runtime server.

Steps

from your projects directory clone the netbox repository

$ git clone https://github.com/netbox-community/netbox
$ cd netbox

install the virtual environment

$ pipenv shell
$ pipenv install

create and edit netbox/configuration.py (based on the template file) add these lines at the end of the file;

DEBUG = True
SECRET_KEY = 'dummy'
DEVELOPER = True
PLUGINS = [
    'netbox_slm',
]

The NetBox installation above will be used to run Django management commands like runserver, makemigrations and migrate, which will be explained in the next steps below;

from your projects directory clone the netbox-slm repository

$ git clone https://github.com/ICTU/netbox_slm
$ cd netbox_slm
$ ./start-netbox.sh

This will start NetBox locally (requires Docker) and forward the redis and postgres ports to the localhost (make sure there’s no processes using these ports or change the dockerfiles accordingly)

Note, you can also start and stop netbox by hand:

$ cd netbox-docker
$ docker-compose up -d

or stop the stack with

$ docker-compose down

to start fresh:

$ docker-compose down
$ docker volume rm netbox-docker_netbox-postgres-data  # et cetera
$ docker-compose up -d --force-recreate

this will require you to re-run the migrate commando's for netbox-slm, see further down below

Go back to the netbox configuration.py file and update the postgres and redis connection strings (username, password) to the ones the netbox docker backend is using, for example (using default user and passwords from the netbox docker example):

<<collapsed>>

# PostgreSQL database configuration. See the Django documentation for a complete list of available parameters:
#   https://docs.djangoproject.com/en/stable/ref/settings/#databases
DATABASE = {
    'NAME': 'netbox',               # Database name
    'USER': 'netbox',               # PostgreSQL username
    'PASSWORD': 'J5brHrAXFLQSif0K', # PostgreSQL password
    'HOST': 'localhost',            # Database server
    'PORT': '',                     # Database port (leave blank for default)
    'CONN_MAX_AGE': 300,            # Max database connection age
}

# Redis database settings. Redis is used for caching and for queuing background tasks such as webhook events. A separate
# configuration exists for each. Full connection details are required in both sections, and it is strongly recommended
# to use two separate database IDs.
REDIS = {
    'tasks': {
        'HOST': 'localhost',
        'PORT': 6379,
        # Comment out `HOST` and `PORT` lines and uncomment the following if using Redis Sentinel
        # 'SENTINELS': [('mysentinel.redis.example.com', 6379)],
        # 'SENTINEL_SERVICE': 'netbox',
        'PASSWORD': 'H733Kdjndks81',
        'DATABASE': 0,
        'SSL': False,
        # Set this to True to skip TLS certificate verification
        # This can expose the connection to attacks, be careful
        # 'INSECURE_SKIP_TLS_VERIFY': False,
    },
    'caching': {
        'HOST': 'localhost',
        'PORT': 6379,
        # Comment out `HOST` and `PORT` lines and uncomment the following if using Redis Sentinel
        # 'SENTINELS': [('mysentinel.redis.example.com', 6379)],
        # 'SENTINEL_SERVICE': 'netbox',
        'PASSWORD': 'H733Kdjndks81',
        'DATABASE': 1,
        'SSL': False,
        # Set this to True to skip TLS certificate verification
        # This can expose the connection to attacks, be careful
        # 'INSECURE_SKIP_TLS_VERIFY': False,
    }
}

<<collapsed>>

Now you can run commands from the netbox repository like this;

$ cd netbox/netbox
$ export PYTHONPATH=../../netbox_slm/netbox_slm/  # or with the pipenv activated run `python3 setup.py develop` from the netbox_slm directory
$ python3 manage.py migrate netbox_slm
$ python3 manage.py runserver 8001

Visit http://127.0.0.1:8001 in the browser to see the auto reloading version of the netbox UI. Port 8000 is taken by the docker ran variant.

Get in touch

Point of contact for this repository is Mart Visser, who can be reached by opening a new issue in this repository's issue tracker.

netbox_slm's People

Contributors

fniessink avatar hedde avatar wkoot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

netbox_slm's Issues

Add field 'Stored location URL' to Licenses model

I would also like to be able to specify a URL of the 'Storage Location'.

In the overview, the entered 'Storage Location' (default to "Link" if not given) should then be clickable with this URL.

Installation of netbox_slm plugin failed

Hello everyone,

I've tried to install the netbox_slm plugin. But it fails when I run bash docker-compose up -d.
I've followed the instructions on netbox_slm README.md. Moreover, I use the 1.4 version of the plugin. I have created the following files in the netbox's repository.

plugin_requirements.txt
netbox-slm

plugins.py

PLUGINS = ["netbox_slm"]

docker-compose.override.yml

version: '3.4' # This is NOT the version of NetBox! No need to adjust :)
services:
  netbox:
    image: netbox:latest-plugins
    ports:
      - 8000:8080
    build:
      context: .
      dockerfile: Dockerfile-Plugins
  netbox-worker:
    image: netbox:latest-plugins
    build:
      context: .
      dockerfile: Dockerfile-Plugins
  netbox-housekeeping:
    image: netbox:latest-plugins
    build:
      context: .
      dockerfile: Dockerfile-Plugins

Dockerfile-Plugins

FROM netboxcommunity/netbox:v3.6-2.7.0 //last version of netbox

COPY ./plugin_requirements.txt /opt/netbox/
RUN /opt/netbox/venv/bin/pip install  --no-warn-script-location -r /opt/netbox/plugin_requirements.txt

# These lines are only required if your plugin has its own static files.
COPY configuration/configuration.py /etc/netbox/config/configuration.py
COPY configuration/plugins.py /etc/netbox/config/plugins.py
RUN SECRET_KEY="dummydummydummydummydummydummydummydummydummydummy" /opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py collectstatic --no-input

The build works.
I have the following logs :

netbox-docker-netbox-1 | **ImportError: cannot import name 'DynamicModelChoiceField'** from 'utilities.forms' (/opt/netbox/netbox/utilities/forms/__init__.py)

How can I resolve this issue ?

Netbox 3.1 support

You doc says:

The Netbox SLM plugin currently only works with v3.0.9 of Netbox due to backwards incompatible changes in newer version of Netbox

What are these changes?
We are very interested in such a plugin and would like to help to update and test the plugin with Netbox 3.1 and upcoming 3.2 releases.

Error to add a license

Hello,
When I try to add a new license for a software product. I have the following message :

Server Error
A database programming error was detected while processing this request. Common causes include the following:

Database migrations missing. When upgrading to a new NetBox release, the upgrade script must be run to apply any new database migrations.
You can run migrations manually by executing python3 manage.py migrate from the command line.

Unsupported PostgreSQL version. Ensure that PostgreSQL version 12 or later is in use.
You can check this by connecting to the database using NetBox's credentials and issuing a query for SELECT VERSION().

The complete exception is provided below:
<class 'django.db.utils.ProgrammingError'>

column "stored_location_url" of relation "netbox_slm_softwarelicense" does not exist
LINE 1: ..."name", "description", "type", "stored_location", "stored_lo...
                                                             ^

Python version: 3.11.4
NetBox version: 3.6.3
Plugins: 
  netbox_dns: 0.19.3
  netbox_slm: 1.5

However, I have the correct version of Postgres and of the plugin.
I've already seen in another issue that the problem was fixed but in my case, it doesn't work.
In advance, thank you for your answer.

Allow link installation to VM Cluster

Allow to link installations on "VM Cluster" objects, like "Kubernetes Cluster".

Deployments or StateFulSets are not VM, but reside in a "VM Cluster" (Kubernetes)

Add software license to software installation

Please add the ability to register the software license used for a software installation.
Preferably, allow for the software license to be shared among installations.

License would include:

  • kind/type (e.g. GPL, CC, single payment, repeated payment)
  • expiration date that can be queried (including NULL iff not paid license)

NOTE Actual license keys should not be stored here. They should be kept in a separate secure place. A reference to that place could be included here.

SLM Under Different Navigation Field

I have Just Started Using this plugin With Netbox 3.7.5 for managing Licenses in my organisation. Everything looks good and it's a perfect fit for my needs.
I just have 2 Queries regarding this:

  1. How I can Move it to a different Navigation Field? As of now, it's coming under Plugins. Is there any way that I can move it under some different or new field?
    image

  2. When In noebox we are not logged in it Shows the Plugin tab and SLM under this. Anyway to hide this
    image

Update the Software Product Version Model

Add the following:

    release_date = models.DateField(null=True, blank=True, verbose_name="Release Date")
    end_of_support = models.DateField(null=True, blank=True, verbose_name="End of Software Support")
    documentation_url = models.URLField(blank=True, verbose_name="Documentation URL")
    long_term_support = models.BooleanField(verbose_name="Long Term Support", blank=True, null=True)
    release_type = models.BooleanField(verbose_name="Release Type", default=False)  # Options (Pre-Release, Stable, Feature, etc)
    file_checksum= models.CharField(max_length=200, blank=True, null=True)
    filename = models.CharField(max_length=50, blank=True, null=True)
    file_link = models.URLField(blank=True, verbose_name="File Link")

Tweak plugin model

Possibly get rid of Software Products Model and associate SoftwareProductVersion directly to a platform since software actually links to a platform IE it runs on top of a platform or is the platform. You could create a list view bubbling up SoftwareVersion to Platform and show software summaries.

I also recommend some rework of the model to include the below fields.

Possible models.py example

class SoftwareVersion(NetBoxModel)
    platform = models.ForeignKey(to="dcim.Platform", on_delete=models.CASCADE, verbose_name="Platform")
    version = models.CharField(max_length=50)
    alias = models.CharField(max_length=50, blank=True, null=True)
    release_date = models.DateField(null=True, blank=True, verbose_name="Release Date")
    end_of_support = models.DateField(null=True, blank=True, verbose_name="End of Software Support")
    documentation_url = models.URLField(blank=True, verbose_name="Documentation URL")
    long_term_support = models.BooleanField(verbose_name="Long Term Support", blank=True, null=True)
    release_type = models.BooleanField(verbose_name="Release Type", default=False)  # Options (Pre-Release, Stable, Feature, etc)
    file_checksum= models.CharField(max_length=200, blank=True, null=True)
    filename = models.CharField(max_length=50, blank=True, null=True)
    file_link = models.URLField(blank=True, verbose_name="File Link")

This would allow for something more similar to:

Make plugin compatible with Netbox release v3.5.x

Currently, the plugin has only been tested against release v3.4. I am currently running it successfully on 3.4.10.

When trying to run it on 3.5.7, it fails to start with the following error:
ImportError: cannot import name 'DynamicModelChoiceField' from 'utilities.forms' (/opt/netbox/netbox/utilities/forms/__init__.py)

Fix CSV/Bulk imports for SLM models

It seems relationships can only be imported based on their numeral primary key (which might makes sense as the name does not currently have a unique constraint)

Add Fields for user assigned/limited licenses

I'd like to store some more information about some licenses
for example a confluence Server License:
number of licensed Users
users currently assigned
as comment: users get there license via ldap group synchronization

or for example volumelicenses:
number of licenses
users currently holding these licenses
as comment: where to find the installer

Expand the plugin to track all life cycle

The plugin to compare this to would be Nautbot's Device Lifecycle Mgmt

It would be nice to eventually expand to hardware life cycle items. I am raising this feature request for debate. I think we should button up the software lifecycle before expanding to include hardware, but I wanted to get this idea out sooner rather than later. Something like this makes sense:

class HardwareLM:

    # Set model columns
    device_type = models.ForeignKey(
        to="dcim.DeviceType",
        on_delete=models.CASCADE,
        verbose_name="Device Type",
        blank=True,
        null=True,
    )
    module_type = models.ForeignKey(
        to="dcim.ModuleType",
        on_delete=models.CASCADE,
        verbose_name="Module Type",
        blank=True,
        null=True,
    )
   
    inventory_item = models.CharField(verbose_name="Inventory Item Part", max_length=255, blank=True, null=True)
    release_date = models.DateField(null=True, blank=True, verbose_name="Release Date")
    end_of_sale = models.DateField(null=True, blank=True, verbose_name="End of Sale")
    end_of_support = models.DateField(null=True, blank=True, verbose_name="End of Support")
    end_of_sw_releases = models.DateField(null=True, blank=True, verbose_name="End of Software Releases")
    end_of_security_patches = models.DateField(null=True, blank=True, verbose_name="End of Security Patches")
    documentation_url = models.URLField(blank=True, verbose_name="Documentation URL")
    comments = models.TextField(null=True, blank=True, verbose_name="Comments")

API Call to softwareproductinstallations show json invalid error

<class 'TypeError'>

Object of type SoftwareProductInstallation is not JSON serializable

Python version: 3.10.6
NetBox version: 3.4.5
SLM version: 1.2

Error Log

Internal Server Error: /api/plugins/slm/softwareproductinstallations/
Traceback (most recent call last):
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 56, in inner
    response = get_response(request)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/handlers/base.py", line 220, in _get_response
    response = response.render()
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/template/response.py", line 114, in render
    self.content = self.rendered_content
  File "/opt/netbox/venv/lib/python3.10/site-packages/rest_framework/response.py", line 70, in rendered_content
    ret = renderer.render(self.data, accepted_media_type, context)
  File "/opt/netbox/venv/lib/python3.10/site-packages/rest_framework/renderers.py", line 723, in render
    context = self.get_context(data, accepted_media_type, renderer_context)
  File "/opt/netbox/venv/lib/python3.10/site-packages/rest_framework/renderers.py", line 679, in get_context
    'content': self.get_content(renderer, data, accepted_media_type, renderer_context),
  File "/opt/netbox/venv/lib/python3.10/site-packages/rest_framework/renderers.py", line 412, in get_content
    content = renderer.render(data, accepted_media_type, renderer_context)
  File "/opt/netbox/venv/lib/python3.10/site-packages/rest_framework/renderers.py", line 99, in render
    ret = json.dumps(
  File "/opt/netbox/venv/lib/python3.10/site-packages/rest_framework/utils/json.py", line 25, in dumps
    return json.dumps(*args, **kwargs)
  File "/usr/lib/python3.10/json/__init__.py", line 238, in dumps
    **kw).encode(obj)
  File "/usr/lib/python3.10/json/encoder.py", line 201, in encode
    chunks = list(chunks)
  File "/usr/lib/python3.10/json/encoder.py", line 431, in _iterencode
    yield from _iterencode_dict(o, _current_indent_level)
  File "/usr/lib/python3.10/json/encoder.py", line 405, in _iterencode_dict
    yield from chunks
  File "/usr/lib/python3.10/json/encoder.py", line 325, in _iterencode_list
    yield from chunks
  File "/usr/lib/python3.10/json/encoder.py", line 405, in _iterencode_dict
    yield from chunks
  File "/usr/lib/python3.10/json/encoder.py", line 438, in _iterencode
    o = _default(o)
  File "/opt/netbox/venv/lib/python3.10/site-packages/rest_framework/utils/encoders.py", line 67, in default
    return super().default(obj)
  File "/usr/lib/python3.10/json/encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type SoftwareProductInstallation is not JSON serializable

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.