From 02444385e977d1c3d002a764a11fd6f9fc2aa0dc Mon Sep 17 00:00:00 2001 From: Li Zhu Date: Thu, 29 Feb 2024 20:07:49 -0500 Subject: [PATCH] Output an informative message after running out-of-sync operations Add a minor enhancement to GEO-redundancy. Output an informative message after running below out-of-sync operations, informing the operator that a sync command should be executed. Adding subcloud(s) to the SPG. Removing subcloud(s) from the SPG. Updating subcloud(s) in the SPG. Test plan: Pre-Steps: 1. Create the system peer from Site A to Site B 2. Create System peer from Site B to Site A 3. Create the subcloud peer group in the Site A 4. Add subcloud(s) to the peer group 5. Create peer group association to associate system peer and subcloud peer group - Site A 6. Check current sync status on Sites A and B. Verify they are 'in-sync'. PASS: Verify that the corresponding informative message is printed out after running below out-of-sync operations: 1. Adding subcloud to the SPG. 2. Removing subcloud from the SPG. 3. Updating subcloud in the SPG, for example, bootstrap address, bootstrap values or install values. PASS: Verify that informative message is not printed when running any operation on the sublcoud which does not belong to an SPG. Depends-On: https://review.opendev.org/c/starlingx/distcloud/+/909277 Closes-Bug: 2054124 Change-Id: I1614a719190b2645eb8139b158b0bab257d0f91d Signed-off-by: lzhu1 --- .../dcmanagerclient/api/base.py | 3 +++ .../commands/v1/subcloud_manager.py | 17 ++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/distributedcloud-client/dcmanagerclient/api/base.py b/distributedcloud-client/dcmanagerclient/api/base.py index b7c9c36..9195734 100644 --- a/distributedcloud-client/dcmanagerclient/api/base.py +++ b/distributedcloud-client/dcmanagerclient/api/base.py @@ -57,6 +57,7 @@ class Subcloud(Resource): "prestage-status": "prestage_status", "prestage-versions": "prestage_versions", "region-name": "region_name", + "info_message": "info_message" } def __init__( @@ -89,6 +90,7 @@ class Subcloud(Resource): region_name=None, prestage_status=None, prestage_versions=None, + info_message=None ): if endpoint_sync_status is None: endpoint_sync_status = {} @@ -122,6 +124,7 @@ class Subcloud(Resource): self.region_name = region_name self.prestage_status = prestage_status self.prestage_versions = prestage_versions + self.info_message = info_message @classmethod def from_payload(cls, manager, payload): diff --git a/distributedcloud-client/dcmanagerclient/commands/v1/subcloud_manager.py b/distributedcloud-client/dcmanagerclient/commands/v1/subcloud_manager.py index 51b3bbe..5911160 100644 --- a/distributedcloud-client/dcmanagerclient/commands/v1/subcloud_manager.py +++ b/distributedcloud-client/dcmanagerclient/commands/v1/subcloud_manager.py @@ -23,7 +23,10 @@ from osc_lib.command import command from dcmanagerclient import exceptions, utils from dcmanagerclient.commands.v1 import base -SET_FIELD_VALUE_DICT = {"region_name": None} +SET_FIELD_VALUE_DICT = { + "region_name": None, + "info_message": None +} def basic_format(subcloud=None): @@ -546,6 +549,17 @@ class ManageSubcloud(base.DCManagerShowOne): class UpdateSubcloud(base.DCManagerShowOne): """Update attributes of a subcloud.""" + _info_message = None + + def produce_output(self, parsed_args, column_names, data): + """Overrides method from cliff.Lister/cliff.ShowOne.""" + + # Print out a note or informational message above the formatted + # response. + if self._info_message: + self.app.stdout.write(self._info_message) + + return super().produce_output(parsed_args, column_names, data) def _get_format_function(self): return detail_format @@ -727,6 +741,7 @@ class UpdateSubcloud(base.DCManagerShowOne): result = dcmanager_client.subcloud_manager.update_subcloud( subcloud_ref, files=files, data=data ) + self._info_message = getattr(result[0], 'info_message') update_fields_values(result) return result except Exception as e: