Merge "Remove central backup path when subcloud deleted"

This commit is contained in:
Zuul 2022-11-18 17:06:47 +00:00 committed by Gerrit Code Review
commit 94dccf19bb
1 changed files with 13 additions and 0 deletions

View File

@ -24,6 +24,7 @@ import json
import keyring
import netaddr
import os
import shutil
import threading
import time
@ -1625,9 +1626,21 @@ class SubcloudManager(manager.Manager):
# Delete the subcloud intermediate certificate
SubcloudManager._delete_subcloud_cert(subcloud.name)
# Delete the subcloud backup path
self._delete_subcloud_backup_data(subcloud.name)
# Regenerate the addn_hosts_dc file
self._create_addn_hosts_dc(context)
@staticmethod
def _delete_subcloud_backup_data(subcloud_name):
try:
backup_path = os.path.join(CENTRAL_BACKUP_DIR, subcloud_name)
if os.path.exists(backup_path):
shutil.rmtree(backup_path)
except Exception as e:
LOG.exception(e)
def delete_subcloud(self, context, subcloud_id):
"""Delete subcloud and notify orchestrators.