diff --git a/disaster_recovery/api/api.py b/disaster_recovery/api/api.py index 858745c..c10e034 100644 --- a/disaster_recovery/api/api.py +++ b/disaster_recovery/api/api.py @@ -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 = { diff --git a/disaster_recovery/utils.py b/disaster_recovery/utils.py index 8ef9c9d..873d415 100644 --- a/disaster_recovery/utils.py +++ b/disaster_recovery/utils.py @@ -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):