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 <li.zhu@windriver.com>
This commit is contained in:
Li Zhu 2024-02-29 20:07:49 -05:00
parent d847780a4d
commit 02444385e9
2 changed files with 19 additions and 1 deletions

View File

@ -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):

View File

@ -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: