From 9a64a8cb787519daf2715865acee3f96c262f4bc Mon Sep 17 00:00:00 2001 From: bakebot Date: Tue, 17 Oct 2023 14:01:16 +0000 Subject: [PATCH 1/9] Cookie initialy baked by NetworkToCode Cookie Drift Manager Tool Template: ``` { "template": "https://github.com/nautobot/cookiecutter-nautobot-app.git", "dir": "nautobot-app", "ref": "develop", "path": null } ``` Cookie: ``` { "remote": "https://github.com/nautobot/nautobot-plugin-nornir.git", "path": "/opt/ntc/drift-manager/outputs/nautobot-plugin-nornir", "repository_path": "/opt/ntc/drift-manager/outputs/nautobot-plugin-nornir", "dir": "", "branch_prefix": "drift-manager", "context": { "codeowner_github_usernames": "@smith-ntc", "full_name": "Network to Code, LLC", "email": "info@networktocode.com", "github_org": "nautobot", "plugin_name": "nautobot_plugin_nornir", "verbose_name": "Nautobot Nornir Plugin", "plugin_slug": "nautobot-plugin-nornir", "project_slug": "nautobot-plugin-nornir", "repo_url": "https://github.com/nautobot/nautobot-plugin-nornir", "base_url": "plugin-nornir", "min_nautobot_version": "2.0.0", "max_nautobot_version": "2.9999", "camel_name": "NautobotPluginNornir", "project_short_description": "Nautobot Nornir Plugin", "model_class_name": "None", "open_source_license": "Apache-2.0", "docs_base_url": "https://docs.nautobot.com", "docs_app_url": "https://docs.nautobot.com/projects/plugin-nornir/en/latest", "_template": "https://github.com/nautobot/cookiecutter-nautobot-app.git", "_output_dir": "/opt/ntc/drift-manager/outputs", "_repo_dir": "/opt/ntc/drift-manager/outputs/.cookiecutters/cookiecutter-nautobot-app/nautobot-app", "_checkout": "develop" }, "base_branch": "develop", "remote_name": "origin", "pull_request_strategy": "PullRequestStrategy.UPDATE_OR_CREATE", "post_actions": [ "PostAction.BLACK" ], "baked_commit_ref": "", "draft": true } ``` CLI Arguments: ``` { "cookie_dir": "", "input": false, "json_filename": "setup-cookie-nornir.json", "output_dir": "./outputs", "push": true, "template": "https://github.com/nautobot/cookiecutter-nautobot-app.git", "template_dir": "nautobot-app", "template_ref": "develop", "pull_request": "update-or-create", "post_action": [ "black" ], "disable_post_actions": false, "draft": true } ``` --- .cookiecutter.json | 57 +-- .flake8 | 6 +- .github/CODEOWNERS | 5 +- .github/ISSUE_TEMPLATE/bug_report.md | 18 +- .github/ISSUE_TEMPLATE/feature_request.md | 6 +- .../pull_request_template.md | 35 ++ .github/workflows/ci.yml | 128 +++++-- .github/workflows/rebake.yml | 118 ++++++ .github/workflows/upstream_testing.yml | 2 +- .gitignore | 24 +- .yamllint.yml | 1 + LICENSE | 2 +- README.md | 50 ++- development/Dockerfile | 22 +- development/development.env | 2 - development/docker-compose.base.yml | 14 +- development/docker-compose.dev.yml | 4 + development/docker-compose.mysql.yml | 8 +- development/docker-compose.postgres.yml | 4 +- development/nautobot_config.py | 118 +++--- docs/admin/compatibility_matrix.md | 16 +- docs/admin/install.md | 81 ++++ docs/admin/release_notes/index.md | 2 +- docs/admin/release_notes/version_1.0.md | 58 +-- docs/admin/uninstall.md | 18 + docs/admin/upgrade.md | 10 + docs/assets/extra.css | 76 +++- docs/assets/overrides/partials/copyright.html | 2 + docs/dev/arch_decision.md | 7 + docs/dev/code_reference/api.md | 5 + docs/dev/code_reference/index.md | 5 +- docs/dev/code_reference/package.md | 1 + docs/dev/contributing.md | 24 ++ docs/dev/dev_environment.md | 33 +- docs/dev/extending.md | 6 + docs/images/icon-nautobot-plugin-nornir.png | Bin 0 -> 74601 bytes docs/requirements.txt | 5 +- docs/user/app_getting_started.md | 16 +- docs/user/app_overview.md | 30 +- docs/user/app_use_cases.md | 11 +- docs/user/external_interactions.md | 17 + docs/user/faq.md | 1 + invoke.example.yml | 2 +- invoke.mysql.yml | 2 +- mkdocs.yml | 47 ++- nautobot_plugin_nornir/__init__.py | 60 +-- nautobot_plugin_nornir/api/__init__.py | 1 + nautobot_plugin_nornir/migrations/__init__.py | 0 nautobot_plugin_nornir/tests/__init__.py | 2 +- nautobot_plugin_nornir/tests/test_api.py | 28 ++ nautobot_plugin_nornir/tests/test_basic.py | 12 + pyproject.toml | 50 +-- tasks.py | 347 +++++++++++++++--- 53 files changed, 1153 insertions(+), 446 deletions(-) create mode 100644 .github/PULL_REQUEST_TEMPLATE/pull_request_template.md create mode 100644 .github/workflows/rebake.yml create mode 100644 docs/admin/install.md create mode 100644 docs/admin/uninstall.md create mode 100644 docs/admin/upgrade.md create mode 100644 docs/dev/arch_decision.md create mode 100644 docs/dev/code_reference/api.md create mode 100644 docs/dev/code_reference/package.md create mode 100644 docs/dev/contributing.md create mode 100644 docs/dev/extending.md create mode 100644 docs/images/icon-nautobot-plugin-nornir.png create mode 100644 docs/user/external_interactions.md create mode 100644 docs/user/faq.md create mode 100644 nautobot_plugin_nornir/api/__init__.py create mode 100644 nautobot_plugin_nornir/migrations/__init__.py create mode 100644 nautobot_plugin_nornir/tests/test_api.py diff --git a/.cookiecutter.json b/.cookiecutter.json index 06717a2..a745c8e 100644 --- a/.cookiecutter.json +++ b/.cookiecutter.json @@ -1,26 +1,35 @@ { - "cookiecutter": { - "codeowner_github_usernames": "@smith-ntc", - "full_name": "Network to Code, LLC", - "email": "info@networktocode.com", - "github_org": "nautobot", - "plugin_name": "nautobot_plugin_nornir", - "verbose_name": "Nautobot Nornir Plugin", - "plugin_slug": "nautobot-plugin-nornir", - "project_slug": "nautobot-plugin-nornir", - "repo_url": "https://github.com/nautobot/nautobot-plugin-nornir", - "base_url": "plugin-nornir", - "min_nautobot_version": "1.4.0", - "max_nautobot_version": "1.9999", - "nautobot_version": "latest", - "camel_name": "NautobotPluginNornir", - "project_short_description": "Nautobot Nornir Plugin", - "version": "0.1.0", - "model_class_name": "None", - "open_source_license": "Apache-2.0", - "docs_base_url": "https://docs.nautobot.com", - "docs_app_url": "https://docs.nautobot.com/projects/plugin-nornir/en/latest", - "_template": "/opt/ntc/networktocode-llc/cookiecutter-ntc/nautobot-plugin", - "_output_dir": "/opt/ntc/baked" - } + "cookiecutter": { + "codeowner_github_usernames": "@smith-ntc", + "full_name": "Network to Code, LLC", + "email": "info@networktocode.com", + "github_org": "nautobot", + "plugin_name": "nautobot_plugin_nornir", + "verbose_name": "Nautobot Nornir Plugin", + "plugin_slug": "nautobot-plugin-nornir", + "project_slug": "nautobot-plugin-nornir", + "repo_url": "https://github.com/nautobot/nautobot-plugin-nornir", + "base_url": "plugin-nornir", + "min_nautobot_version": "2.0.0", + "max_nautobot_version": "2.9999", + "camel_name": "NautobotPluginNornir", + "project_short_description": "Nautobot Nornir Plugin", + "model_class_name": "None", + "open_source_license": "Apache-2.0", + "docs_base_url": "https://docs.nautobot.com", + "docs_app_url": "https://docs.nautobot.com/projects/plugin-nornir/en/latest", + "_drift_manager": { + "template": "https://github.com/nautobot/cookiecutter-nautobot-app.git", + "template_dir": "nautobot-app", + "template_ref": "develop", + "cookie_dir": "", + "branch_prefix": "drift-manager", + "pull_request_strategy": "update-or-create", + "post_actions": [ + "black" + ], + "draft": true, + "baked_commit_ref": "7cd62373450b4459a5fa3397a2d27214f7217a9c" + } + } } diff --git a/.flake8 b/.flake8 index 888023f..c9f5e84 100644 --- a/.flake8 +++ b/.flake8 @@ -1,7 +1,7 @@ [flake8] -# E501: Line length is enforced by Black, so flake8 doesn't need to check it -# W503: Black disagrees with this rule, as does PEP 8; Black wins -ignore = E501, W503 +ignore = + E501, # Line length is enforced by Black, so flake8 doesn't need to check it + W503 # Black disagrees with this rule, as does PEP 8; Black wins exclude = migrations, __pycache__, diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 649e9c0..283f0a2 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,3 +1,2 @@ -# Default owners for all files in this repository -* @itdependsnetworks -* @jeffkala \ No newline at end of file +# Default owner(s) of all files in this repository +* @smith-ntc diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 1f0c4af..37fd21f 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -4,10 +4,17 @@ about: Report a reproducible bug in the current release of nautobot-plugin-norni --- ### Environment -* Python version: -* Nautobot version: +* Python version: +* Nautobot version: * nautobot-plugin-nornir version: + +### Expected Behavior + + + +### Observed Behavior + -### Expected Behavior - - - -### Observed Behavior diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index 44a32c1..34f1cd1 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -1,11 +1,11 @@ --- name: ✨ Feature Request -about: Propose a new feature or enhancement for nautobot-plugin-nornir +about: Propose a new feature or enhancement + --- ### Environment -* Python version: -* Nautobot version: +* Nautobot version: * nautobot-plugin-nornir version: + +# Closes: # + +## What's Changed + + + +## To Do + + +- [ ] Explanation of Change(s) +- [ ] Added change log fragment(s) (for more information see [the documentation](https://docs.nautobot.com/projects/core/en/stable/development/#creating-changelog-fragments)) +- [ ] Attached Screenshots, Payload Example +- [ ] Unit, Integration Tests +- [ ] Documentation Updates (when adding/changing features) +- [ ] Example Plugin Updates (when adding/changing features) +- [ ] Outline Remaining Work, Constraints from Design diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5c6ffa6..13a5610 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,56 +17,67 @@ env: jobs: black: - runs-on: "ubuntu-20.04" + runs-on: "ubuntu-22.04" env: INVOKE_NAUTOBOT_PLUGIN_NORNIR_LOCAL: "True" steps: - name: "Check out repository code" - uses: "actions/checkout@v2" + uses: "actions/checkout@v4" - name: "Setup environment" uses: "networktocode/gh-action-setup-poetry-environment@v4" - name: "Linting: black" run: "poetry run invoke black" bandit: - runs-on: "ubuntu-20.04" + runs-on: "ubuntu-22.04" env: INVOKE_NAUTOBOT_PLUGIN_NORNIR_LOCAL: "True" steps: - name: "Check out repository code" - uses: "actions/checkout@v2" + uses: "actions/checkout@v4" - name: "Setup environment" uses: "networktocode/gh-action-setup-poetry-environment@v4" - name: "Linting: bandit" run: "poetry run invoke bandit" pydocstyle: - runs-on: "ubuntu-20.04" + runs-on: "ubuntu-22.04" env: INVOKE_NAUTOBOT_PLUGIN_NORNIR_LOCAL: "True" steps: - name: "Check out repository code" - uses: "actions/checkout@v2" + uses: "actions/checkout@v4" - name: "Setup environment" uses: "networktocode/gh-action-setup-poetry-environment@v4" - name: "Linting: pydocstyle" run: "poetry run invoke pydocstyle" flake8: - runs-on: "ubuntu-20.04" + runs-on: "ubuntu-22.04" env: INVOKE_NAUTOBOT_PLUGIN_NORNIR_LOCAL: "True" steps: - name: "Check out repository code" - uses: "actions/checkout@v2" + uses: "actions/checkout@v4" - name: "Setup environment" uses: "networktocode/gh-action-setup-poetry-environment@v4" - name: "Linting: flake8" run: "poetry run invoke flake8" + poetry: + runs-on: "ubuntu-22.04" + env: + INVOKE_NAUTOBOT_PLUGIN_NORNIR_LOCAL: "True" + steps: + - name: "Check out repository code" + uses: "actions/checkout@v4" + - name: "Setup environment" + uses: "networktocode/gh-action-setup-poetry-environment@v4" + - name: "Checking: poetry lock file" + run: "poetry run invoke lock --check" yamllint: - runs-on: "ubuntu-20.04" + runs-on: "ubuntu-22.04" env: INVOKE_NAUTOBOT_PLUGIN_NORNIR_LOCAL: "True" steps: - name: "Check out repository code" - uses: "actions/checkout@v2" + uses: "actions/checkout@v4" - name: "Setup environment" uses: "networktocode/gh-action-setup-poetry-environment@v4" - name: "Linting: yamllint" @@ -76,9 +87,10 @@ jobs: - "bandit" - "pydocstyle" - "flake8" + - "poetry" - "yamllint" - "black" - runs-on: "ubuntu-20.04" + runs-on: "ubuntu-22.04" strategy: fail-fast: true matrix: @@ -89,14 +101,14 @@ jobs: INVOKE_NAUTOBOT_PLUGIN_NORNIR_NAUTOBOT_VER: "${{ matrix.nautobot-version }}" steps: - name: "Check out repository code" - uses: "actions/checkout@v2" + 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@v1" + uses: "docker/setup-buildx-action@v3" - name: "Build" - uses: "docker/build-push-action@v2" + uses: "docker/build-push-action@v5" with: builder: "${{ steps.buildx.outputs.name }}" context: "./" @@ -113,43 +125,80 @@ 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.0.0"] + env: + INVOKE_NAUTOBOT_PLUGIN_NORNIR_PYTHON_VER: "${{ matrix.python-version }}" + INVOKE_NAUTOBOT_PLUGIN_NORNIR_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: migrations" + run: "poetry run invoke check-migrations" unittest: needs: - "pylint" + - "check-migrations" strategy: fail-fast: true matrix: - python-version: ["3.8"] - db-backend: ["postgresql", "mysql"] - nautobot-version: ["2.0.0"] - # The include is a method to limit the amount of jobs ran. This essentially - # means that in addition to standard postgres and stable, also the lowest - # supported version and with mysql + python-version: ["3.8", "3.11"] + db-backend: ["postgresql"] + nautobot-version: ["stable"] include: - python-version: "3.11" db-backend: "postgresql" nautobot-version: "2.0.0" - - python-version: "3.11" - db-backend: "postgresql" - nautobot-version: "stable" - python-version: "3.11" db-backend: "mysql" nautobot-version: "stable" - - runs-on: "ubuntu-20.04" + runs-on: "ubuntu-22.04" env: INVOKE_NAUTOBOT_PLUGIN_NORNIR_PYTHON_VER: "${{ matrix.python-version }}" INVOKE_NAUTOBOT_PLUGIN_NORNIR_NAUTOBOT_VER: "${{ matrix.nautobot-version }}" steps: - name: "Check out repository code" - uses: "actions/checkout@v2" + 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@v1" + uses: "docker/setup-buildx-action@v3" - name: "Build" - uses: "docker/build-push-action@v2" + uses: "docker/build-push-action@v5" with: builder: "${{ steps.buildx.outputs.name }}" context: "./" @@ -173,13 +222,13 @@ jobs: needs: - "unittest" name: "Publish to GitHub" - runs-on: "ubuntu-20.04" + runs-on: "ubuntu-22.04" if: "startsWith(github.ref, 'refs/tags/v')" steps: - name: "Check out repository code" - uses: "actions/checkout@v2" + uses: "actions/checkout@v4" - name: "Set up Python" - uses: "actions/setup-python@v2" + uses: "actions/setup-python@v4" with: python-version: "3.11" - name: "Install Python Packages" @@ -193,7 +242,7 @@ jobs: - 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 @@ -202,13 +251,13 @@ jobs: needs: - "unittest" name: "Push Package to PyPI" - runs-on: "ubuntu-20.04" + runs-on: "ubuntu-22.04" if: "startsWith(github.ref, 'refs/tags/v')" steps: - name: "Check out repository code" - uses: "actions/checkout@v2" + uses: "actions/checkout@v4" - name: "Set up Python" - uses: "actions/setup-python@v2" + uses: "actions/setup-python@v4" with: python-version: "3.11" - name: "Install Python Packages" @@ -228,9 +277,9 @@ jobs: needs: - "publish_gh" - "publish_pypi" - runs-on: "ubuntu-20.04" + runs-on: "ubuntu-22.04" env: - SLACK_WEBHOOK_URL: "${{ '{{ secrets.SLACK_WEBHOOK_URL }}' }}" + SLACK_WEBHOOK_URL: "${{ secrets.SLACK_WEBHOOK_URL }}" SLACK_MESSAGE: >- *NOTIFICATION: NEW-RELEASE-PUBLISHED*\n Repository: <${{ github.server_url }}/${{ github.repository }}|${{ github.repository }}>\n @@ -240,11 +289,12 @@ jobs: - name: "Send a notification to Slack" # ENVs cannot be used directly in job.if. This is a workaround to check # if SLACK_WEBHOOK_URL is present. - if: "${{ env.SLACK_WEBHOOK_URL != '' }}" - uses: "slackapi/slack-github-action@v1.17.0" + if: "env.SLACK_WEBHOOK_URL != ''" + uses: "slackapi/slack-github-action@v1" with: payload: | { + "text": "${{ env.SLACK_MESSAGE }}", "blocks": [ { "type": "section", diff --git a/.github/workflows/rebake.yml b/.github/workflows/rebake.yml new file mode 100644 index 0000000..b468884 --- /dev/null +++ b/.github/workflows/rebake.yml @@ -0,0 +1,118 @@ +--- +name: "Rebake Cookie" +on: # yamllint disable-line rule:truthy + workflow_call: + inputs: + cookie: + description: "The cookie to rebake" + type: "string" + default: "" + draft: + description: "Whether to create the pull request as a draft" + type: "string" + default: "" + pull-request: + description: "The pull request strategy" + type: "string" + default: "" + template: + description: "The template repository URL" + type: "string" + default: "" + template-dir: + description: "The directory within the template repository to use as the template" + type: "string" + default: "" + template-ref: + description: "The branch or tag to use for the template" + type: "string" + default: "" + drift-manager-tag: + description: "The drift manager Docker image tag to use" + type: "string" + default: "prod" + workflow_dispatch: + inputs: + cookie: + description: "The cookie to rebake" + type: "string" + default: "" + draft: + description: "Whether to create the pull request as a draft" + type: "string" + default: "" + pull-request: + description: "The pull request strategy" + type: "string" + default: "" + template: + description: "The template repository URL" + type: "string" + default: "" + template-dir: + description: "The directory within the template repository to use as the template" + type: "string" + default: "" + template-ref: + description: "The branch or tag to use for the template" + type: "string" + default: "" + drift-manager-tag: + description: "The drift manager Docker image tag to use" + type: "string" + default: "prod" +jobs: + rebake: + runs-on: "ubuntu-22.04" + permissions: + actions: "write" + contents: "write" + packages: "read" + pull-requests: "write" + container: "ghcr.io/nautobot/cookiecutter-nautobot-app-drift-manager/prod:${{ github.event.inputs.drift-manager-tag }}" + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + steps: + - name: "Configure Rebake Arguments" + id: "config" + shell: "bash" + run: | + ARGS='--push' + + if [[ '${{ github.event.inputs.draft }}' == 'true' ]]; then + ARGS="$ARGS --draft" + elif [[ '${{ github.event.inputs.draft }}' == 'false' ]]; then + ARGS="$ARGS --no-draft" + elif [[ '${{ github.event.inputs.draft }}' == '' ]]; then + echo "Using repo default value for --draft" + else + echo "ERROR: Invalid value for draft: '${{ github.event.inputs.draft }}'" + exit 1 + fi + + if [[ '${{ github.event.inputs.pull-request }}' != '' ]]; then + ARGS="$ARGS --pull-request='${{ github.event.inputs.pull-request }}'" + fi + + if [[ '${{ github.event.inputs.template }}' != '' ]]; then + ARGS="$ARGS --template='${{ github.event.inputs.template }}'" + fi + + if [[ '${{ github.event.inputs.template-dir }}' != '' ]]; then + ARGS="$ARGS --template-dir='${{ github.event.inputs.template-dir }}'" + fi + + if [[ '${{ github.event.inputs.template-ref }}' != '' ]]; then + ARGS="$ARGS --template-ref='${{ github.event.inputs.template-ref }}'" + fi + + if [[ '${{ github.event.inputs.cookie }}' == '' ]]; then + ARGS="$ARGS '${{ github.repositoryUrl }}'" + else + ARGS="$ARGS '${{ github.event.inputs.cookie }}'" + fi + + echo "args=$ARGS" >> $GITHUB_OUTPUT + - name: "Rebake" + run: | + python -m ntc_cookie_drift_manager rebake ${{ steps.config.outputs.args }} diff --git a/.github/workflows/upstream_testing.yml b/.github/workflows/upstream_testing.yml index c1b6c51..e14212c 100644 --- a/.github/workflows/upstream_testing.yml +++ b/.github/workflows/upstream_testing.yml @@ -9,5 +9,5 @@ jobs: upstream-test: uses: "nautobot/nautobot/.github/workflows/plugin_upstream_testing_base.yml@develop" with: # Below could potentially be collapsed into a single argument if a concrete relationship between both is enforced - invoke_context_name: "NORNIR" + invoke_context_name: "NAUTOBOT_PLUGIN_NORNIR" plugin_name: "nautobot-plugin-nornir" diff --git a/.gitignore b/.gitignore index ae46c7d..51186e0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,3 @@ -# Specific ignores -nautobot_backup.dump -.creds.env -creds.env -nautobot_golden_config/transposer.py -docker-compose.override.yml -packages/ - # Ansible Retry Files *.retry @@ -200,9 +192,6 @@ $RECYCLE.BIN/ # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 -# Jetbrains IDE configs -.idea/ - # User-specific stuff .idea/**/workspace.xml .idea/**/tasks.xml @@ -306,6 +295,15 @@ fabric.properties .vscode/* *.code-workspace +# Rando +creds.env +development/*.txt + +# Invoke overrides +invoke.yml -# MKDocs Build -nautobot_plugin_nornir/static/nautobot_plugin_nornir/docs \ No newline at end of file +# Docs +public +/compose.yaml +/dump.sql +/nautobot_plugin_nornir/static/nautobot_plugin_nornir/docs diff --git a/.yamllint.yml b/.yamllint.yml index b49e490..8cc3e9a 100644 --- a/.yamllint.yml +++ b/.yamllint.yml @@ -10,3 +10,4 @@ rules: quote-type: "double" ignore: | .venv/ + compose.yaml diff --git a/LICENSE b/LICENSE index 087f92f..d46cc97 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ Apache Software License 2.0 -Copyright (c) 2021, Network to Code, LLC +Copyright (c) 2023, Network to Code, LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/README.md b/README.md index 58bacea..f6b1881 100644 --- a/README.md +++ b/README.md @@ -1,56 +1,66 @@ -# Nautobot Plugin Nornir +# Nautobot Nornir Plugin + +

- +

- An App for Nautobot. + An App for Nautobot.

## Overview -A plugin for [Nautobot](https://github.com/nautobot/nautobot), that intends to be a small shim layer between [nornir-nautobot](https://github.com/nautobot/nornir-nautobot) and other plugins. The primary abilities that the plugin provides is a native Nornir ORM based inventory and a credential manager. +> Developer Note: Add a long (2-3 paragraphs) description of what the App does, what problems it solves, what functionality it adds to Nautobot, what external systems it works with etc. -![Architecture Overview](https://raw.githubusercontent.com/nautobot/nautobot-plugin-nornir/develop/docs/images/architecture-overview.png) - -As of the writing of this readme, the only plugin leveraging this plugin is the [golden-config](https://github.com/nautobot/nautobot-plugin-golden-config). However, future plugins are planned, such as the "network importer". +### Screenshots -That being said, there is currently little reason to install this plugin by itself, without an enabler, which can be seen represented as the white rectangles inside the yellow rectangle in the diagram above. An enabler could be a Plugin, Job, or another piece of code like a Chatops command. +> Developer Note: Add any representative screenshots of the App in action. These images should also be added to the `docs/user/app_use_cases.md` section. -### Screenshots +> Developer Note: Place the files in the `docs/images/` folder and link them using only full URLs from GitHub, for example: `![Overview](https://raw.githubusercontent.com/nautobot/nautobot-plugin-nornir/develop/docs/images/plugin-overview.png)`. This absolute static linking is required to ensure the README renders properly in GitHub, the docs site, and any other external sites like PyPI. -As previously mentioned, the plugin is mostly a shim layer, here is an example of how Nautobot Golden Config uses a Nornir Job. +More screenshots can be found in the [Using the App](https://docs.nautobot.com/projects/plugin-nornir/en/latest/user/app_use_cases/) page in the documentation. Here's a quick overview of some of the plugin's added functionality: -![Backup Job](https://raw.githubusercontent.com/nautobot/nautobot-plugin-nornir/develop/docs/images/nornir-backup-job.png) +![](https://raw.githubusercontent.com/nautobot/nautobot-plugin-nornir/develop/docs/images/placeholder.png) ## Try it out! -This App is installed in the Nautobot Community Sandbox found over at [demo.nautobot.com](https://demo.nautobot.com/)! This is used within the Nautobot Golden Config plugin, when the tasks of generating config, running backup of configs, or comparing configs. +> Developer Note: Only keep this section if appropriate. Update link to correct sandbox. + +This App is installed in the Nautobot Community Sandbox found over at [demo.nautobot.com](https://demo.nautobot.com/)! > For a full list of all the available always-on sandbox environments, head over to the main page on [networktocode.com](https://www.networktocode.com/nautobot/sandbox-environments/). ## Documentation -Full web-based HTML documentation for this app can be found over on the [Nautobot Docs](https://docs.nautobot.com/projects/plugin-nornir/en/latest/) website: +Full documentation for this App can be found over on the [Nautobot Docs](https://docs.nautobot.com) website: - [User Guide](https://docs.nautobot.com/projects/plugin-nornir/en/latest/user/app_overview/) - Overview, Using the App, Getting Started. -- [Administrator Guide](https://docs.nautobot.com/projects/plugin-nornir/en/latest/admin/admin_install/) - How to Install, Configure, Upgrade, or Uninstall the App. -- [Developer Guide](https://docs.nautobot.com/projects/plugin-nornir/en/latest/dev/dev_contributing/) - Extending the App, Code Reference, Contribution Guide. +- [Administrator Guide](https://docs.nautobot.com/projects/plugin-nornir/en/latest/admin/install/) - How to Install, Configure, Upgrade, or Uninstall the App. +- [Developer Guide](https://docs.nautobot.com/projects/plugin-nornir/en/latest/dev/contributing/) - Extending the App, Code Reference, Contribution Guide. - [Release Notes / Changelog](https://docs.nautobot.com/projects/plugin-nornir/en/latest/admin/release_notes/). -- [Frequently Asked Questions](https://docs.nautobot.com/projects/plugin-nornir/en/latest/user/app_faq/). +- [Frequently Asked Questions](https://docs.nautobot.com/projects/plugin-nornir/en/latest/user/faq/). -### Contributing to the Docs +### Contributing to the Documentation -You can find all the Markdown source for the App documentation under the [docs](https://github.com/nautobot/nautobot-plugin-nornir/tree/develop/docs) folder in this repository. For simple edits, a Markdown capable editor is sufficient - clone the repository and edit away. +You can find all the Markdown source for the App documentation under the [`docs`](https://github.com/nautobot/nautobot-plugin-nornir/tree/develop/docs) folder in this repository. For simple edits, a Markdown capable editor is sufficient: clone the repository and edit away. -If you need to view the fully generated documentation site, you can build it with [mkdocs](https://www.mkdocs.org/). A container hosting the docs will be started using the invoke commands (details in the [Development Environment Guide](https://docs.nautobot.com/projects/plugin-nornir/en/latest/dev/dev_environment/#docker-development-environment)) on [http://localhost:8001](http://localhost:8001). As your changes are saved, the live docs will be automatically reloaded. +If you need to view the fully-generated documentation site, you can build it with [MkDocs](https://www.mkdocs.org/). A container hosting the documentation can be started using the `invoke` commands (details in the [Development Environment Guide](https://docs.nautobot.com/projects/plugin-nornir/en/latest/dev/dev_environment/#docker-development-environment)) on [http://localhost:8001](http://localhost:8001). Using this container, as your changes to the documentation are saved, they will be automatically rebuilt and any pages currently being viewed will be reloaded in your browser. Any PRs with fixes or improvements are very welcome! ## Questions -For any questions or comments, please check the [FAQ](https://docs.nautobot.com/projects/plugin-nornir/en/latest/user/app_faq/) first. Feel free to also swing by the [Network to Code Slack](https://networktocode.slack.com/) (channel `#nautobot`), sign up [here](http://slack.networktocode.com/) if you don't have an account. +For any questions or comments, please check the [FAQ](https://docs.nautobot.com/projects/plugin-nornir/en/latest/user/faq/) first. Feel free to also swing by the [Network to Code Slack](https://networktocode.slack.com/) (channel `#nautobot`), sign up [here](http://slack.networktocode.com/) if you don't have an account. diff --git a/development/Dockerfile b/development/Dockerfile index b89a369..4d10419 100644 --- a/development/Dockerfile +++ b/development/Dockerfile @@ -6,11 +6,11 @@ # ------------------------------------------------------------------------------------- # !!! USE CAUTION WHEN MODIFYING LINES BELOW -# Accepts a desired Nautobot version as build argument, default to 2.0.0-rc.2 -ARG NAUTOBOT_VER="2.0.0-rc.3" +# Accepts a desired Nautobot version as build argument, default to 2.0.0 +ARG NAUTOBOT_VER="2.0.0" -# Accepts a desired Python version as build argument, default to 3.8 -ARG PYTHON_VER="3.8" +# Accepts a desired Python version as build argument, default to 3.11 +ARG PYTHON_VER="3.11" # Retrieve published development image of Nautobot base which should include most CI dependencies FROM ghcr.io/nautobot/nautobot-dev:${NAUTOBOT_VER}-py${PYTHON_VER} @@ -19,21 +19,21 @@ FROM ghcr.io/nautobot/nautobot-dev:${NAUTOBOT_VER}-py${PYTHON_VER} ARG NAUTOBOT_ROOT=/opt/nautobot ENV prometheus_multiproc_dir=/prom_cache -ENV NAUTOBOT_ROOT ${NAUTOBOT_ROOT} +ENV NAUTOBOT_ROOT=${NAUTOBOT_ROOT} +ENV INVOKE_NAUTOBOT_PLUGIN_NORNIR_LOCAL=true # Install Poetry manually via its installer script; # We might be using an older version of Nautobot that includes an older version of Poetry # and CI and local development may have a newer version of Poetry # Since this is only used for development and we don't ship this container, pinning Poetry back is not expressly necessary # We also don't need virtual environments in container -ARG POETRY_VERSION=1.5.1 -RUN curl -sSL https://install.python-poetry.org | python3 - && \ +RUN which poetry || curl -sSL https://install.python-poetry.org | python3 - && \ poetry config virtualenvs.create false # !!! USE CAUTION WHEN MODIFYING LINES ABOVE # ------------------------------------------------------------------------------------- # App-specifc system build/test dependencies. -# +# # Example: LDAP requires `libldap2-dev` to be apt-installed before the Python package. # ------------------------------------------------------------------------------------- # --> Start safe to modify section @@ -69,11 +69,13 @@ RUN sort poetry_freeze_base.txt poetry_freeze_all.txt | uniq -u > poetry_freeze_ # Install all local project as editable, constrained on Nautobot version, to get any additional # direct dependencies of the app -RUN pip install -c constraints.txt -e . +RUN --mount=type=cache,target="/root/.cache/pip",sharing=locked \ + pip install -c constraints.txt -e .[all] # Install any dev dependencies frozen from Poetry # Can be improved in Poetry 1.2 which allows `poetry install --only dev` -RUN pip install -c constraints.txt -r poetry_freeze_dev.txt +RUN --mount=type=cache,target="/root/.cache/pip",sharing=locked \ + pip install -c constraints.txt -r poetry_freeze_dev.txt COPY development/nautobot_config.py ${NAUTOBOT_ROOT}/nautobot_config.py # !!! USE CAUTION WHEN MODIFYING LINES ABOVE diff --git a/development/development.env b/development/development.env index 1945f95..54f0b87 100644 --- a/development/development.env +++ b/development/development.env @@ -7,8 +7,6 @@ NAUTOBOT_BANNER_TOP="Local" NAUTOBOT_CHANGELOG_RETENTION=0 NAUTOBOT_DEBUG=True -NAUTOBOT_DJANGO_EXTENSIONS_ENABLED=True -NAUTOBOT_DJANGO_TOOLBAR_ENABLED=True NAUTOBOT_LOG_LEVEL=DEBUG NAUTOBOT_METRICS_ENABLED=True NAUTOBOT_NAPALM_TIMEOUT=5 diff --git a/development/docker-compose.base.yml b/development/docker-compose.base.yml index 07b1421..847efaa 100644 --- a/development/docker-compose.base.yml +++ b/development/docker-compose.base.yml @@ -21,7 +21,9 @@ services: condition: "service_started" db: condition: "service_healthy" - <<: [*nautobot-build, *nautobot-base] + <<: + - *nautobot-base + - *nautobot-build worker: entrypoint: - "sh" @@ -36,3 +38,13 @@ services: retries: 3 test: ["CMD", "bash", "-c", "nautobot-server celery inspect ping --destination celery@$$HOSTNAME"] ## $$ because of docker-compose <<: *nautobot-base + beat: + entrypoint: + - "sh" + - "-c" # this is to evaluate the $NAUTOBOT_LOG_LEVEL from the env + - "nautobot-server celery beat -l $$NAUTOBOT_LOG_LEVEL" ## $$ because of docker-compose + depends_on: + - "nautobot" + healthcheck: + disable: true + <<: *nautobot-base diff --git a/development/docker-compose.dev.yml b/development/docker-compose.dev.yml index 4fe673f..3554722 100644 --- a/development/docker-compose.dev.yml +++ b/development/docker-compose.dev.yml @@ -12,6 +12,8 @@ services: volumes: - "./nautobot_config.py:/opt/nautobot/nautobot_config.py" - "../:/source" + healthcheck: + test: ["CMD", "true"] # Due to layering, disable: true won't work. Instead, change the test docs: entrypoint: "mkdocs serve -v -a 0.0.0.0:8080" ports: @@ -30,6 +32,8 @@ services: volumes: - "./nautobot_config.py:/opt/nautobot/nautobot_config.py" - "../:/source" + healthcheck: + test: ["CMD", "true"] # Due to layering, disable: true won't work. Instead, change the test # To expose postgres or redis to the host uncomment the following # postgres: # ports: diff --git a/development/docker-compose.mysql.yml b/development/docker-compose.mysql.yml index c7fa6a1..062ada9 100644 --- a/development/docker-compose.mysql.yml +++ b/development/docker-compose.mysql.yml @@ -20,6 +20,7 @@ services: image: "mysql:8" command: - "--default-authentication-plugin=mysql_native_password" + - "--max_connections=1000" env_file: - "development.env" - "creds.env" @@ -27,7 +28,12 @@ services: volumes: - "mysql_data:/var/lib/mysql" healthcheck: - test: ["CMD", "mysqladmin", "ping", "-h", "localhost"] + test: + - "CMD" + - "mysqladmin" + - "ping" + - "-h" + - "localhost" timeout: "20s" retries: 10 volumes: diff --git a/development/docker-compose.postgres.yml b/development/docker-compose.postgres.yml index 55afdb7..12d1de3 100644 --- a/development/docker-compose.postgres.yml +++ b/development/docker-compose.postgres.yml @@ -7,11 +7,13 @@ services: - "NAUTOBOT_DB_ENGINE=django.db.backends.postgresql" db: image: "postgres:13-alpine" + command: + - "-c" + - "max_connections=200" env_file: - "development.env" - "creds.env" volumes: - # - "./nautobot.sql:/tmp/nautobot.sql" - "postgres_data:/var/lib/postgresql/data" healthcheck: test: "pg_isready --username=$$POSTGRES_USER --dbname=$$POSTGRES_DB" diff --git a/development/nautobot_config.py b/development/nautobot_config.py index dba0dd9..b5343dc 100644 --- a/development/nautobot_config.py +++ b/development/nautobot_config.py @@ -1,11 +1,25 @@ """Nautobot development configuration file.""" -# pylint: disable=invalid-envvar-default import os import sys from nautobot.core.settings import * # noqa: F403 # pylint: disable=wildcard-import,unused-wildcard-import from nautobot.core.settings_funcs import is_truthy, parse_redis_connection +# +# Debug +# + +DEBUG = is_truthy(os.getenv("NAUTOBOT_DEBUG", False)) +_TESTING = len(sys.argv) > 1 and sys.argv[1] == "test" + +if DEBUG and not _TESTING: + DEBUG_TOOLBAR_CONFIG = {"SHOW_TOOLBAR_CALLBACK": lambda _request: True} + + if "debug_toolbar" not in INSTALLED_APPS: # noqa: F405 + INSTALLED_APPS.append("debug_toolbar") # noqa: F405 + if "debug_toolbar.middleware.DebugToolbarMiddleware" not in MIDDLEWARE: # noqa: F405 + MIDDLEWARE.insert(0, "debug_toolbar.middleware.DebugToolbarMiddleware") # noqa: F405 + # # Misc. settings # @@ -13,6 +27,9 @@ ALLOWED_HOSTS = os.getenv("NAUTOBOT_ALLOWED_HOSTS", "").split(" ") SECRET_KEY = os.getenv("NAUTOBOT_SECRET_KEY", "") +# +# Database +# nautobot_db_engine = os.getenv("NAUTOBOT_DB_ENGINE", "django.db.backends.postgresql") default_db_settings = { @@ -42,20 +59,28 @@ DATABASES["default"]["OPTIONS"] = {"charset": "utf8mb4"} # -# Debug +# Redis # -DEBUG = is_truthy(os.getenv("NAUTOBOT_DEBUG", False)) - -TESTING = len(sys.argv) > 1 and sys.argv[1] == "test" +# The django-redis cache is used to establish concurrent locks using Redis. +CACHES = { + "default": { + "BACKEND": "django_redis.cache.RedisCache", + "LOCATION": parse_redis_connection(redis_database=0), + "TIMEOUT": 300, + "OPTIONS": { + "CLIENT_CLASS": "django_redis.client.DefaultClient", + }, + } +} -# Django Debug Toolbar -DEBUG_TOOLBAR_CONFIG = {"SHOW_TOOLBAR_CALLBACK": lambda _request: DEBUG and not TESTING} +# Redis Cacheops +CACHEOPS_REDIS = parse_redis_connection(redis_database=1) -if DEBUG and "debug_toolbar" not in INSTALLED_APPS: # noqa: F405 - INSTALLED_APPS.append("debug_toolbar") # noqa: F405 -if DEBUG and "debug_toolbar.middleware.DebugToolbarMiddleware" not in MIDDLEWARE: # noqa: F405 - MIDDLEWARE.insert(0, "debug_toolbar.middleware.DebugToolbarMiddleware") # noqa: F405 +# +# Celery settings are not defined here because they can be overloaded with +# environment variables. By default they use `CACHES["default"]["LOCATION"]`. +# # # Logging @@ -64,7 +89,7 @@ LOG_LEVEL = "DEBUG" if DEBUG else "INFO" # Verbose logging during normal development operation, but quiet logging during unit test execution -if not TESTING: +if not _TESTING: LOGGING = { "version": 1, "disable_existing_loggers": False, @@ -100,66 +125,17 @@ } # -# Redis +# Apps # -# The django-redis cache is used to establish concurrent locks using Redis. The -# django-rq settings will use the same instance/database by default. -# -# This "default" server is now used by RQ_QUEUES. -# >> See: nautobot.core.settings.RQ_QUEUES -CACHES = { - "default": { - "BACKEND": "django_redis.cache.RedisCache", - "LOCATION": parse_redis_connection(redis_database=0), - "TIMEOUT": 300, - "OPTIONS": { - "CLIENT_CLASS": "django_redis.client.DefaultClient", - }, - } -} - -# RQ_QUEUES is not set here because it just uses the default that gets imported -# up top via `from nautobot.core.settings import *`. - -# Redis Cacheops -CACHEOPS_REDIS = parse_redis_connection(redis_database=1) - -# -# Celery settings are not defined here because they can be overloaded with -# environment variables. By default they use `CACHES["default"]["LOCATION"]`. -# - -# Enable installed plugins. Add the name of each plugin to the list. +# Enable installed Apps. Add the name of each App to the list. PLUGINS = ["nautobot_plugin_nornir"] -# Plugins configuration settings. These settings are used by various plugins that the user may have installed. -# Each key in the dictionary is the name of an installed plugin and its value is a dictionary of settings. -PLUGINS_CONFIG = { - "nautobot_plugin_nornir": { - "allowed_location_types": [], - "denied_location_types": [], - "use_config_context": {"use_config_context": {"secrets": False, "connection_options": True}}, - "connection_options": { - "napalm": { - "extras": { - "optional_args": {"global_delay_factor": 1}, - }, - }, - "netmiko": { - "extras": { - "global_delay_factor": 1, - }, - }, - }, - "nornir_settings": { - "credentials": "nautobot_plugin_nornir.plugins.credentials.env_vars.CredentialsEnvVars", - "runner": { - "plugin": "threaded", - "options": { - "num_workers": 20, - }, - }, - }, - }, -} +# Apps configuration settings. These settings are used by various Apps that the user may have installed. +# Each key in the dictionary is the name of an installed App and its value is a dictionary of settings. +# PLUGINS_CONFIG = { +# 'nautobot_plugin_nornir': { +# 'foo': 'bar', +# 'buzz': 'bazz' +# } +# } diff --git a/docs/admin/compatibility_matrix.md b/docs/admin/compatibility_matrix.md index d6d4398..ef5a0f5 100644 --- a/docs/admin/compatibility_matrix.md +++ b/docs/admin/compatibility_matrix.md @@ -1,12 +1,8 @@ - -# Deprecation Policy - -While that last supported version will not be strictly enforced--via the max_version setting, any issues with an updated Nautobot supported version in a minor release, will require a bug to be raised and a fix in Nautobot core to address, with no fixes expected in this plugin. This allows the Nautobot Nornir Plugin the ability to quickly take advantage of the latest features. - # Compatibility Matrix -| Nautobot Plugin Nornir Version | Nautobot First Support Version | Nautobot Last Support Version | -| ------------------------------ | ------------------------------ | ----------------------------- | -| 0.9.X | 1.0.0 | 1.2.99 | -| 1.0.X | 1.2.0 | 1.3.99 | -| 2.0.X | 2.0.0 | 2.9999 | +!!! warning "Developer Note - Remove Me!" + Explain how the release models of the plugin and of Nautobot work together, how releases are supported, how features and older releases are deprecated etc. + +| Nautobot Nornir Plugin Version | Nautobot First Support Version | Nautobot Last Support Version | +| ------------- | -------------------- | ------------- | +| 1.0.X | 2.0.0 | 1.99.99 | diff --git a/docs/admin/install.md b/docs/admin/install.md new file mode 100644 index 0000000..1b26500 --- /dev/null +++ b/docs/admin/install.md @@ -0,0 +1,81 @@ +# Installing the App in Nautobot + +Here you will find detailed instructions on how to **install** and **configure** the App within your Nautobot environment. + +!!! warning "Developer Note - Remove Me!" + Detailed instructions on installing the App. You will need to update this section based on any additional dependencies or prerequisites. + +## Prerequisites + +- The plugin is compatible with Nautobot 2.0.0 and higher. +- Databases supported: PostgreSQL, MySQL + +!!! note + Please check the [dedicated page](compatibility_matrix.md) for a full compatibility matrix and the deprecation policy. + +### Access Requirements + +!!! warning "Developer Note - Remove Me!" + What external systems (if any) it needs access to in order to work. + +## Install Guide + +!!! note + Plugins can be installed manually or using Python's `pip`. See the [nautobot documentation](https://nautobot.readthedocs.io/en/latest/plugins/#install-the-package) for more details. The pip package name for this plugin is [`nautobot-plugin-nornir`](https://pypi.org/project/nautobot-plugin-nornir/). + +The plugin is available as a Python package via PyPI and can be installed with `pip`: + +```shell +pip install nautobot-plugin-nornir +``` + +To ensure Nautobot Nornir Plugin is automatically re-installed during future upgrades, create a file named `local_requirements.txt` (if not already existing) in the Nautobot root directory (alongside `requirements.txt`) and list the `nautobot-plugin-nornir` package: + +```shell +echo nautobot-plugin-nornir >> local_requirements.txt +``` + +Once installed, the plugin needs to be enabled in your Nautobot configuration. The following block of code below shows the additional configuration required to be added to your `nautobot_config.py` file: + +- Append `"nautobot_plugin_nornir"` to the `PLUGINS` list. +- Append the `"nautobot_plugin_nornir"` dictionary to the `PLUGINS_CONFIG` dictionary and override any defaults. + +```python +# In your nautobot_config.py +PLUGINS = ["nautobot_plugin_nornir"] + +# PLUGINS_CONFIG = { +# "nautobot_plugin_nornir": { +# ADD YOUR SETTINGS HERE +# } +# } +``` + +Once the Nautobot configuration is updated, run the Post Upgrade command (`nautobot-server post_upgrade`) to run migrations and clear any cache: + +```shell +nautobot-server post_upgrade +``` + +Then restart (if necessary) the Nautobot services which may include: + +- Nautobot +- Nautobot Workers +- Nautobot Scheduler + +```shell +sudo systemctl restart nautobot nautobot-worker nautobot-scheduler +``` + +## App Configuration + +!!! warning "Developer Note - Remove Me!" + Any configuration required to get the App set up. Edit the table below as per the examples provided. + +The plugin behavior can be controlled with the following list of settings: + +| Key | Example | Default | Description | +| ------- | ------ | -------- | ------------------------------------- | +| `enable_backup` | `True` | `True` | A boolean to represent whether or not to run backup configurations within the plugin. | +| `platform_slug_map` | `{"cisco_wlc": "cisco_aireos"}` | `None` | A dictionary in which the key is the platform slug and the value is what netutils uses in any "network_os" parameter. | +| `per_feature_bar_width` | `0.15` | `0.15` | The width of the table bar within the overview report | diff --git a/docs/admin/release_notes/index.md b/docs/admin/release_notes/index.md index 5793227..12cb516 100644 --- a/docs/admin/release_notes/index.md +++ b/docs/admin/release_notes/index.md @@ -1,3 +1,3 @@ # Release Notes -All the published release notes can be found via the navigation menu. All patch releases are included in the same minor release (e.g. `v1.1`) document. +All the published release notes can be found via the navigation menu. All patch releases are included in the same minor release (e.g. `v1.2`) document. diff --git a/docs/admin/release_notes/version_1.0.md b/docs/admin/release_notes/version_1.0.md index 08ef97c..7030d1a 100644 --- a/docs/admin/release_notes/version_1.0.md +++ b/docs/admin/release_notes/version_1.0.md @@ -1,44 +1,48 @@ # v1.0 Release Notes +!!! warning "Developer Note - Remove Me!" + Guiding Principles: -## Release Overview + - Changelogs are for humans, not machines. + - There should be an entry for every single version. + - The same types of changes should be grouped. + - Versions and sections should be linkable. + - The latest version comes first. + - The release date of each version is displayed. + - Mention whether you follow Semantic Versioning. -- Add provider class for Nautobot Secrets Functionality + Types of changes: -## [v1.0.1] - 2023-08 + - `Added` for new features. + - `Changed` for changes in existing functionality. + - `Deprecated` for soon-to-be removed features. + - `Removed` for now removed features. + - `Fixed` for any bug fixes. + - `Security` in case of vulnerabilities. -### Changed -- [#53](https://github.com/nautobot/nautobot-plugin-nornir/issues/53) - Update credentials for GH publishing. -- [#60](https://github.com/nautobot/nautobot-plugin-nornir/issues/60) - Doc cleanup and better error handling. -- [#62](https://github.com/nautobot/nautobot-plugin-nornir/issues/62) - Update readme to describe secrets usage. -- [#63](https://github.com/nautobot/nautobot-plugin-nornir/issues/63) - Update docs to new standards and development environment to NTC standards. -- [#64](https://github.com/nautobot/nautobot-plugin-nornir/issues/64) - Update links on Readme to point to read the docs page. -- [#65](https://github.com/nautobot/nautobot-plugin-nornir/issues/65) - More update links on Readme to point to read the docs page. -- [#66](https://github.com/nautobot/nautobot-plugin-nornir/issues/66) - Even more update links on Readme to point to read the docs page. -- [#69](https://github.com/nautobot/nautobot-plugin-nornir/issues/69) - Add suggested custom CSS for mkdocstrings indentation. -- [#70](https://github.com/nautobot/nautobot-plugin-nornir/issues/70) - Remove Args from class definition docstring. -- [#80](https://github.com/nautobot/nautobot-plugin-nornir/issues/80) - Update docs to new standards and development environment to NTC standards March addition. -- [#72](https://github.com/nautobot/nautobot-plugin-nornir/issues/72) - Update __init__.py to better describe the app in the UI. -- [#93](https://github.com/nautobot/nautobot-plugin-nornir/issues/93) - fix and cleanup some incorrect docs. +This document describes all new features and changes in the release `1.0`. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -### Fixed +## Release Overview + +- Major features or milestones +- Achieved in this `x.y` release +- Changes to compatibility with Nautobot and/or other plugins, libraries etc. -- [#68](https://github.com/nautobot/nautobot-plugin-nornir/issues/68) - Merge dispatcher rather than overwrite. -- [#91](https://github.com/nautobot/nautobot-plugin-nornir/issues/91) - Fix conn_options by using deepcopy to avoid pointers. -- [#102](https://github.com/nautobot/nautobot-plugin-nornir/issues/102) - Fix jinja settings support for golden config plugin. +## [v1.0.1] - 2021-09-08 -## [v1.0.0] - 2022-02 +### Added ### Changed -- [#43](https://github.com/nautobot/nautobot-plugin-nornir/issues/43) Update postgres Docker tag to v14. -- [#46](https://github.com/nautobot/nautobot-plugin-nornir/issues/46) Update Dependencies. -- [#48](https://github.com/nautobot/nautobot-plugin-nornir/issues/48) Make consistent default NORNIR_SETTINGS. +### Fixed + +- [#123](https://github.com/nautobot/nautobot-plugin-nornir/issues/123) Fixed Tag filtering not working in job launch form + +## [v1.0.0] - 2021-08-03 ### Added -- [#41](https://github.com/nautobot/nautobot-plugin-nornir/issues/41) Configure Renovate. -- [#45](https://github.com/nautobot/nautobot-plugin-nornir/issues/45) Add napalm/netmiko extras support to plugin config. -- [#49](https://github.com/nautobot/nautobot-plugin-nornir/issues/49) Add provider class for Nautobot Secrets Functionality. +### Changed +### Fixed diff --git a/docs/admin/uninstall.md b/docs/admin/uninstall.md new file mode 100644 index 0000000..7cd1603 --- /dev/null +++ b/docs/admin/uninstall.md @@ -0,0 +1,18 @@ +# Uninstall the App from Nautobot + +Here you will find any steps necessary to cleanly remove the App from your Nautobot environment. + +## Database Cleanup + +Prior to removing the plugin from the `nautobot_config.py`, run the following command to roll back any migration specific to this plugin. + +```shell +nautobot-server migrate nautobot_plugin_nornir zero +``` + +!!! warning "Developer Note - Remove Me!" + Any other cleanup operations to ensure the database is clean after the app is removed. Is there anything else that needs cleaning up, such as CFs, relationships, etc. if they're no longer desired? + +## Remove App configuration + +Remove the configuration you added in `nautobot_config.py` from `PLUGINS` & `PLUGINS_CONFIG`. diff --git a/docs/admin/upgrade.md b/docs/admin/upgrade.md new file mode 100644 index 0000000..17ac5d2 --- /dev/null +++ b/docs/admin/upgrade.md @@ -0,0 +1,10 @@ +# Upgrading the App + +Here you will find any steps necessary to upgrade the App in your Nautobot environment. + +## Upgrade Guide + +!!! warning "Developer Note - Remove Me!" + Add more detailed steps on how the app is upgraded in an existing Nautobot setup and any version specifics (such as upgrading between major versions with breaking changes). + +When a new release comes out it may be necessary to run a migration of the database to account for any changes in the data models used by this plugin. Execute the command `nautobot-server post-upgrade` within the runtime environment of your Nautobot installation after updating the `nautobot-plugin-nornir` package via `pip`. diff --git a/docs/assets/extra.css b/docs/assets/extra.css index 131cef7..dfe2e4b 100644 --- a/docs/assets/extra.css +++ b/docs/assets/extra.css @@ -18,6 +18,15 @@ font-size: 0.7rem; } +/* +* The default max-width is 61rem which does not provide nearly enough space to present code examples or larger tables +*/ +.md-grid { + margin-left: auto; + margin-right: auto; + max-width: 95%; +} + .md-tabs__link { font-size: 0.8rem; } @@ -39,7 +48,7 @@ } img.logo { - height: 100px; + height: 200px; } img.copyright-logo { @@ -85,3 +94,68 @@ a.autorefs-external::after { a.autorefs-external:hover::after { background-color: var(--md-accent-fg-color); } + + +/* Customization for mkdocs-version-annotations */ +:root { + /* Icon for "version-added" admonition: Material Design Icons "plus-box-outline" */ + --md-admonition-icon--version-added: url('data:image/svg+xml;charset=utf-8,'); + /* Icon for "version-changed" admonition: Material Design Icons "delta" */ + --md-admonition-icon--version-changed: url('data:image/svg+xml;charset=utf-8,'); + /* Icon for "version-removed" admonition: Material Design Icons "minus-circle-outline" */ + --md-admonition-icon--version-removed: url('data:image/svg+xml;charset=utf-8,'); +} + +/* "version-added" admonition in green */ +.md-typeset .admonition.version-added, +.md-typeset details.version-added { + border-color: rgb(0, 200, 83); +} + +.md-typeset .version-added>.admonition-title, +.md-typeset .version-added>summary { + background-color: rgba(0, 200, 83, .1); +} + +.md-typeset .version-added>.admonition-title::before, +.md-typeset .version-added>summary::before { + background-color: rgb(0, 200, 83); + -webkit-mask-image: var(--md-admonition-icon--version-added); + mask-image: var(--md-admonition-icon--version-added); +} + +/* "version-changed" admonition in orange */ +.md-typeset .admonition.version-changed, +.md-typeset details.version-changed { + border-color: rgb(255, 145, 0); +} + +.md-typeset .version-changed>.admonition-title, +.md-typeset .version-changed>summary { + background-color: rgba(255, 145, 0, .1); +} + +.md-typeset .version-changed>.admonition-title::before, +.md-typeset .version-changed>summary::before { + background-color: rgb(255, 145, 0); + -webkit-mask-image: var(--md-admonition-icon--version-changed); + mask-image: var(--md-admonition-icon--version-changed); +} + +/* "version-removed" admonition in red */ +.md-typeset .admonition.version-removed, +.md-typeset details.version-removed { + border-color: rgb(255, 82, 82); +} + +.md-typeset .version-removed>.admonition-title, +.md-typeset .version-removed>summary { + background-color: rgba(255, 82, 82, .1); +} + +.md-typeset .version-removed>.admonition-title::before, +.md-typeset .version-removed>summary::before { + background-color: rgb(255, 82, 82); + -webkit-mask-image: var(--md-admonition-icon--version-removed); + mask-image: var(--md-admonition-icon--version-removed); +} diff --git a/docs/assets/overrides/partials/copyright.html b/docs/assets/overrides/partials/copyright.html index e0b77e5..b92cf5e 100644 --- a/docs/assets/overrides/partials/copyright.html +++ b/docs/assets/overrides/partials/copyright.html @@ -1,3 +1,4 @@ +