Skip to content

Commit

Permalink
Merge pull request #374 from nautobot/release-2.2.0
Browse files Browse the repository at this point in the history
Release v2.2.0
  • Loading branch information
bradh11 authored Sep 6, 2024
2 parents 2d68b7d + 8530038 commit 1e45ede
Show file tree
Hide file tree
Showing 61 changed files with 2,345 additions and 2,245 deletions.
4 changes: 2 additions & 2 deletions .cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@
"_drift_manager": {
"template": "https://github.com/nautobot/cookiecutter-nautobot-app.git",
"template_dir": "nautobot-app",
"template_ref": "refs/tags/nautobot-app-v2.2.0",
"template_ref": "refs/tags/nautobot-app-v2.3.2",
"cookie_dir": "",
"branch_prefix": "drift-manager",
"pull_request_strategy": "create",
"post_actions": [
"black"
],
"draft": true,
"baked_commit_ref": "88f34a0a58485295d8fb90427ee664eda511430d"
"baked_commit_ref": "3f6783c6371261fc6cffe4247c4ae238ce1284cb"
}
}
}
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ FAQ.md
.git/
.gitignore
.github
tasks.py
LICENSE
**/*.log
**/.vscode/
Expand Down
10 changes: 0 additions & 10 deletions .flake8

This file was deleted.

58 changes: 22 additions & 36 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ on: # yamllint disable-line rule:truthy rule:comments
pull_request: ~

env:
APP_NAME: "nautobot-app-device-lifecycle-mgmt"
APP_NAME: "nautobot-device-lifecycle-mgmt"

jobs:
black:
ruff-format:
runs-on: "ubuntu-22.04"
env:
INVOKE_NAUTOBOT_DEVICE_LIFECYCLE_MGMT_LOCAL: "True"
Expand All @@ -25,20 +25,9 @@ jobs:
uses: "actions/checkout@v4"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v6"
- name: "Linting: black"
run: "poetry run invoke black"
bandit:
runs-on: "ubuntu-22.04"
env:
INVOKE_NAUTOBOT_DEVICE_LIFECYCLE_MGMT_LOCAL: "True"
steps:
- name: "Check out repository code"
uses: "actions/checkout@v4"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v6"
- name: "Linting: bandit"
run: "poetry run invoke bandit"
ruff:
- name: "Linting: ruff format"
run: "poetry run invoke ruff --action format"
ruff-lint:
runs-on: "ubuntu-22.04"
env:
INVOKE_NAUTOBOT_DEVICE_LIFECYCLE_MGMT_LOCAL: "True"
Expand All @@ -48,7 +37,7 @@ jobs:
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v6"
- name: "Linting: ruff"
run: "poetry run invoke ruff"
run: "poetry run invoke ruff --action lint"
check-docs-build:
runs-on: "ubuntu-22.04"
env:
Expand All @@ -60,17 +49,6 @@ jobs:
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:
INVOKE_NAUTOBOT_DEVICE_LIFECYCLE_MGMT_LOCAL: "True"
steps:
- name: "Check out repository code"
uses: "actions/checkout@v4"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v6"
- name: "Linting: flake8"
run: "poetry run invoke flake8"
poetry:
runs-on: "ubuntu-22.04"
env:
Expand All @@ -95,12 +73,10 @@ jobs:
run: "poetry run invoke yamllint"
check-in-docker:
needs:
- "bandit"
- "ruff"
- "flake8"
- "ruff-format"
- "ruff-lint"
- "poetry"
- "yamllint"
- "black"
runs-on: "ubuntu-22.04"
strategy:
fail-fast: true
Expand All @@ -115,6 +91,10 @@ jobs:
uses: "actions/checkout@v4"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v6"
- name: "Constrain Nautobot version and regenerate lock file"
env:
INVOKE_NAUTOBOT_DEVICE_LIFECYCLE_MGMT_LOCAL: "true"
run: "poetry run invoke lock --constrain-nautobot-ver --constrain-python-ver"
- name: "Set up Docker Buildx"
id: "buildx"
uses: "docker/setup-buildx-action@v3"
Expand All @@ -132,6 +112,7 @@ jobs:
build-args: |
NAUTOBOT_VER=${{ matrix.nautobot-version }}
PYTHON_VER=${{ matrix.python-version }}
CI=true
- name: "Copy credentials"
run: "cp development/creds.example.env development/creds.env"
- name: "Linting: pylint"
Expand All @@ -146,14 +127,14 @@ jobs:
strategy:
fail-fast: true
matrix:
python-version: ["3.8", "3.11"]
python-version: ["3.8", "3.12"]
db-backend: ["postgresql"]
nautobot-version: ["stable"]
include:
- python-version: "3.11"
db-backend: "postgresql"
nautobot-version: "2.0.0"
# - python-version: "3.11"
# - python-version: "3.12"
# db-backend: "mysql"
# nautobot-version: "stable"
runs-on: "ubuntu-22.04"
Expand All @@ -165,6 +146,10 @@ jobs:
uses: "actions/checkout@v4"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v6"
- name: "Constrain Nautobot version and regenerate lock file"
env:
INVOKE_NAUTOBOT_DEVICE_LIFECYCLE_MGMT_LOCAL: "true"
run: "poetry run invoke lock --constrain-nautobot-ver --constrain-python-ver"
- name: "Set up Docker Buildx"
id: "buildx"
uses: "docker/setup-buildx-action@v3"
Expand All @@ -182,6 +167,7 @@ jobs:
build-args: |
NAUTOBOT_VER=${{ matrix.nautobot-version }}
PYTHON_VER=${{ matrix.python-version }}
CI=true
- name: "Copy credentials"
run: "cp development/creds.example.env development/creds.env"
- name: "Use Mysql invoke settings when needed"
Expand Down Expand Up @@ -219,7 +205,7 @@ jobs:
- name: "Set up Python"
uses: "actions/setup-python@v5"
with:
python-version: "3.11"
python-version: "3.12"
- name: "Install Python Packages"
run: "pip install poetry"
- name: "Set env"
Expand Down Expand Up @@ -254,7 +240,7 @@ jobs:
- name: "Set up Python"
uses: "actions/setup-python@v5"
with:
python-version: "3.11"
python-version: "3.12"
- name: "Install Python Packages"
run: "pip install poetry"
- name: "Set env"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<a href="https://pypi.org/project/nautobot-device-lifecycle-mgmt/"><img src="https://img.shields.io/pypi/v/nautobot-device-lifecycle-mgmt"></a>
<a href="https://pypi.org/project/nautobot-device-lifecycle-mgmt/"><img src="https://img.shields.io/pypi/dm/nautobot-device-lifecycle-mgmt"></a>
<br>
An App for <a href="https://github.com/nautobot/nautobot">Nautobot</a>.
An <a href="https://networktocode.com/nautobot-apps/">App</a> for <a href="https://nautobot.com/">Nautobot</a>.
</p>

## Overview
Expand Down
39 changes: 14 additions & 25 deletions development/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
# -------------------------------------------------------------------------------------
# !!! USE CAUTION WHEN MODIFYING LINES BELOW

# Accepts a desired Nautobot version as build argument, default to 2.0.0
ARG NAUTOBOT_VER="2.0.0"
# Accepts a desired Nautobot version as build argument, default to 2.3.0
ARG NAUTOBOT_VER="2.3.0"

# Accepts a desired Python version as build argument, default to 3.11
ARG PYTHON_VER="3.11"
# Accepts a desired Python version as build argument, default to 3.12
ARG PYTHON_VER="3.12"

# Retrieve published development image of Nautobot base which should include most CI dependencies
FROM ghcr.io/nautobot/nautobot-dev:${NAUTOBOT_VER}-py${PYTHON_VER}
Expand Down Expand Up @@ -53,29 +53,18 @@ RUN which poetry || curl -sSL https://install.python-poetry.org | python3 - && \
WORKDIR /source
COPY . /source

# Get container's installed Nautobot version as a forced constraint
# NAUTOBOT_VER may be a branch name and not a published release therefor we need to get the installed version
# so pip can use it to recognize local constraints.
RUN pip show nautobot | grep "^Version: " | sed -e 's/Version: /nautobot==/' > constraints.txt
# Build args must be declared in each stage
ARG PYTHON_VER

# Use Poetry to grab dev dependencies from the lock file
# Can be improved in Poetry 1.2 which allows `poetry install --only dev`
#
# We can't use the entire freeze as it takes forever to resolve with rigidly fixed non-direct dependencies,
# especially those that are only direct to Nautobot but the container included versions slightly mismatch
RUN poetry export -f requirements.txt --without-hashes --extras all --output poetry_freeze_base.txt
RUN poetry export -f requirements.txt --without-hashes --extras all --with dev --output poetry_freeze_all.txt
RUN sort poetry_freeze_base.txt poetry_freeze_all.txt | uniq -u > poetry_freeze_dev.txt

# Install all local project as editable, constrained on Nautobot version, to get any additional
# direct dependencies of the app
RUN --mount=type=cache,target="/root/.cache/pip",sharing=locked \
pip install -c constraints.txt -e .[all]
# Constrain the Nautobot version to NAUTOBOT_VER
# In CI, this should be done outside of the Dockerfile to prevent cross-compile build failures
ARG CI
RUN if [ -z "${CI+x}" ]; then \
INSTALLED_NAUTOBOT_VER=$(pip show nautobot | grep "^Version" | sed "s/Version: //"); \
poetry add --lock nautobot@${INSTALLED_NAUTOBOT_VER} --python ${PYTHON_VER}; fi

# Install any dev dependencies frozen from Poetry
# Can be improved in Poetry 1.2 which allows `poetry install --only dev`
RUN --mount=type=cache,target="/root/.cache/pip",sharing=locked \
pip install -c constraints.txt -r poetry_freeze_dev.txt
# Install the app
RUN poetry install --extras all --with dev

COPY development/nautobot_config.py ${NAUTOBOT_ROOT}/nautobot_config.py
# !!! USE CAUTION WHEN MODIFYING LINES ABOVE
1 change: 1 addition & 0 deletions development/app_config_schema.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""App Config Schema Generator and Validator."""

import json
from importlib import import_module
from os import getenv
Expand Down
2 changes: 2 additions & 0 deletions development/development.env
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,5 @@ POSTGRES_DB=${NAUTOBOT_DB_NAME}
MYSQL_USER=${NAUTOBOT_DB_USER}
MYSQL_DATABASE=${NAUTOBOT_DB_NAME}
MYSQL_ROOT_HOST=%

NAUTOBOT_DLM_ENABLED_METRICS = "nautobot_lcm_software_compliance_per_device_type,nautobot_lcm_software_compliance_per_inventory_item,nautobot_lcm_hw_end_of_support_per_part_number,nautobot_lcm_hw_end_of_support_per_location"
1 change: 0 additions & 1 deletion development/docker-compose.base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ x-nautobot-base: &nautobot-base
- "creds.env"
tty: true

version: "3.8"
services:
nautobot:
depends_on:
Expand Down
1 change: 0 additions & 1 deletion development/docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# any override will need to include these volumes to use them.
# see: https://github.com/docker/compose/issues/3729
---
version: "3.8"
services:
nautobot:
command: "nautobot-server runserver 0.0.0.0:8080"
Expand Down
3 changes: 0 additions & 3 deletions development/docker-compose.mysql.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
---
version: "3.8"

services:
nautobot:
environment:
Expand All @@ -19,7 +17,6 @@ services:
db:
image: "mysql:8"
command:
- "--default-authentication-plugin=mysql_native_password"
- "--max_connections=1000"
env_file:
- "development.env"
Expand Down
2 changes: 0 additions & 2 deletions development/docker-compose.postgres.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
---
version: "3.8"

services:
nautobot:
environment:
Expand Down
1 change: 0 additions & 1 deletion development/docker-compose.redis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---
version: "3.8"
services:
redis:
image: "redis:6-alpine"
Expand Down
9 changes: 6 additions & 3 deletions development/nautobot_config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Nautobot development configuration file."""

import os
import sys

Expand All @@ -9,7 +10,7 @@
# Debug
#

DEBUG = is_truthy(os.getenv("NAUTOBOT_DEBUG", False))
DEBUG = is_truthy(os.getenv("NAUTOBOT_DEBUG", "false"))
_TESTING = len(sys.argv) > 1 and sys.argv[1] == "test"

if DEBUG and not _TESTING:
Expand Down Expand Up @@ -47,9 +48,10 @@
"PASSWORD": os.getenv("NAUTOBOT_DB_PASSWORD", ""), # Database password
"HOST": os.getenv("NAUTOBOT_DB_HOST", "localhost"), # Database server
"PORT": os.getenv(
"NAUTOBOT_DB_PORT", default_db_settings[nautobot_db_engine]["NAUTOBOT_DB_PORT"]
"NAUTOBOT_DB_PORT",
default_db_settings[nautobot_db_engine]["NAUTOBOT_DB_PORT"],
), # Database port, default to postgres
"CONN_MAX_AGE": int(os.getenv("NAUTOBOT_DB_TIMEOUT", 300)), # Database timeout
"CONN_MAX_AGE": int(os.getenv("NAUTOBOT_DB_TIMEOUT", "300")), # Database timeout
"ENGINE": nautobot_db_engine,
}
}
Expand Down Expand Up @@ -135,5 +137,6 @@
"barchart_bar_width": float(os.environ.get("BARCHART_BAR_WIDTH", 0.1)),
"barchart_width": int(os.environ.get("BARCHART_WIDTH", 12)),
"barchart_height": int(os.environ.get("BARCHART_HEIGHT", 5)),
"enabled_metrics": [x for x in os.environ.get("NAUTOBOT_DLM_ENABLED_METRICS", "").split(",") if x],
},
}
1 change: 1 addition & 0 deletions docs/admin/compatibility_matrix.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

| Device Lifecycle Management Version | Nautobot First Support Version | Nautobot Last Support Version |
| ------------- | -------------------- | ------------- |
| 2.2.X | 2.0.0 | 2.99.99 |
| 2.1.2-2.1.X | 2.0.0 | 2.99.99 |
| 2.1.0-2.1.1 | 2.0.0 | 2.2.99 |
| 2.0.X | 2.0.0 | 2.2.99 |
Expand Down
26 changes: 20 additions & 6 deletions docs/admin/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,23 @@ sudo systemctl restart nautobot nautobot-worker nautobot-scheduler
## App Configuration

The app behavior can be controlled with the following list of settings:
| Key | Example | Default | Description |
| -------------------- | ------------------------- | ------- | -------------------------------------------------------------------- |
| `expired_field` | `end_of_support` | | The field name representing the expiry date. |
| `barchart_bar_width` | `0.1` | `0.15` | The width of the table bar within the overview report. |
| `barchart_width` | `12` | | The width of the barchart within the overview report. |
| `barchart_height` | `5` | | The height of the barchart within the overview report. |

| Key | ENV VAR | Example | Default | Description |
| -------------------- | ------- | ------------------------- | ------- | -------------------------------------------------------------------- |
| `expired_field` | `NAUTOBOT_DLM_EXPIRED_FIELD` | `end_of_support` | `end_of_support` | The field name representing the expiry date. |
| `barchart_bar_width` | `BARCHART_BAR_WIDTH` | `0.1` | `0.15` | The width of the table bar within the overview report. |
| `barchart_width` | `BARCHART_WIDTH` | `12` | `12` | The width of the barchart within the overview report. |
| `barchart_height` | `BARCHART_HEIGHT` | `5` | `5` | The height of the barchart within the overview report. |
| `enabled_metrics` | `NAUTOBOT_DLM_ENABLED_METRICS` | `["nautobot_lcm_hw_end_of_support_per_location"]` | `[]` | Enables metrics corresponding to the provided, comma separated, entries. |

### Available Metric Names

Following are the metric names that can be defined in `enabled_metrics`:

- `nautobot_lcm_software_compliance_per_device_type`: Number of devices with valid/invalid software by device_type.

- `nautobot_lcm_software_compliance_per_inventory_item`: Number of inventory items with valid/invalid software.

- `nautobot_lcm_hw_end_of_support_per_part_number`: Number of End of Support devices and inventory items per Part Number.

- `nautobot_lcm_hw_end_of_support_per_location`: Number of End of Support devices and inventory items per Location.
Loading

0 comments on commit 1e45ede

Please sign in to comment.