Enhance strategy error messages in dcmanager-api

This commit removes the generic error message from dcmanager-client
to dcmanager-api handle a more detailed message when exceptions occur.
The commands that are affected by this change are:
dcmanager <strategy-type>-strategy create/apply/abort/delete.

Test Plan:

Test Plan:
1. Test the `dcmanager <strategy_type>-strategy create/delete/abort/apply` commands for the following strategies:
- fw-update-strategy, kube-rootca-update-strategy, kube-upgrade-strategy, patch-strategy, prestage-strategy, and upgrade-strategy.
2. Validate that the exception message does not include the old generic reason: "Unable to <command> sw update strategy"

Partial-Bug: 2026604

Change-Id: I60e1188dcbedba7ffb8e8d9e76bb563417b1b69a
Signed-off-by: Hugo Brito <hugo.brito@windriver.com>
This commit is contained in:
Hugo Brito 2023-07-07 16:08:24 -03:00 committed by Hugo Nicodemos
parent 822cd5c0c4
commit a45e26cfb7
1 changed files with 3 additions and 18 deletions

View File

@ -246,12 +246,7 @@ class DeleteSwUpdateStrategy(base.DCManagerShowOne):
return detail_format
def _get_resources(self, parsed_args):
try:
return self.get_sw_update_manager().delete_sw_update_strategy()
except Exception as e:
print(e)
error_msg = "Unable to delete sw update strategy"
raise exceptions.DCManagerClientException(error_msg)
return self.get_sw_update_manager().delete_sw_update_strategy()
class ApplySwUpdateStrategy(base.DCManagerShowOne):
@ -265,12 +260,7 @@ class ApplySwUpdateStrategy(base.DCManagerShowOne):
return detail_format
def _get_resources(self, parsed_args):
try:
return self.get_sw_update_manager().apply_sw_update_strategy()
except Exception as e:
print(e)
error_msg = "Unable to apply sw update strategy"
raise exceptions.DCManagerClientException(error_msg)
return self.get_sw_update_manager().apply_sw_update_strategy()
class AbortSwUpdateStrategy(base.DCManagerShowOne):
@ -284,12 +274,7 @@ class AbortSwUpdateStrategy(base.DCManagerShowOne):
return detail_format
def _get_resources(self, parsed_args):
try:
return self.get_sw_update_manager().abort_sw_update_strategy()
except Exception as e:
print(e)
error_msg = "Unable to abort sw update strategy"
raise exceptions.DCManagerClientException(error_msg)
return self.get_sw_update_manager().abort_sw_update_strategy()
class ListSwUpdateStrategyStep(base.DCManagerLister):