Add --migrate option to subcloud unmanage
This commit adds the --migrate option to the subcloud unmanage command, besides unmanaging the subcloud it also changes its deploy status to 'rehome-pending'. It should be used when unmanaging a subcloud before the rehoming/migration operation. This new status will then be used by cert-mon to determine when it should stop auditing an unmanaged subcloud, to avoid certificate issues during the rehoming operation. It's only possible to use this option when the subcloud's deploy status is 'complete'. It's possible to manage it back in case the rehoming operation is not going to be executed anymore; in this case the deploy-status will be reverted back to 'complete'. Example usage: dcmanager subcloud unmanage --migrate subcloud1 Test Plan: 1. PASS - Unmanage a subcloud without --migrate and verify that it still works and that cert-mon continues to audit it; 2. PASS - Manage a subcloud, verify that the operation still works as expected; 3. PASS - Try to unmanage with --migrate when the subcloud's deploy status is different than 'complete' and verify that it doesn't allow it; 4. PASS - Unmanage a subcloud using the --migrate option and verify that its deploy status changes to 'rehome-pending', all the sync statuses change to 'unknown', and that cert-mon stops auditing the subcloud; 5. PASS - Manage a 'rehome-pending' subcloud and verify that it succeeds while also reverting its deploy_status to 'complete'; Depends-on: https://review.opendev.org/c/starlingx/distcloud/+/900288 Story: 2010852 Task: 49060 Signed-off-by: Gustavo Herzmann <gustavo.herzmann@windriver.com> Change-Id: I1d761c1a0ae401a11443d80df70338acb2a0a14a
This commit is contained in:
parent
5b00ad57ed
commit
9d384d63b1
|
@ -422,6 +422,14 @@ class UnmanageSubcloud(base.DCManagerShowOne):
|
|||
'subcloud',
|
||||
help='Name or ID of the subcloud to unmanage.'
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
'--migrate',
|
||||
required=False,
|
||||
action='store_true',
|
||||
help='Mark the subcloud for an upcoming migration.'
|
||||
)
|
||||
|
||||
return parser
|
||||
|
||||
def _get_resources(self, parsed_args):
|
||||
|
@ -429,6 +437,10 @@ class UnmanageSubcloud(base.DCManagerShowOne):
|
|||
dcmanager_client = self.app.client_manager.subcloud_manager
|
||||
kwargs = dict()
|
||||
kwargs['management-state'] = 'unmanaged'
|
||||
|
||||
if parsed_args.migrate:
|
||||
kwargs['migrate'] = 'true'
|
||||
|
||||
try:
|
||||
result = dcmanager_client.subcloud_manager.update_subcloud(
|
||||
subcloud_ref, files=None, data=kwargs)
|
||||
|
|
|
@ -221,6 +221,15 @@ class TestCLISubcloudManagerV1(base.BaseCommandTest):
|
|||
base.SUBCLOUD_FIELD_RESULT_LIST_WITH_PEERID,
|
||||
actual_call[1])
|
||||
|
||||
def test_unmanage_subcloud_with_migrate(self):
|
||||
self.client.subcloud_manager.update_subcloud.\
|
||||
return_value = [base.SUBCLOUD_RESOURCE]
|
||||
actual_call = self.call(
|
||||
subcloud_cmd.UnmanageSubcloud, app_args=[base.ID, '--migrate'])
|
||||
self.assertEqual(
|
||||
base.SUBCLOUD_FIELD_RESULT_LIST_WITH_PEERID,
|
||||
actual_call[1])
|
||||
|
||||
def test_unmanage_subcloud_without_subcloud_id(self):
|
||||
self.assertRaises(SystemExit, self.call,
|
||||
subcloud_cmd.UnmanageSubcloud, app_args=[])
|
||||
|
|
Loading…
Reference in New Issue