Skip to content

Commit

Permalink
Merge pull request #216 from nautobot/drift-manager/pr
Browse files Browse the repository at this point in the history
Cookie updated by NetworkToCode Cookie Drift Manager Tool
  • Loading branch information
scetron authored Aug 14, 2024
2 parents 995c739 + cbbefe7 commit 31a0df0
Show file tree
Hide file tree
Showing 23 changed files with 150 additions and 369 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.1",
"template_ref": "refs/tags/nautobot-app-v2.3.0",
"cookie_dir": "",
"branch_prefix": "drift-manager",
"pull_request_strategy": "create",
"post_actions": [
"black"
],
"draft": true,
"baked_commit_ref": "e99ba259e45876cf5a3432b7b02f95feac3ae6ad"
"baked_commit_ref": "32dbed28878e65887bfd9bd5601a0d4c5b5220e8"
}
}
}
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.

36 changes: 6 additions & 30 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ env:
APP_NAME: "nautobot-app-device-onboarding"

jobs:
black:
ruff-format:
runs-on: "ubuntu-22.04"
env:
INVOKE_NAUTOBOT_DEVICE_ONBOARDING_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_ONBOARDING_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_ONBOARDING_LOCAL: "True"
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_ONBOARDING_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 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-onboarding/"><img src="https://img.shields.io/pypi/v/nautobot-device-onboarding"></a>
<a href="https://pypi.org/project/nautobot-device-onboarding/"><img src="https://img.shields.io/pypi/dm/nautobot-device-onboarding"></a>
<br>
A plugin for <a href="https://github.com/nautobot/nautobot">Nautobot</a> to easily onboard new devices.
An <a href="https://networktocode.com/nautobot-apps/">App</a> for <a href="https://nautobot.com/">Nautobot</a>.
</p>

## Overview
Expand Down
1 change: 1 addition & 0 deletions changes/216.housekeeping
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Rebake using 2.3 Nautobot-App-Cookiecutter.
1 change: 0 additions & 1 deletion development/docker-compose.mysql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ services:
db:
image: "mysql:8"
command:
- "--default-authentication-plugin=mysql_native_password"
- "--max_connections=1000"
env_file:
- "development.env"
Expand Down
7 changes: 4 additions & 3 deletions development/nautobot_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,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 @@ -48,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
2 changes: 1 addition & 1 deletion docs/assets/extra.css
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ a.autorefs-external:hover::after {
}


/* Customization for mkdocs-version-annotations */
/* Customization for markdown-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,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19 19V5H5v14h14m0-16a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14m-8 4h2v4h4v2h-4v4h-2v-4H7v-2h4V7Z"/></svg>');
Expand Down
2 changes: 1 addition & 1 deletion docs/dev/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The project is packaged with a light [development environment](dev_environment.m

The project is following Network to Code software development guidelines and is leveraging the following:

- Python linting and formatting: `black`, `pylint`, `bandit`, `flake8`, and `ruff`.
- Python linting and formatting: `pylint` and `ruff`.
- YAML linting is done with `yamllint`.
- Django unit test to ensure the app is working properly.

Expand Down
10 changes: 2 additions & 8 deletions docs/dev/dev_environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,7 @@ Each command can be executed with `invoke <command>`. All commands support the a
#### Testing

```
bandit Run bandit to validate basic static code security analysis.
black Run black to check that Python files adhere to its style standards.
flake8 Run flake8 to check that Python files adhere to its style standards.
ruff Run ruff to validate docstring formatting adheres to NTC defined standards.
ruff Run ruff to perform code formatting and/or linting.
pylint Run pylint code analysis.
tests Run all tests for this app.
unittest Run Django unit tests for the app.
Expand Down Expand Up @@ -457,7 +454,7 @@ This is the same as running:

### Tests

To run tests against your code, you can run all of the tests that TravisCI runs against any new PR with:
To run tests against your code, you can run all of the tests that the CI runs against any new PR with:

```bash
➜ invoke tests
Expand All @@ -467,9 +464,6 @@ To run an individual test, you can run any or all of the following:

```bash
➜ invoke unittest
➜ invoke bandit
➜ invoke black
➜ invoke flake8
➜ invoke ruff
➜ invoke pylint
```
2 changes: 1 addition & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
mkdocs==1.5.2
mkdocs-material==9.1.15
mkdocs-version-annotations==1.0.0
markdown-version-annotations==1.0.1
mkdocstrings-python==1.5.2
mkdocstrings==0.22.0
3 changes: 2 additions & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ extra:
link: "https://twitter.com/networktocode"
name: "Network to Code Twitter"
markdown_extensions:
- "markdown_version_annotations":
admonition_tag: "???"
- "admonition"
- "toc":
permalink: true
Expand All @@ -85,7 +87,6 @@ markdown_extensions:
- "footnotes"
plugins:
- "search"
- "mkdocs-version-annotations"
- "mkdocstrings":
default_handler: "python"
handlers:
Expand Down
3 changes: 1 addition & 2 deletions nautobot_device_onboarding/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""App declaration for nautobot_device_onboarding."""

# Metadata is inherited from Nautobot
# If not including Nautobot in the environment, this should be added
# Metadata is inherited from Nautobot. If not including Nautobot in the environment, this should be added
from importlib import metadata

from nautobot.apps import NautobotAppConfig
Expand Down
6 changes: 3 additions & 3 deletions nautobot_device_onboarding/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,9 +383,9 @@ def _process_csv_data(self, csv_file):
processed_csv_data[row["ip_address_host"]]["port"] = int(row["port"].strip())
processed_csv_data[row["ip_address_host"]]["timeout"] = int(row["timeout"].strip())
processed_csv_data[row["ip_address_host"]]["set_mgmt_only"] = set_mgmgt_only
processed_csv_data[row["ip_address_host"]][
"update_devices_without_primary_ip"
] = update_devices_without_primary_ip
processed_csv_data[row["ip_address_host"]]["update_devices_without_primary_ip"] = (
update_devices_without_primary_ip
)
processed_csv_data[row["ip_address_host"]]["device_role"] = device_role
processed_csv_data[row["ip_address_host"]]["device_status"] = device_status
processed_csv_data[row["ip_address_host"]]["interface_status"] = interface_status
Expand Down
28 changes: 28 additions & 0 deletions nautobot_device_onboarding/tests/test_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""Unit tests for nautobot_device_onboarding."""

from django.contrib.auth import get_user_model
from django.test import TestCase
from django.urls import reverse
from nautobot.users.models import Token
from rest_framework import status
from rest_framework.test import APIClient

User = get_user_model()


class PlaceholderAPITest(TestCase):
"""Test the NautobotDeviceOnboarding API."""

def setUp(self):
"""Create a superuser and token for API calls."""
self.user = User.objects.create(username="testuser", is_superuser=True)
self.token = Token.objects.create(user=self.user)
self.client = APIClient()
self.client.credentials(HTTP_AUTHORIZATION=f"Token {self.token.key}")

def test_placeholder(self):
"""Verify that devices can be listed."""
url = reverse("dcim-api:device-list")
response = self.client.get(url)
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(response.data["count"], 0)
7 changes: 4 additions & 3 deletions nautobot_device_onboarding/tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ def test_version(self):
with open(f"{parent_path}/docs/requirements.txt", "r", encoding="utf-8") as file:
requirements = [line for line in file.read().splitlines() if (len(line) > 0 and not line.startswith("#"))]
for pkg in requirements:
if len(pkg.split("==")) == 2:
pkg, version = pkg.split("==")
package_name = pkg
if len(pkg.split("==")) == 2: # noqa: PLR2004
package_name, version = pkg.split("==")
else:
version = "*"
self.assertEqual(poetry_details[pkg], version)
self.assertEqual(poetry_details[package_name], version)
2 changes: 1 addition & 1 deletion nautobot_device_onboarding/tests/test_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

from nautobot_device_onboarding.nornir_plays.formatter import (
extract_and_post_process,
perform_data_extraction,
normalize_processed_data,
perform_data_extraction,
)
from nautobot_device_onboarding.nornir_plays.transform import add_platform_parsing_info

Expand Down
1 change: 1 addition & 0 deletions nautobot_device_onboarding/tests/test_jinja_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import unittest
import unittest.mock

from nautobot_device_onboarding.jinja_filters import (
extract_prefix,
flatten_dict_from_value,
Expand Down
4 changes: 1 addition & 3 deletions nautobot_device_onboarding/tests/test_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,7 @@ def test_git_repo_was_created(self, MockGitRepo): # pylint:disable=invalid-name
self.assertEqual(1, repo_count)

@mock.patch("nautobot_device_onboarding.nornir_plays.transform.load_command_mappers_from_dir")
def test_pull_git_repository_and_refresh_data_with_valid_data(
self, mock_load_command_mappers, MockGitRepo
): # pylint:disable=invalid-name
def test_pull_git_repository_and_refresh_data_with_valid_data(self, mock_load_command_mappers, MockGitRepo): # pylint:disable=invalid-name
"""
The test_pull_git_repository_and_refresh_data job should succeed if valid data is present in the repo.
"""
Expand Down
Loading

0 comments on commit 31a0df0

Please sign in to comment.