Added prerequisite models (#78)

* added prerequisite models #77
This commit is contained in:
Abhimanyu Saharan 2023-01-21 08:48:30 +05:30 committed by GitHub
parent 3ce62abec8
commit d24175504f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 29 additions and 12 deletions

View File

@ -9,7 +9,7 @@ PLUGINS = [
"netbox_acls",
]
PLUGINS_CONFIG = { # type: ignore
PLUGINS_CONFIG = { # type: ignore
"netbox_initializers": {},
"netbox_acls": {},
}

View File

@ -3,7 +3,7 @@
# separate terms of service, privacy policy, and support
# documentation.
# This workflow helps you trigger a SonarCloud analysis of your code and populates
# This workflow helps you trigger a SonarCloud analysis of your code and populates
# GitHub Code Scanning alerts with the vulnerabilities found.
# Free for open source project.
@ -11,16 +11,16 @@
# 2. Import your project on SonarCloud
# * Add your GitHub organization first, then add your repository as a new project.
# * Please note that many languages are eligible for automatic analysis,
# * Please note that many languages are eligible for automatic analysis,
# which means that the analysis will start automatically without the need to set up GitHub Actions.
# * This behavior can be changed in Administration > Analysis Method.
#
#
# 3. Follow the SonarCloud in-product tutorial
# * a. Copy/paste the Project Key and the Organization Key into the args parameter below
# (You'll find this information in SonarCloud. Click on "Information" at the bottom left)
#
# * b. Generate a new token and add it to your Github repository's secrets using the name SONAR_TOKEN
# (On SonarCloud, click on your avatar on top-right > My account > Security
# (On SonarCloud, click on your avatar on top-right > My account > Security
# or go directly to https://sonarcloud.io/account/security/)
# Feel free to take a look at our documentation (https://docs.sonarcloud.io/getting-started/github/)
@ -41,9 +41,9 @@ permissions:
jobs:
Analysis:
runs-on: ubuntu-latest
steps:
- name: Analyze with SonarCloud
- name: Analyze with SonarCloud
# You can pin the exact commit or the version.
# uses: SonarSource/sonarcloud-github-action@de2e56b42aa84d0b1c5b622644ac17e505c9a049
@ -53,7 +53,7 @@ jobs:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} # Generate a token on Sonarcloud.io, add it to the secrets of this repo with the name SONAR_TOKEN (Settings > Secrets > Actions > add new repository secret)
with:
# Additional arguments for the sonarcloud scanner
args:
args:
# Unique keys of your project and organization. You can find them in SonarCloud > Information (bottom-left menu)
# mandatory
-Dsonar.projectKey=
@ -65,4 +65,4 @@ jobs:
# Comma-separated paths to directories containing test source files.
#-Dsonar.tests= # optional. For more info about Code Coverage, please refer to https://docs.sonarcloud.io/enriching/test-coverage/overview/
# Adds more detail to both client and server-side analysis logs, activating DEBUG mode for the scanner, and adding client-side environment variables and system properties to the server-side log of analysis report processing.
#-Dsonar.verbose= # optional, default is false
#-Dsonar.verbose= # optional, default is false

View File

@ -62,4 +62,4 @@ repos:
# entry: wily diff
# verbose: true
# language: python
# additional_dependencies: [wily]
# additional_dependencies: [wily]

View File

@ -410,7 +410,7 @@ class ACLInterfaceAssignmentForm(NetBoxModelForm):
def save(self, *args, **kwargs):
# Set assigned object
self.instance.assigned_object = self.cleaned_data.get(
"interface"
"interface",
) or self.cleaned_data.get("vminterface")
return super().save(*args, **kwargs)

View File

@ -2,6 +2,7 @@
Define the django models for this plugin.
"""
from django.apps import apps
from django.contrib.postgres.fields import ArrayField
from django.db import models
from django.urls import reverse
@ -57,6 +58,10 @@ class ACLRule(NetBoxModel):
def get_action_color(self):
return ACLRuleActionChoices.colors.get(self.action)
@classmethod
def get_prerequisite_models(cls):
return [apps.get_model("ipam.Prefix"), AccessList]
class Meta:
"""
Define the common model properties:
@ -90,6 +95,10 @@ class ACLStandardRule(ACLRule):
"""
return reverse("plugins:netbox_acls:aclstandardrule", args=[self.pk])
@classmethod
def get_prerequisite_models(cls):
return [AccessList]
class Meta(ACLRule.Meta):
"""
Define the model properties adding to or overriding the inherited class:
@ -151,6 +160,10 @@ class ACLExtendedRule(ACLRule):
def get_protocol_color(self):
return ACLProtocolChoices.colors.get(self.protocol)
@classmethod
def get_prerequisite_models(cls):
return [apps.get_model("ipam.Prefix"), AccessList]
class Meta(ACLRule.Meta):
"""
Define the model properties adding to or overriding the inherited class:

View File

@ -139,6 +139,10 @@ class ACLInterfaceAssignment(NetBoxModel):
args=[self.pk],
)
@classmethod
def get_prerequisite_models(cls):
return [AccessList]
def get_direction_color(self):
return ACLAssignmentDirectionChoices.colors.get(self.direction)

View File

@ -3,7 +3,7 @@ import os.path
from setuptools import find_packages, setup
with open("README.md", "r") as fh:
with open("README.md") as fh:
long_description = fh.read()