Remove subcloud migrate from CLI
This commit removes "subcloud migrate" command since "subcloud-peer-group migrate" command can be re-executed to migrate a single subcloud that failed to migrate in the previous attempt. Test Plan: PASS - Verify that "dcmanager subcloud migrate" and "dcmanager help subcloud migrate" return an error (dcmanager: 'subcloud migrate' is not a dcmanager command. See 'dcmanager --help'.) Closes-Bug: 2049336 Change-Id: I793bee7d680d59a4d29a585c88c8c1689976ee1b Signed-off-by: Zhang Rong(Jon) <rong.zhang@windriver.com>
This commit is contained in:
parent
c749b71531
commit
c9e03caa9d
|
@ -1,5 +1,5 @@
|
||||||
# Copyright (c) 2017 Ericsson AB.
|
# Copyright (c) 2017 Ericsson AB.
|
||||||
# Copyright (c) 2017-2023 Wind River Systems, Inc.
|
# Copyright (c) 2017-2024 Wind River Systems, Inc.
|
||||||
# All Rights Reserved.
|
# All Rights Reserved.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
@ -75,16 +75,6 @@ class subcloud_manager(base.ResourceManager):
|
||||||
resource.append(self.json_to_resource(json_object))
|
resource.append(self.json_to_resource(json_object))
|
||||||
return resource
|
return resource
|
||||||
|
|
||||||
def subcloud_migrate(self, url, data):
|
|
||||||
data = json.dumps(data)
|
|
||||||
resp = self.http_client.patch(url, data)
|
|
||||||
if resp.status_code != 200:
|
|
||||||
self._raise_api_exception(resp)
|
|
||||||
json_object = get_json(resp)
|
|
||||||
subcloud = self.resource_class.from_payload(self, json_object)
|
|
||||||
resource = [subcloud]
|
|
||||||
return resource
|
|
||||||
|
|
||||||
def _subcloud_prestage(self, url, data):
|
def _subcloud_prestage(self, url, data):
|
||||||
data = json.dumps(data)
|
data = json.dumps(data)
|
||||||
resp = self.http_client.patch(url, data)
|
resp = self.http_client.patch(url, data)
|
||||||
|
@ -160,8 +150,3 @@ class subcloud_manager(base.ResourceManager):
|
||||||
data = kwargs.get('data')
|
data = kwargs.get('data')
|
||||||
url = '/subclouds/%s/redeploy' % subcloud_ref
|
url = '/subclouds/%s/redeploy' % subcloud_ref
|
||||||
return self.subcloud_redeploy(url, files, data)
|
return self.subcloud_redeploy(url, files, data)
|
||||||
|
|
||||||
def migrate_subcloud(self, subcloud_ref, **kwargs):
|
|
||||||
data = kwargs.get('data')
|
|
||||||
url = '/subclouds/%s/migrate' % subcloud_ref
|
|
||||||
return self.subcloud_migrate(url, data)
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# Copyright (c) 2017 Ericsson AB.
|
# Copyright (c) 2017 Ericsson AB.
|
||||||
# Copyright (c) 2017-2023 Wind River Systems, Inc.
|
# Copyright (c) 2017-2024 Wind River Systems, Inc.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
|
@ -958,48 +958,3 @@ class PrestageSubcloud(base.DCManagerShowOne):
|
||||||
print(e)
|
print(e)
|
||||||
error_msg = "Unable to prestage subcloud %s" % (subcloud_ref)
|
error_msg = "Unable to prestage subcloud %s" % (subcloud_ref)
|
||||||
raise exceptions.DCManagerClientException(error_msg)
|
raise exceptions.DCManagerClientException(error_msg)
|
||||||
|
|
||||||
|
|
||||||
class MigrateSubcloud(base.DCManagerShowOne):
|
|
||||||
"""Migrate a secondary status subcloud."""
|
|
||||||
def _get_format_function(self):
|
|
||||||
return detail_format
|
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
|
||||||
parser = super(MigrateSubcloud, self).get_parser(prog_name)
|
|
||||||
|
|
||||||
parser.add_argument(
|
|
||||||
'subcloud',
|
|
||||||
help='Name or ID of the subcloud to migrate.'
|
|
||||||
)
|
|
||||||
|
|
||||||
parser.add_argument(
|
|
||||||
'--sysadmin-password',
|
|
||||||
required=False,
|
|
||||||
help='sysadmin password of the subcloud to be configured, '
|
|
||||||
'if not provided you will be prompted.'
|
|
||||||
)
|
|
||||||
return parser
|
|
||||||
|
|
||||||
def _get_resources(self, parsed_args):
|
|
||||||
subcloud_ref = parsed_args.subcloud
|
|
||||||
dcmanager_client = self.app.client_manager.subcloud_manager
|
|
||||||
data = dict()
|
|
||||||
if parsed_args.sysadmin_password is not None:
|
|
||||||
data['sysadmin_password'] = base64.b64encode(
|
|
||||||
parsed_args.sysadmin_password.encode("utf-8")).decode("utf-8")
|
|
||||||
else:
|
|
||||||
password = utils.prompt_for_password()
|
|
||||||
data["sysadmin_password"] = base64.b64encode(
|
|
||||||
password.encode("utf-8")).decode("utf-8")
|
|
||||||
|
|
||||||
try:
|
|
||||||
result = dcmanager_client.subcloud_manager.migrate_subcloud(
|
|
||||||
subcloud_ref=subcloud_ref, data=data)
|
|
||||||
update_fields_values(result)
|
|
||||||
return result
|
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
print(e)
|
|
||||||
error_msg = "Unable to migrate subcloud %s" % (subcloud_ref)
|
|
||||||
raise exceptions.DCManagerClientException(error_msg)
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# Copyright 2015 - Ericsson AB.
|
# Copyright 2015 - Ericsson AB.
|
||||||
# Copyright (c) 2017-2023 Wind River Systems, Inc.
|
# Copyright (c) 2017-2024 Wind River Systems, Inc.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
|
@ -542,7 +542,6 @@ class DCManagerShell(app.App):
|
||||||
'subcloud redeploy': sm.RedeploySubcloud,
|
'subcloud redeploy': sm.RedeploySubcloud,
|
||||||
'subcloud restore': sm.RestoreSubcloud,
|
'subcloud restore': sm.RestoreSubcloud,
|
||||||
'subcloud prestage': sm.PrestageSubcloud,
|
'subcloud prestage': sm.PrestageSubcloud,
|
||||||
'subcloud migrate': sm.MigrateSubcloud,
|
|
||||||
'subcloud-backup create': sbm.CreateSubcloudBackup,
|
'subcloud-backup create': sbm.CreateSubcloudBackup,
|
||||||
'subcloud-backup delete': sbm.DeleteSubcloudBackup,
|
'subcloud-backup delete': sbm.DeleteSubcloudBackup,
|
||||||
'subcloud-backup restore': sbm.RestoreSubcloudBackup,
|
'subcloud-backup restore': sbm.RestoreSubcloudBackup,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# Copyright (c) 2017 Ericsson AB.
|
# Copyright (c) 2017 Ericsson AB.
|
||||||
# Copyright (c) 2017-2023 Wind River Systems, Inc.
|
# Copyright (c) 2017-2024 Wind River Systems, Inc.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
|
@ -387,16 +387,3 @@ class TestCLISubcloudManagerV1(base.BaseCommandTest):
|
||||||
base.SUBCLOUD_FIELD_RESULT_LIST_WITH_PEERID +
|
base.SUBCLOUD_FIELD_RESULT_LIST_WITH_PEERID +
|
||||||
(base.SOFTWARE_VERSION,),
|
(base.SOFTWARE_VERSION,),
|
||||||
actual_call_with_release[1])
|
actual_call_with_release[1])
|
||||||
|
|
||||||
def test_migrate_subcloud(self):
|
|
||||||
self.client.subcloud_manager.migrate_subcloud. \
|
|
||||||
return_value = [base.SUBCLOUD_RESOURCE]
|
|
||||||
actual_call_without_release = self.call(
|
|
||||||
subcloud_cmd.MigrateSubcloud,
|
|
||||||
app_args=[base.ID,
|
|
||||||
'--sysadmin-password', 'testpassword'])
|
|
||||||
self.assertEqual(
|
|
||||||
base.SUBCLOUD_FIELD_RESULT_LIST_WITH_PEERID,
|
|
||||||
actual_call_without_release[1])
|
|
||||||
self.assertRaises(SystemExit, self.call,
|
|
||||||
subcloud_cmd.MigrateSubcloud, app_args=[])
|
|
||||||
|
|
Loading…
Reference in New Issue