diff --git a/nautobot_config.py b/nautobot_config.py index 2967753..395860a 100644 --- a/nautobot_config.py +++ b/nautobot_config.py @@ -1,260 +1,605 @@ -################################################################### -# This file serves as a base configuration for testing purposes # -# only. It is not intended for production use. # -################################################################### - import os +import sys -from nautobot.core.settings import * # noqa: F403 # undefined-local-with-import-star -from nautobot.core.settings_funcs import parse_redis_connection +from nautobot.core.settings import * # noqa F401,F403 +from nautobot.core.settings_funcs import is_truthy, parse_redis_connection -ALLOWED_HOSTS = ["nautobot.example.com"] +######################### +# # +# Required settings # +# # +######################### -# Do *not* send anonymized install metrics when migration or post_upgrade management commands are run while testing -INSTALLATION_METRICS_ENABLED = False +# This is a list of valid fully-qualified domain names (FQDNs) for the Nautobot server. Nautobot will not permit write +# access to the server via any other hostnames. The first FQDN in the list will be treated as the preferred name. +# +# Example: ALLOWED_HOSTS = ['nautobot.example.com', 'nautobot.internal.local'] +# +# ALLOWED_HOSTS = os.getenv("NAUTOBOT_ALLOWED_HOSTS", "").split(" ") -# Discover test jobs from within the Nautobot source code -JOBS_ROOT = os.path.join( - os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))), "extras", "test_jobs" -) +# The django-redis cache is used to establish concurrent locks using Redis. +# +# CACHES = { +# "default": { +# "BACKEND": os.getenv( +# "NAUTOBOT_CACHES_BACKEND", +# "django_prometheus.cache.backends.redis.RedisCache" if METRICS_ENABLED else "django_redis.cache.RedisCache", +# ), +# "LOCATION": parse_redis_connection(redis_database=1), +# "TIMEOUT": 300, +# "OPTIONS": { +# "CLIENT_CLASS": "django_redis.client.DefaultClient", +# "PASSWORD": "", +# }, +# } +# } -# Enable both example apps -PLUGINS = [ - "example_app", - "example_app_with_view_override", -] +# Number of seconds to cache ContentType lookups. Set to 0 to disable caching. +# CONTENT_TYPE_CACHE_TIMEOUT = int(os.getenv("NAUTOBOT_CONTENT_TYPE_CACHE_TIMEOUT", "0")) -# Hard-code the SECRET_KEY for simplicity -SECRET_KEY = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" # noqa: S105 # hardcoded-password-string +# Celery Beat heartbeat file path - will be touched by Beat each time it wakes up as a proof-of-health. +# CELERY_BEAT_HEARTBEAT_FILE = os.getenv( +# "NAUTOBOT_CELERY_BEAT_HEARTBEAT_FILE", +# os.path.join(tempfile.gettempdir(), "nautobot_celery_beat_heartbeat"), +# ) -# Redis variables +# Celery broker URL used to tell workers where queues are located +# +# CELERY_BROKER_URL = os.getenv("NAUTOBOT_CELERY_BROKER_URL", parse_redis_connection(redis_database=0)) -# Use *different* redis_databases than the ones (0 and 1) used during non-automated-testing operations. -CACHES["default"]["LOCATION"] = parse_redis_connection(redis_database=2) # noqa: F405 # undefined-local-with-import-star-usage +# Optional configuration dict for Celery to use custom SSL certificates to connect to Redis. +# +# CELERY_BROKER_USE_SSL = None -# Testing storages within cli.py -STORAGE_CONFIG = { - "AWS_ACCESS_KEY_ID": "ASFWDAMWWOQMEOQMWPMDA.`. Add '*' to this list to exempt all models. +# Defaults to []. +# +# EXEMPT_VIEW_PERMISSIONS = [ +# 'dcim.location', +# 'ipam.prefix', +# ] + +# Global 3rd-party authentication settings +# +# EXTERNAL_AUTH_DEFAULT_GROUPS = [] +# EXTERNAL_AUTH_DEFAULT_PERMISSIONS = {} + +# Directory where cloned Git repositories will be stored. +# +# GIT_ROOT = os.getenv("NAUTOBOT_GIT_ROOT", os.path.join(NAUTOBOT_ROOT, "git").rstrip("/")) + +# Prefixes to use for custom fields, relationships, and computed fields in GraphQL representation of data. +# +# GRAPHQL_COMPUTED_FIELD_PREFIX = "cpf" +# GRAPHQL_CUSTOM_FIELD_PREFIX = "cf" +# GRAPHQL_RELATIONSHIP_PREFIX = "rel" + +# HTTP proxies Nautobot should use when sending outbound HTTP requests (e.g. for webhooks). +# +# HTTP_PROXIES = { +# 'http': 'http://10.10.1.10:3128', +# 'https': 'http://10.10.1.10:1080', +# } + +# Send anonymized installation metrics when `nautobot-server post_upgrade` command is run. +# +INSTALLATION_METRICS_ENABLED = is_truthy(os.getenv("NAUTOBOT_INSTALLATION_METRICS_ENABLED", "False")) + +# Storage backend to use for Job input files and Job output files. +# +# Note: the default is for backwards compatibility and it is recommended to change it if possible for your deployment. +# +# JOB_FILE_IO_STORAGE = os.getenv("NAUTOBOT_JOB_FILE_IO_STORAGE", "db_file_storage.storage.DatabaseFileStorage") + +# Maximum size in bytes of any single file created by Job.create_file(). +# +# JOB_CREATE_FILE_MAX_SIZE = 10 << 20 + +# Directory where Jobs can be discovered. +# +# JOBS_ROOT = os.getenv("NAUTOBOT_JOBS_ROOT", os.path.join(NAUTOBOT_ROOT, "jobs").rstrip("/")) + +# Location names are not guaranteed globally-unique by Nautobot but in practice they often are. +# Set this to True to use the location name alone as the natural key for Location objects. +# Set this to False to use the sequence (name, parent__name, parent__parent__name, ...) as the natural key instead. +# +# if "NAUTOBOT_LOCATION_NAME_AS_NATURAL_KEY" in os.environ and os.environ["NAUTOBOT_LOCATION_NAME_AS_NATURAL_KEY"] != "": +# LOCATION_NAME_AS_NATURAL_KEY = is_truthy(os.environ["NAUTOBOT_LOCATION_NAME_AS_NATURAL_KEY"]) + +# Log Nautobot deprecation warnings. Note that this setting is ignored (deprecation logs always enabled) if DEBUG = True +# +# LOG_DEPRECATION_WARNINGS = is_truthy(os.getenv("NAUTOBOT_LOG_DEPRECATION_WARNINGS", "False")) + +# Setting this to True will display a "maintenance mode" banner at the top of every page. +# +# MAINTENANCE_MODE = is_truthy(os.getenv("NAUTOBOT_MAINTENANCE_MODE", "False")) + +# Maximum number of objects that the UI and API will retrieve in a single request. Default is 1000 +# +# if "NAUTOBOT_MAX_PAGE_SIZE" in os.environ and os.environ["NAUTOBOT_MAX_PAGE_SIZE"] != "": +# MAX_PAGE_SIZE = int(os.environ["NAUTOBOT_MAX_PAGE_SIZE"]) + +# Expose Prometheus monitoring metrics at the HTTP endpoint '/metrics' +# +# METRICS_ENABLED = is_truthy(os.getenv("NAUTOBOT_METRICS_ENABLED", "False")) + +# Require API Authentication to HTTP endpoint '/metrics' +# +# METRICS_AUTHENTICATED = is_truthy(os.getenv("NAUTOBOT_METRICS_AUTHENTICATED", "False")) + +# Disable app metrics for specific apps +# +# if "NAUTOBOT_METRICS_DISABLED_APPS" in os.environ and os.environ["NAUTOBOT_METRICS_DISABLED_APPS"] != "": +# METRICS_DISABLED_APPS = os.getenv("NAUTOBOT_METRICS_DISABLED_APPS", "").split(",") + +# Credentials that Nautobot will uses to authenticate to devices when connecting via NAPALM. +# +# NAPALM_USERNAME = os.getenv("NAUTOBOT_NAPALM_USERNAME", "") +# NAPALM_PASSWORD = os.getenv("NAUTOBOT_NAPALM_PASSWORD", "") + +# NAPALM timeout (in seconds). (Default: 30) +# +# NAPALM_TIMEOUT = int(os.getenv("NAUTOBOT_NAPALM_TIMEOUT", "30")) + +# NAPALM optional arguments (see https://napalm.readthedocs.io/en/latest/support/#optional-arguments). Arguments must +# be provided as a dictionary. +# +# NAPALM_ARGS = {} + +# Expiration date (YYYY-MM-DD) for an active Nautobot support contract with Network to Code. +# Displayed in the About page. +# if ( +# "NAUTOBOT_NTC_SUPPORT_CONTRACT_EXPIRATION_DATE" in os.environ +# and os.environ["NAUTOBOT_NTC_SUPPORT_CONTRACT_EXPIRATION_DATE"] != "" +# ): +# NTC_SUPPORT_CONTRACT_EXPIRATION_DATE = datetime.date.fromisoformat( +# os.environ["NAUTOBOT_NTC_SUPPORT_CONTRACT_EXPIRATION_DATE"] +# ) + +# Default number of objects to display per page of the UI and REST API. Default is 50 +# +# if "NAUTOBOT_PAGINATE_COUNT" in os.environ and os.environ["NAUTOBOT_PAGINATE_COUNT"] != "": +# PAGINATE_COUNT = int(os.environ["NAUTOBOT_PAGINATE_COUNT"]) + +# Options given in the web UI for the number of objects to display per page. +# Default is [25, 50, 100, 250, 500, 1000] +# +# if "NAUTOBOT_PER_PAGE_DEFAULTS" in os.environ and os.environ["NAUTOBOT_PER_PAGE_DEFAULTS"] != "": +# PER_PAGE_DEFAULTS = [int(val) for val in os.environ["NAUTOBOT_PER_PAGE_DEFAULTS"].split(",")] + +# Enable installed plugins. Add the name of each plugin to the list. +# +# PLUGINS = [] + +# Plugins configuration settings. These settings are used by various plugins that the user may have installed. +# Each key in the dictionary is the name of an installed plugin and its value is a dictionary of settings. +# +# PLUGINS_CONFIG = { +# 'my_plugin': { +# 'foo': 'bar', +# 'buzz': 'bazz' +# } +# } + +# Prefer IPv6 addresses or IPv4 addresses in selecting a device's primary IP address? Default False +# +# if "NAUTOBOT_PREFER_IPV4" in os.environ and os.environ["NAUTOBOT_PREFER_IPV4"] != "": +# PREFER_IPV4 = is_truthy(os.environ["NAUTOBOT_PREFER_IPV4"]) + +# Publish a simple "no-index" robots.txt for Nautobot? +# PUBLISH_ROBOTS_TXT = is_truthy(os.getenv("NAUTOBOT_PUBLISH_ROBOTS_TXT", "True")) + +# Default height and width in pixels of a single rack unit in rendered rack elevations. Defaults are 22 and 230 +# +# if ( +# "NAUTOBOT_RACK_ELEVATION_DEFAULT_UNIT_HEIGHT" in os.environ +# and os.environ["NAUTOBOT_RACK_ELEVATION_DEFAULT_UNIT_HEIGHT"] != "" +# ): +# RACK_ELEVATION_DEFAULT_UNIT_HEIGHT = int(os.environ["NAUTOBOT_RACK_ELEVATION_DEFAULT_UNIT_HEIGHT"]) +# if ( +# "NAUTOBOT_RACK_ELEVATION_DEFAULT_UNIT_WIDTH" in os.environ +# and os.environ["NAUTOBOT_RACK_ELEVATION_DEFAULT_UNIT_WIDTH"] != "" +# ): +# RACK_ELEVATION_DEFAULT_UNIT_WIDTH = int(os.environ["NAUTOBOT_RACK_ELEVATION_DEFAULT_UNIT_WIDTH"]) + +# Enable two-digit format for the rack unit numbering in rack elevations. +# +# if ( +# "NAUTOBOT_RACK_ELEVATION_UNIT_TWO_DIGIT_FORMAT" in os.environ +# and os.environ["NAUTOBOT_RACK_ELEVATION_UNIT_TWO_DIGIT_FORMAT"] != "" +# ): +# RACK_ELEVATION_UNIT_TWO_DIGIT_FORMAT = is_truthy(os.environ["NAUTOBOT_RACK_ELEVATION_UNIT_TWO_DIGIT_FORMAT"]) + +# Sets an age out timer of redis lock. This is NOT implicitly applied to locks, must be added +# to a lock creation as `timeout=settings.REDIS_LOCK_TIMEOUT` +# +# REDIS_LOCK_TIMEOUT = int(os.getenv("NAUTOBOT_REDIS_LOCK_TIMEOUT", "600")) + +# How frequently to check for a new Nautobot release on GitHub, and the URL to check for this information. +# Defaults to disabled (no URL) and check every 24 hours when enabled +# +# if "NAUTOBOT_RELEASE_CHECK_TIMEOUT" in os.environ and os.environ["NAUTOBOT_RELEASE_CHECK_TIMEOUT"] != "": +# RELEASE_CHECK_TIMEOUT = int(os.environ["NAUTOBOT_RELEASE_CHECK_TIMEOUT"]) +# if "NAUTOBOT_RELEASE_CHECK_URL" in os.environ and os.environ["NAUTOBOT_RELEASE_CHECK_URL"] != "": +# RELEASE_CHECK_URL = os.environ["NAUTOBOT_RELEASE_CHECK_URL"] + +# Remote auth backend settings +# +# REMOTE_AUTH_AUTO_CREATE_USER = False +# REMOTE_AUTH_HEADER = "HTTP_REMOTE_USER" + +# Job log entry sanitization and similar +# +# SANITIZER_PATTERNS = [ +# # General removal of username-like and password-like tokens +# (re.compile(r"(https?://)?\S+\s*@", re.IGNORECASE), r"\1{replacement}@"), +# ( +# re.compile(r"(username|password|passwd|pwd|secret|secrets)([\"']?(?:\s+is.?|:)?\s+)\S+[\"']?", re.IGNORECASE), +# r"\1\2{replacement}", +# ), +# ] + +# Configure SSO, for more information see docs/configuration/authentication/sso.md +# +# SOCIAL_AUTH_POSTGRES_JSONFIELD = False + +# By default uploaded media is stored on the local filesystem. Using Django-storages is also supported. Provide the +# class path of the storage driver in STORAGE_BACKEND and any configuration options in STORAGE_CONFIG. +# These default to None and {} respectively. +# +# STORAGE_BACKEND = 'storages.backends.s3.S3Storage' +# STORAGE_CONFIG = { +# 'AWS_ACCESS_KEY_ID': 'Key ID', +# 'AWS_SECRET_ACCESS_KEY': 'Secret', +# 'AWS_STORAGE_BUCKET_NAME': 'nautobot', +# 'AWS_S3_REGION_NAME': 'eu-west-1', +# } + +# Reject invalid UI/API filter parameters, or discard them while logging a warning? +# +# STRICT_FILTERING = is_truthy(os.getenv("NAUTOBOT_STRICT_FILTERING", "True")) + +# Custom message to display on 4xx and 5xx error pages. Markdown and HTML are supported. +# Default message directs the user to #nautobot on NTC's Slack community. +# +# if "NAUTOBOT_SUPPORT_MESSAGE" in os.environ and os.environ["NAUTOBOT_SUPPORT_MESSAGE"] != "": +# SUPPORT_MESSAGE = os.environ["NAUTOBOT_SUPPORT_MESSAGE"] + +# UI_RACK_VIEW_TRUNCATE_FUNCTION +# +# def UI_RACK_VIEW_TRUNCATE_FUNCTION(device_display_name): +# """Given device display name, truncate to fit the rack elevation view. +# +# :param device_display_name: Full display name of the device attempting to be rendered in the rack elevation. +# :type device_display_name: str +# +# :return: Truncated device name +# :type: str +# """ +# return str(device_display_name).split(".")[0] + +# A list of strings designating all applications that are enabled in this Django installation. +# Each string should be a dotted Python path to an application configuration class (preferred), +# or a package containing an application. +# https://docs.nautobot.com/projects/core/en/latest/configuration/optional-settings/#extra-applications +# EXTRA_INSTALLED_APPS = [] + +# Allow users to enable request profiling on their login session +# ALLOW_REQUEST_PROFILING = False