forked from QualiSystems/cloudshell-orch-sandbox
-
Notifications
You must be signed in to change notification settings - Fork 1
/
teardown_resources.py
38 lines (32 loc) · 1.95 KB
/
teardown_resources.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# coding=utf-8
from cloudshell.core.logger import qs_logger
from cloudshell.helpers.scripts import cloudshell_scripts_helpers as helpers
from sandbox_scripts.QualiEnvironmentUtils.Sandbox import SandboxBase
from sandbox_scripts.helpers.Networking.save_restore_mgr import SaveRestoreManager
from QualiUtils import QualiError
class EnvironmentTeardownResources:
def __init__(self):
self.reservation_id = helpers.get_reservation_context_details().id
self.logger = qs_logger.get_qs_logger(log_file_prefix="CloudShell Sandbox Teardown Resources",
log_group=self.reservation_id,
log_category='Teardown')
#@profileit(scriptName="Teardown")
def execute(self):
sandbox = SandboxBase(self.reservation_id, self.logger)
saveNRestoreTool = SaveRestoreManager(sandbox)
sandbox.report_info("Beginning load configuration for resources")
sandbox.clear_all_resources_live_status()
try:
if saveNRestoreTool.get_storage_manager():
ignore_models = ['Generic TFTP server', 'Config Set Pool', 'Generic FTP server', 'netscout switch 3912',
'OnPATH Switch 3903', 'Ixia Traffic generator', "SubNet-28", "SubNet-30"]
saveNRestoreTool.load_config(config_stage='Base', config_type='Running',
ignore_models=ignore_models, remove_temp_files=True, in_teardown_mode=True)
else:
sandbox.report_info("Skipping load configuration. No storage resource associated with the blueprint ",
write_to_output_window=True)
sandbox.report_info('Sandbox teardown finished successfully')
except QualiError as qe:
self.logger.error("Teardown failed. " + str(qe))
except:
self.logger.error("Teardown failed. Unexpected error:" + str(sys.exc_info()[0]))