Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _restore_files_to_manager(self):
ctx.logger.info('Restoring files from the archive to the manager')
utils.copy_files_between_manager_and_snapshot(
self._tempdir,
self._config,
to_archive=False,
tenant_name=(
ctx.tenant_name if self._snapshot_version < V_4_0_0 else None
),
)
utils.restore_stage_files(self._tempdir)
utils.restore_composer_files(self._tempdir)
ctx.logger.info('Successfully restored archive files')
def _restore_files_to_manager(self):
ctx.logger.info('Restoring files from the archive to the manager')
utils.copy_files_between_manager_and_snapshot(
self._tempdir,
self._config,
to_archive=False,
tenant_name=(
ctx.tenant_name if self._snapshot_version < V_4_0_0 else None
),
)
utils.restore_stage_files(self._tempdir)
utils.restore_composer_files(self._tempdir)
ctx.logger.info('Successfully restored archive files')
def __init__(self,
snapshot_id,
config,
include_credentials,
include_logs,
include_events):
self._snapshot_id = snapshot_id
self._config = utils.DictToAttributes(config)
self._include_credentials = include_credentials
self._include_logs = include_logs
self._include_events = include_events
self._tempdir = None
self._client = get_rest_client()
def _restore_certificate(self):
archive_cert_dir = os.path.join(self._tempdir, ARCHIVE_CERT_DIR)
old_cert_dir = os.path.dirname(get_local_rest_certificate())
new_cert_dir = old_cert_dir + '_from_snapshot'
utils.copy_snapshot_path(archive_cert_dir, new_cert_dir)
time_to_wait_for_workflow_to_finish = 3
cmd = 'sleep {0}; rm -rf {1}; mv {2} {1}'.format(
time_to_wait_for_workflow_to_finish, old_cert_dir, new_cert_dir)
if not self._no_reboot:
cmd += '; sudo shutdown -r now'
subprocess.Popen(cmd, shell=True)
def _dump_files(self):
ctx.logger.info('Dumping files to the archive from the manager')
utils.copy_files_between_manager_and_snapshot(
self._tempdir,
self._config,
to_archive=True
)
utils.copy_stage_files(self._tempdir)
utils.copy_composer_files(self._tempdir)
def _dump_files(self):
ctx.logger.info('Dumping files to the archive from the manager')
utils.copy_files_between_manager_and_snapshot(
self._tempdir,
self._config,
to_archive=True
)
utils.copy_stage_files(self._tempdir)
utils.copy_composer_files(self._tempdir)
def _restore_files_to_manager(self):
ctx.logger.info('Restoring files from the archive to the manager')
utils.copy_files_between_manager_and_snapshot(
self._tempdir,
self._config,
to_archive=False,
tenant_name=(
ctx.tenant_name if self._snapshot_version < V_4_0_0 else None
),
)
utils.restore_stage_files(self._tempdir)
utils.restore_composer_files(self._tempdir)
ctx.logger.info('Successfully restored archive files')
def _dump_files(self):
ctx.logger.info('Dumping files to the archive from the manager')
utils.copy_files_between_manager_and_snapshot(
self._tempdir,
self._config,
to_archive=True
)
utils.copy_stage_files(self._tempdir)
utils.copy_composer_files(self._tempdir)
def _create_archive(self):
snapshot_archive_name = self._get_snapshot_archive_name()
ctx.logger.info(
'Creating snapshot archive: {0}'.format(snapshot_archive_name))
utils.make_zip64_archive(snapshot_archive_name, self._tempdir)