From 01fb97e87ab86e171ce0e7144874068c9683180c Mon Sep 17 00:00:00 2001 From: Christopher de Oliveira Souza Date: Tue, 6 Feb 2024 17:02:36 +0000 Subject: [PATCH] Revert "Add the --upload-only option to dcmanager upgrade_strategy CLI" This reverts commit f7487d291f663a151f1042c9adda211e62abc390. Reason for revert: This change no longer will be necessary Change-Id: I4b8b60044b95f6c5f91703274a408f4235df9f15 --- .../api/v1/sw_upgrade_manager.py | 5 +-- .../commands/v1/sw_update_manager.py | 2 - .../commands/v1/sw_upgrade_manager.py | 33 +-------------- .../tests/v1/test_sw_upgrade_strategy.py | 41 +------------------ 4 files changed, 4 insertions(+), 77 deletions(-) diff --git a/distributedcloud-client/dcmanagerclient/api/v1/sw_upgrade_manager.py b/distributedcloud-client/dcmanagerclient/api/v1/sw_upgrade_manager.py index 622f212..1ef2939 100644 --- a/distributedcloud-client/dcmanagerclient/api/v1/sw_upgrade_manager.py +++ b/distributedcloud-client/dcmanagerclient/api/v1/sw_upgrade_manager.py @@ -1,5 +1,5 @@ # Copyright (c) 2017 Ericsson AB. -# Copyright (c) 2020-2023 Wind River Systems, Inc. +# Copyright (c) 2020-2021 Wind River Systems, Inc. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -24,5 +24,4 @@ class sw_upgrade_manager(sw_update_manager): def __init__(self, http_client): super(sw_upgrade_manager, self).__init__( http_client, - update_type=SW_UPDATE_TYPE_UPGRADE, - extra_args=['upload-only']) + update_type=SW_UPDATE_TYPE_UPGRADE) diff --git a/distributedcloud-client/dcmanagerclient/commands/v1/sw_update_manager.py b/distributedcloud-client/dcmanagerclient/commands/v1/sw_update_manager.py index 280ba7b..abeeb3a 100644 --- a/distributedcloud-client/dcmanagerclient/commands/v1/sw_update_manager.py +++ b/distributedcloud-client/dcmanagerclient/commands/v1/sw_update_manager.py @@ -24,8 +24,6 @@ from dcmanagerclient import exceptions # also handles 'steps' and 'strategies' -# A new field may change where the upload only column -# will be added by the upgrade manager. def detail_format(sw_update_strategy=None): columns = ( 'strategy type', diff --git a/distributedcloud-client/dcmanagerclient/commands/v1/sw_upgrade_manager.py b/distributedcloud-client/dcmanagerclient/commands/v1/sw_upgrade_manager.py index c72d28c..21e3f27 100644 --- a/distributedcloud-client/dcmanagerclient/commands/v1/sw_upgrade_manager.py +++ b/distributedcloud-client/dcmanagerclient/commands/v1/sw_upgrade_manager.py @@ -1,5 +1,5 @@ # Copyright (c) 2017 Ericsson AB. -# Copyright (c) 2020-2023 Wind River Systems, Inc. +# Copyright (c) 2020-2021 Wind River Systems, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -23,23 +23,6 @@ class SwUpgradeManagerMixin(object): dcmanager_client = self.app.client_manager.sw_upgrade_manager return dcmanager_client.sw_upgrade_manager - def custom_format_function(self, sw_update_strategy=None): - original_fmt_func = super()._get_format_function() - columns, data = original_fmt_func(sw_update_strategy) - if sw_update_strategy and sw_update_strategy.extra_args: - upload_only = sw_update_strategy.extra_args.get("upload-only", - False) - else: - upload_only = False - # Insert the 'upload only' field before the 'state', - # 'created_at' and 'updated_at' fields - columns = columns[:-3] + ("upload only",) + columns[-3:] - data = data[:-3] + (upload_only,) + data[-3:] - return columns, data - - def _get_format_function(self): - return self.custom_format_function - class CreateSwUpgradeStrategy(SwUpgradeManagerMixin, sw_update_manager.CreateSwUpdateStrategy): @@ -57,22 +40,8 @@ class CreateSwUpgradeStrategy(SwUpgradeManagerMixin, parser = super(CreateSwUpgradeStrategy, self).get_parser(prog_name) - parser.add_argument( - '--upload-only', - required=False, - action='store_true', - help='Stops strategy after uploading releases to subclouds' - ) - return parser - def process_custom_params(self, parsed_args, kwargs_dict): - """Updates kwargs dictionary from parsed_args for patching""" - if parsed_args.upload_only: - kwargs_dict['upload-only'] = 'true' - else: - kwargs_dict['upload-only'] = 'false' - # override validate_force_params defined in CreateSwUpdateStrategy def validate_force_params(self, parsed_args): pass diff --git a/distributedcloud-client/dcmanagerclient/tests/v1/test_sw_upgrade_strategy.py b/distributedcloud-client/dcmanagerclient/tests/v1/test_sw_upgrade_strategy.py index fe20b55..8ae4453 100644 --- a/distributedcloud-client/dcmanagerclient/tests/v1/test_sw_upgrade_strategy.py +++ b/distributedcloud-client/dcmanagerclient/tests/v1/test_sw_upgrade_strategy.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2020-2023 Wind River Systems, Inc. +# Copyright (c) 2020-2021 Wind River Systems, Inc. # # SPDX-License-Identifier: Apache-2.0 # @@ -7,17 +7,12 @@ from dcmanagerclient.commands.v1 import sw_upgrade_manager as cli_cmd from dcmanagerclient.tests import base from dcmanagerclient.tests.v1.mixins import UpdateStrategyMixin -from dcmanagerclient.tests.v1 import utils class TestSwUpgradeStrategy(UpdateStrategyMixin, base.BaseCommandTest): def setUp(self): super(TestSwUpgradeStrategy, self).setUp() - - # Increase results_length due to the 'upload only' field - self.results_length += 1 - self.sw_update_manager = \ self.app.client_manager.sw_upgrade_manager.sw_upgrade_manager self.create_command = cli_cmd.CreateSwUpgradeStrategy @@ -25,37 +20,3 @@ class TestSwUpgradeStrategy(UpdateStrategyMixin, base.BaseCommandTest): self.delete_command = cli_cmd.DeleteSwUpgradeStrategy self.apply_command = cli_cmd.ApplySwUpgradeStrategy self.abort_command = cli_cmd.AbortSwUpgradeStrategy - - def test_create_strategy_upload_only(self): - """Test that a strategy can be created with the --upload-only option""" - - # prepare mixin attributes - manager_to_test = self.sw_update_manager - expected_strategy_type = manager_to_test.update_type - - # mock the result of the API call - strategy = utils.make_strategy(strategy_type=expected_strategy_type, - extra_args={"upload-only": True}) - - # mock that there is no pre-existing strategy - manager_to_test.create_sw_update_strategy.return_value = strategy - - # invoke the backend method for the CLI. - # Returns a tuple of field descriptions, and a second tuple of values - fields, results = self.call(self.create_command, ['--upload-only']) - - # results is a tuple of expected length - self.assertEqual(len(results), self.results_length) - # result tuple values are - # - strategy type - # - subcloud apply type - # - max parallel subclouds - # - stop on failure - # - upload only - # - state - # - created_at - # - updated_at - - self.assertEqual(results[0], expected_strategy_type) - self.assertEqual(fields[-4], 'upload only') - self.assertEqual(results[-4], True)