From 61dd16b7d2b923e1770b9a4418aab43ab0e38d15 Mon Sep 17 00:00:00 2001 From: "Mitch Harding (the weird one)" Date: Fri, 7 Jun 2024 13:41:18 -0400 Subject: [PATCH 1/6] Remove obsolete BOA references in code comments --- src/bos/operators/utils/boot_image_metadata/factory.py | 3 +-- src/bos/operators/utils/clients/hsm.py | 2 +- src/bos/operators/utils/rootfs/__init__.py | 3 +-- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/bos/operators/utils/boot_image_metadata/factory.py b/src/bos/operators/utils/boot_image_metadata/factory.py index ac94cebd..c0ecabb7 100644 --- a/src/bos/operators/utils/boot_image_metadata/factory.py +++ b/src/bos/operators/utils/boot_image_metadata/factory.py @@ -1,7 +1,7 @@ # # MIT License # -# (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP +# (C) Copyright 2021-2022, 2024 Hewlett Packard Enterprise Development LP # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), @@ -31,7 +31,6 @@ class BootImageMetaDataUnknown(Exception): """ Raised when a user requests a Provider provisioning mechanism that is not known - by BOA. """ class BootImageMetaDataFactory(object): diff --git a/src/bos/operators/utils/clients/hsm.py b/src/bos/operators/utils/clients/hsm.py index a1b26c3c..f72fb3b6 100644 --- a/src/bos/operators/utils/clients/hsm.py +++ b/src/bos/operators/utils/clients/hsm.py @@ -151,7 +151,7 @@ class Inventory(object): Inventory handles the generation of a hardware inventory in a similar manner to how the dynamic inventory is generated for CFS. To reduce the number of calls to HSM, everything is cached for repeated checks, stored both as overall inventory and separate group types to allow - use in finding BOA's base list of nodes, and lazily loaded to prevent extra calls when no limit + use in finding BOS's base list of nodes, and lazily loaded to prevent extra calls when no limit is used. """ diff --git a/src/bos/operators/utils/rootfs/__init__.py b/src/bos/operators/utils/rootfs/__init__.py index 44db882c..d00f90c5 100644 --- a/src/bos/operators/utils/rootfs/__init__.py +++ b/src/bos/operators/utils/rootfs/__init__.py @@ -1,7 +1,7 @@ # # MIT License # -# (C) Copyright 2019-2022 Hewlett Packard Enterprise Development LP +# (C) Copyright 2019-2022, 2024 Hewlett Packard Enterprise Development LP # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), @@ -35,7 +35,6 @@ class ProviderNotImplemented(Exception): """ Raised when a user requests a Provider Provisioning mechanism that isn't yet supported - by BOA. """ From 05d531e41f16db0d8bbb0a8d406eedb77cae791a Mon Sep 17 00:00:00 2001 From: "Mitch Harding (the weird one)" Date: Wed, 10 Jul 2024 13:36:21 -0400 Subject: [PATCH 2/6] Remove vestigial BASEKEY definition --- CHANGELOG.md | 3 +++ src/bos/server/controllers/v2/sessions.py | 1 - src/bos/server/controllers/v2/sessiontemplates.py | 1 - 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 48b816b8..5a14b39b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Removed +- Remove vestigial `BASEKEY` definition from sessions and templates server controller source files + ## [2.20.0] - 2024-06-05 ### Fixed - Some schemas in the API used the `format` keyword to mean `pattern`, and thus the patterns they specified were not being diff --git a/src/bos/server/controllers/v2/sessions.py b/src/bos/server/controllers/v2/sessions.py index dda45e0d..5ce0edc9 100644 --- a/src/bos/server/controllers/v2/sessions.py +++ b/src/bos/server/controllers/v2/sessions.py @@ -44,7 +44,6 @@ DB = dbutils.get_wrapper(db='sessions') COMPONENTS_DB = dbutils.get_wrapper(db='components') STATUS_DB = dbutils.get_wrapper(db='session_status') -BASEKEY = "/sessions" MAX_COMPONENTS_IN_ERROR_DETAILS = 10 diff --git a/src/bos/server/controllers/v2/sessiontemplates.py b/src/bos/server/controllers/v2/sessiontemplates.py index 6332969e..6f86d3ea 100644 --- a/src/bos/server/controllers/v2/sessiontemplates.py +++ b/src/bos/server/controllers/v2/sessiontemplates.py @@ -33,7 +33,6 @@ LOGGER = logging.getLogger('bos.server.controllers.v2.sessiontemplates') DB = dbutils.get_wrapper(db='session_templates') -BASEKEY = "/sessionTemplates" EXAMPLE_BOOT_SET = { "type": "s3", From 0cec0cae9300a3e4b15e4ff9a1fca503d0fbd603 Mon Sep 17 00:00:00 2001 From: "Mitch Harding (the weird one)" Date: Thu, 11 Jul 2024 12:29:27 -0400 Subject: [PATCH 3/6] Remove unnecessary (and invalid) __all__ assignment from __init__.py in filters module --- CHANGELOG.md | 1 + src/bos/operators/filters/__init__.py | 6 +----- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a14b39b..c729dae3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Removed - Remove vestigial `BASEKEY` definition from sessions and templates server controller source files +- Remove unnecessary (and invalid) `__all__` assignment from `__init__.py` in filters module ## [2.20.0] - 2024-06-05 ### Fixed diff --git a/src/bos/operators/filters/__init__.py b/src/bos/operators/filters/__init__.py index b063e94c..a8eac696 100644 --- a/src/bos/operators/filters/__init__.py +++ b/src/bos/operators/filters/__init__.py @@ -2,7 +2,7 @@ # # MIT License # -# (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP +# (C) Copyright 2021-2022, 2024 Hewlett Packard Enterprise Development LP # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), @@ -27,7 +27,3 @@ from .filters import BOSQuery, HSMState, TimeSinceLastAction,\ LastActionIs, BootArtifactStatesMatch, DesiredConfigurationSetInCFS, DesiredBootStateIsNone,\ DesiredConfigurationIsNone, DesiredBootStateIsOff, OR, NOT, ActualStateAge, ActualBootStateIsSet - -__all__ = [BOSQuery, HSMState, TimeSinceLastAction, LastActionIs, BootArtifactStatesMatch, - DesiredConfigurationSetInCFS, DesiredBootStateIsNone, DesiredConfigurationIsNone, - DesiredBootStateIsOff, OR, NOT, ActualStateAge, ActualBootStateIsSet] From 21f039dc4b6d29c05d8546e77ceb742339e062ae Mon Sep 17 00:00:00 2001 From: Jason Sollom Date: Wed, 10 Jul 2024 17:13:43 -0500 Subject: [PATCH 4/6] CASMCMS-9039: Fix applystage to work under multi-tenancy When executing the applystage operation, BOS needs to look up the session ID using the tenant. The code has been changed to do this. --- CHANGELOG.md | 3 +++ src/bos/server/controllers/v2/components.py | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c729dae3..8fd1f286 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed +- The applystage operation works again. It was broken when multi-tenancy support was added. + ### Removed - Remove vestigial `BASEKEY` definition from sessions and templates server controller source files - Remove unnecessary (and invalid) `__all__` assignment from `__init__.py` in filters module diff --git a/src/bos/server/controllers/v2/components.py b/src/bos/server/controllers/v2/components.py index e32b0499..e81805ce 100644 --- a/src/bos/server/controllers/v2/components.py +++ b/src/bos/server/controllers/v2/components.py @@ -25,7 +25,7 @@ import logging from bos.common.utils import exc_type_msg, get_current_timestamp -from bos.common.tenant_utils import get_tenant_from_header, get_tenant_component_set, tenant_error_handler +from bos.common.tenant_utils import get_tenant_from_header, get_tenant_component_set, tenant_error_handler, get_tenant_aware_key from bos.common.values import Phase, Action, Status, EMPTY_STAGED_STATE, EMPTY_BOOT_ARTIFACTS from bos.server import redis_db_utils as dbutils from bos.server.controllers.v2.options import get_v2_options_data @@ -504,7 +504,9 @@ def _apply_staged(component_id, clear_staged=False): def _set_state_from_staged(data): staged_state = data.get("staged_state", {}) - staged_session_id = staged_state.get("session", "") + staged_session_id_sans_tenant = staged_state.get("session", "") + tenant = get_tenant_from_header() + staged_session_id = get_tenant_aware_key(staged_session_id_sans_tenant, tenant) if staged_session_id not in SESSIONS_DB: raise Exception("Staged session no longer exists") session = SESSIONS_DB.get(staged_session_id) From 7dcc93026ae08695d247249e1cb4da0b768774d8 Mon Sep 17 00:00:00 2001 From: Jason Sollom Date: Thu, 11 Jul 2024 14:33:09 -0500 Subject: [PATCH 5/6] Updating CHANGELOG prior to release. --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8fd1f286..e367b24b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,9 @@ All notable changes to this project will be documented in this file. 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] +## Unreleased + +## [2.21.0] ### Fixed - The applystage operation works again. It was broken when multi-tenancy support was added. From 36e46f8ca712af54c48b100c9d35a283c93165db Mon Sep 17 00:00:00 2001 From: "Mitch Harding (the weird one)" Date: Fri, 12 Jul 2024 10:56:20 -0400 Subject: [PATCH 6/6] Fix incorrect exception instantiation arguments --- CHANGELOG.md | 1 + src/bos/operators/utils/boot_image_metadata/factory.py | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e367b24b..23b1bb62 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - The applystage operation works again. It was broken when multi-tenancy support was added. +- Fix incorrect exception instantiation arguments in `boot_image_metadata/factory.py` ### Removed - Remove vestigial `BASEKEY` definition from sessions and templates server controller source files diff --git a/src/bos/operators/utils/boot_image_metadata/factory.py b/src/bos/operators/utils/boot_image_metadata/factory.py index c0ecabb7..c9aef39e 100644 --- a/src/bos/operators/utils/boot_image_metadata/factory.py +++ b/src/bos/operators/utils/boot_image_metadata/factory.py @@ -47,5 +47,4 @@ def __call__(self): if path_type == 's3': return S3BootImageMetaData(self.boot_set) else: - raise BootImageMetaDataUnknown("No BootImageMetaData class for " - "type %s", path_type) \ No newline at end of file + raise BootImageMetaDataUnknown(f"No BootImageMetaData class for type {path_type}")