From bf3d515c943a896fa43216fcbb806ace7f540470 Mon Sep 17 00:00:00 2001 From: twang4 Date: Fri, 22 Sep 2023 13:55:11 +0800 Subject: [PATCH] Remove subcloud add secondary from CLI Remove "dcmanager subcloud add --secondary" from CLI. This command is not supposed to be used by end user. Test Plan: 1. PASS - Run 'dcmanager subcloud add --secondary' and verify that the error message prompted; 2. PASS - Run a normal 'subcloud add' (without --secondary) and verify that the command work as expected. Story: 2010852 Task: 48818 Signed-off-by: Wang Tao Change-Id: Ib3069797a9dcb90242e7eb8ec2584d1b2faf38d4 --- .../commands/v1/subcloud_manager.py | 33 +++++-------------- .../tests/v1/test_subcloud_manager.py | 29 ---------------- 2 files changed, 8 insertions(+), 54 deletions(-) diff --git a/distributedcloud-client/dcmanagerclient/commands/v1/subcloud_manager.py b/distributedcloud-client/dcmanagerclient/commands/v1/subcloud_manager.py index cbead4e..1b64319 100644 --- a/distributedcloud-client/dcmanagerclient/commands/v1/subcloud_manager.py +++ b/distributedcloud-client/dcmanagerclient/commands/v1/subcloud_manager.py @@ -229,13 +229,6 @@ class AddSubcloud(base.DCManagerShowOne): 'release of the system controller will be used.' ) - parser.add_argument( - '--secondary', - required=False, - action='store_true', - help='A flag indicating if this subcloud is a placeholder ' - 'for incoming subcloud rehoming.' - ) return parser def _get_resources(self, parsed_args): @@ -265,27 +258,20 @@ class AddSubcloud(base.DCManagerShowOne): error_msg = "migrate with deploy-config is not allowed" raise exceptions.DCManagerClientException(error_msg) - if parsed_args.secondary: - error_msg = "secondary with deploy-config is not allowed" - raise exceptions.DCManagerClientException(error_msg) - if not os.path.isfile(parsed_args.deploy_config): error_msg = "deploy-config does not exist: %s" % \ parsed_args.deploy_config raise exceptions.DCManagerClientException(error_msg) files['deploy_config'] = parsed_args.deploy_config - # To add a secondary subcloud, - # do not need sysadmin_password - if not parsed_args.secondary: - # Prompt the user for the subcloud's password if it isn't provided - if parsed_args.sysadmin_password is not None: - data['sysadmin_password'] = base64.b64encode( - parsed_args.sysadmin_password.encode("utf-8")) - else: - password = utils.prompt_for_password() - data["sysadmin_password"] = base64.b64encode( - password.encode("utf-8")) + # Prompt the user for the subcloud's password if it isn't provided + if parsed_args.sysadmin_password is not None: + data['sysadmin_password'] = base64.b64encode( + parsed_args.sysadmin_password.encode("utf-8")) + else: + password = utils.prompt_for_password() + data["sysadmin_password"] = base64.b64encode( + password.encode("utf-8")) if parsed_args.install_values is not None: if parsed_args.bmc_password is not None: @@ -305,9 +291,6 @@ class AddSubcloud(base.DCManagerShowOne): if parsed_args.release is not None: data['release'] = parsed_args.release - if parsed_args.secondary: - data['secondary'] = 'true' - if parsed_args.name is not None: if parsed_args.migrate: data['name'] = parsed_args.name diff --git a/distributedcloud-client/dcmanagerclient/tests/v1/test_subcloud_manager.py b/distributedcloud-client/dcmanagerclient/tests/v1/test_subcloud_manager.py index a3b30fa..1527db4 100644 --- a/distributedcloud-client/dcmanagerclient/tests/v1/test_subcloud_manager.py +++ b/distributedcloud-client/dcmanagerclient/tests/v1/test_subcloud_manager.py @@ -391,32 +391,3 @@ class TestCLISubcloudManagerV1(base.BaseCommandTest): actual_call_without_release[1]) self.assertRaises(SystemExit, self.call, subcloud_cmd.MigrateSubcloud, app_args=[]) - - def test_add_secondary_subcloud(self): - self.client.subcloud_manager.add_subcloud.\ - return_value = [base.SUBCLOUD_RESOURCE] - - with tempfile.NamedTemporaryFile(mode='w') as f_bootstrap: - bootstrap_file_path = os.path.abspath(f_bootstrap.name) - actual_call = self.call( - subcloud_cmd.AddSubcloud, - app_args=[ - '--bootstrap-address', base.BOOTSTRAP_ADDRESS, - '--bootstrap-values', bootstrap_file_path, - '--sysadmin-password', 'testpassword', - '--secondary', - ]) - self.assertEqual( - base.SUBCLOUD_FIELD_RESULT_LIST_WITH_PEERID_REHOME_DATA, - actual_call[1]) - with tempfile.NamedTemporaryFile() as f_config: - config_file_path = os.path.abspath(f_config.name) - self.assertRaises( - DCManagerClientException, self.call, - subcloud_cmd.AddSubcloud, app_args=[ - '--bootstrap-address', base.BOOTSTRAP_ADDRESS, - '--bootstrap-values', bootstrap_file_path, - '--sysadmin-password', 'testpassword', - '--deploy-config', config_file_path, - '--secondary' - ])