Fix minor bugs in freezer dashboard
freezer dashboard now handles slashes in the dynamic urls improve resilience of backup table updated backup_id encoding when it contains slash or back slash Change-Id: I66e6973e5b55cd8845ec90413867fe5694f1433a
This commit is contained in:
parent
7b12891d57
commit
d4c7b4d2f0
@ -401,6 +401,14 @@ def backups_list(request, offset=0, time_after=None, time_before=None,
|
||||
|
||||
def backup_get(request, backup_id):
|
||||
"""Get a single backup"""
|
||||
# for a local or ssh backup, the backup_id contains the
|
||||
# path of the directory to backup, so that includes "/"
|
||||
# or "\" for windows.
|
||||
# so we send "--" instead "/" from the client to avoid
|
||||
# conflicts in the api endpoint
|
||||
backup_id = backup_id.replace("/", '--')
|
||||
backup_id = backup_id.replace("\\", '--')
|
||||
|
||||
backup = _freezerclient(request).backups.get(backup_id)
|
||||
backup = Backup(backup)
|
||||
return backup
|
||||
|
@ -47,12 +47,11 @@ def icons(backup):
|
||||
level_txt = "Level: {} ({} backup) out of {}".format(
|
||||
backup.level, "Full" if backup.level == 0 else "Incremental",
|
||||
backup.max_level)
|
||||
except Exception:
|
||||
level_txt = 'N/A'
|
||||
|
||||
result.append(
|
||||
'<i class="fa fa-fw fa-custom-number" title="{}">{}</i>'.format(
|
||||
level_txt, backup.level))
|
||||
except Exception:
|
||||
result.append("Level: {}".format("Full"))
|
||||
|
||||
try:
|
||||
if backup.encrypted:
|
||||
@ -84,13 +83,12 @@ def icons(backup):
|
||||
|
||||
def backup_detail_view(backup):
|
||||
return reverse("horizon:freezer_ui:backups:detail",
|
||||
args=[backup.id])
|
||||
args=[backup.backup_id])
|
||||
|
||||
|
||||
class BackupsTable(tables.DataTable):
|
||||
name = tables.Column('backup_name',
|
||||
verbose_name=_("Backup Name"),
|
||||
link=backup_detail_view)
|
||||
backup_name = tables.Column('backup_name',
|
||||
verbose_name=_("Backup Name"))
|
||||
hostname = tables.Column('hostname', verbose_name=_("Hostname"))
|
||||
created = tables.Column("time_stamp",
|
||||
verbose_name=_("Created At"),
|
||||
|
@ -51,9 +51,9 @@ class RestoreView(workflows.WorkflowView):
|
||||
workflow_class = restore_workflow.Restore
|
||||
|
||||
def get_object(self, *args, **kwargs):
|
||||
id = self.kwargs['backup_id']
|
||||
backup_id = self.kwargs['backup_id']
|
||||
try:
|
||||
return freezer_api.backup_get(self.request, id)
|
||||
return freezer_api.backup_get(self.request, backup_id)
|
||||
except Exception:
|
||||
redirect = reverse("horizon:freezer_ui:backups:index")
|
||||
msg = _('Unable to retrieve details.')
|
||||
@ -63,12 +63,13 @@ class RestoreView(workflows.WorkflowView):
|
||||
return 'name' in self.kwargs and bool(self.kwargs['name'])
|
||||
|
||||
def get_workflow_name(self):
|
||||
backup = freezer_api.backup_get(self.request, self.kwargs['backup_id'])
|
||||
backup_id = self.kwargs['backup_id']
|
||||
backup = freezer_api.backup_get(self.request, backup_id)
|
||||
backup_date = datetime.datetime.fromtimestamp(
|
||||
int(backup.data_dict[0]['backup_metadata']['time_stamp']))
|
||||
int(backup.data_dict['backup_metadata']['time_stamp']))
|
||||
backup_date_str = django_date(backup_date, 'SHORT_DATETIME_FORMAT')
|
||||
return "Restore '{}' from {}".format(
|
||||
backup.data_dict[0]['backup_metadata']['backup_name'],
|
||||
backup.data_dict['backup_metadata']['backup_name'],
|
||||
backup_date_str)
|
||||
|
||||
def get_initial(self):
|
||||
@ -77,5 +78,4 @@ class RestoreView(workflows.WorkflowView):
|
||||
def get_workflow(self, *args, **kwargs):
|
||||
workflow = super(RestoreView, self).get_workflow(*args, **kwargs)
|
||||
workflow.name = self.get_workflow_name()
|
||||
|
||||
return workflow
|
||||
|
@ -83,10 +83,10 @@ class Restore(workflows.Workflow):
|
||||
"original_name": job, # this is the job_id
|
||||
"action": "restore",
|
||||
"backup_name":
|
||||
backup.data_dict[0]['backup_metadata']['backup_name'],
|
||||
backup.data_dict['backup_metadata']['backup_name'],
|
||||
"restore_abs_path": data['path'],
|
||||
"container":
|
||||
backup.data_dict[0]['backup_metadata']['container'],
|
||||
backup.data_dict['backup_metadata']['container'],
|
||||
"restore_from_host": client.hostname,
|
||||
"max_retries": 3,
|
||||
"max_retries_interval": 60,
|
||||
|
@ -324,12 +324,13 @@ class SnapshotConfiguration(workflows.Step):
|
||||
contributes = ('use_snapshot',
|
||||
'is_windows',
|
||||
'vssadmin',
|
||||
'lvm_auto_snap',
|
||||
'lvm_srcvol',
|
||||
'lvm_snapname',
|
||||
'lvm_snapsize',
|
||||
'lvm_dirmount',
|
||||
'lvm_volgroup',)
|
||||
# 'lvm_auto_snap',
|
||||
# 'lvm_srcvol',
|
||||
# 'lvm_snapname',
|
||||
# 'lvm_snapsize',
|
||||
# 'lvm_dirmount',
|
||||
# 'lvm_volgroup',
|
||||
)
|
||||
|
||||
|
||||
class AdvancedConfigurationAction(workflows.Action):
|
||||
@ -527,25 +528,26 @@ class AdvancedConfigurationAction(workflows.Action):
|
||||
class AdvancedConfiguration(workflows.Step):
|
||||
action_class = AdvancedConfigurationAction
|
||||
contributes = ('log_file',
|
||||
'exclude',
|
||||
'proxy',
|
||||
'os_auth_ver',
|
||||
'upload_limit',
|
||||
'download_limit',
|
||||
'optimize',
|
||||
'compression',
|
||||
'max_segment_size',
|
||||
'hostname',
|
||||
'encryption_password',
|
||||
'no_incremental',
|
||||
'max_level',
|
||||
'always_level',
|
||||
'restart_always_level',
|
||||
'insecure',
|
||||
'dereference_symlink',
|
||||
'dry_run',
|
||||
'max_priority',
|
||||
'quiet',)
|
||||
# 'exclude',
|
||||
# 'proxy',
|
||||
# 'os_auth_ver',
|
||||
# 'upload_limit',
|
||||
# 'download_limit',
|
||||
# 'optimize',
|
||||
# 'compression',
|
||||
# 'max_segment_size',
|
||||
# 'hostname',
|
||||
# 'encryption_password',
|
||||
# 'no_incremental',
|
||||
# 'max_level',
|
||||
# 'always_level',
|
||||
# 'restart_always_level',
|
||||
# 'insecure',
|
||||
# 'dereference_symlink',
|
||||
# 'dry_run',
|
||||
# 'max_priority',
|
||||
# 'quiet',
|
||||
)
|
||||
|
||||
|
||||
class RulesConfigurationAction(workflows.Action):
|
||||
|
Loading…
Reference in New Issue
Block a user