From 472fbdc6543550aff35582d4d674ca1ce3abdc56 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Fri, 2 Aug 2024 08:05:08 -0400 Subject: [PATCH] Closes #17051: Introduce the `ISOLATED_DEPLOYMENT` config parameter (#17067) * Closes #17051: Introduce ISOLATED_DEPLOYMENT config parameter * Revert omission of external footer links --- docs/configuration/system.md | 13 ++++++++++++- netbox/core/plugins.py | 4 ++++ netbox/extras/management/commands/housekeeping.py | 5 ++++- netbox/netbox/settings.py | 3 ++- 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/docs/configuration/system.md b/docs/configuration/system.md index f3c68db1b..dcfc39ee2 100644 --- a/docs/configuration/system.md +++ b/docs/configuration/system.md @@ -87,6 +87,17 @@ addresses (and [`DEBUG`](#debug) is true). --- +## ISOLATED_DEPLOYMENT + +Default: False + +Set this configuration parameter to True for NetBox deployments which do not have Internet access. This will disable miscellaneous functionality which depends on access to the Internet. + +!!! note + If Internet access is available via a proxy, set [`HTTP_PROXIES`](#http_proxies) instead. + +--- + ## JINJA2_FILTERS Default: `{}` @@ -143,7 +154,7 @@ LOGGING = { ## MEDIA_ROOT -Default: $INSTALL_ROOT/netbox/media/ +Default: `$INSTALL_ROOT/netbox/media/` The file path to the location where media files (such as image attachments) are stored. By default, this is the `netbox/media/` directory within the base NetBox installation path. diff --git a/netbox/core/plugins.py b/netbox/core/plugins.py index 9fac88005..192a57658 100644 --- a/netbox/core/plugins.py +++ b/netbox/core/plugins.py @@ -107,6 +107,10 @@ def get_catalog_plugins(): """ session = requests.Session() + # Disable catalog fetching for isolated deployments + if settings.ISOLATED_DEPLOYMENT: + return {} + def get_pages(): # TODO: pagination is currently broken in API payload = {'page': '1', 'per_page': '50'} diff --git a/netbox/extras/management/commands/housekeeping.py b/netbox/extras/management/commands/housekeeping.py index 2ba0cbd72..cb8137ee2 100644 --- a/netbox/extras/management/commands/housekeeping.py +++ b/netbox/extras/management/commands/housekeeping.py @@ -93,7 +93,10 @@ class Command(BaseCommand): # Check for new releases (if enabled) if options['verbosity']: self.stdout.write("[*] Checking for latest release") - if settings.RELEASE_CHECK_URL: + if settings.ISOLATED_DEPLOYMENT: + if options['verbosity']: + self.stdout.write(f"\tSkipping: ISOLATED_DEPLOYMENT is enabled") + elif settings.RELEASE_CHECK_URL: headers = { 'Accept': 'application/vnd.github.v3+json', } diff --git a/netbox/netbox/settings.py b/netbox/netbox/settings.py index aa0acbd91..ce7fd10a0 100644 --- a/netbox/netbox/settings.py +++ b/netbox/netbox/settings.py @@ -112,6 +112,7 @@ FIELD_CHOICES = getattr(configuration, 'FIELD_CHOICES', {}) FILE_UPLOAD_MAX_MEMORY_SIZE = getattr(configuration, 'FILE_UPLOAD_MAX_MEMORY_SIZE', 2621440) HTTP_PROXIES = getattr(configuration, 'HTTP_PROXIES', None) INTERNAL_IPS = getattr(configuration, 'INTERNAL_IPS', ('127.0.0.1', '::1')) +ISOLATED_DEPLOYMENT = getattr(configuration, 'ISOLATED_DEPLOYMENT', False) JINJA2_FILTERS = getattr(configuration, 'JINJA2_FILTERS', {}) LANGUAGE_CODE = getattr(configuration, 'DEFAULT_LANGUAGE', 'en-us') LANGUAGE_COOKIE_PATH = CSRF_COOKIE_PATH @@ -578,7 +579,7 @@ CENSUS_PARAMS = { 'python_version': sys.version.split()[0], 'deployment_id': DEPLOYMENT_ID, } -if CENSUS_REPORTING_ENABLED and not DEBUG and 'test' not in sys.argv: +if CENSUS_REPORTING_ENABLED and not ISOLATED_DEPLOYMENT and not DEBUG and 'test' not in sys.argv: try: # Report anonymous census data requests.get(f'{CENSUS_URL}?{urlencode(CENSUS_PARAMS)}', timeout=3, proxies=HTTP_PROXIES)