Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature delices v2 #146

Merged
merged 150 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
150 commits
Select commit Hold shift + click to select a range
f288516
refactor: Removed unused debugging statement
abates Jul 28, 2023
2c7c1a4
feat: Initial design models
abates Jul 28, 2023
c1221e1
Merge branch 'develop' into feature_delices
abates Jul 31, 2023
51c4306
style: Black formatting
abates Jul 31, 2023
24a473a
refactor: Updates based on feedback
abates Jul 31, 2023
63c306c
Merge branch 'develop' into feature_delices
abates Aug 17, 2023
a23177f
feat: implements views (#64)
Kircheneer Aug 17, 2023
1b99087
refactor: Initial rename of `design_builder` to `nautobot_design_buil…
abates Aug 28, 2023
4affd35
refactor: Renamed `base.py` to `design_job.py`
abates Aug 28, 2023
39fc040
docs: Updated remarks and documentation
abates Aug 28, 2023
5f84072
docs: Updated documentation
abates Aug 28, 2023
88b2cdb
fix: Corrected dry run/commit logic
abates Aug 28, 2023
3562b9a
style:
abates Aug 28, 2023
ae13e5c
refactor: Changed type hinting for `BaseModel`
abates Aug 28, 2023
004aa71
refactor: Moved example designs and updated documentation
abates Aug 29, 2023
b256ffa
docs: Updated design development documentation
abates Aug 29, 2023
28e2766
style: Removed unused import
abates Aug 29, 2023
feb11a1
docs: Updated documentation for example designs
abates Aug 29, 2023
a2f56e3
style: Formatting
abates Aug 29, 2023
b58b462
ci: Fixed invoke env variables
abates Aug 29, 2023
e4b7e57
docs: Updated pydocs
abates Aug 29, 2023
4e3738c
fix: Removed the `indent` block tag from the jinja module.
abates Aug 29, 2023
f7182aa
refactor: Removed duplicate unittest
abates Aug 29, 2023
0351087
fix: Commit/rollback functionality
abates Aug 29, 2023
0a5dea7
refactor: Updated context code to use collections base classes
abates Sep 5, 2023
fc0ca43
fix: Fixed extra slash in volume mounts
abates Sep 5, 2023
84cdc70
docs: Updated documentation
abates Sep 5, 2023
0650513
docs: Additional developer API docs
abates Sep 5, 2023
3f58533
Merge branch 'osrb' into feature_delices
abates Sep 5, 2023
e9a0a0d
Merge branch 'develop' into feature_delices
abates Oct 5, 2023
d7e02e2
Add journaling to Design Builder (#69)
abates Oct 5, 2023
3b3e4b0
add DateTime in DesignInstance
gertzakis Nov 7, 2023
35cd8f9
Merge branch 'develop' into feature_delices
gertzakis Nov 7, 2023
c6224f3
adds q filters on filter sets for design models
Kircheneer Nov 8, 2023
1f735c0
Merge pull request #82 from networktocode-llc/feature_delices_q_filte…
Kircheneer Nov 8, 2023
3837819
feat: :sparkles: Change status from Design to Design Instance (#84)
chadell Dec 12, 2023
df33046
feat: :sparkles: Decommissioning Job (#85)
chadell Jan 4, 2024
e9e7c14
fix: :bug: Fix migrations backwards (#96)
chadell Jan 11, 2024
e807828
fix: :bug: Decommissioning feature handles attributes that are "prope…
chadell Jan 18, 2024
ddf73ac
fix: :bug: StatusFieldSerializer incorporartes the ID (#103)
chadell Jan 25, 2024
09699bc
Merge branch 'develop' into feature_delices
abates Feb 16, 2024
7c1adf0
Merge pull request #112 from nautobot/feature_delices-merge_develop
abates Feb 16, 2024
79b9348
feat: :sparkles: Re Run a Design Job to Update it (#99)
chadell Feb 19, 2024
ef3b197
Added initial state to line 393 in design.py
qduk Feb 26, 2024
dd8b78f
Merge pull request #113 from nautobot/ab_update_initial_state
abates Feb 26, 2024
5f4da90
fixes navigation (#114)
Kircheneer Feb 29, 2024
8c93065
adds journal and design instance PK to job output
Kircheneer Mar 8, 2024
3b852a7
Data Protection: Update and Delete (#116)
chadell Apr 2, 2024
3d94ba2
style: move the Designs into its own navigation tab
chadell Apr 4, 2024
fdcf825
style: define a Jobs group name for design builder jobs, different fr…
chadell Apr 4, 2024
681a122
style: use play button
chadell Apr 4, 2024
ee9d7b2
style: change last implemented to last updated
chadell Apr 4, 2024
4630a25
style: move from live state to operational state
chadell Apr 4, 2024
d2b3f84
feat: adding version representation
chadell Apr 5, 2024
fc1d197
tests: fix version tests
chadell Apr 5, 2024
c2b799d
refactor: add reference to change owner reference in Nautobot 2.0
chadell Apr 5, 2024
2e76123
refactor: replace 'owner' by computed 'created_by' and 'last_updated…
chadell Apr 8, 2024
06550d9
feat: add last time the design jobs were synced
chadell Apr 8, 2024
45aef4f
feat: add and optional description metadata for designjobs
chadell Apr 8, 2024
34224f9
refactor: remove direct access to Jounral and fix view from DesignIns…
chadell Apr 8, 2024
6086198
refactor: replace design instance by deployment without renaming the …
chadell Apr 8, 2024
645ff07
feat: add support for docs per design
chadell Apr 9, 2024
37245d6
fix: clean up Tag of desing instance after deletion
chadell Apr 9, 2024
1777b06
feat: allow desing job edition from design table
chadell Apr 9, 2024
5945177
ci: fix duplicated middleware addition
chadell Apr 10, 2024
ab967a1
fix: use the last used journal input data
chadell Apr 10, 2024
6ab7440
chore: remove nonrelevant comment
chadell Apr 10, 2024
e93470e
feat: support design deletion
chadell Apr 10, 2024
13dc7dc
chore: squash migrations
chadell Apr 10, 2024
f7e4da1
fix: black for migrations
chadell Apr 10, 2024
45273c7
feat: small improvements
chadell Apr 10, 2024
130f674
docs: improve docs
chadell Apr 11, 2024
a6fcf77
fix: used design deployment in templates
chadell Apr 12, 2024
d9517d0
Merge branch 'develop' into feature_delices_prepare-for-develop
abates Apr 12, 2024
8127eda
Prepare Design lifecycle features for develop (#131)
chadell Apr 15, 2024
91e2dab
Backported most changes from develop
abates Apr 15, 2024
acf6f98
Merge branch 'feature_delices' into feature_delices_merge_from_develop
abates Apr 15, 2024
b86a1c9
Fixes
abates Apr 15, 2024
19c30ff
Auto-formatting
abates Apr 15, 2024
5b80a37
linting errors
abates Apr 15, 2024
1fe2a83
LTM separation
abates Apr 16, 2024
a83f211
tests: add a basic test to check end to end run of the design deployment
chadell Apr 18, 2024
f824b13
tests: add a more complex integration test
chadell Apr 18, 2024
187b6e7
fix linting
chadell Apr 18, 2024
345f75a
tests: add update case
chadell Apr 19, 2024
9409d10
fix: test issue
chadell Apr 19, 2024
00ec4bf
Merge pull request #137 from nautobot/feature_delices-integration-tes…
abates Apr 22, 2024
faa5c6e
Merge remote-tracking branch 'origin' into feature_delices_merge_from…
abates Apr 23, 2024
d1adfc2
Merge branch 'feature_delices' into feature_delices_merge_from_develop
abates Apr 23, 2024
c2eeb34
Initial updates for new test
abates Apr 24, 2024
f383c94
Updates
abates Apr 25, 2024
8ba4222
Updates to tests and code
abates Apr 30, 2024
0e2ba17
Prep for 1.2 release
abates Apr 30, 2024
bc6c80b
Minor cleanup
abates Apr 30, 2024
843aa57
Merge pull request #135 from nautobot/feature_delices_merge_from_develop
abates Apr 30, 2024
20ace41
docs: Updated changelog
abates May 1, 2024
d73a4f3
fix: Fixed MySQL container in docker-compose
abates May 1, 2024
350d5c2
refactor: The version attribute is not necessary for compose V2
abates May 1, 2024
a61bc84
cleanup
abates May 1, 2024
57613c9
ci: Removed Nautobot 2 from CI pipeline
abates May 1, 2024
be60145
test: Fixed unit tests
abates May 1, 2024
b17545d
Merge pull request #143 from nautobot/1.2-release-prep
abates May 1, 2024
001d925
Merge branch 'ltm-1.6' into feature_delices
abates May 2, 2024
01cf778
Merge branch 'develop' into feature_delices_v2
abates May 2, 2024
db49939
Added yamlized unittests
abates May 9, 2024
7603ddc
Added branch arg to install_demo_designs mgmt cmd
abates May 9, 2024
1cd0a54
Fixed many-to-many through
abates May 9, 2024
c259b43
Misc fixes
abates May 9, 2024
063cca7
Auto-formatting
abates May 9, 2024
11692c9
Status content-types test
abates May 9, 2024
e295571
Autoformatting
abates May 9, 2024
06d3752
docs: Documented `add_arguments` method
abates May 9, 2024
221e463
Fixed bandit complaint about password
abates May 9, 2024
62399ad
Aligning project files with cookiecutter
abates May 9, 2024
a072d63
docs: Linting and docs updates
abates May 10, 2024
1eae675
refactor: Refactored builder_test_case decorator
abates May 13, 2024
f5be35f
refactor: Removed `live_state` attribute
abates May 13, 2024
23cac85
fix: Fixed missing import
abates May 28, 2024
4adce41
fix: CableConnectionExtension
abates May 13, 2024
b13c431
feat: Added `instance_name` into design render context
abates May 14, 2024
74cf686
refactor: Rename `DesignInstance` model to `Deployment`
abates May 29, 2024
8e974aa
refactor: Renamed `Journal` to `ChangeSet` and `JournalEntry` to `Cha…
abates May 29, 2024
78f87bd
migrations and final changes for model renames
abates May 29, 2024
21b1e0a
design mode
abates May 29, 2024
d94d4a1
aligning tables and views with feature_delices
abates May 29, 2024
8c1215d
Merge branch 'develop' into feature_delices_v2
abates May 29, 2024
e31dd99
More model renaming cleanup
abates May 30, 2024
c04596a
refactor: Updates for unit tests to align with feature_delices
abates May 31, 2024
892e224
refactor: Linting and cleanup
abates May 31, 2024
5a3fd30
refactor: Aligned signal code with feature_delices
abates May 31, 2024
8bcb07c
ci: Updated pipeline
abates May 31, 2024
5d086b3
docs: Added changelog fragment
abates Jun 24, 2024
a120bcb
Ensure that a failed deployment is not created (#172)
chadell Jun 13, 2024
62d63ac
test: Fixed incorrect keyword argument
abates Jun 24, 2024
a56c8ca
ci: Attempting to fix the pipeline
abates Jun 24, 2024
e8fb1b3
test: Fixed unittest for deployment rollback
abates Jun 25, 2024
b00bf8d
style: Removed unused imports
abates Jun 25, 2024
0cbe6e6
test: Improved design lifecycle testing
abates Jun 26, 2024
36e79f6
style: Removed unused debugging statement
abates Jun 26, 2024
b2806e9
style: Fixed linting error
abates Jun 26, 2024
00ece20
refactor: Moved logging to use Nautobot 2 job logger
abates Aug 13, 2024
45d0dd5
test: Added additional interface IP address assignment test
abates Aug 13, 2024
490e6fd
feat: Improved changeset and change record view tables
abates Aug 13, 2024
96a43eb
fix: Minor bug fixes
abates Aug 14, 2024
fc0d305
style: Linting fixes
abates Aug 14, 2024
f8e7f5c
fix: Fixed custom validator for instances with no active change records
abates Aug 14, 2024
cbb3caf
style: Added css class to match buttons
abates Aug 14, 2024
55355f7
fix: Fixed issue related to Django 4
abates Aug 14, 2024
1f5f84f
Merge branch 'develop' into feature_delices_v2
abates Oct 1, 2024
1d265f2
Updates for mkdocstrings versions
abates Oct 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
128 changes: 65 additions & 63 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on: # yamllint disable-line rule:truthy rule:comments
pull_request: ~

env:
PLUGIN_NAME: "nautobot-app-design-builder"
APP_NAME: "nautobot-app-design-builder"

jobs:
black:
Expand All @@ -24,7 +24,7 @@ jobs:
- name: "Check out repository code"
uses: "actions/checkout@v4"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v4"
uses: "networktocode/gh-action-setup-poetry-environment@v6"
- name: "Linting: black"
run: "poetry run invoke black"
bandit:
Expand All @@ -35,20 +35,31 @@ jobs:
- name: "Check out repository code"
uses: "actions/checkout@v4"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v4"
uses: "networktocode/gh-action-setup-poetry-environment@v6"
- name: "Linting: bandit"
run: "poetry run invoke bandit"
pydocstyle:
ruff:
runs-on: "ubuntu-22.04"
env:
INVOKE_NAUTOBOT_DESIGN_BUILDER_LOCAL: "True"
steps:
- name: "Check out repository code"
uses: "actions/checkout@v4"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v4"
- name: "Linting: pydocstyle"
run: "poetry run invoke pydocstyle"
uses: "networktocode/gh-action-setup-poetry-environment@v6"
- name: "Linting: ruff"
run: "poetry run invoke ruff"
check-docs-build:
runs-on: "ubuntu-22.04"
env:
INVOKE_NAUTOBOT_DESIGN_BUILDER_LOCAL: "True"
steps:
- name: "Check out repository code"
uses: "actions/checkout@v4"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v6"
- name: "Check Docs Build"
run: "poetry run invoke build-and-check-docs"
flake8:
runs-on: "ubuntu-22.04"
env:
Expand All @@ -57,7 +68,7 @@ jobs:
- name: "Check out repository code"
uses: "actions/checkout@v4"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v4"
uses: "networktocode/gh-action-setup-poetry-environment@v6"
- name: "Linting: flake8"
run: "poetry run invoke flake8"
poetry:
Expand All @@ -68,7 +79,7 @@ jobs:
- name: "Check out repository code"
uses: "actions/checkout@v4"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v4"
uses: "networktocode/gh-action-setup-poetry-environment@v6"
- name: "Checking: poetry lock file"
run: "poetry run invoke lock --check"
yamllint:
Expand All @@ -79,13 +90,13 @@ jobs:
- name: "Check out repository code"
uses: "actions/checkout@v4"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v4"
uses: "networktocode/gh-action-setup-poetry-environment@v6"
- name: "Linting: yamllint"
run: "poetry run invoke yamllint"
pylint:
check-in-docker:
needs:
- "bandit"
- "pydocstyle"
- "ruff"
- "flake8"
- "poetry"
- "yamllint"
Expand All @@ -95,15 +106,15 @@ jobs:
fail-fast: true
matrix:
python-version: ["3.11"]
nautobot-version: ["2.2"]
nautobot-version: ["stable"]
env:
INVOKE_NAUTOBOT_DESIGN_BUILDER_PYTHON_VER: "${{ matrix.python-version }}"
INVOKE_NAUTOBOT_DESIGN_BUILDER_NAUTOBOT_VER: "${{ matrix.nautobot-version }}"
steps:
- name: "Check out repository code"
uses: "actions/checkout@v4"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v4"
uses: "networktocode/gh-action-setup-poetry-environment@v6"
- name: "Set up Docker Buildx"
id: "buildx"
uses: "docker/setup-buildx-action@v3"
Expand All @@ -114,7 +125,7 @@ jobs:
context: "./"
push: false
load: true
tags: "${{ env.PLUGIN_NAME }}/nautobot:${{ matrix.nautobot-version }}-py${{ matrix.python-version }}"
tags: "${{ env.APP_NAME }}/nautobot:${{ matrix.nautobot-version }}-py${{ matrix.python-version }}"
file: "./development/Dockerfile"
cache-from: "type=gha,scope=${{ matrix.nautobot-version }}-py${{ matrix.python-version }}"
cache-to: "type=gha,scope=${{ matrix.nautobot-version }}-py${{ matrix.python-version }}"
Expand All @@ -125,60 +136,23 @@ jobs:
run: "cp development/creds.example.env development/creds.env"
- name: "Linting: pylint"
run: "poetry run invoke pylint"
check-migrations:
needs:
- "bandit"
- "pydocstyle"
- "flake8"
- "poetry"
- "yamllint"
- "black"
runs-on: "ubuntu-22.04"
strategy:
fail-fast: true
matrix:
python-version: ["3.11"]
nautobot-version: ["2.2"]
env:
INVOKE_NAUTOBOT_DESIGN_BUILDER_PYTHON_VER: "${{ matrix.python-version }}"
INVOKE_NAUTOBOT_DESIGN_BUILDER_NAUTOBOT_VER: "${{ matrix.nautobot-version }}"
steps:
- name: "Check out repository code"
uses: "actions/checkout@v4"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v4"
- name: "Set up Docker Buildx"
id: "buildx"
uses: "docker/setup-buildx-action@v3"
- name: "Build"
uses: "docker/build-push-action@v5"
with:
builder: "${{ steps.buildx.outputs.name }}"
context: "./"
push: false
load: true
tags: "${{ env.PLUGIN_NAME }}/nautobot:${{ matrix.nautobot-version }}-py${{ matrix.python-version }}"
file: "./development/Dockerfile"
cache-from: "type=gha,scope=${{ matrix.nautobot-version }}-py${{ matrix.python-version }}"
cache-to: "type=gha,scope=${{ matrix.nautobot-version }}-py${{ matrix.python-version }}"
build-args: |
NAUTOBOT_VER=${{ matrix.nautobot-version }}
PYTHON_VER=${{ matrix.python-version }}
- name: "Copy credentials"
run: "cp development/creds.example.env development/creds.env"
- name: "Checking: App Config"
run: "poetry run invoke validate-app-config"
- name: "Checking: migrations"
run: "poetry run invoke check-migrations"
unittest:
needs:
- "pylint"
- "check-migrations"
- "check-in-docker"
strategy:
fail-fast: true
matrix:
python-version: ["3.8", "3.11"]
db-backend: ["postgresql"]
nautobot-version: ["stable"]
include:
- python-version: "3.11"
db-backend: "postgresql"
nautobot-version: "stable"
- python-version: "3.11"
db-backend: "mysql"
nautobot-version: "stable"
Expand All @@ -190,7 +164,7 @@ jobs:
- name: "Check out repository code"
uses: "actions/checkout@v4"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v4"
uses: "networktocode/gh-action-setup-poetry-environment@v6"
- name: "Set up Docker Buildx"
id: "buildx"
uses: "docker/setup-buildx-action@v3"
Expand All @@ -201,7 +175,7 @@ jobs:
context: "./"
push: false
load: true
tags: "${{ env.PLUGIN_NAME }}/nautobot:${{ matrix.nautobot-version }}-py${{ matrix.python-version }}"
tags: "${{ env.APP_NAME }}/nautobot:${{ matrix.nautobot-version }}-py${{ matrix.python-version }}"
file: "./development/Dockerfile"
cache-from: "type=gha,scope=${{ matrix.nautobot-version }}-py${{ matrix.python-version }}"
cache-to: "type=gha,scope=${{ matrix.nautobot-version }}-py${{ matrix.python-version }}"
Expand All @@ -215,17 +189,35 @@ jobs:
if: "matrix.db-backend == 'mysql'"
- name: "Run Tests"
run: "poetry run invoke unittest"
changelog:
if: |
contains(fromJson('["develop","ltm-1.6"]'), github.base_ref) &&
(github.head_ref != 'main')
runs-on: "ubuntu-22.04"
steps:
- name: "Check out repository code"
uses: "actions/checkout@v4"
with:
fetch-depth: "0"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v6"
- name: "Check for changelog entry"
run: |
git fetch --no-tags origin +refs/heads/${{ github.base_ref }}:refs/remotes/origin/${{ github.base_ref }}
poetry run towncrier check --compare-with origin/${{ github.base_ref }}
publish_gh:
needs:
- "unittest"
name: "Publish to GitHub"
runs-on: "ubuntu-22.04"
if: "startsWith(github.ref, 'refs/tags/v')"
env:
INVOKE_NAUTOBOT_DESIGN_BUILDER_LOCAL: "True"
steps:
- name: "Check out repository code"
uses: "actions/checkout@v4"
- name: "Set up Python"
uses: "actions/setup-python@v4"
uses: "actions/setup-python@v5"
with:
python-version: "3.11"
- name: "Install Python Packages"
Expand All @@ -234,12 +226,16 @@ jobs:
run: "echo RELEASE_VERSION=${GITHUB_REF:10} >> $GITHUB_ENV"
- name: "Run Poetry Version"
run: "poetry version $RELEASE_VERSION"
- name: "Install Dependencies (needed for mkdocs)"
run: "poetry install --no-root"
- name: "Build Documentation"
run: "poetry run invoke build-and-check-docs"
- name: "Run Poetry Build"
run: "poetry build"
- name: "Upload binaries to release"
uses: "svenstaro/upload-release-action@v2"
with:
repo_token: "${{ secrets.GH_NAUTOBOT_BOT_TOKEN }}"
repo_token: "${{ secrets.NTC_GITHUB_TOKEN }}" # use GH_NAUTOBOT_BOT_TOKEN for Nautobot Org repos.
file: "dist/*"
tag: "${{ github.ref }}"
overwrite: true
Expand All @@ -250,11 +246,13 @@ jobs:
name: "Push Package to PyPI"
runs-on: "ubuntu-22.04"
if: "startsWith(github.ref, 'refs/tags/v')"
env:
INVOKE_NAUTOBOT_DESIGN_BUILDER_LOCAL: "True"
steps:
- name: "Check out repository code"
uses: "actions/checkout@v4"
- name: "Set up Python"
uses: "actions/setup-python@v4"
uses: "actions/setup-python@v5"
with:
python-version: "3.11"
- name: "Install Python Packages"
Expand All @@ -263,6 +261,10 @@ jobs:
run: "echo RELEASE_VERSION=${GITHUB_REF:10} >> $GITHUB_ENV"
- name: "Run Poetry Version"
run: "poetry version $RELEASE_VERSION"
- name: "Install Dependencies (needed for mkdocs)"
run: "poetry install --no-root"
- name: "Build Documentation"
run: "poetry run invoke build-and-check-docs"
- name: "Run Poetry Build"
run: "poetry build"
- name: "Push to PyPI"
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

Design Builder is a Nautobot application for easily populating data within Nautobot using standardized design files. These design files are just Jinja templates that describe the Nautobot objects to be created or updated.

It also introduces the concept of a design-oriented Source of Truth with a complete lifecycle management of the design deployments (i.e., an instantiation of a design with concrete input data). With this approach, the users of the application can not only create (or populate) data within Nautobot but also update or decommission it while enforcing data protection and dependency.

## Documentation

Full documentation for this App can be found over on the [Nautobot Docs](https://docs.nautobot.com) website:
Expand Down
1 change: 1 addition & 0 deletions changes/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
!.gitignore
2 changes: 2 additions & 0 deletions changes/146.added
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Add a new mode that tracks design deployments providing a full lifecycle for design updates and decommissioning
Provide data protection (optional) for data that has been created or modified by a design deployment.
65 changes: 65 additions & 0 deletions development/app_config_schema.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
"""App Config Schema Generator and Validator."""

import json
from importlib import import_module
from os import getenv
from pathlib import Path
from urllib.parse import urlparse

import jsonschema
import toml
from django.conf import settings
from to_json_schema.to_json_schema import SchemaBuilder


def _enrich_object_schema(schema, defaults, required):
schema["additionalProperties"] = False
for key, value in schema["properties"].items():
if required and key in required:
value["required"] = True
default_value = defaults and defaults.get(key, None)
if value["type"] == "object" and "properties" in value:
_enrich_object_schema(value, default_value, None)
elif default_value is not None:
value["default"] = default_value


def _main():
pyproject = toml.loads(Path("pyproject.toml").read_text())
url = urlparse(pyproject["tool"]["poetry"]["repository"])
_, owner, repository = url.path.split("/")
package_name = pyproject["tool"]["poetry"]["packages"][0]["include"]
app_config = settings.PLUGINS_CONFIG[package_name] # type: ignore
schema_path = Path(package_name) / "app-config-schema.json"
command = getenv("APP_CONFIG_SCHEMA_COMMAND", "")
if command == "generate":
schema = {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": f"https://raw.githubusercontent.com/{owner}/{repository}/develop/{package_name}/app-config-schema.json",
"$comment": "TBD: Update $id, replace `develop` with the future release tag",
**SchemaBuilder().to_json_schema(app_config), # type: ignore
}
app_config = import_module(package_name).config
_enrich_object_schema(schema, app_config.default_settings, app_config.required_settings)
schema_path.write_text(json.dumps(schema, indent=4) + "\n")
print(f"\n==================\nGenerated schema:\n\n{schema_path}\n")
print(
"WARNING: Review and edit the generated file before committing.\n"
"\n"
"Its content is inferred from:\n"
"\n"
"- The current configuration in `PLUGINS_CONFIG`\n"
"- `NautobotAppConfig.default_settings`\n"
"- `NautobotAppConfig.required_settings`"
)
elif command == "validate":
schema = json.loads(schema_path.read_text())
jsonschema.validate(app_config, schema)
print(
f"\n==================\nValidated configuration using the schema:\n{schema_path}\nConfiguration is valid."
)
else:
raise RuntimeError(f"Unknown command: {command}")


_main()
20 changes: 19 additions & 1 deletion development/nautobot_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
if "debug_toolbar.middleware.DebugToolbarMiddleware" not in MIDDLEWARE: # noqa: F405
MIDDLEWARE.insert(0, "debug_toolbar.middleware.DebugToolbarMiddleware") # noqa: F405

if "nautobot_design_builder.middleware.GlobalRequestMiddleware" not in MIDDLEWARE: # noqa: F405
MIDDLEWARE.insert(0, "nautobot_design_builder.middleware.GlobalRequestMiddleware") # noqa: F405

#
# Misc. settings
#
Expand Down Expand Up @@ -138,4 +141,19 @@
if is_truthy(os.getenv("DESIGN_BUILDER_ENABLE_BGP", "False")):
PLUGINS.append("nautobot_bgp_models")

PLUGINS_CONFIG = {"design_builder": {"context_repository": os.getenv("DESIGN_BUILDER_CONTEXT_REPO_SLUG", None)}}

def pre_decommission_hook_example(design_instance):
"""Example decomission hook."""
return True, "Everything good!"


PLUGINS_CONFIG = {
"nautobot_design_builder": {
"context_repository": os.getenv("DESIGN_BUILDER_CONTEXT_REPO_SLUG", None),
"pre_decommission_hook": pre_decommission_hook_example,
"protected_models": [("dcim", "region"), ("dcim", "device"), ("dcim", "interface")],
"protected_superuser_bypass": False,
}
}

STRICT_FILTERING = False
Loading