mirror of
https://github.com/lucaspalomodevelop/netbox-acls.git
synced 2026-03-12 23:27:23 +00:00
lint corrections
This commit is contained in:
parent
5b0198ed5d
commit
5b5e506f88
@ -1,9 +1,8 @@
|
||||
# Based on https://github.com/netbox-community/netbox-docker/blob/release/configuration/configuration.py
|
||||
import re
|
||||
from os import environ
|
||||
from os.path import abspath, dirname, join
|
||||
|
||||
# For reference see https://netbox.readthedocs.io/en/stable/configuration/
|
||||
# Based on https://github.com/netbox-community/netbox/blob/master/netbox/netbox/configuration.example.py
|
||||
|
||||
# Read secret from file
|
||||
def _read_secret(secret_name, default=None):
|
||||
|
||||
@ -2,26 +2,14 @@ repos:
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v4.3.0
|
||||
hooks:
|
||||
- id: trailing-whitespace
|
||||
- id: end-of-file-fixer
|
||||
- id: check-yaml
|
||||
- id: check-docstring-first
|
||||
- id: check-merge-conflict
|
||||
- id: check-yaml
|
||||
- id: debug-statements
|
||||
- id: end-of-file-fixer
|
||||
- id: name-tests-test
|
||||
- id: requirements-txt-fixer
|
||||
- id: check-docstring-first
|
||||
- repo: https://github.com/asottile/add-trailing-comma
|
||||
rev: v2.2.3
|
||||
hooks:
|
||||
- id: add-trailing-comma
|
||||
args:
|
||||
- "--py36-plus"
|
||||
- repo: https://github.com/asottile/pyupgrade
|
||||
rev: v2.37.3
|
||||
hooks:
|
||||
- id: pyupgrade
|
||||
args:
|
||||
- "--py37-plus"
|
||||
- id: trailing-whitespace
|
||||
- repo: https://github.com/PyCQA/isort
|
||||
rev: 5.10.1
|
||||
hooks:
|
||||
@ -34,6 +22,22 @@ repos:
|
||||
hooks:
|
||||
- id: black
|
||||
language_version: python3
|
||||
- repo: https://github.com/asottile/add-trailing-comma
|
||||
rev: v2.2.3
|
||||
hooks:
|
||||
- id: add-trailing-comma
|
||||
args:
|
||||
- "--py36-plus"
|
||||
- repo: https://github.com/PyCQA/flake8
|
||||
rev: 4.0.1
|
||||
hooks:
|
||||
- id: flake8
|
||||
- repo: https://github.com/asottile/pyupgrade
|
||||
rev: v2.37.3
|
||||
hooks:
|
||||
- id: pyupgrade
|
||||
args:
|
||||
- "--py37-plus"
|
||||
#- repo: https://github.com/adrienverge/yamllint
|
||||
# rev: v1.26.3
|
||||
# hooks:
|
||||
@ -52,11 +56,11 @@ repos:
|
||||
rev: v0.32.1
|
||||
hooks:
|
||||
- id: markdownlint
|
||||
- repo: local
|
||||
hooks:
|
||||
- id: wily
|
||||
name: wily
|
||||
entry: wily diff
|
||||
verbose: true
|
||||
language: python
|
||||
additional_dependencies: [wily]
|
||||
#- repo: local
|
||||
# hooks:
|
||||
# - id: wily
|
||||
# name: wily
|
||||
# entry: wily diff
|
||||
# verbose: true
|
||||
# language: python
|
||||
# additional_dependencies: [wily]
|
||||
|
||||
@ -97,7 +97,9 @@ class AccessListSerializer(NetBoxModelSerializer):
|
||||
# Check that the GFK object is valid.
|
||||
if "assigned_object_type" in data and "assigned_object_id" in data:
|
||||
try:
|
||||
assigned_object = data["assigned_object_type"].get_object_for_this_type(
|
||||
assigned_object = data[ # noqa: F841
|
||||
"assigned_object_type"
|
||||
].get_object_for_this_type(
|
||||
id=data["assigned_object_id"],
|
||||
)
|
||||
except ObjectDoesNotExist:
|
||||
@ -175,7 +177,9 @@ class ACLInterfaceAssignmentSerializer(NetBoxModelSerializer):
|
||||
# Check that the GFK object is vlaid.
|
||||
if "assigned_object_type" in data and "assigned_object_id" in data:
|
||||
try:
|
||||
assigned_object = data["assigned_object_type"].get_object_for_this_type(
|
||||
assigned_object = data[ # noqa: F841
|
||||
"assigned_object_type"
|
||||
].get_object_for_this_type(
|
||||
id=data["assigned_object_id"],
|
||||
)
|
||||
except ObjectDoesNotExist:
|
||||
|
||||
@ -18,7 +18,8 @@ from .serializers import (
|
||||
__all__ = [
|
||||
"AccessListViewSet",
|
||||
"ACLStandardRuleViewSet",
|
||||
"ACLInterfaceAssignmentViewSet" "ACLExtendedRuleViewSet",
|
||||
"ACLInterfaceAssignmentViewSet",
|
||||
"ACLExtendedRuleViewSet",
|
||||
]
|
||||
|
||||
|
||||
|
||||
@ -7,7 +7,7 @@ from dcim.models import Device, Interface, VirtualChassis
|
||||
from netbox.filtersets import NetBoxModelFilterSet
|
||||
from virtualization.models import VirtualMachine, VMInterface
|
||||
|
||||
from .models import *
|
||||
from .models import AccessList, ACLExtendedRule, ACLInterfaceAssignment, ACLStandardRule
|
||||
|
||||
__all__ = (
|
||||
"AccessListFilterSet",
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
# flake8: noqa
|
||||
"""
|
||||
Import each of the directory's scripts.
|
||||
"""
|
||||
|
||||
# from .bulk_create import *
|
||||
from .bulk_edit import *
|
||||
# from .bulk_edit import *
|
||||
|
||||
# from .bulk_import import *
|
||||
# from .connections import *
|
||||
|
||||
@ -2,21 +2,22 @@
|
||||
Draft for a possible BulkEditForm, but may not be worth wile.
|
||||
"""
|
||||
|
||||
from dcim.models import Device, Region, Site, SiteGroup, VirtualChassis
|
||||
from django import forms
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.utils.safestring import mark_safe
|
||||
from netbox.forms import NetBoxModelBulkEditForm
|
||||
from utilities.forms import (
|
||||
ChoiceField,
|
||||
DynamicModelChoiceField,
|
||||
StaticSelect,
|
||||
add_blank_choice,
|
||||
)
|
||||
from virtualization.models import VirtualMachine
|
||||
# from dcim.models import Device, Region, Site, SiteGroup, VirtualChassis
|
||||
# from django import forms
|
||||
# from django.core.exceptions import ValidationError
|
||||
# from django.utils.safestring import mark_safe
|
||||
# from netbox.forms import NetBoxModelBulkEditForm
|
||||
# from utilities.forms import (
|
||||
# ChoiceField,
|
||||
# DynamicModelChoiceField,
|
||||
# StaticSelect,
|
||||
# add_blank_choice,
|
||||
# )
|
||||
# from virtualization.models import VirtualMachine
|
||||
|
||||
# from ..choices import ACLActionChoices, ACLTypeChoices
|
||||
# from ..models import AccessList
|
||||
|
||||
from ..choices import ACLActionChoices, ACLTypeChoices
|
||||
from ..models import AccessList
|
||||
|
||||
# __all__ = (
|
||||
# 'AccessListBulkEditForm',
|
||||
|
||||
@ -66,6 +66,14 @@ class AccessListFilterForm(NetBoxModelFilterSetForm):
|
||||
},
|
||||
required=False,
|
||||
)
|
||||
virtual_machine = DynamicModelChoiceField(
|
||||
queryset=VirtualMachine.objects.all(),
|
||||
required=False,
|
||||
)
|
||||
virtual_chassis = DynamicModelChoiceField(
|
||||
queryset=VirtualChassis.objects.all(),
|
||||
required=False,
|
||||
)
|
||||
type = ChoiceField(
|
||||
choices=add_blank_choice(ACLTypeChoices),
|
||||
required=False,
|
||||
@ -83,7 +91,17 @@ class AccessListFilterForm(NetBoxModelFilterSetForm):
|
||||
|
||||
fieldsets = (
|
||||
(None, ("q", "tag")),
|
||||
("Host Details", ("region", "site_group", "site", "device")),
|
||||
(
|
||||
"Host Details",
|
||||
(
|
||||
"region",
|
||||
"site_group",
|
||||
"site",
|
||||
"device",
|
||||
"virtual_chassis",
|
||||
"virtual_machine",
|
||||
),
|
||||
),
|
||||
("ACL Details", ("type", "default_action")),
|
||||
)
|
||||
|
||||
|
||||
@ -184,7 +184,6 @@ class AccessListForm(NetBoxModelForm):
|
||||
name=name,
|
||||
virtual_machine=virtual_machine,
|
||||
).exists()
|
||||
host = cleaned_data.get(host_type)
|
||||
|
||||
# Check if duplicate entry.
|
||||
if (
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
# flake8: noqa
|
||||
"""
|
||||
Import each of the directory's scripts.
|
||||
"""
|
||||
|
||||
@ -7,7 +7,7 @@ from django.db import models
|
||||
from django.urls import reverse
|
||||
from netbox.models import NetBoxModel
|
||||
|
||||
from ..choices import *
|
||||
from ..choices import ACLProtocolChoices, ACLRuleActionChoices
|
||||
from .access_lists import AccessList
|
||||
|
||||
__all__ = (
|
||||
|
||||
@ -11,7 +11,7 @@ from django.urls import reverse
|
||||
from netbox.models import NetBoxModel
|
||||
from virtualization.models import VirtualMachine, VMInterface
|
||||
|
||||
from ..choices import *
|
||||
from ..choices import ACLActionChoices, ACLAssignmentDirectionChoices, ACLTypeChoices
|
||||
from ..constants import ACL_HOST_ASSIGNMENT_MODELS, ACL_INTERFACE_ASSIGNMENT_MODELS
|
||||
|
||||
__all__ = (
|
||||
|
||||
@ -3,7 +3,7 @@ Define the object lists / table view for each of the plugin models.
|
||||
"""
|
||||
|
||||
import django_tables2 as tables
|
||||
from netbox.tables import ChoiceFieldColumn, NetBoxTable, TemplateColumn, columns
|
||||
from netbox.tables import ChoiceFieldColumn, NetBoxTable, columns
|
||||
|
||||
from .models import AccessList, ACLExtendedRule, ACLInterfaceAssignment, ACLStandardRule
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user