From 6959785cd1a2e040375432d650cdd2ec806d2963 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Tue, 14 Jan 2020 12:01:23 -0500 Subject: [PATCH] Define __all__ for models.py within each app --- netbox/circuits/models.py | 8 ++++++++ netbox/extras/models.py | 20 ++++++++++++++++++++ netbox/ipam/constants.py | 11 +++++++++++ netbox/ipam/models.py | 20 ++++++++++++-------- netbox/secrets/models.py | 8 ++++++++ netbox/tenancy/models.py | 6 ++++++ netbox/users/models.py | 5 +++++ netbox/utilities/models.py | 5 +++++ netbox/virtualization/models.py | 8 ++++++++ netbox/virtualization/tests/test_models.py | 1 + 10 files changed, 84 insertions(+), 8 deletions(-) create mode 100644 netbox/ipam/constants.py diff --git a/netbox/circuits/models.py b/netbox/circuits/models.py index aabb51ca5..59f6e2004 100644 --- a/netbox/circuits/models.py +++ b/netbox/circuits/models.py @@ -12,6 +12,14 @@ from utilities.utils import serialize_object from .choices import * +__all__ = ( + 'Circuit', + 'CircuitTermination', + 'CircuitType', + 'Provider', +) + + class Provider(ChangeLoggedModel, CustomFieldModel): """ Each Circuit belongs to a Provider. This is usually a telecommunications company or similar organization. This model diff --git a/netbox/extras/models.py b/netbox/extras/models.py index 46d5a54d8..e7cef777a 100644 --- a/netbox/extras/models.py +++ b/netbox/extras/models.py @@ -19,6 +19,26 @@ from .constants import * from .querysets import ConfigContextQuerySet +__all__ = ( + 'ConfigContext', + 'ConfigContextModel', + 'CustomField', + 'CustomFieldChoice', + 'CustomFieldModel', + 'CustomFieldValue', + 'CustomLink', + 'ExportTemplate', + 'Graph', + 'ImageAttachment', + 'ObjectChange', + 'ReportResult', + 'Script', + 'Tag', + 'TaggedItem', + 'Webhook', +) + + # # Webhooks # diff --git a/netbox/ipam/constants.py b/netbox/ipam/constants.py new file mode 100644 index 000000000..0a42d82dc --- /dev/null +++ b/netbox/ipam/constants.py @@ -0,0 +1,11 @@ +from .choices import IPAddressRoleChoices + +IPADDRESS_ROLES_NONUNIQUE = ( + # IPAddress roles which are exempt from unique address enforcement + IPAddressRoleChoices.ROLE_ANYCAST, + IPAddressRoleChoices.ROLE_VIP, + IPAddressRoleChoices.ROLE_VRRP, + IPAddressRoleChoices.ROLE_HSRP, + IPAddressRoleChoices.ROLE_GLBP, + IPAddressRoleChoices.ROLE_CARP, +) diff --git a/netbox/ipam/models.py b/netbox/ipam/models.py index 92c45f20a..988416e28 100644 --- a/netbox/ipam/models.py +++ b/netbox/ipam/models.py @@ -15,6 +15,7 @@ from utilities.models import ChangeLoggedModel from utilities.utils import serialize_object from virtualization.models import VirtualMachine from .choices import * +from .constants import IPADDRESS_ROLES_NONUNIQUE from .fields import IPNetworkField, IPAddressField from .querysets import PrefixQuerySet from .validators import DNSValidator @@ -26,14 +27,17 @@ AF_CHOICES = ( (6, 'IPv6'), ) -IPADDRESS_ROLES_NONUNIQUE = ( - # IPAddress roles which are exempt from unique address enforcement - IPAddressRoleChoices.ROLE_ANYCAST, - IPAddressRoleChoices.ROLE_VIP, - IPAddressRoleChoices.ROLE_VRRP, - IPAddressRoleChoices.ROLE_HSRP, - IPAddressRoleChoices.ROLE_GLBP, - IPAddressRoleChoices.ROLE_CARP, + +__all__ = ( + 'Aggregate', + 'IPAddress', + 'Prefix', + 'RIR', + 'Role', + 'Service', + 'VLAN', + 'VLANGroup', + 'VRF', ) diff --git a/netbox/secrets/models.py b/netbox/secrets/models.py index f14d2d982..e01e502c0 100644 --- a/netbox/secrets/models.py +++ b/netbox/secrets/models.py @@ -21,6 +21,14 @@ from .hashers import SecretValidationHasher from .querysets import UserKeyQuerySet +__all__ = ( + 'Secret', + 'SecretRole', + 'SessionKey', + 'UserKey', +) + + def generate_random_key(bits=256): """ Generate a random encryption key. Sizes is given in bits and must be in increments of 32. diff --git a/netbox/tenancy/models.py b/netbox/tenancy/models.py index dde4039da..9fa7f23ea 100644 --- a/netbox/tenancy/models.py +++ b/netbox/tenancy/models.py @@ -7,6 +7,12 @@ from extras.models import CustomFieldModel, TaggedItem from utilities.models import ChangeLoggedModel +__all__ = ( + 'Tenant', + 'TenantGroup', +) + + class TenantGroup(ChangeLoggedModel): """ An arbitrary collection of Tenants. diff --git a/netbox/users/models.py b/netbox/users/models.py index 2956a9778..cf0d826b5 100644 --- a/netbox/users/models.py +++ b/netbox/users/models.py @@ -7,6 +7,11 @@ from django.db import models from django.utils import timezone +__all__ = ( + 'Token', +) + + class Token(models.Model): """ An API token used for user authentication. This extends the stock model to allow each user to have multiple tokens. diff --git a/netbox/utilities/models.py b/netbox/utilities/models.py index 286814237..ac3812ea8 100644 --- a/netbox/utilities/models.py +++ b/netbox/utilities/models.py @@ -4,6 +4,11 @@ from extras.models import ObjectChange from utilities.utils import serialize_object +__all__ = ( + 'ChangeLoggedModel', +) + + class ChangeLoggedModel(models.Model): """ An abstract model which adds fields to store the creation and last-updated times for an object. Both fields can be diff --git a/netbox/virtualization/models.py b/netbox/virtualization/models.py index 86d31afcb..54dc2d246 100644 --- a/netbox/virtualization/models.py +++ b/netbox/virtualization/models.py @@ -11,6 +11,14 @@ from utilities.models import ChangeLoggedModel from .choices import * +__all__ = ( + 'Cluster', + 'ClusterGroup', + 'ClusterType', + 'VirtualMachine', +) + + # # Cluster types # diff --git a/netbox/virtualization/tests/test_models.py b/netbox/virtualization/tests/test_models.py index ce126fc99..3b4d73a30 100644 --- a/netbox/virtualization/tests/test_models.py +++ b/netbox/virtualization/tests/test_models.py @@ -1,3 +1,4 @@ +from django.core.exceptions import ValidationError from django.test import TestCase from virtualization.models import *