Skip to content

Commit

Permalink
Merge pull request #2 from menckend/main
Browse files Browse the repository at this point in the history
Rebasing dev
  • Loading branch information
menckend authored Oct 25, 2024
2 parents 97cb35e + 53d77cf commit 7335b6d
Show file tree
Hide file tree
Showing 2,523 changed files with 547,668 additions and 71 deletions.
31 changes: 23 additions & 8 deletions .github/workflows/mkdocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,28 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Sphinx Builder
uses: Kjuly/[email protected]
with:
source_root: 'docs'
build_root: 'build'
default_lang: 'en'
lang_mappings: ''
- name: Build Docs With Sphinx
shell: bash
run: |
SOURCE_ROOT='docs'
BUILD_ROOT='build'
sudo apt-get install -y graphviz
pip install -U sphinx
# Install extra dependencies if the requirements.txt file exits.
requirements_file="$SOURCE_ROOT/requirements.txt"
if [ -f "$requirements_file" ]; then
printf 'Install dependencies with %s ...', "$requirements_file"
pip install -r "$requirements_file"
fi
config_base_file="$SOURCE_ROOT/conf.py"
# Input & output dirs.
input_dir="$SOURCE_ROOT/"
output_dir="$BUILD_ROOT"
# Sphinx config file
config_file="$input_dir/conf.py"
# Build with Sphinx
printf "\n# Start building for %s ..\n"
sphinx-build -M html "$input_dir" "$output_dir"
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Upload Pages Artifact
Expand All @@ -37,4 +52,4 @@ jobs:
path: '${{ github.workspace }}/build/html'
- name: deployment
id: deployment
uses: actions/deploy-pages@v4
uses: actions/deploy-pages@v4
5 changes: 1 addition & 4 deletions .github/workflows/publish-pypi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,7 @@ jobs:
name: python-package-distributions
path: dist/
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://pypi.org/p/

uses: pypa/gh-action-pypi-publish@release/v1
publish-to-pypi-test:
if: contains(github.ref, '/tags/') && contains(github.event.base_ref, 'test')
environment:
Expand Down
17 changes: 3 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Netbox plugin for pulling runstate (config and topology) from Arista switches an
## Features

* Creates a new model/table for storing the DNS names of your GNS3 servers. [("Boring, Sidney; borrring, borrrrrrring"](https://youtu.be/ieqxmg4pmZo?si=rXJtimC0e0_QpEp7&t=147), I know.)

* Provides a screen/page that prompts you to:
* Select a GNS3 server and as few or as many Arista switches as you want from your devices table.
* Enter a set of Arista EOS credentials
Expand All @@ -22,11 +23,8 @@ Netbox plugin for pulling runstate (config and topology) from Arista switches an
* Running the same cEOS version as the switch that it is emulating (if you have a matching Docker template installed on your GNS3 server)
* Happy to run as an EVPN/VXLAN fabric, if that's your bag. (There's some per-VRF/network-namespace ipfilters tweaking that may still need to be cleared up.)
* Has "links" provisioned in the vlab, **mirroring the inter-switch links of the "live" switches you're modeling** (detected when inspecting th LLDP tables of the switches)

* Returns a URL ![image](./images/ptov-pic2.png)



* ...at which you can access the virtual-lab you just created. ![image](./images/ptov-pic3.png)


Expand All @@ -36,7 +34,7 @@ Change modeling, obviously. Invasive troubleshooting of pesky routing issues th

## Under the hood

* All of the heavy lifting is done by the [dcnodatg package](https://menckend.github.io/dcnodatg)
All of the heavy lifting is done by the [dcnodatg package](https://menckend.github.io/dcnodatg)

## Compatibility

Expand Down Expand Up @@ -70,15 +68,6 @@ PLUGINS = [
]

PLUGINS_CONFIG = {
"netbox_ptov": {},
"netbox_ptov": {'top_level_menu': False},
}
```

## Credits

Based on the NetBox plugin tutorial:

- [demo repository](https://github.com/netbox-community/netbox-plugin-demo)
- [tutorial](https://github.com/netbox-community/netbox-plugin-tutorial)

This package was created with [Cookiecutter](https://github.com/audreyr/cookiecutter) and the [`netbox-community/cookiecutter-netbox-plugin`](https://github.com/netbox-community/cookiecutter-netbox-plugin) project template.
86 changes: 46 additions & 40 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@
import os
import sys

sys.path.insert(0, os.path.abspath('../external_sources/django/'))
sys.path.insert(0, os.path.abspath('../external_sources/dcnodatg/'))
sys.path.insert(0, os.path.abspath('../images/'))
sys.path.insert(0, os.path.realpath(os.path.dirname(__file__)))
sys.path.insert(0, os.path.abspath('../external_sources/netbox/'))
sys.path.insert(0, os.path.abspath('../netbox_ptov/'))

#sys.path.insert(0, os.path.abspath('./external_sources/django/'))
#sys.path.insert(0, os.path.abspath('./external_sources/dcnodatg/'))
#sys.path.insert(0, os.path.abspath('../images/'))
#sys.path.insert(0, os.path.abspath('./external_sources/netbox/'))
#sys.path.insert(0, os.path.abspath('../netbox_ptov/'))

# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
Expand All @@ -20,54 +23,56 @@
author = 'Mencken Davidson'

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
source_suffix = [".rst", ".md"]
templates_path = ['_templates']
exclude_patterns = ['_build', '_templates', 'Thumbs.db', '.DS_Store']
html_show_sourcelink = False # Remove 'view source code' from top of page (for html, not python)
html_theme = 'sphinx_rtd_theme'
html_css_files = [
"css/custom.css",
]
html_static_path = ['_static']

# -- Extensions to use ---------------------------------------------------
extensions = [
'sphinx.ext.napoleon',
'autoapi.extension',
'myst_parser',
'sphinx.ext.autodoc', # Core Sphinx library for auto html doc generation from docstrings
'sphinx.ext.autodoc.typehints',
'sphinx.ext.autosummary', # Create neat summary tables for modules/classes/methods etc
'sphinx.ext.intersphinx', # Link to other project's documentation (see mapping below)
'sphinx.ext.napoleon',
'sphinx.ext.viewcode', # Add a link to the Python source code for classes, functions etc.
'sphinx_autodoc_typehints', # Automatically document param types (less noise in class signature)
'autoapi.extension',
'sphinx.ext.inheritance_diagram'
]

source_suffix = [".rst", ".md"]
templates_path = ['_templates']
exclude_patterns = ['_build', '_templates', 'Thumbs.db', '.DS_Store']
html_show_sourcelink = False # Remove 'view source code' from top of page (for html, not python)
html_theme = 'sphinx_rtd_theme'
autodoc_typehints = "signature"
# -- Autoapi extension configuraiton ---------------------------------------------------
autodoc_typehints = "description"
autoapi_template_dir = "_templates/autoapi"
#autodoc_class_signature = "separated"
autoapi_own_page_level = "function"
autoapi_dirs = ['../netbox_ptov/', '../external_sources/netbox/']
autoapi_own_page_level = "module"
autoapi_dirs = ['../netbox_ptov/']
autoapi_type = "python"
autoapi_options = [
"members",
"undoc-members",
"show-inheritance",
"show-module-summary",
"imported-members",
"show-inheritance-diagram",
]

html_css_files = [
"css/custom.css",
]

#on_rtd = os.environ.get("READTHEDOCS", None) == "True"
#if not on_rtd: # only import and set the theme if we're building docs locally
# import sphinx_rtd_theme
# html_theme = "sphinx_rtd_theme"
# html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
#html_css_files = ["readthedocs-custom.css"] # Override some CSS settings

# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_static_path = ['_static']
#--RTD theme configuration ----------------------------------------------------------------------------
html_theme_options = {
# Toc options
'collapse_navigation': True,
'sticky_navigation': True,
'navigation_depth': -1,
'includehidden': True,
'titles_only': False
}

#--Napoleon extnesion ocnfiguration ------------------------------------------------------
napoleon_google_docstring = True
napoleon_numpy_docstring = True
napoleon_include_init_with_doc = True
Expand All @@ -83,20 +88,21 @@
napoleon_type_aliases = None
napoleon_attr_annotations = True

#--Functions ----------------------------------------------------------------------------
def contains(seq, item):
return item in seq

def prepare_jinja_env(jinja_env) -> None:
jinja_env.tests["contains"] = contains

autoapi_prepare_jinja_env = prepare_jinja_env
def linkcode_resolve(domain, info):
if domain != 'py':
return None
if not info['module']:
return None
filename = info['module'].replace('.', '/')
return "https://github.com/netbox-community/netbox/%s.py" % filename




html_theme_options = {
# Toc options
'collapse_navigation': True,
'sticky_navigation': True,
'navigation_depth': 4,
'includehidden': True,
'titles_only': False
}
24 changes: 24 additions & 0 deletions docs/external_sources/django/django/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from django.utils.version import get_version

VERSION = (5, 1, 3, "alpha", 0)

__version__ = get_version(VERSION)


def setup(set_prefix=True):
"""
Configure the settings (this happens as a side effect of accessing the
first setting), configure logging and populate the app registry.
Set the thread-local urlresolvers script prefix if `set_prefix` is True.
"""
from django.apps import apps
from django.conf import settings
from django.urls import set_script_prefix
from django.utils.log import configure_logging

configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
if set_prefix:
set_script_prefix(
"/" if settings.FORCE_SCRIPT_NAME is None else settings.FORCE_SCRIPT_NAME
)
apps.populate(settings.INSTALLED_APPS)
10 changes: 10 additions & 0 deletions docs/external_sources/django/django/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"""
Invokes django-admin when the django module is run as a script.
Example: python -m django check
"""

from django.core import management

if __name__ == "__main__":
management.execute_from_command_line()
4 changes: 4 additions & 0 deletions docs/external_sources/django/django/apps/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from .config import AppConfig
from .registry import apps

__all__ = ["AppConfig", "apps"]
Loading

0 comments on commit 7335b6d

Please sign in to comment.