Skip to content

Commit

Permalink
Merge pull request #85 from peteeckel/fix/custom-field-warning
Browse files Browse the repository at this point in the history
Fix the startup warning for missing custom fields
  • Loading branch information
peteeckel authored Oct 20, 2023
2 parents 6340163 + bc2cb37 commit 0c9b9b9
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions netbox_dns/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import logging
import sys

from extras.plugins import PluginConfig

logger = logging.getLogger("netbox.config")
from extras.plugins.utils import get_plugin_config

__version__ = "0.20.2"

Expand Down Expand Up @@ -39,9 +38,9 @@ class DNSConfig(PluginConfig):

def ready(self):
#
# Check if required custom field exist for IPAM coupling
# Check if required custom fields exist for IPAM coupling
#
if self.default_settings["feature_ipam_coupling"]:
if get_plugin_config("netbox_dns", "feature_ipam_coupling"):
from extras.models import CustomField
from ipam.models import IPAddress
from django.contrib.contenttypes.models import ContentType
Expand All @@ -52,11 +51,12 @@ def ready(self):
if CustomField.objects.filter(
name__in=required_cf, content_types=objtype
).count() < len(required_cf):
logger.warning(
"'feature_ipam_coupling' is enabled, but the required custom"
" fields for IPAM-DNS coupling are missing. Please run the"
" Django management command 'setup_coupling' to create the"
" custom fields."
print(
"WARNING: 'feature_ipam_coupling' is enabled, but the required"
" custom fields for IPAM DNS coupling are missing. Please run"
" the Django management command 'setup_coupling' to create the"
" custom fields.",
file=sys.stderr,
)

super().ready()
Expand Down

0 comments on commit 0c9b9b9

Please sign in to comment.