Restore from swift, local and ssh from the dashboard

Restore a backup from the dashboard now supports different storage media to restore from

Change-Id: I303785be5c212c3c30f41d8c3dbf1c23f7818b73
This commit is contained in:
memo 2015-11-25 13:51:38 +00:00
parent 3cce1e3d3b
commit 1c5a79cdef
2 changed files with 30 additions and 4 deletions

View File

@ -464,6 +464,12 @@ class Backup(object):
total_broken_links=b.get('backup_metadata', {}).get(
'total_broken_links'),
excluded_files=b.get('backup_metadata', {}).get('excluded_files'),
storage=b.get('backup_metadata', {}).get('storage'),
ssh_host=b.get('backup_metadata', {}).get('ssh_host'),
ssh_key=b.get('backup_metadata', {}).get('ssh_key'),
ssh_username=b.get('backup_metadata', {}).get('ssh_username'),
ssh_port=b.get('backup_metadata', {}).get('ssh_port'),
mode=b.get('backup_metadata', {}).get('ssh_mode'),
) for b in backups]
def get(self, backup_id, json=False):
@ -492,22 +498,34 @@ class Backup(object):
total_broken_links=b.get('backup_metadata', {}).get(
'total_broken_links'),
excluded_files=b.get('backup_metadata', {}).get('excluded_files'),
storage=b.get('backup_metadata', {}).get('storage'),
ssh_host=b.get('backup_metadata', {}).get('ssh_host'),
ssh_key=b.get('backup_metadata', {}).get('ssh_key'),
ssh_username=b.get('backup_metadata', {}).get('ssh_username'),
ssh_port=b.get('backup_metadata', {}).get('ssh_port'),
mode=b.get('backup_metadata', {}).get('ssh_mode'),
)
def restore(self, data):
backup = self.get(data['backup_id'])
client_id = data['client']
name = "Restore job for {0}".format(client_id)
# TODO(m3m0): change storage to be flexible
name = "Restore {0} for {1}".format(backup.backup_name, client_id)
action = {
'action': 'restore',
'backup_name': backup.backup_name,
'restore_abs_path': data['path'],
'container': backup.container,
'restore_from_host': backup.hostname,
'storage': 'local'
'storage': backup.storage
}
if backup.storage == 'ssh':
action['ssh_host'] = backup.ssh_host
action['ssh_key'] = backup.ssh_key
action['ssh_username'] = backup.ssh_username
action['ssh_port'] = backup.ssh_port
action_id = Action(self.request).create(action)
job = {

View File

@ -129,7 +129,9 @@ class BackupObject(object):
backup_name=None, backup_media=None, path_to_backup=None,
hostname=None, level=None, container=None,
curr_backup_level=None, encrypted=None,
total_broken_links=None, excluded_files=None):
total_broken_links=None, excluded_files=None, storage=None,
ssh_host=None, ssh_key=None, ssh_username=None,
ssh_port=None, mode=None):
self.backup_id = backup_id
self.id = backup_id
self.backup_name = backup_name
@ -144,6 +146,12 @@ class BackupObject(object):
self.encrypted = encrypted
self.total_broken_links = total_broken_links or 0
self.excluded_files = excluded_files
self.storage = storage
self.ssh_host = ssh_host
self.ssh_key = ssh_key
self.ssh_username = ssh_username
self.ssh_port = ssh_port or 22
self.mode = mode or 'fs'
class ClientObject(object):