|
| 1 | +# Copyright 2025 Red Hat, Inc. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +# Define all settings use internally, not exposed to users for overwriting. |
| 16 | + |
| 17 | +INSTALLED_APPS = [ |
| 18 | + "daphne", |
| 19 | + "flags", |
| 20 | + # Django apps |
| 21 | + "django.contrib.auth", |
| 22 | + "django.contrib.contenttypes", |
| 23 | + "django.contrib.sessions", |
| 24 | + "django.contrib.staticfiles", |
| 25 | + # Third party apps |
| 26 | + "rest_framework", |
| 27 | + "drf_spectacular", |
| 28 | + "django_rq", |
| 29 | + "django_filters", |
| 30 | + "ansible_base.rbac", |
| 31 | + "ansible_base.resource_registry", |
| 32 | + "ansible_base.jwt_consumer", |
| 33 | + "ansible_base.rest_filters", |
| 34 | + "ansible_base.feature_flags", |
| 35 | + # Local apps |
| 36 | + "aap_eda.api", |
| 37 | + "aap_eda.core", |
| 38 | +] |
| 39 | + |
| 40 | + |
| 41 | +MIDDLEWARE = [ |
| 42 | + "django.middleware.security.SecurityMiddleware", |
| 43 | + "django.contrib.sessions.middleware.SessionMiddleware", |
| 44 | + "django.middleware.locale.LocaleMiddleware", |
| 45 | + "django.middleware.common.CommonMiddleware", |
| 46 | + "django.middleware.csrf.CsrfViewMiddleware", |
| 47 | + "django.contrib.auth.middleware.AuthenticationMiddleware", |
| 48 | + "django.middleware.clickjacking.XFrameOptionsMiddleware", |
| 49 | + "crum.CurrentRequestUserMiddleware", |
| 50 | +] |
| 51 | + |
| 52 | +ROOT_URLCONF = "aap_eda.urls" |
| 53 | + |
| 54 | +TEMPLATES = [ |
| 55 | + { |
| 56 | + "BACKEND": "django.template.backends.django.DjangoTemplates", |
| 57 | + "DIRS": [], |
| 58 | + "APP_DIRS": True, |
| 59 | + "OPTIONS": { |
| 60 | + "context_processors": [ |
| 61 | + "django.template.context_processors.debug", |
| 62 | + "django.template.context_processors.request", |
| 63 | + "django.contrib.auth.context_processors.auth", |
| 64 | + ], |
| 65 | + }, |
| 66 | + }, |
| 67 | +] |
| 68 | + |
| 69 | +WSGI_APPLICATION = "aap_eda.wsgi.application" |
| 70 | + |
| 71 | +ASGI_APPLICATION = "aap_eda.asgi.application" |
| 72 | + |
| 73 | +# Password validation |
| 74 | +# https://docs.djangoproject.com/en/4.1/ref/settings/#auth-password-validators |
| 75 | + |
| 76 | +AUTH_PASSWORD_VALIDATORS = [ |
| 77 | + { |
| 78 | + "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator", # noqa: E501 |
| 79 | + }, |
| 80 | + { |
| 81 | + "NAME": "django.contrib.auth.password_validation.MinimumLengthValidator", # noqa: E501 |
| 82 | + }, |
| 83 | + { |
| 84 | + "NAME": "django.contrib.auth.password_validation.CommonPasswordValidator", # noqa: E501 |
| 85 | + }, |
| 86 | + { |
| 87 | + "NAME": "django.contrib.auth.password_validation.NumericPasswordValidator", # noqa: E501 |
| 88 | + }, |
| 89 | +] |
| 90 | + |
| 91 | +# Internationalization |
| 92 | +# https://docs.djangoproject.com/en/4.1/topics/i18n/ |
| 93 | + |
| 94 | +LANGUAGE_CODE = "en-us" |
| 95 | + |
| 96 | +USE_I18N = True |
| 97 | + |
| 98 | +TIME_ZONE = "UTC" |
| 99 | + |
| 100 | +USE_TZ = True |
| 101 | + |
| 102 | +# Default primary key field type |
| 103 | +# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field |
| 104 | +DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" |
| 105 | + |
| 106 | +AUTH_USER_MODEL = "core.User" |
| 107 | + |
| 108 | +REST_FRAMEWORK = { |
| 109 | + "DEFAULT_SCHEMA_CLASS": "drf_spectacular.openapi.AutoSchema", |
| 110 | + "DEFAULT_PAGINATION_CLASS": "aap_eda.api.pagination.DefaultPagination", |
| 111 | + "PAGE_SIZE": 20, |
| 112 | + "DEFAULT_AUTHENTICATION_CLASSES": [ |
| 113 | + "aap_eda.api.authentication.SessionAuthentication", |
| 114 | + "rest_framework.authentication.BasicAuthentication", |
| 115 | + "aap_eda.api.authentication.WebsocketJWTAuthentication", |
| 116 | + "ansible_base.jwt_consumer.eda.auth.EDAJWTAuthentication", |
| 117 | + ], |
| 118 | + "DEFAULT_PERMISSION_CLASSES": [ |
| 119 | + "rest_framework.permissions.IsAuthenticated", |
| 120 | + "ansible_base.rbac.api.permissions.AnsibleBaseObjectPermissions", |
| 121 | + ], |
| 122 | + "TEST_REQUEST_DEFAULT_FORMAT": "json", |
| 123 | + "DEFAULT_METADATA_CLASS": "aap_eda.api.metadata.EDAMetadata", |
| 124 | + "EXCEPTION_HANDLER": "aap_eda.api.exceptions.api_fallback_handler", |
| 125 | +} |
| 126 | + |
| 127 | +DEFAULT_REDIS_DB = 0 |
| 128 | + |
| 129 | +# --------------------------------------------------------- |
| 130 | +# TASKING SETTINGS |
| 131 | +# --------------------------------------------------------- |
| 132 | +RQ = { |
| 133 | + "JOB_CLASS": "aap_eda.core.tasking.Job", |
| 134 | + "QUEUE_CLASS": "aap_eda.core.tasking.Queue", |
| 135 | + "SCHEDULER_CLASS": "aap_eda.core.tasking.Scheduler", |
| 136 | + "WORKER_CLASS": "aap_eda.core.tasking.Worker", |
| 137 | +} |
| 138 | + |
| 139 | +# Time window in seconds to consider a worker as dead |
| 140 | +DEFAULT_WORKER_HEARTBEAT_TIMEOUT = 60 |
| 141 | +DEFAULT_WORKER_TTL = 5 |
| 142 | + |
| 143 | +RQ_STARTUP_JOBS = [] |
| 144 | + |
| 145 | +# Id of the scheduler job it's required when we have multiple instances of |
| 146 | +# the scheduler running to avoid duplicate jobs |
| 147 | +RQ_PERIODIC_JOBS = [ |
| 148 | + { |
| 149 | + "func": ( |
| 150 | + "aap_eda.tasks.orchestrator.enqueue_monitor_rulebook_processes" |
| 151 | + ), |
| 152 | + "interval": 5, |
| 153 | + "id": "enqueue_monitor_rulebook_processes", |
| 154 | + }, |
| 155 | + { |
| 156 | + "func": "aap_eda.tasks.project.monitor_project_tasks", |
| 157 | + "interval": 30, |
| 158 | + "id": "monitor_project_tasks", |
| 159 | + }, |
| 160 | +] |
| 161 | +RQ_CRON_JOBS = [] |
| 162 | + |
| 163 | +ANSIBLE_BASE_CUSTOM_VIEW_PARENT = "aap_eda.api.views.dab_base.BaseAPIView" |
| 164 | + |
| 165 | +# --------------------------------------------------------- |
| 166 | +# DJANGO ANSIBLE BASE RESOURCES REGISTRY SETTINGS |
| 167 | +# --------------------------------------------------------- |
| 168 | +ANSIBLE_BASE_RESOURCE_CONFIG_MODULE = "aap_eda.api.resource_api" |
| 169 | + |
| 170 | +# --------------------------------------------------------- |
| 171 | +# DJANGO ANSIBLE BASE RBAC SETTINGS |
| 172 | +# --------------------------------------------------------- |
| 173 | +DEFAULT_ORGANIZATION_NAME = "Default" |
| 174 | +ANSIBLE_BASE_SERVICE_PREFIX = "eda" |
| 175 | +ANSIBLE_BASE_TEAM_MODEL = "core.Team" |
| 176 | +ANSIBLE_BASE_ORGANIZATION_MODEL = "core.Organization" |
| 177 | + |
| 178 | +# Organization and object roles will come from create_initial_data |
| 179 | +ANSIBLE_BASE_ROLE_PRECREATE = {} |
| 180 | + |
| 181 | +ANSIBLE_BASE_ALLOW_SINGLETON_USER_ROLES = True |
| 182 | +ANSIBLE_BASE_CHECK_RELATED_PERMISSIONS = ["view"] |
| 183 | + |
| 184 | +DEFAULT_SYSTEM_PG_NOTIFY_CREDENTIAL_NAME = "_DEFAULT_EDA_PG_NOTIFY_CREDS" |
0 commit comments