Skip to content

Commit

Permalink
Closes #17051: Introduce ISOLATED_DEPLOYMENT config parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremystretch committed Aug 1, 2024
1 parent 80fc9ab commit bec1de0
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 15 deletions.
13 changes: 12 additions & 1 deletion docs/configuration/system.md
Original file line number Diff line number Diff line change
Expand Up @@ -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: `{}`
Expand Down Expand Up @@ -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.

Expand Down
4 changes: 4 additions & 0 deletions netbox/core/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'}
Expand Down
5 changes: 4 additions & 1 deletion netbox/extras/management/commands/housekeeping.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,10 @@ def handle(self, *args, **options):
# 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',
}
Expand Down
3 changes: 2 additions & 1 deletion netbox/netbox/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
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
Expand Down Expand Up @@ -578,7 +579,7 @@ def _setting(name, default=None):
'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)
Expand Down
26 changes: 14 additions & 12 deletions netbox/templates/base/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -164,18 +164,20 @@ <h1 class="navbar-brand navbar-brand-autodark">
</a>
</li>
{% endif %}
{# GitHub #}
<li class="list-inline-item">
<a href="https://github.com/netbox-community/netbox" target="_blank" class="link-secondary" rel="noopener">
<i title="{% trans "Source Code" %}" class="mdi mdi-github text-primary" data-bs-placement="top" data-bs-toggle="tooltip"></i>
</a>
</li>
{# NetDev Slack #}
<li class="list-inline-item">
<a href="https://netdev.chat" target="_blank" class="link-secondary" rel="noopener">
<i title="{% trans "Community" %}" class="mdi mdi-slack text-primary" data-bs-placement="top" data-bs-toggle="tooltip"></i>
</a>
</li>
{% if not settings.ISOLATED_DEPLOYMENT %}
{# GitHub #}
<li class="list-inline-item">
<a href="https://github.com/netbox-community/netbox" target="_blank" class="link-secondary" rel="noopener">
<i title="{% trans "Source Code" %}" class="mdi mdi-github text-primary" data-bs-placement="top" data-bs-toggle="tooltip"></i>
</a>
</li>
{# NetDev Slack #}
<li class="list-inline-item">
<a href="https://netdev.chat" target="_blank" class="link-secondary" rel="noopener">
<i title="{% trans "Community" %}" class="mdi mdi-slack text-primary" data-bs-placement="top" data-bs-toggle="tooltip"></i>
</a>
</li>
{% endif %}
{% endblock footer_links %}
</ul>
{# /Footer links #}
Expand Down

0 comments on commit bec1de0

Please sign in to comment.