From 59084472a5ddb019a7bf425e22b677c8bf180448 Mon Sep 17 00:00:00 2001 From: "Zhang Rong(Jon)" Date: Fri, 20 Oct 2023 10:31:13 +0800 Subject: [PATCH] Remove peer group add/update priority from CLI; Add heartbeat_status for peer Remove "dcmanager subcloud-peer-group add --group-priority" and remove "dcmanager subcloud-peer-group update --group-priority" from CLI. This command is not supposed to be used by end user; Add heartbeat_status into the "dcmanager system-peer show". Test Plan: 1. PASS - Run 'dcmanager subcloud-peer-group add --group-priority' and verify that the error message prompted; 2. PASS - Run the normal 'dcmanager subcloud-peer-group add' (without --group-priority) and verify that the command work as expected; 3. PASS - Run 'dcmanager subcloud-peer-group update --group-priority' and verify that the error message prompted; 4. PASS - Run the normal 'dcmanager subcloud-peer-group update' (without --group-priority) and verify that the command work as expected; 5. PASS - Run 'dcmanager system-peer show' and verify that the command show the heartbeat status; Story: 2010852 Task: 48970 Task: 48971 Change-Id: Ia50280b7678374793eb4785767de1564cfa84e4e Signed-off-by: Zhang Rong(Jon) --- .../api/v1/system_peer_manager.py | 3 +++ .../v1/subcloud_peer_group_manager.py | 21 ------------------- .../commands/v1/system_peer_manager.py | 2 ++ .../v1/test_subcloud_peer_group_manager.py | 4 +--- .../tests/v1/test_system_peer_manager.py | 8 ++++++- 5 files changed, 13 insertions(+), 25 deletions(-) diff --git a/distributedcloud-client/dcmanagerclient/api/v1/system_peer_manager.py b/distributedcloud-client/dcmanagerclient/api/v1/system_peer_manager.py index ee6c4f2..f2ff46b 100644 --- a/distributedcloud-client/dcmanagerclient/api/v1/system_peer_manager.py +++ b/distributedcloud-client/dcmanagerclient/api/v1/system_peer_manager.py @@ -27,6 +27,7 @@ class SystemPeer(base.Resource): heartbeat_failure_threshold, heartbeat_failure_policy, heartbeat_maintenance_timeout, + heartbeat_status, created_at, updated_at): self.manager = manager @@ -41,6 +42,7 @@ class SystemPeer(base.Resource): self.heartbeat_failure_threshold = heartbeat_failure_threshold self.heartbeat_failure_policy = heartbeat_failure_policy self.heartbeat_maintenance_timeout = heartbeat_maintenance_timeout + self.heartbeat_status = heartbeat_status self.created_at = created_at self.updated_at = updated_at @@ -65,6 +67,7 @@ class system_peer_manager(base.ResourceManager): heartbeat_failure_policy=json_object['heartbeat-failure-policy'], heartbeat_maintenance_timeout=json_object[ 'heartbeat-maintenance-timeout'], + heartbeat_status=json_object['heartbeat-status'], created_at=json_object['created-at'], updated_at=json_object['updated-at']) diff --git a/distributedcloud-client/dcmanagerclient/commands/v1/subcloud_peer_group_manager.py b/distributedcloud-client/dcmanagerclient/commands/v1/subcloud_peer_group_manager.py index 4cd1849..5c00c34 100644 --- a/distributedcloud-client/dcmanagerclient/commands/v1/subcloud_peer_group_manager.py +++ b/distributedcloud-client/dcmanagerclient/commands/v1/subcloud_peer_group_manager.py @@ -104,14 +104,6 @@ class AddSubcloudPeerGroup(base.DCManagerShowOne): help='Name for the new subcloud peer group.' ) - parser.add_argument( - '--group-priority', - required=False, - type=int, - default=0, - help='Assigned priority for the group.' - ) - parser.add_argument( '--group-state', required=False, @@ -135,9 +127,6 @@ class AddSubcloudPeerGroup(base.DCManagerShowOne): kwargs['peer-group-name'] = parsed_args.peer_group_name - if parsed_args.group_priority is not None: - kwargs['group-priority'] = parsed_args.group_priority - if parsed_args.group_state is not None: kwargs['group-state'] = parsed_args.group_state @@ -256,13 +245,6 @@ class UpdateSubcloudPeerGroup(base.DCManagerShowOne): help='Name for the new subcloud peer group.' ) - parser.add_argument( - '--group-priority', - required=False, - type=int, - help='Assigned priority for the peer group.' - ) - parser.add_argument( '--group-state', required=False, @@ -286,9 +268,6 @@ class UpdateSubcloudPeerGroup(base.DCManagerShowOne): if parsed_args.peer_group_name is not None: kwargs['peer-group-name'] = parsed_args.peer_group_name - if parsed_args.group_priority is not None: - kwargs['group-priority'] = parsed_args.group_priority - if parsed_args.group_state is not None: kwargs['group-state'] = parsed_args.group_state diff --git a/distributedcloud-client/dcmanagerclient/commands/v1/system_peer_manager.py b/distributedcloud-client/dcmanagerclient/commands/v1/system_peer_manager.py index 8514545..7905f7e 100644 --- a/distributedcloud-client/dcmanagerclient/commands/v1/system_peer_manager.py +++ b/distributedcloud-client/dcmanagerclient/commands/v1/system_peer_manager.py @@ -50,6 +50,7 @@ def detail_peer_format(system_peer=None): 'heartbeat failure threshold', 'heartbeat failure policy', 'heartbeat maintenance timeout', + 'heartbeat status', 'created_at', 'updated_at', ) @@ -67,6 +68,7 @@ def detail_peer_format(system_peer=None): system_peer.heartbeat_failure_threshold, system_peer.heartbeat_failure_policy, system_peer.heartbeat_maintenance_timeout, + system_peer.heartbeat_status, system_peer.created_at, system_peer.updated_at, ) diff --git a/distributedcloud-client/dcmanagerclient/tests/v1/test_subcloud_peer_group_manager.py b/distributedcloud-client/dcmanagerclient/tests/v1/test_subcloud_peer_group_manager.py index 7a34424..b44930d 100644 --- a/distributedcloud-client/dcmanagerclient/tests/v1/test_subcloud_peer_group_manager.py +++ b/distributedcloud-client/dcmanagerclient/tests/v1/test_subcloud_peer_group_manager.py @@ -16,7 +16,7 @@ from dcmanagerclient.tests import base FAKE_MANAGER = None PG_ID = "1" PG_NAME = "test-pg-name" -PG_GROUP_PRIORITY = "99" +PG_GROUP_PRIORITY = "0" PG_GROUP_STATE = "disabled" PG_MAX_SUBCLOUD_REHOMING = "10" PG_SYSTEM_LEADER_ID = "d9dea83f-f271-470d-9cce-44b0162a800b" @@ -92,7 +92,6 @@ class TestCLISubcloudPeerGroupManager(base.BaseCommandTest): actual_call2 = self.call( subcloud_peer_group_cmd.AddSubcloudPeerGroup, app_args=[ '--peer-group-name', PG_NAME, - '--group-priority', PG_GROUP_PRIORITY, '--group-state', PG_GROUP_STATE, '--max-subcloud-rehoming', PG_MAX_SUBCLOUD_REHOMING ]) @@ -117,7 +116,6 @@ class TestCLISubcloudPeerGroupManager(base.BaseCommandTest): app_args=[ base.ID, '--peer-group-name', PG_NAME, - '--group-priority', PG_GROUP_PRIORITY, '--group-state', PG_GROUP_STATE, '--max-subcloud-rehoming', PG_MAX_SUBCLOUD_REHOMING]) self.assertEqual( diff --git a/distributedcloud-client/dcmanagerclient/tests/v1/test_system_peer_manager.py b/distributedcloud-client/dcmanagerclient/tests/v1/test_system_peer_manager.py index 1c9a770..cae531e 100644 --- a/distributedcloud-client/dcmanagerclient/tests/v1/test_system_peer_manager.py +++ b/distributedcloud-client/dcmanagerclient/tests/v1/test_system_peer_manager.py @@ -25,6 +25,7 @@ HEARTBEAT_INTERVAL = 10 HEARTBEAT_FAILURE_THRESHOLD = 3 HEARTBEAT_FAILURES_POLICY = 'alarm' HEARTBEAT_MAINTENANCE_TIMEOUT = 600 +HEARTBEAT_STATUS = 'alive' PEER_CONTROLLER_GATEWAY_IP = '128.128.128.1' TIME_NOW = timeutils.utcnow().isoformat() NEW_PEER_CONTROLLER_GATEWAY_IP = '128.1.1.1' @@ -40,6 +41,7 @@ SYSTEM_PEER_DICT = { 'HEARTBEAT_FAILURE_THRESHOLD': HEARTBEAT_FAILURE_THRESHOLD, 'HEARTBEAT_FAILURE_POLICY': HEARTBEAT_FAILURES_POLICY, 'HEARTBEAT_MAINTENANCE_TIMEOUT': HEARTBEAT_MAINTENANCE_TIMEOUT, + 'HEARTBEAT_STATUS': HEARTBEAT_STATUS, 'PEER_CONTROLLER_GATEWAY_IP': PEER_CONTROLLER_GATEWAY_IP, 'CREATED_AT': TIME_NOW, 'UPDATED_AT': TIME_NOW @@ -60,6 +62,7 @@ SYSTEM_PEER = spm.SystemPeer( heartbeat_failure_policy=SYSTEM_PEER_DICT['HEARTBEAT_FAILURE_POLICY'], heartbeat_maintenance_timeout=SYSTEM_PEER_DICT[ 'HEARTBEAT_MAINTENANCE_TIMEOUT'], + heartbeat_status=SYSTEM_PEER_DICT['HEARTBEAT_STATUS'], peer_controller_gateway_address=SYSTEM_PEER_DICT[ 'PEER_CONTROLLER_GATEWAY_IP'], created_at=SYSTEM_PEER_DICT['CREATED_AT'], @@ -114,6 +117,7 @@ class TestCLISystemPeerManagerV1(base.BaseCommandTest): HEARTBEAT_FAILURE_THRESHOLD, HEARTBEAT_FAILURES_POLICY, HEARTBEAT_MAINTENANCE_TIMEOUT, + HEARTBEAT_STATUS, TIME_NOW, TIME_NOW), actual_call[1]) @@ -123,7 +127,7 @@ class TestCLISystemPeerManagerV1(base.BaseCommandTest): return_value = [] actual_call = self.call(system_peer_cmd.ShowSystemPeer, app_args=[ID]) - self.assertEqual((tuple('' for _ in range(13)),), + self.assertEqual((tuple('' for _ in range(14)),), actual_call[1]) def test_add_system_peer(self): @@ -159,6 +163,7 @@ class TestCLISystemPeerManagerV1(base.BaseCommandTest): HEARTBEAT_FAILURE_THRESHOLD, HEARTBEAT_FAILURES_POLICY, HEARTBEAT_MAINTENANCE_TIMEOUT, + HEARTBEAT_STATUS, TIME_NOW, TIME_NOW), actual_call[1]) @@ -185,6 +190,7 @@ class TestCLISystemPeerManagerV1(base.BaseCommandTest): HEARTBEAT_FAILURE_THRESHOLD, HEARTBEAT_FAILURES_POLICY, HEARTBEAT_MAINTENANCE_TIMEOUT, + HEARTBEAT_STATUS, TIME_NOW, TIME_NOW), actual_call[1])