Rename software deploy strategy, command and parameter
This commit renames the following to be consistent with other repos: - Command from `software-deploy-strategy` to `sw-deploy-strategy` - Strategy from `software` to `sw-deploy` - Parameter `release-id` to `release` - The `release` parameter is now positional and no longer optional. - A validation was added to check the required `release` parameter. Test Plan: PASS - Perform a software deploy strategy Story: 2010676 Task: 50354 Change-Id: I0f63755bb586500b958a94a772ad84b5b8c97254 Signed-off-by: Hugo Brito <hugo.brito@windriver.com>
This commit is contained in:

committed by
Hugo Nicodemos

parent
7541341e4f
commit
75b8bedf4c
@@ -166,6 +166,12 @@ class SwUpdateStrategyController(object):
|
||||
message = f"Patch file {patch_file} is missing."
|
||||
pecan.abort(400, _(message))
|
||||
|
||||
if strategy_type == consts.SW_UPDATE_TYPE_SOFTWARE and not payload.get(
|
||||
'release'):
|
||||
message = ("Release parameter is required for strategy "
|
||||
f"type {strategy_type}.")
|
||||
pecan.abort(400, _(message))
|
||||
|
||||
max_parallel_subclouds_str = payload.get('max-parallel-subclouds')
|
||||
if max_parallel_subclouds_str is not None:
|
||||
max_parallel_subclouds = None
|
||||
|
@@ -81,7 +81,7 @@ SW_UPDATE_TYPE_KUBERNETES = "kubernetes"
|
||||
SW_UPDATE_TYPE_PATCH = "patch"
|
||||
SW_UPDATE_TYPE_PRESTAGE = "prestage"
|
||||
SW_UPDATE_TYPE_UPGRADE = "upgrade"
|
||||
SW_UPDATE_TYPE_SOFTWARE = "software"
|
||||
SW_UPDATE_TYPE_SOFTWARE = "sw-deploy"
|
||||
|
||||
# Software update states
|
||||
SW_UPDATE_STATE_INITIAL = "initial"
|
||||
@@ -394,7 +394,7 @@ EXTRA_ARGS_UPLOAD_ONLY = 'upload-only'
|
||||
EXTRA_ARGS_PATCH = 'patch'
|
||||
|
||||
# extra_args for software
|
||||
EXTRA_ARGS_RELEASE_ID = 'release_id'
|
||||
EXTRA_ARGS_RELEASE = 'release'
|
||||
|
||||
# http request/response arguments for prestage
|
||||
PRESTAGE_SOFTWARE_VERSION = 'prestage-software-version'
|
||||
|
@@ -42,7 +42,7 @@ class CreatingVIMStrategyState(BaseState):
|
||||
# Get release parameter data for sw-deploy strategy
|
||||
if self.strategy_name == vim.STRATEGY_NAME_SW_USM:
|
||||
extra_args = utils.get_sw_update_strategy_extra_args(self.context)
|
||||
release_id = extra_args.get(consts.EXTRA_ARGS_RELEASE_ID)
|
||||
release_id = extra_args.get(consts.EXTRA_ARGS_RELEASE)
|
||||
opts_dict["release"] = release_id
|
||||
|
||||
# Call the API to build the VIM strategy
|
||||
|
@@ -85,7 +85,7 @@ class PreCheckState(BaseState):
|
||||
|
||||
# Check for prestaged data
|
||||
extra_args = utils.get_sw_update_strategy_extra_args(self.context)
|
||||
release_id = extra_args.get(consts.EXTRA_ARGS_RELEASE_ID)
|
||||
release_id = extra_args.get(consts.EXTRA_ARGS_RELEASE)
|
||||
try:
|
||||
self.info_log(
|
||||
strategy_step, f"Check prestaged data for release: {release_id}"
|
||||
|
@@ -475,9 +475,7 @@ class SwUpdateManager(manager.Manager):
|
||||
}
|
||||
elif strategy_type == consts.SW_UPDATE_TYPE_SOFTWARE:
|
||||
extra_args = {
|
||||
consts.EXTRA_ARGS_RELEASE_ID: payload.get(
|
||||
consts.EXTRA_ARGS_RELEASE_ID
|
||||
)
|
||||
consts.EXTRA_ARGS_RELEASE: payload.get(consts.EXTRA_ARGS_RELEASE)
|
||||
}
|
||||
|
||||
# Don't create a strategy if any of the subclouds is online and the
|
||||
|
@@ -28,14 +28,15 @@ class TestCreateVIMSoftwareStrategyState(TestSoftwareOrchestrator):
|
||||
self.subcloud = self.setup_subcloud()
|
||||
|
||||
# Create default strategy with release parameter
|
||||
extra_args = {"release_id": RELEASE_ID}
|
||||
extra_args = {"release": RELEASE_ID}
|
||||
self.strategy = fake_strategy.create_fake_strategy(
|
||||
self.ctx, self.DEFAULT_STRATEGY_TYPE, extra_args=extra_args
|
||||
)
|
||||
|
||||
# Add the strategy_step state being processed by this unit test
|
||||
self.strategy_step = self.setup_strategy_step(
|
||||
self.subcloud.id, consts.STRATEGY_STATE_SW_CREATE_VIM_STRATEGY)
|
||||
self.subcloud.id, consts.STRATEGY_STATE_SW_CREATE_VIM_STRATEGY
|
||||
)
|
||||
|
||||
# Mock the API calls made by the state
|
||||
self.vim_client.create_strategy = mock.MagicMock()
|
||||
@@ -68,5 +69,4 @@ class TestCreateVIMSoftwareStrategyState(TestSoftwareOrchestrator):
|
||||
)
|
||||
|
||||
# On success, the state should transition to the next state
|
||||
self.assert_step_updated(
|
||||
self.strategy_step.subcloud_id, self.on_success_state)
|
||||
self.assert_step_updated(self.strategy_step.subcloud_id, self.on_success_state)
|
||||
|
@@ -49,7 +49,7 @@ class TestPreCheckState(TestSoftwareOrchestrator):
|
||||
self.subcloud = self.setup_subcloud()
|
||||
|
||||
# Create default strategy with release parameter
|
||||
extra_args = {"release_id": "starlingx-9.0.1"}
|
||||
extra_args = {"release": "starlingx-9.0.1"}
|
||||
self.strategy = fake_strategy.create_fake_strategy(
|
||||
self.ctx, self.DEFAULT_STRATEGY_TYPE, extra_args=extra_args
|
||||
)
|
||||
@@ -62,9 +62,7 @@ class TestPreCheckState(TestSoftwareOrchestrator):
|
||||
self._mock_read_from_cache(pre_check.PreCheckState)
|
||||
self._mock_openstack_driver(pre_check.sdk_platform)
|
||||
self._mock_vim_client(pre_check.vim)
|
||||
self.software_client.list = mock.MagicMock(
|
||||
return_value=FAKE_SUBCLOUD_RELEASES
|
||||
)
|
||||
self.software_client.list = mock.MagicMock(return_value=FAKE_SUBCLOUD_RELEASES)
|
||||
self.mock_read_from_cache.return_value = FAKE_REGION_ONE_RELEASE_PRESTAGED
|
||||
self.mock_vim_client().get_current_strategy = mock.MagicMock(return_value={})
|
||||
|
||||
@@ -78,9 +76,7 @@ class TestPreCheckState(TestSoftwareOrchestrator):
|
||||
self.software_client.list.assert_called()
|
||||
|
||||
# On success, the state should transition to the next state
|
||||
self.assert_step_updated(
|
||||
self.strategy_step.subcloud_id, self.on_success_state
|
||||
)
|
||||
self.assert_step_updated(self.strategy_step.subcloud_id, self.on_success_state)
|
||||
|
||||
def test_pre_check_success_valid_software_strategy(self):
|
||||
"""Test pre-check when the API call succeeds with a valid VIM strategy."""
|
||||
@@ -96,9 +92,7 @@ class TestPreCheckState(TestSoftwareOrchestrator):
|
||||
self.software_client.list.assert_called()
|
||||
|
||||
# On success, the state should transition to the next state
|
||||
self.assert_step_updated(
|
||||
self.strategy_step.subcloud_id, self.on_success_state
|
||||
)
|
||||
self.assert_step_updated(self.strategy_step.subcloud_id, self.on_success_state)
|
||||
|
||||
def test_pre_check_failed_invalid_software_strategy(self):
|
||||
"""Test pre-check when the API call fails with an invalid VIM strategy."""
|
||||
|
Reference in New Issue
Block a user