Fix dcmanager complete execution
The implementation [1] to deprecate commands in dcmanager's client raised an exception when dcmanager help <command> was executed which happened to break the dcmanager complete command used during bootstrap. This fix solves the issue and adds the deprecation message as a notice in the relevant commands. [1]: https://review.opendev.org/c/starlingx/distcloud-client/+/917493 Test plan: 1. PASS: Run dcmanager help <command> displays the relevant deprecation message 2. PASS: Run dcmanager <command> displays the relevant deprecation message and does not execute 3. PASS: Run dcmanager complete command Closes-Bug: 2064677 Change-Id: Icbe6e6f5e8145bb786d4b6aebb804416959cbb67 Signed-off-by: Raphael Lima <Raphael.Lima@windriver.com>
This commit is contained in:
parent
b4a8ec19dc
commit
e55e4a5c49
@ -164,33 +164,33 @@ class SubcloudDeployShow(base.DCManagerShowOne):
|
||||
|
||||
|
||||
class DeprecatedSubcloudDeployShow(SubcloudDeployShow):
|
||||
def _raise_deprecation_message(self):
|
||||
deprecation_msg = (
|
||||
"This command has been deprecated. Please use "
|
||||
"subcloud deploy show instead."
|
||||
)
|
||||
raise exceptions.DCManagerClientException(deprecation_msg)
|
||||
DEPRECATION_MESSAGE = ("This command has been deprecated. Please use "
|
||||
"subcloud deploy show instead.")
|
||||
|
||||
def get_parser(self, _):
|
||||
self._raise_deprecation_message()
|
||||
def get_parser(self, prog_name):
|
||||
parser = super().get_parser(prog_name)
|
||||
parser.add_argument_group(
|
||||
title="Notice", description=self.DEPRECATION_MESSAGE
|
||||
)
|
||||
return parser
|
||||
|
||||
def _get_resources(self, _):
|
||||
self._raise_deprecation_message()
|
||||
raise exceptions.DCManagerClientException(self.DEPRECATION_MESSAGE)
|
||||
|
||||
|
||||
class DeprecatedSubcloudDeployUpload(SubcloudDeployUpload):
|
||||
def _raise_deprecation_message(self):
|
||||
deprecation_msg = (
|
||||
"This command has been deprecated. Please use "
|
||||
"subcloud deploy upload instead."
|
||||
)
|
||||
raise exceptions.DCManagerClientException(deprecation_msg)
|
||||
DEPRECATION_MESSAGE = ("This command has been deprecated. Please use "
|
||||
"subcloud deploy upload instead.")
|
||||
|
||||
def get_parser(self, _):
|
||||
self._raise_deprecation_message()
|
||||
def get_parser(self, prog_name):
|
||||
parser = super().get_parser(prog_name)
|
||||
parser.add_argument_group(
|
||||
title="Notice", description=self.DEPRECATION_MESSAGE
|
||||
)
|
||||
return parser
|
||||
|
||||
def _get_resources(self, _):
|
||||
self._raise_deprecation_message()
|
||||
raise exceptions.DCManagerClientException(self.DEPRECATION_MESSAGE)
|
||||
|
||||
|
||||
class SubcloudDeployDelete(command.Command):
|
||||
|
@ -750,41 +750,41 @@ class UpdateSubcloud(base.DCManagerShowOne):
|
||||
class ReconfigSubcloud(base.DCManagerShowOne):
|
||||
"""Reconfigure a subcloud."""
|
||||
|
||||
def _raise_deprecation_message(self):
|
||||
deprecation_msg = (
|
||||
"This command has been deprecated. Please use "
|
||||
"'subcloud deploy config' instead."
|
||||
)
|
||||
raise exceptions.DCManagerClientException(deprecation_msg)
|
||||
DEPRECATION_MESSAGE = ("This command has been deprecated. Please use "
|
||||
"'subcloud deploy config' instead.")
|
||||
|
||||
def _get_format_function(self):
|
||||
return detail_format
|
||||
|
||||
def get_parser(self, _):
|
||||
self._raise_deprecation_message()
|
||||
def get_parser(self, prog_name):
|
||||
parser = super().get_parser(prog_name)
|
||||
parser.add_argument_group(
|
||||
title="Notice", description=self.DEPRECATION_MESSAGE
|
||||
)
|
||||
return parser
|
||||
|
||||
def _get_resources(self, _):
|
||||
self._raise_deprecation_message()
|
||||
def _get_resources(self, parsed_args):
|
||||
raise exceptions.DCManagerClientException(self.DEPRECATION_MESSAGE)
|
||||
|
||||
|
||||
class ReinstallSubcloud(base.DCManagerShowOne):
|
||||
"""Reinstall a subcloud."""
|
||||
|
||||
def _raise_deprecation_message(self):
|
||||
deprecation_msg = (
|
||||
"This command has been deprecated. Please use "
|
||||
"'subcloud redeploy' instead."
|
||||
)
|
||||
raise exceptions.DCManagerClientException(deprecation_msg)
|
||||
DEPRECATION_MESSAGE = ("This command has been deprecated. Please use "
|
||||
"'subcloud redeploy' instead.")
|
||||
|
||||
def _get_format_function(self):
|
||||
return detail_format
|
||||
|
||||
def get_parser(self, _):
|
||||
self._raise_deprecation_message()
|
||||
def get_parser(self, prog_name):
|
||||
parser = super().get_parser(prog_name)
|
||||
parser.add_argument_group(
|
||||
title="Notice", description=self.DEPRECATION_MESSAGE
|
||||
)
|
||||
return parser
|
||||
|
||||
def _get_resources(self, _):
|
||||
self._raise_deprecation_message()
|
||||
def _get_resources(self, parsed_args):
|
||||
raise exceptions.DCManagerClientException(self.DEPRECATION_MESSAGE)
|
||||
|
||||
|
||||
class RedeploySubcloud(base.DCManagerShowOne):
|
||||
@ -925,21 +925,21 @@ class RedeploySubcloud(base.DCManagerShowOne):
|
||||
class RestoreSubcloud(base.DCManagerShowOne):
|
||||
"""Restore a subcloud."""
|
||||
|
||||
def _raise_deprecation_message(self):
|
||||
deprecation_msg = (
|
||||
"This command has been deprecated. Please use "
|
||||
"subcloud-backup restore instead."
|
||||
)
|
||||
raise exceptions.DCManagerClientException(deprecation_msg)
|
||||
DEPRECATION_MESSAGE = ("This command has been deprecated. Please use "
|
||||
"subcloud-backup restore instead.")
|
||||
|
||||
def _get_format_function(self):
|
||||
return detail_format
|
||||
|
||||
def get_parser(self, _):
|
||||
self._raise_deprecation_message()
|
||||
def get_parser(self, prog_name):
|
||||
parser = super().get_parser(prog_name)
|
||||
parser.add_argument_group(
|
||||
title="Notice", description=self.DEPRECATION_MESSAGE
|
||||
)
|
||||
return parser
|
||||
|
||||
def _get_resources(self, _):
|
||||
self._raise_deprecation_message()
|
||||
def _get_resources(self, parsed_args):
|
||||
raise exceptions.DCManagerClientException(self.DEPRECATION_MESSAGE)
|
||||
|
||||
|
||||
class PrestageSubcloud(base.DCManagerShowOne):
|
||||
|
@ -431,14 +431,10 @@ class TestCLISubcloudManagerV1(base.BaseCommandTest):
|
||||
|
||||
@mock.patch("getpass.getpass", return_value="testpassword")
|
||||
def test_restore_subcloud(self, _mock_getpass):
|
||||
with tempfile.NamedTemporaryFile() as f:
|
||||
file_path = os.path.abspath(f.name)
|
||||
|
||||
e = self.assertRaises(
|
||||
DCManagerClientException,
|
||||
self.call,
|
||||
subcloud_cmd.RestoreSubcloud,
|
||||
app_args=[base.ID, "--restore-values", file_path],
|
||||
)
|
||||
|
||||
deprecation_msg = (
|
||||
|
Loading…
Reference in New Issue
Block a user