Add 'subcloud deploy complete' command to dcmanager
This commit adds the subcloud deploy complete command to dcmanager client. It's used to mark the subcloud deployment as 'complete', usefull when the user manually configures the subcloud and wants to finalize the deployment without running 'dcmanager subcloud deploy config'. Usage: dcmanager subcloud deploy complete subcloud-name To run the 'deploy complete' operation deploy status of the subcloud must be 'bootstrap-complete' Test Plan: 1. PASS - Verify that the dcmanager help subcloud deploy complete shows the correct help message; 2. PASS - Run 'dcmanager subcloud deploy complete' and verify that the correct API call is made; 3. PASS - Verify that the subcloud name/id parameter is required. Depends-On: https://review.opendev.org/c/starlingx/distcloud/+/889877 Story: 2010756 Task: 48454 Change-Id: I53929dcad068c93982e3381f47f4dda61b3b5d1e Signed-off-by: Gustavo Herzmann <gustavo.herzmann@windriver.com>
This commit is contained in:
parent
8da7608d20
commit
d6335fc1cc
|
@ -61,6 +61,10 @@ class phased_subcloud_deploy_manager(base.ResourceManager):
|
|||
url = BASE_URL + "%s/configure" % subcloud_ref
|
||||
return self._deploy_operation(url, files, data, method='patch')
|
||||
|
||||
def subcloud_deploy_complete(self, subcloud_ref):
|
||||
url = BASE_URL + "%s/complete" % subcloud_ref
|
||||
return self._deploy_operation(url, {}, {}, method='patch')
|
||||
|
||||
def subcloud_deploy_abort(self, subcloud_ref, **kwargs):
|
||||
# Currently it's not passed neither data or files to abort,
|
||||
# so we pass an empty dict to use the _deploy_operation function
|
||||
|
|
|
@ -490,3 +490,33 @@ class ConfigPhasedSubcloudDeploy(base.DCManagerShowOne):
|
|||
print(e)
|
||||
error_msg = "Unable to configure subcloud %s" % (subcloud_ref)
|
||||
raise exceptions.DCManagerClientException(error_msg)
|
||||
|
||||
|
||||
class CompletePhasedSubcloudDeploy(base.DCManagerShowOne):
|
||||
"""Complete a subcloud deployment."""
|
||||
|
||||
def _get_format_function(self):
|
||||
return utils.subcloud_detail_format
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super().get_parser(prog_name)
|
||||
|
||||
parser.add_argument(
|
||||
'subcloud',
|
||||
help='Name or ID of the subcloud to complete the deployment.'
|
||||
)
|
||||
|
||||
return parser
|
||||
|
||||
def _get_resources(self, parsed_args):
|
||||
subcloud_ref = parsed_args.subcloud
|
||||
dcmanager_client = self.app.client_manager.\
|
||||
phased_subcloud_deploy_manager.phased_subcloud_deploy_manager
|
||||
|
||||
try:
|
||||
return dcmanager_client.subcloud_deploy_complete(subcloud_ref)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
error_msg = "Unable to complete the deployment of subcloud %s" % (
|
||||
subcloud_ref)
|
||||
raise exceptions.DCManagerClientException(error_msg)
|
||||
|
|
|
@ -549,6 +549,7 @@ class DCManagerShell(app.App):
|
|||
'subcloud deploy bootstrap': psdm.BootstrapPhasedSubcloudDeploy,
|
||||
'subcloud deploy config': psdm.ConfigPhasedSubcloudDeploy,
|
||||
'subcloud deploy install': psdm.InstallPhasedSubcloudDeploy,
|
||||
'subcloud deploy complete': psdm.CompletePhasedSubcloudDeploy,
|
||||
'subcloud deploy resume': psdm.PhasedSubcloudDeployResume,
|
||||
'subcloud deploy upload': sdm.SubcloudDeployUpload,
|
||||
'subcloud deploy show': sdm.SubcloudDeployShow,
|
||||
|
|
|
@ -138,6 +138,14 @@ class TestCLIPhasedSubcloudDeployManagerV1(base.BaseCommandTest):
|
|||
'--deploy-config', file_path])
|
||||
self.assertTrue('deploy-config file does not exist' in str(e))
|
||||
|
||||
def test_complete_subcloud_deployment(self):
|
||||
self.client.subcloud_deploy_complete.return_value = [
|
||||
base.SUBCLOUD_RESOURCE]
|
||||
actual_call = self.call(
|
||||
cmd.CompletePhasedSubcloudDeploy,
|
||||
app_args=[base.NAME])
|
||||
self.assertEqual(base.SUBCLOUD_FIELD_RESULT_LIST, actual_call[1])
|
||||
|
||||
def test_abort_subcloud(self):
|
||||
self.client.subcloud_deploy_abort.return_value = [
|
||||
base.SUBCLOUD_RESOURCE]
|
||||
|
|
Loading…
Reference in New Issue