From 8bd7e14435a4d34f42c71ebdbfd3f7ec4fb34afb Mon Sep 17 00:00:00 2001 From: "Mitch Harding (the weird one)" Date: Thu, 10 Oct 2024 11:38:18 -0400 Subject: [PATCH 1/2] CASMCMS-9161: Fix type hint for validate_boot_sets function --- CHANGELOG.md | 2 ++ src/bos/server/controllers/v2/boot_set/validate.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 63dd242b..62ae8a82 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Fixed +- Fixed type hint for `validate_boot_sets` function ## [2.30.2] - 2024-10-09 ### Changed diff --git a/src/bos/server/controllers/v2/boot_set/validate.py b/src/bos/server/controllers/v2/boot_set/validate.py index 415886b3..c45b9547 100644 --- a/src/bos/server/controllers/v2/boot_set/validate.py +++ b/src/bos/server/controllers/v2/boot_set/validate.py @@ -35,7 +35,7 @@ def validate_boot_sets(session_template: dict, operation: str, template_name: str, - options_data: OptionsData|None=None) -> tuple[str, BootSetStatus]: + options_data: OptionsData|None=None) -> tuple[BootSetStatus, str]: """ Validates the boot sets listed in a session template. This is called when creating a session or when using the sessiontemplatesvalid endpoint From 60fc17bcca05efc8d92bcb117ed0b11abdc0f6bb Mon Sep 17 00:00:00 2001 From: "Mitch Harding (the weird one)" Date: Thu, 10 Oct 2024 11:31:07 -0400 Subject: [PATCH 2/2] CASMCMS-9161: Changed BootSetStatus from Enum to IntEnum; restored inequality comparison of same in sessions controller --- CHANGELOG.md | 6 ++++++ src/bos/server/controllers/v2/boot_set/defs.py | 5 +++-- src/bos/server/controllers/v2/sessions.py | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 62ae8a82..8e253fb0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] + +## [2.30.3] - 2024-10-10 +### Changed +- Changed `BootSetStatus` type from Enum to IntEnum, to allow inequality comparisons +- Reverted change in `2.30.1` now that inequalities work as expected + ### Fixed - Fixed type hint for `validate_boot_sets` function diff --git a/src/bos/server/controllers/v2/boot_set/defs.py b/src/bos/server/controllers/v2/boot_set/defs.py index a9478016..5a21a33a 100644 --- a/src/bos/server/controllers/v2/boot_set/defs.py +++ b/src/bos/server/controllers/v2/boot_set/defs.py @@ -22,12 +22,13 @@ # OTHER DEALINGS IN THE SOFTWARE. # -from enum import Enum +from enum import IntEnum import logging LOGGER = logging.getLogger('bos.server.controllers.v2.boot_set') -class BootSetStatus(Enum): +# Use IntEnum to allow for inequalities +class BootSetStatus(IntEnum): """ In ascending order of error severity """ diff --git a/src/bos/server/controllers/v2/sessions.py b/src/bos/server/controllers/v2/sessions.py index ed97468f..9a5aaa0e 100644 --- a/src/bos/server/controllers/v2/sessions.py +++ b/src/bos/server/controllers/v2/sessions.py @@ -105,7 +105,7 @@ def post_v2_session(): # noqa: E501 # Validate health/validity of the sessiontemplate before creating a session error_code, msg = validate_boot_sets(session_template, session_create.operation, template_name, options_data=options_data) - if error_code == BootSetStatus.ERROR: + if error_code >= BootSetStatus.ERROR: LOGGER.error("Session template fails check: %s", msg) return msg, 400