NetBox Scripts Library
A shared library of utility functions and tools for NetBox Custom Scripts.
Overview
This package provides reusable utilities for NetBox custom scripts, including:
- Email notification and validation
- URL generation for NetBox objects
- Markdown link formatting
Installation
pip install netbox_scripts_lib
Or from source:
git clone <repository-url>
cd netbox_scripts_lib
pip install .
For development:
pip install -e .
Usage
Import the utilities in your NetBox custom scripts:
from netbox_scripts_lib import prepare_and_send_email, get_markdown_link, get_object_url
from extras.scripts import Script
class MyScript(Script):
def run(self, data, commit):
# Your script logic here
results = []
status = "Failed" # or "Success"
# Send notification email on failure
prepare_and_send_email(
script=self,
subject="Script Execution Alert",
emails="admin@example.com;team@example.com",
status=status,
all_results=results
)
# Generate markdown links for NetBox objects
link = get_markdown_link(some_netbox_object)
self.log_info(f"Created: {link}")
Available Functions
prepare_and_send_email(script, subject, emails, status, all_results, sender=SENDER)
Sends email notifications for script execution. Only sends emails when status is NOT "Success" (notification-on-failure pattern).
Parameters:
script: NetBox Script instance (self)subject: Email subject lineemails: Semicolon-separated email addresses (e.g., "user1@example.com;user2@example.com")status: Script execution status (sends only if not "Success")all_results: List of result messages to include in email bodysender: Email sender address (optional, defaults to "noreply@cesnet.cz")
Returns: Status message string
is_valid_email(email)
Validates an email address using regex pattern.
Parameters:
email: Email address string
Returns: Boolean
get_object_url(object)
Generates the full URL for a NetBox object.
Parameters:
object: NetBox model instance (optional)
Returns: Full URL string or empty string if object is None
get_markdown_link(object)
Generates a markdown-formatted link for a NetBox object.
Parameters:
object: NetBox model instance (optional)
Returns: Markdown link string in format [#id name](url) or empty string if object is None
Requirements
- Django >= 3.0
- NetBox (must be run within a NetBox environment)
Building
To build a distribution package:
python setup.py sdist
Built package will be in dist/ directory.
Author
Jiri Vrany (jiri.vrany@cesnet.cz)
License
See LICENSE file for details.
Metadata
Release files for netbox-scripts-lib 0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| netbox_scripts_lib-0.3.tar.gz | 3.1 kB | Without provenance | Details for netbox_scripts_lib-0.3.tar.gz |
Release files / netbox_scripts_lib-0.3.tar.gz
| Download URL | netbox_scripts_lib-0.3.tar.gz |
|---|---|
| Size | 3.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9221542b49bdd9cf5c96383b0f71d66855ac46b4c7e9cb1bb4414ae7656fbcad
|
|
BLAKE2b-256 checksum How to use checksums |
6479d8d471d33e697678133ea1ab577226e042b1803c5239744733563a549e71
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.0
|
Security for netbox-scripts-lib 0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.