Upgrade to Django4

* Now supports py10, py11. Drop py8
* Update unit test template as per https://review.opendev.org/c/openstack/adjutant/+/904651

Change-Id: I1209cf9b35c42262396bbc0e00898110e3111255
This commit is contained in:
Dale Smith 2024-07-10 12:51:55 +12:00
parent 8deababd1b
commit 96fa3ea6e4
12 changed files with 42 additions and 46 deletions

View File

@ -16,7 +16,7 @@
- publish-openstack-docs-pti - publish-openstack-docs-pti
- build-release-notes-jobs-python3 - build-release-notes-jobs-python3
- openstack-cover-jobs - openstack-cover-jobs
- openstack-python3-zed-jobs - openstack-python3-jobs
check: check:
jobs: jobs:
- adjutant-black-style-check - adjutant-black-style-check

View File

@ -12,6 +12,6 @@ class Migration(migrations.Migration):
migrations.AddField( migrations.AddField(
model_name="action", model_name="action",
name="auto_approve", name="auto_approve",
field=models.NullBooleanField(default=None), field=models.BooleanField(null=True, default=None),
), ),
] ]

View File

@ -12,7 +12,7 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from django.conf.urls import url, include from django.urls import include, re_path
from django.conf import settings from django.conf import settings
from rest_framework_swagger.views import get_swagger_view from rest_framework_swagger.views import get_swagger_view
@ -22,15 +22,15 @@ from adjutant.api.views import build_version_details
from adjutant.api.v1 import views as views_v1 from adjutant.api.v1 import views as views_v1
urlpatterns = [ urlpatterns = [
url(r"^$", views.VersionView.as_view()), re_path(r"^$", views.VersionView.as_view()),
] ]
# NOTE(adriant): make this conditional once we have a v2. # NOTE(adriant): make this conditional once we have a v2.
build_version_details("1.0", "CURRENT", relative_endpoint="v1/") build_version_details("1.0", "CURRENT", relative_endpoint="v1/")
urlpatterns.append(url(r"^v1/?$", views_v1.V1VersionEndpoint.as_view())) urlpatterns.append(re_path(r"^v1/?$", views_v1.V1VersionEndpoint.as_view()))
urlpatterns.append(url(r"^v1/", include("adjutant.api.v1.urls"))) urlpatterns.append(re_path(r"^v1/", include("adjutant.api.v1.urls")))
if settings.DEBUG: if settings.DEBUG:
schema_view = get_swagger_view(title="Adjutant API") schema_view = get_swagger_view(title="Adjutant API")
urlpatterns.append(url(r"^docs/", schema_view)) urlpatterns.append(re_path(r"^docs/", schema_view))

View File

@ -12,23 +12,23 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from django.conf.urls import url from django.urls import re_path
from adjutant.api.v1 import views from adjutant.api.v1 import views
from adjutant import api from adjutant import api
from adjutant.config import CONF from adjutant.config import CONF
urlpatterns = [ urlpatterns = [
url(r"^status/?$", views.StatusView.as_view()), re_path(r"^status/?$", views.StatusView.as_view()),
url(r"^tasks/(?P<uuid>\w+)/?$", views.TaskDetail.as_view()), re_path(r"^tasks/(?P<uuid>\w+)/?$", views.TaskDetail.as_view()),
url(r"^tasks/?$", views.TaskList.as_view()), re_path(r"^tasks/?$", views.TaskList.as_view()),
url(r"^tokens/(?P<id>\w+)", views.TokenDetail.as_view()), re_path(r"^tokens/(?P<id>\w+)", views.TokenDetail.as_view()),
url(r"^tokens/?$", views.TokenList.as_view()), re_path(r"^tokens/?$", views.TokenList.as_view()),
url(r"^notifications/(?P<uuid>\w+)/?$", views.NotificationDetail.as_view()), re_path(r"^notifications/(?P<uuid>\w+)/?$", views.NotificationDetail.as_view()),
url(r"^notifications/?$", views.NotificationList.as_view()), re_path(r"^notifications/?$", views.NotificationList.as_view()),
] ]
for active_view in CONF.api.active_delegate_apis: for active_view in CONF.api.active_delegate_apis:
delegate_api = api.DELEGATE_API_CLASSES[active_view] delegate_api = api.DELEGATE_API_CLASSES[active_view]
urlpatterns.append(url(delegate_api.url, delegate_api.as_view())) urlpatterns.append(re_path(delegate_api.url, delegate_api.as_view()))

View File

@ -101,9 +101,9 @@ def register_notification_handler(notification_handler):
"'%s' is not a built off the BaseNotificationHandler class." "'%s' is not a built off the BaseNotificationHandler class."
% notification_handler.__name__ % notification_handler.__name__
) )
notifications.NOTIFICATION_HANDLERS[ notifications.NOTIFICATION_HANDLERS[notification_handler.__name__] = (
notification_handler.__name__ notification_handler
] = notification_handler )
if notification_handler.config_group: if notification_handler.config_group:
# NOTE(adriant): We copy the config_group before naming it # NOTE(adriant): We copy the config_group before naming it
# to avoid cases where a subclass inherits but doesn't extend it # to avoid cases where a subclass inherits but doesn't extend it

View File

@ -29,14 +29,14 @@ class KeystoneHeaderUnwrapper:
def __call__(self, request): def __call__(self, request):
try: try:
token_data = { token_data = {
"project_domain_id": request.META["HTTP_X_PROJECT_DOMAIN_ID"], "project_domain_id": request.headers["x-project-domain-id"],
"project_name": request.META["HTTP_X_PROJECT_NAME"], "project_name": request.headers["x-project-name"],
"project_id": request.META["HTTP_X_PROJECT_ID"], "project_id": request.headers["x-project-id"],
"roles": request.META["HTTP_X_ROLES"].split(","), "roles": request.headers["x-roles"].split(","),
"user_domain_id": request.META["HTTP_X_USER_DOMAIN_ID"], "user_domain_id": request.headers["x-user-domain-id"],
"username": request.META["HTTP_X_USER_NAME"], "username": request.headers["x-user-name"],
"user_id": request.META["HTTP_X_USER_ID"], "user_id": request.headers["x-user-id"],
"authenticated": request.META["HTTP_X_IDENTITY_STATUS"], "authenticated": request.headers["x-identity-status"],
} }
except KeyError: except KeyError:
token_data = {} token_data = {}
@ -60,18 +60,16 @@ class TestingHeaderUnwrapper:
# TODO(adriant): follow up patch to update all the test # TODO(adriant): follow up patch to update all the test
# headers to provide domain values. # headers to provide domain values.
# Default here is just a temporary measure. # Default here is just a temporary measure.
"project_domain_id": request.META["headers"].get( "project_domain_id": request.headers.get(
"project_domain_id", "default" "project_domain_id", "default"
), ),
"project_name": request.META["headers"]["project_name"], "project_name": request.headers["project_name"],
"project_id": request.META["headers"]["project_id"], "project_id": request.headers["project_id"],
"roles": request.META["headers"]["roles"].split(","), "roles": request.headers["roles"].split(","),
"user_domain_id": request.META["headers"].get( "user_domain_id": request.headers.get("user_domain_id", "default"),
"user_domain_id", "default" "username": request.headers["username"],
), "user_id": request.headers["user_id"],
"username": request.META["headers"]["username"], "authenticated": request.headers["authenticated"],
"user_id": request.META["headers"]["user_id"],
"authenticated": request.META["headers"]["authenticated"],
} }
except KeyError: except KeyError:
token_data = {} token_data = {}

View File

@ -45,7 +45,7 @@ INSTALLED_APPS = (
"adjutant.api", "adjutant.api",
"adjutant.notifications", "adjutant.notifications",
"adjutant.tasks", "adjutant.tasks",
"adjutant.startup", "adjutant.startup.config.StartUpConfig",
) )
MIDDLEWARE = ( MIDDLEWARE = (
@ -70,8 +70,6 @@ TIME_ZONE = "UTC"
USE_I18N = True USE_I18N = True
USE_L10N = True
USE_TZ = True USE_TZ = True
STATIC_URL = "/static/" STATIC_URL = "/static/"

View File

@ -1 +0,0 @@
default_app_config = "adjutant.startup.config.StartUpConfig"

View File

@ -12,8 +12,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from django.conf.urls import include, url from django.urls import include, re_path
urlpatterns = [ urlpatterns = [
url(r"^", include("adjutant.api.urls")), re_path(r"^", include("adjutant.api.urls")),
] ]

View File

@ -8,7 +8,7 @@ virtual/libffi [platform:gentoo]
libssl-dev [platform:dpkg] libssl-dev [platform:dpkg]
openssl-devel [platform:rpm] openssl-devel [platform:rpm]
libmysqlclient-dev [platform:dpkg] default-libmysqlclient-dev [platform:dpkg]
mariadb-devel [platform:redhat] mariadb-devel [platform:redhat]
libmariadb-devel [platform:suse] libmariadb-devel [platform:suse]
dev-db/mariadb [platform:gentoo] dev-db/mariadb [platform:gentoo]

View File

@ -1,6 +1,6 @@
pbr>=5.2.0 pbr>=5.2.0
Django>=3.2.12 Django>=4.2
Babel>=2.6.0 Babel>=2.6.0
decorator>=4.4.0 decorator>=4.4.0
django-rest-swagger>=2.2.0 django-rest-swagger>=2.2.0

View File

@ -18,8 +18,9 @@ classifier =
License :: OSI Approved :: Apache Software License License :: OSI Approved :: Apache Software License
Framework :: Django :: 3.2 Framework :: Django :: 3.2
Programming Language :: Python :: 3 Programming Language :: Python :: 3
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Environment :: OpenStack Environment :: OpenStack
keywords = keywords =