Skip to content

Commit

Permalink
Cookie updated by NetworkToCode Cookie Drift Manager Tool (#401)
Browse files Browse the repository at this point in the history
* Cookie updated by NetworkToCode Cookie Drift Manager Tool

Template:

```
{
    "template": "https://github.com/nautobot/cookiecutter-nautobot-app.git",
    "dir": "nautobot-app",
    "ref": "refs/tags/nautobot-app-v2.4.1",
    "path": null
}
```

Cookie:

```
{
    "remote": "https://github.com/nautobot/nautobot-app-device-lifecycle-mgmt.git",
    "path": "/tmp/tmp9t0bkxk7/nautobot-app-device-lifecycle-mgmt",
    "repository_path": "/tmp/tmp9t0bkxk7/nautobot-app-device-lifecycle-mgmt",
    "dir": "",
    "branch_prefix": "drift-manager",
    "context": {
        "codeowner_github_usernames": "@josh5276 @jvanderaa @progala",
        "full_name": "Network to Code, LLC",
        "email": "[email protected]",
        "github_org": "nautobot",
        "app_name": "nautobot_device_lifecycle_mgmt",
        "verbose_name": "Device Lifecycle Management",
        "app_slug": "nautobot-device-lifecycle-mgmt",
        "project_slug": "nautobot-app-device-lifecycle-mgmt",
        "repo_url": "https://github.com/nautobot/nautobot-app-device-lifecycle-mgmt",
        "base_url": "nautobot-device-lifecycle-mgmt",
        "min_nautobot_version": "2.0.0",
        "max_nautobot_version": "2.9999",
        "camel_name": "NautobotDeviceLifecycleManagement",
        "project_short_description": "Device Lifecycle Management",
        "model_class_name": "HardwareLCM",
        "open_source_license": "Apache-2.0",
        "docs_base_url": "https://docs.nautobot.com",
        "docs_app_url": "https://docs.nautobot.com/projects/device-lifecycle/en/latest",
        "_template": "https://github.com/nautobot/cookiecutter-nautobot-app.git",
        "_output_dir": "/tmp/tmp9t0bkxk7",
        "_repo_dir": "/github/home/.cookiecutters/cookiecutter-nautobot-app/nautobot-app",
        "_checkout": "refs/tags/nautobot-app-v2.4.1"
    },
    "base_branch": "develop",
    "remote_name": "origin",
    "pull_request_strategy": "PullRequestStrategy.CREATE",
    "post_actions": [
        "PostAction.RUFF",
        "PostAction.POETRY"
    ],
    "baked_commit_ref": "9f5d82bd64864882fb5b6cd7edd997aa4b451a19",
    "draft": false
}
```

CLI Arguments:

```
{
    "cookie_dir": "",
    "input": false,
    "json_filename": "",
    "output_dir": "",
    "push": true,
    "template": "",
    "template_dir": "",
    "template_ref": "refs/tags/nautobot-app-v2.4.1",
    "pull_request": null,
    "post_action": [
        "ruff",
        "poetry"
    ],
    "disable_post_actions": true,
    "draft": false
}
```

* Correct issues from Drift Management.

* Add missing serializer.

* Add another Drift Managed removal

* OrganizationalModel does not have tags.

* Add back app_name

---------

Co-authored-by: bakebot <[email protected]>
Co-authored-by: Stephen Kiely <[email protected]>
  • Loading branch information
3 people authored Jan 28, 2025
1 parent da62cc9 commit 2aa785b
Show file tree
Hide file tree
Showing 14 changed files with 888 additions and 877 deletions.
4 changes: 2 additions & 2 deletions .cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"_drift_manager": {
"template": "https://github.com/nautobot/cookiecutter-nautobot-app.git",
"template_dir": "nautobot-app",
"template_ref": "refs/tags/nautobot-app-v2.4.0",
"template_ref": "refs/tags/nautobot-app-v2.4.1",
"cookie_dir": "",
"branch_prefix": "drift-manager",
"pull_request_strategy": "create",
Expand All @@ -30,7 +30,7 @@
"poetry"
],
"draft": false,
"baked_commit_ref": "9f5d82bd64864882fb5b6cd7edd997aa4b451a19"
"baked_commit_ref": "304a9faa5035b6192406467e56e1f6b8bbd1e815"
}
}
}
File renamed without changes.
16 changes: 16 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ jobs:
uses: "actions/checkout@v4"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v6"
with:
poetry-version: "1.8.5"
- name: "Linting: ruff format"
run: "poetry run invoke ruff --action format"
ruff-lint:
Expand All @@ -36,6 +38,8 @@ jobs:
uses: "actions/checkout@v4"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v6"
with:
poetry-version: "1.8.5"
- name: "Linting: ruff"
run: "poetry run invoke ruff --action lint"
check-docs-build:
Expand All @@ -47,6 +51,8 @@ jobs:
uses: "actions/checkout@v4"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v6"
with:
poetry-version: "1.8.5"
- name: "Check Docs Build"
run: "poetry run invoke build-and-check-docs"
poetry:
Expand All @@ -58,6 +64,8 @@ jobs:
uses: "actions/checkout@v4"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v6"
with:
poetry-version: "1.8.5"
- name: "Checking: poetry lock file"
run: "poetry run invoke lock --check"
yamllint:
Expand All @@ -69,6 +77,8 @@ jobs:
uses: "actions/checkout@v4"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v6"
with:
poetry-version: "1.8.5"
- name: "Linting: yamllint"
run: "poetry run invoke yamllint"
check-in-docker:
Expand All @@ -91,6 +101,8 @@ jobs:
uses: "actions/checkout@v4"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v6"
with:
poetry-version: "1.8.5"
- name: "Constrain Nautobot version and regenerate lock file"
env:
INVOKE_NAUTOBOT_DEVICE_LIFECYCLE_MGMT_LOCAL: "true"
Expand Down Expand Up @@ -146,6 +158,8 @@ jobs:
uses: "actions/checkout@v4"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v6"
with:
poetry-version: "1.8.5"
- name: "Constrain Nautobot version and regenerate lock file"
env:
INVOKE_NAUTOBOT_DEVICE_LIFECYCLE_MGMT_LOCAL: "true"
Expand Down Expand Up @@ -187,6 +201,8 @@ jobs:
fetch-depth: "0"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v6"
with:
poetry-version: "1.8.5"
- name: "Check for changelog entry"
run: |
git fetch --no-tags origin +refs/heads/${{ github.base_ref }}:refs/remotes/origin/${{ github.base_ref }}
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Apache Software License 2.0

Copyright (c) 2024, Network to Code, LLC
Copyright (c) 2025, 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.
Expand Down
1 change: 1 addition & 0 deletions changes/+nautobot-app-v2.4.1.housekeeping
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Rebaked from the cookie `nautobot-app-v2.4.1`.
6 changes: 4 additions & 2 deletions development/docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,12 @@ services:
volumes:
- "./nautobot_config.py:/opt/nautobot/nautobot_config.py"
- "../:/source"
# To expose postgres or redis to the host uncomment the following
# postgres:
# To expose postgres (5432), myql (3306) on db service or redis (6379) to the host uncomment the
# following. Ensure to match the 2 idented spaces which to have the service nested under services.
# db:
# ports:
# - "5432:5432"
# - "3306:3306"
# redis:
# ports:
# - "6379:6379"
7 changes: 7 additions & 0 deletions development/docker-compose.mysql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ services:
- "development.env"
- "creds.env"
- "development_mysql.env"
beat:
environment:
- "NAUTOBOT_DB_ENGINE=django.db.backends.mysql"
env_file:
- "development.env"
- "creds.env"
- "development_mysql.env"
db:
image: "mysql:8"
command:
Expand Down
14 changes: 3 additions & 11 deletions development/nautobot_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
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
from nautobot.core.settings_funcs import is_truthy

#
# Debug
Expand Down Expand Up @@ -65,16 +65,8 @@
#

# 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",
},
}
}
# Inherited from nautobot.core.settings
# CACHES = {....}

#
# Celery settings are not defined here because they can be overloaded with
Expand Down
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ nav:
- Extending the App: "dev/extending.md"
- Contributing to the App: "dev/contributing.md"
- Development Environment: "dev/dev_environment.md"
- Release Checklist: "dev/release_checklist.md"
- Architecture Decision Records: "dev/arch_decision.md"
- Code Reference:
- "dev/code_reference/index.md"
Expand Down
85 changes: 38 additions & 47 deletions nautobot_device_lifecycle_mgmt/api/serializers.py
Original file line number Diff line number Diff line change
@@ -1,109 +1,100 @@
"""API serializers implementation for the LifeCycle Management app."""
"""API serializers for nautobot_device_lifecycle_mgmt."""

from nautobot.apps.api import NautobotModelSerializer, TaggedModelSerializerMixin

from nautobot_device_lifecycle_mgmt.models import (
CVELCM,
ContactLCM,
ContractLCM,
DeviceSoftwareValidationResult,
HardwareLCM,
InventoryItemSoftwareValidationResult,
ProviderLCM,
SoftwareImageLCM,
SoftwareLCM,
ValidatedSoftwareLCM,
VulnerabilityLCM,
)
from nautobot_device_lifecycle_mgmt import models


class HardwareLCMSerializer(NautobotModelSerializer): # pylint: disable=R0901,too-few-public-methods
"""API serializer."""
class HardwareLCMSerializer(NautobotModelSerializer, TaggedModelSerializerMixin): # pylint: disable=too-many-ancestors
"""HardwareLCM Serializer."""

class Meta:
"""Meta attributes."""

model = HardwareLCM
model = models.HardwareLCM
fields = "__all__"

# Option for disabling write for certain fields:
# read_only_fields = []

class ProviderLCMSerializer(NautobotModelSerializer): # pylint: disable=R0901,too-few-public-methods
"""API serializer."""

class ProviderLCMSerializer(NautobotModelSerializer): # pylint: disable=too-many-ancestors
"""ProviderLCM Serializer."""

class Meta:
"""Meta attributes."""

model = ProviderLCM
model = models.ProviderLCM
fields = "__all__"


class ContractLCMSerializer(NautobotModelSerializer, TaggedModelSerializerMixin): # pylint: disable=R0901,too-few-public-methods
"""API serializer."""
class ContractLCMSerializer(NautobotModelSerializer, TaggedModelSerializerMixin): # pylint: disable=too-many-ancestors
"""ContractLCM Serializer."""

class Meta:
"""Meta attributes."""

model = ContractLCM
model = models.ContractLCM
fields = "__all__"


class ContactLCMSerializer(NautobotModelSerializer): # pylint: disable=R0901,too-few-public-methods
"""API serializer."""
class ContactLCMSerializer(NautobotModelSerializer, TaggedModelSerializerMixin): # pylint: disable=too-many-ancestors
"""ContactLCM Serializer."""

class Meta:
"""Meta attributes."""

model = ContactLCM
model = models.ContactLCM
fields = "__all__"


class SoftwareLCMSerializer(NautobotModelSerializer):
"""REST API serializer for SoftwareLCM records."""
class SoftwareLCMSerializer(NautobotModelSerializer, TaggedModelSerializerMixin): # pylint: disable=too-many-ancestors
"""SoftwareLCM Serializer."""

class Meta:
"""Meta attributes."""

model = SoftwareLCM
model = models.SoftwareLCM
fields = "__all__"


class SoftwareImageLCMSerializer(NautobotModelSerializer):
"""REST API serializer for SoftwareImageLCM records."""
class SoftwareImageLCMSerializer(NautobotModelSerializer, TaggedModelSerializerMixin): # pylint: disable=too-many-ancestors
"""SoftwareImageLCM Serializer."""

class Meta:
"""Meta attributes."""

model = SoftwareImageLCM
model = models.SoftwareImageLCM
fields = "__all__"


class ValidatedSoftwareLCMSerializer(NautobotModelSerializer):
"""REST API serializer for ValidatedSoftwareLCM records."""
class ValidatedSoftwareLCMSerializer(NautobotModelSerializer, TaggedModelSerializerMixin): # pylint: disable=too-many-ancestors
"""ValidatedSoftwareLCM Serializer."""

class Meta:
"""Meta attributes."""

model = ValidatedSoftwareLCM
model = models.ValidatedSoftwareLCM
fields = "__all__"


class CVELCMSerializer(NautobotModelSerializer): # pylint: disable=abstract-method,too-few-public-methods
"""REST API serializer for CVELCM records."""
class CVELCMSerializer(NautobotModelSerializer, TaggedModelSerializerMixin): # pylint: disable=too-many-ancestors
"""CVELCM Serializer."""

class Meta:
"""Meta attributes."""

model = CVELCM
model = models.CVELCM
fields = "__all__"


class VulnerabilityLCMSerializer(NautobotModelSerializer): # pylint: disable=abstract-method,too-few-public-methods
"""REST API serializer for VulnerabilityLCM records."""
class VulnerabilityLCMSerializer(NautobotModelSerializer, TaggedModelSerializerMixin): # pylint: disable=too-many-ancestors
"""VulnerabilityLCM Serializer."""

class Meta:
"""Meta attributes."""

model = VulnerabilityLCM
model = models.VulnerabilityLCM
fields = "__all__"
read_only_fields = [
"id",
Expand All @@ -116,21 +107,21 @@ class Meta:
]


class DeviceSoftwareValidationResultSerializer(NautobotModelSerializer):
"""REST API serializer for DeviceSoftwareValidationResult records."""
class DeviceSoftwareValidationResultSerializer(NautobotModelSerializer, TaggedModelSerializerMixin): # pylint: disable=too-many-ancestors
"""DeviceSoftwareValidationResult Serializer."""

class Meta:
"""Meta attributes."""

model = DeviceSoftwareValidationResult
model = models.DeviceSoftwareValidationResult
fields = "__all__"


class InventoryItemSoftwareValidationResultSerializer(NautobotModelSerializer):
"""REST API serializer for InventoryItemSoftwareValidationResult records."""
class InventoryItemSoftwareValidationResultSerializer(NautobotModelSerializer, TaggedModelSerializerMixin): # pylint: disable=too-many-ancestors
"""InventoryItemSoftwareValidationResult Serializer."""

class Meta:
"""Meta attributes."""

model = InventoryItemSoftwareValidationResult
model = models.InventoryItemSoftwareValidationResult
fields = "__all__"
47 changes: 17 additions & 30 deletions nautobot_device_lifecycle_mgmt/api/urls.py
Original file line number Diff line number Diff line change
@@ -1,35 +1,22 @@
"""API URLs for the Lifecycle Management app."""
"""Django API urlpatterns declaration for nautobot_device_lifecycle_mgmt app."""

from rest_framework import routers
from nautobot.apps.api import OrderedDefaultRouter

from nautobot_device_lifecycle_mgmt.api.views import (
ContactLCMView,
ContractLCMView,
CVELCMViewSet,
DeviceSoftwareValidationResultListViewSet,
HardwareLCMView,
InventoryItemSoftwareValidationResultListViewSet,
ProviderLCMView,
SoftwareImageLCMViewSet,
SoftwareLCMViewSet,
ValidatedSoftwareLCMViewSet,
VulnerabilityLCMViewSet,
)
from nautobot_device_lifecycle_mgmt.api import views

router = routers.DefaultRouter()

router.register("hardware", HardwareLCMView)
router.register("contract", ContractLCMView)
router.register("provider", ProviderLCMView)
router.register("contact", ContactLCMView)
router.register("software", SoftwareLCMViewSet)
router.register("software-image", SoftwareImageLCMViewSet)
router.register("validated-software", ValidatedSoftwareLCMViewSet)
router.register("cve", CVELCMViewSet)
router.register("vulnerability", VulnerabilityLCMViewSet)
router.register("device-validated-software-result", DeviceSoftwareValidationResultListViewSet)
router.register("inventory-item-validated-software-result", InventoryItemSoftwareValidationResultListViewSet)

app_name = "nautobot_device_lifecycle_mgmt" # pylint: disable=invalid-name
app_name = "nautobot_device_lifecycle_mgmt"
router = OrderedDefaultRouter()
# add the name of your api endpoint, usually hyphenated model name in plural, e.g. "my-model-classes"
router.register("hardware", views.HardwareLCMView)
router.register("contract", views.ContractLCMView)
router.register("provider", views.ProviderLCMView)
router.register("contact", views.ContactLCMView)
router.register("software", views.SoftwareLCMViewSet)
router.register("software-image", views.SoftwareImageLCMViewSet)
router.register("validated-software", views.ValidatedSoftwareLCMViewSet)
router.register("cve", views.CVELCMViewSet)
router.register("vulnerability", views.VulnerabilityLCMViewSet)
router.register("device-validated-software-result", views.DeviceSoftwareValidationResultListViewSet)
router.register("inventory-item-validated-software-result", views.InventoryItemSoftwareValidationResultListViewSet)

urlpatterns = router.urls
Loading

0 comments on commit 2aa785b

Please sign in to comment.