Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

NB-17 Support Added for NetBox v4.0 #51

Merged
merged 5 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 0 additions & 50 deletions .github/ISSUE_TEMPLATE/1-bug-report.yml

This file was deleted.

57 changes: 0 additions & 57 deletions .github/ISSUE_TEMPLATE/2-feature-request.yml

This file was deleted.

37 changes: 0 additions & 37 deletions .github/ISSUE_TEMPLATE/3-documentation-change.yml

This file was deleted.

25 changes: 0 additions & 25 deletions .github/ISSUE_TEMPLATE/4-housekeeping.yml

This file was deleted.

34 changes: 0 additions & 34 deletions .github/ISSUE_TEMPLATE/5-deprecation.yml

This file was deleted.

47 changes: 43 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ on:
- published
workflow_dispatch: { }
push:
branches:
- '*'
tags:
- v[0-9]+.[0-9]+.[0-9]+(-[a-zA-Z]+[0-9]+)?
pull_request:
Expand All @@ -16,10 +18,10 @@ on:
jobs:
pre_commit:
name: Run lint rules
runs-on: ubuntu-latest
runs-on: ubuntu-22.04-sh
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v4.1.1

- name: Set up Python
uses: actions/setup-python@v4.7.0
Expand All @@ -29,12 +31,49 @@ jobs:
- uses: pre-commit/action@v3.0.0

test:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04-sh
name: Runs plugin tests

steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v4.1.1

- name: Login to Registry
uses: docker/login-action@v3
with:
registry: registry.tangience.net
username: ${{ secrets.HARBOR_USERNAME }}
password: ${{ secrets.HARBOR_PASSWORD }}

- name: Test the image
run: ./test.sh

changelog:
name: "Changelog Generator"
runs-on: ubuntu-22.04-sh
needs:
- test
timeout-minutes: 30
if: github.event_name == 'release'
steps:
- name: Checkout code
uses: actions/checkout@v4.1.1

- name: "Generate changelog"
uses: charmixer/auto-changelog-action@v1.4
with:
exclude_labels: "type: skip ci,status: abandoned,type: duplicate,type: question,type: wontfix,type: invalid"
token: ${{ secrets.GIT_TOKEN }}

- name: Commit and push to dev
uses: EndBug/add-and-commit@v9.1.3
env:
GITHUB_TOKEN: ${{ secrets.GIT_TOKEN }}
with:
add: "CHANGELOG.md"
message: "[skip ci] Updated CHANGELOG.md"
new_branch: dev
push: origin dev --set-upstream
committer_name: GitHub Actions
committer_email: actions@github.com
default_author: github_actions
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG NETBOX_VARIANT=v3.7
ARG NETBOX_VARIANT=v4.0

FROM netboxcommunity/netbox:${NETBOX_VARIANT}

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ To use GraphQL API you need to set GitHub personal access token in plugin settin
| 3.5.x | 0.1.x |
| 3.6.x | 0.2.x |
| 3.7.x | 0.3.x |
| 4.0.x | 0.4.x |

## Installation

Expand Down
2 changes: 0 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3.4'

services:
netbox:
build:
Expand Down
6 changes: 3 additions & 3 deletions netbox_metatype_importer/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from importlib.metadata import metadata

from extras.plugins import PluginConfig
from netbox.plugins import PluginConfig

metadata = metadata('netbox_metatype_importer')

Expand All @@ -13,8 +13,8 @@ class NetBoxMetatypeImporterConfig(PluginConfig):
author = metadata.get('Author')
author_email = metadata.get('Author-email')
base_url = "meta-types"
min_version = '3.7.0'
max_version = '3.7.99'
min_version = '4.0.0'
max_version = '4.0.99'
default_settings = {
'repo_owner': 'netbox-community',
'repo': 'devicetype-library',
Expand Down
7 changes: 5 additions & 2 deletions netbox_metatype_importer/api/serializers.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
from netbox_metatype_importer.models import MetaType
from rest_framework import serializers

from ..models import MetaType
from rest_framework.serializers import HyperlinkedIdentityField


class MetaTypeSerializer(serializers.ModelSerializer):
url = HyperlinkedIdentityField(view_name="plugins-api:netbox_metatype_importer-api:metatype-detail")

class Meta:
model = MetaType
fields = "__all__"
brief_fields = ("id", "url", "display", "name", "description")
24 changes: 16 additions & 8 deletions netbox_metatype_importer/api/urls.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
from netbox.api.routers import NetBoxRouter

from . import views
from .views import (
DeviceTypeListViewSet,
ModuleTypeListViewSet,
MetaDeviceTypeLoadViewSet,
MetaModuleTypeLoadViewSet,
MetaDeviceTypeImportViewSet,
MetaModuleTypeImportViewSet,
MetaTypeRootView,
)

router = NetBoxRouter()
router.APIRootView = views.MetaTypeRootView
router.APIRootView = MetaTypeRootView

router.register('device-types', views.DeviceTypeListViewSet, basename='device-types')
router.register('module-types', views.ModuleTypeListViewSet, basename="module-types")
router.register('device-types', DeviceTypeListViewSet, basename='device-types')
router.register('module-types', ModuleTypeListViewSet, basename="module-types")

router.register('device-type-load', views.MetaDeviceTypeLoadViewSet, basename='device-type-load')
router.register('module-type-load', views.MetaModuleTypeLoadViewSet, basename="module-type-load")
router.register('device-type-load', MetaDeviceTypeLoadViewSet, basename='device-type-load')
router.register('module-type-load', MetaModuleTypeLoadViewSet, basename="module-type-load")

router.register('device-type-import', views.MetaDeviceTypeImportViewSet, basename='device-type-import')
router.register('module-type-import', views.MetaModuleTypeImportViewSet, basename="module-type-import")
router.register('device-type-import', MetaDeviceTypeImportViewSet, basename='device-type-import')
router.register('module-type-import', MetaModuleTypeImportViewSet, basename="module-type-import")

urlpatterns = router.urls
6 changes: 3 additions & 3 deletions netbox_metatype_importer/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@
from django.db.models import Q
from django.shortcuts import reverse
from django.utils.text import slugify
from netbox_metatype_importer.filters import MetaTypeFilterSet
from netbox_metatype_importer.forms import MetaTypeFilterForm
from netbox_metatype_importer.graphql.gql import GQLError, GitHubGqlAPI
from rest_framework import mixins as drf_mixins, status
from rest_framework.response import Response
from rest_framework.routers import APIRootView

from dcim import forms
from dcim.models import DeviceType, Manufacturer, ModuleType
from netbox.api.viewsets import BaseViewSet
from netbox_metatype_importer.filters import MetaTypeFilterSet
from netbox_metatype_importer.forms import MetaTypeFilterForm
from utilities.exceptions import AbortTransaction, PermissionsViolation
from utilities.forms.bulk_import import BulkImportForm
from . import serializers
from ..choices import TypeChoices
from ..gql import GQLError, GitHubGqlAPI
from ..models import MetaType
from ..utils import *

Expand Down
Loading
Loading