diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9d580baa4..a52233034 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,7 +9,7 @@ jobs: NETBOX_CONFIGURATION: netbox.configuration_testing strategy: matrix: - python-version: ['3.8', '3.9', '3.10', '3.11'] + python-version: ['3.10', '3.11'] node-version: ['14.x'] services: redis: diff --git a/docs/development/getting-started.md b/docs/development/getting-started.md index 7afd74608..4dbdb63b2 100644 --- a/docs/development/getting-started.md +++ b/docs/development/getting-started.md @@ -7,7 +7,7 @@ Getting started with NetBox development is pretty straightforward, and should fe * A Linux system or compatible environment * A PostgreSQL server, which can be installed locally [per the documentation](../installation/1-postgresql.md) * A Redis server, which can also be [installed locally](../installation/2-redis.md) -* Python 3.8 or later +* Python 3.10 or later ### 1. Fork the Repo diff --git a/docs/installation/3-netbox.md b/docs/installation/3-netbox.md index 4043416a3..80d787254 100644 --- a/docs/installation/3-netbox.md +++ b/docs/installation/3-netbox.md @@ -6,8 +6,8 @@ This section of the documentation discusses installing and configuring the NetBo Begin by installing all system packages required by NetBox and its dependencies. -!!! warning "Python 3.8 or later required" - NetBox requires Python 3.8, 3.9, 3.10 or 3.11. +!!! warning "Python 3.10 or later required" + NetBox requires Python 3.10 or 3.11. === "Ubuntu" @@ -21,7 +21,7 @@ Begin by installing all system packages required by NetBox and its dependencies. sudo yum install -y gcc libxml2-devel libxslt-devel libffi-devel libpq-devel openssl-devel redhat-rpm-config ``` -Before continuing, check that your installed Python version is at least 3.8: +Before continuing, check that your installed Python version is at least 3.10: ```no-highlight python3 -V @@ -255,10 +255,10 @@ Once NetBox has been configured, we're ready to proceed with the actual installa sudo /opt/netbox/upgrade.sh ``` -Note that **Python 3.8 or later is required** for NetBox v3.2 and later releases. If the default Python installation on your server is set to a lesser version, pass the path to the supported installation as an environment variable named `PYTHON`. (Note that the environment variable must be passed _after_ the `sudo` command.) +Note that **Python 3.10 or later is required** for NetBox v4.0 and later releases. If the default Python installation on your server is set to a lesser version, pass the path to the supported installation as an environment variable named `PYTHON`. (Note that the environment variable must be passed _after_ the `sudo` command.) ```no-highlight -sudo PYTHON=/usr/bin/python3.8 /opt/netbox/upgrade.sh +sudo PYTHON=/usr/bin/python3.10 /opt/netbox/upgrade.sh ``` !!! note diff --git a/docs/installation/index.md b/docs/installation/index.md index 5affdf247..4022bf1ad 100644 --- a/docs/installation/index.md +++ b/docs/installation/index.md @@ -20,7 +20,7 @@ The following sections detail how to set up a new instance of NetBox: | Dependency | Minimum Version | |------------|-----------------| -| Python | 3.8 | +| Python | 3.10 | | PostgreSQL | 12 | | Redis | 4.0 | diff --git a/docs/installation/upgrading.md b/docs/installation/upgrading.md index 0aaf94b1e..4e678c013 100644 --- a/docs/installation/upgrading.md +++ b/docs/installation/upgrading.md @@ -19,7 +19,7 @@ NetBox requires the following dependencies: | Dependency | Minimum Version | |------------|-----------------| -| Python | 3.8 | +| Python | 3.10 | | PostgreSQL | 12 | | Redis | 4.0 | @@ -108,10 +108,10 @@ sudo ./upgrade.sh ``` !!! warning - If the default version of Python is not at least 3.8, you'll need to pass the path to a supported Python version as an environment variable when calling the upgrade script. For example: + If the default version of Python is not at least 3.10, you'll need to pass the path to a supported Python version as an environment variable when calling the upgrade script. For example: ```no-highlight - sudo PYTHON=/usr/bin/python3.8 ./upgrade.sh + sudo PYTHON=/usr/bin/python3.10 ./upgrade.sh ``` This script performs the following actions: diff --git a/docs/plugins/development/index.md b/docs/plugins/development/index.md index 4db1d5ef6..c6deb5958 100644 --- a/docs/plugins/development/index.md +++ b/docs/plugins/development/index.md @@ -135,7 +135,7 @@ Any additional apps must be installed within the same Python environment as NetB ## Create setup.py -`setup.py` is the [setup script](https://docs.python.org/3.8/distutils/setupscript.html) used to package and install our plugin once it's finished. The primary function of this script is to call the setuptools library's `setup()` function to create a Python distribution package. We can pass a number of keyword arguments to control the package creation as well as to provide metadata about the plugin. An example `setup.py` is below: +`setup.py` is the [setup script](https://docs.python.org/3.10/distutils/setupscript.html) used to package and install our plugin once it's finished. The primary function of this script is to call the setuptools library's `setup()` function to create a Python distribution package. We can pass a number of keyword arguments to control the package creation as well as to provide metadata about the plugin. An example `setup.py` is below: ```python from setuptools import find_packages, setup @@ -170,7 +170,7 @@ python3 -m venv ~/.virtualenvs/my_plugin You can make NetBox available within this environment by creating a path file pointing to its location. This will add NetBox to the Python path upon activation. (Be sure to adjust the command below to specify your actual virtual environment path, Python version, and NetBox installation.) ```shell -echo /opt/netbox/netbox > $VENV/lib/python3.8/site-packages/netbox.pth +echo /opt/netbox/netbox > $VENV/lib/python3.10/site-packages/netbox.pth ``` ## Development Installation diff --git a/docs/release-notes/version-3.7.md b/docs/release-notes/version-3.7.md index 127e241d7..d6818bdec 100644 --- a/docs/release-notes/version-3.7.md +++ b/docs/release-notes/version-3.7.md @@ -10,6 +10,7 @@ * The internal ConfigRevision model has moved from `extras` to `core`. Configuration history will be retained throughout the upgrade process. * The [L2VPN](../models/vpn/l2vpn.md) and [L2VPNTermination](../models/vpn/l2vpntermination.md) models have moved from the `ipam` app to the new `vpn` app. All object data will be retained, however please note that the relevant API endpoints have likewise moved to `/api/vpn/`. * The `CustomFieldsMixin`, `SavedFiltersMixin`, and `TagsMixin` classes have moved from the `extras.forms.mixins` module to `netbox.forms.mixins`. +* The `netbox.models.features.WebhooksMixin` class has been renamed to `EventRulesMixin`. ### New Features diff --git a/netbox/dcim/tests/test_views.py b/netbox/dcim/tests/test_views.py index 88e0d44f2..53d7f3d34 100644 --- a/netbox/dcim/tests/test_views.py +++ b/netbox/dcim/tests/test_views.py @@ -1,9 +1,5 @@ from decimal import Decimal -try: - from zoneinfo import ZoneInfo -except ImportError: - # Python 3.8 - from backports.zoneinfo import ZoneInfo +from zoneinfo import ZoneInfo import yaml from django.contrib.auth import get_user_model diff --git a/netbox/extras/plugins/__init__.py b/netbox/extras/plugins/__init__.py deleted file mode 100644 index 31ea1ce09..000000000 --- a/netbox/extras/plugins/__init__.py +++ /dev/null @@ -1,9 +0,0 @@ -from .navigation import * -from .registration import * -from .templates import * -from .utils import * -from netbox.plugins import PluginConfig - - -# TODO: Remove in v4.0 -warnings.warn(f"{__name__} is deprecated. Import from netbox.plugins instead.", DeprecationWarning) diff --git a/netbox/extras/plugins/navigation.py b/netbox/extras/plugins/navigation.py deleted file mode 100644 index 08d1baa54..000000000 --- a/netbox/extras/plugins/navigation.py +++ /dev/null @@ -1,7 +0,0 @@ -import warnings - -from netbox.plugins.navigation import * - - -# TODO: Remove in v4.0 -warnings.warn(f"{__name__} is deprecated. Import from netbox.plugins instead.", DeprecationWarning) diff --git a/netbox/extras/plugins/registration.py b/netbox/extras/plugins/registration.py deleted file mode 100644 index 8d2d85573..000000000 --- a/netbox/extras/plugins/registration.py +++ /dev/null @@ -1,7 +0,0 @@ -import warnings - -from netbox.plugins.registration import * - - -# TODO: Remove in v4.0 -warnings.warn(f"{__name__} is deprecated. Import from netbox.plugins instead.", DeprecationWarning) diff --git a/netbox/extras/plugins/templates.py b/netbox/extras/plugins/templates.py deleted file mode 100644 index 0e09f33d2..000000000 --- a/netbox/extras/plugins/templates.py +++ /dev/null @@ -1,7 +0,0 @@ -import warnings - -from netbox.plugins.templates import * - - -# TODO: Remove in v4.0 -warnings.warn(f"{__name__} is deprecated. Import from netbox.plugins instead.", DeprecationWarning) diff --git a/netbox/extras/plugins/urls.py b/netbox/extras/plugins/urls.py deleted file mode 100644 index 8b24e8fd2..000000000 --- a/netbox/extras/plugins/urls.py +++ /dev/null @@ -1,7 +0,0 @@ -import warnings - -from netbox.plugins.urls import * - - -# TODO: Remove in v4.0 -warnings.warn(f"{__name__} is deprecated. Import from netbox.plugins instead.", DeprecationWarning) diff --git a/netbox/extras/plugins/utils.py b/netbox/extras/plugins/utils.py deleted file mode 100644 index 15ae018d1..000000000 --- a/netbox/extras/plugins/utils.py +++ /dev/null @@ -1,7 +0,0 @@ -import warnings - -from netbox.plugins.utils import * - - -# TODO: Remove in v4.0 -warnings.warn(f"{__name__} is deprecated. Import from netbox.plugins instead.", DeprecationWarning) diff --git a/netbox/extras/plugins/views.py b/netbox/extras/plugins/views.py deleted file mode 100644 index 505742e6b..000000000 --- a/netbox/extras/plugins/views.py +++ /dev/null @@ -1,7 +0,0 @@ -import warnings - -from netbox.plugins.views import * - - -# TODO: Remove in v4.0 -warnings.warn(f"{__name__} is deprecated. Import from netbox.plugins instead.", DeprecationWarning) diff --git a/netbox/extras/webhooks_worker.py b/netbox/extras/webhooks_worker.py deleted file mode 100644 index 77535fafa..000000000 --- a/netbox/extras/webhooks_worker.py +++ /dev/null @@ -1,10 +0,0 @@ -import warnings - -from .webhooks import send_webhook as process_webhook - - -# TODO: Remove in v4.0 -warnings.warn( - f"webhooks_worker.process_webhook has been moved to webhooks.send_webhook.", - DeprecationWarning -) diff --git a/netbox/netbox/models/features.py b/netbox/netbox/models/features.py index 0cba27318..a13b84bed 100644 --- a/netbox/netbox/models/features.py +++ b/netbox/netbox/models/features.py @@ -30,13 +30,13 @@ __all__ = ( 'CustomFieldsMixin', 'CustomLinksMixin', 'CustomValidationMixin', + 'EventRulesMixin', 'ExportTemplatesMixin', 'ImageAttachmentsMixin', 'JobsMixin', 'JournalingMixin', 'SyncedDataMixin', 'TagsMixin', - 'EventRulesMixin', ) diff --git a/netbox/netbox/settings.py b/netbox/netbox/settings.py index 33a75b8eb..ae470e5c5 100644 --- a/netbox/netbox/settings.py +++ b/netbox/netbox/settings.py @@ -3,17 +3,18 @@ import importlib import importlib.util import os import platform -import requests import sys import warnings from urllib.parse import urlencode, urlsplit import django +import requests from django.contrib.messages import constants as messages from django.core.exceptions import ImproperlyConfigured, ValidationError from django.core.validators import URLValidator from django.utils.encoding import force_str from django.utils.translation import gettext_lazy as _ + try: import sentry_sdk except ModuleNotFoundError: @@ -37,9 +38,9 @@ HOSTNAME = platform.node() BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Validate Python version -if sys.version_info < (3, 8): +if sys.version_info < (3, 10): raise RuntimeError( - f"NetBox requires Python 3.8 or later. (Currently installed: Python {platform.python_version()})" + f"NetBox requires Python 3.10 or later. (Currently installed: Python {platform.python_version()})" ) # diff --git a/netbox/netbox/views/generic/mixins.py b/netbox/netbox/views/generic/mixins.py index d01c534bb..25621b7bd 100644 --- a/netbox/netbox/views/generic/mixins.py +++ b/netbox/netbox/views/generic/mixins.py @@ -1,5 +1,3 @@ -import warnings - from netbox.constants import DEFAULT_ACTION_PERMISSIONS from utilities.permissions import get_permission_for_model @@ -26,38 +24,11 @@ class ActionsMixin: """ model = model or self.queryset.model - # TODO: Remove backward compatibility in Netbox v4.0 - # Determine how permissions are being mapped to actions for the view - if hasattr(self, 'action_perms'): - # Backward compatibility for <3.7 - permissions_map = self.action_perms - warnings.warn( - "Setting action_perms on views is deprecated and will be removed in NetBox v4.0. Use actions instead.", - DeprecationWarning - ) - elif type(self.actions) is dict: - # New actions format (3.7+) - permissions_map = self.actions - else: - # actions is still defined as a list or tuple (<3.7) but no custom mapping is defined; use the old - # default mapping - permissions_map = { - 'add': {'add'}, - 'import': {'add'}, - 'bulk_edit': {'change'}, - 'bulk_delete': {'delete'}, - } - warnings.warn( - "View actions should be defined as a dictionary mapping. Support for the legacy list format will be " - "removed in NetBox v4.0.", - DeprecationWarning - ) - # Resolve required permissions for each action permitted_actions = [] for action in self.actions: required_permissions = [ - get_permission_for_model(model, name) for name in permissions_map.get(action, set()) + get_permission_for_model(model, name) for name in self.actions.get(action, set()) ] if not required_permissions or user.has_perms(required_permissions): permitted_actions.append(action)