示例#1
0
    def handle(self, request, context):
        try:
            if context['is_windows']:
                client_os = 'Windows'
            else:
                client_os = 'Linux'

            if context['use_snapshot'] and client_os == 'Windows':
                context['vssadmin'] = True
            else:
                context['vssadmin'] = False

            if context['action_id'] == '':
                return freezer_api.action_create(request, context)
            else:
                return freezer_api.action_update(request, context)
        except Exception:
            exceptions.handle(request)
            return False
示例#2
0
    def handle(self, request, data):
        try:
            backup_id = data['backup_id']
            client_id = data['client']
            client = freezer_api.client_get(request, client_id)
            backup = freezer_api.backup_get(request, backup_id)
            name = "Restore job for {0}".format(client_id)

            # 1st step is to create a job
            restore_job = {
                "description": name,
                "client_id": client_id,
                "schedule_end_date": None,
                "schedule_interval": None,
                "schedule_start_date": None
            }
            job = freezer_api.job_create(request, restore_job)

            # 2nd step is to create an action for this job
            restore_action = {
                "original_name":
                job,  # this is the job_id
                "action":
                "restore",
                "backup_name":
                backup.data_dict[0]['backup_metadata']['backup_name'],
                "restore_abs_path":
                data['path'],
                "container":
                backup.data_dict[0]['backup_metadata']['container'],
                "restore_from_host":
                client.hostname,
                "max_retries":
                3,
                "max_retries_interval":
                60,
                "mandatory":
                False
            }
            return freezer_api.action_create(request, restore_action)
        except Exception:
            exceptions.handle(request)
            return False
示例#3
0
    def handle(self, request, data):
        try:
            backup_id = data['backup_id']
            client_id = data['client']
            client = freezer_api.client_get(request, client_id)
            backup = freezer_api.backup_get(request, backup_id)
            name = "Restore job for {0}".format(client_id)

            # 1st step is to create a job
            restore_job = {
                "description": name,
                "client_id": client_id,
                "schedule_end_date": None,
                "schedule_interval": None,
                "schedule_start_date": None
            }
            job = freezer_api.job_create(request, restore_job)

            # 2nd step is to create an action for this job
            restore_action = {
                "original_name": job,  # this is the job_id
                "action": "restore",
                "backup_name":
                    backup.data_dict[0]['backup_metadata']['backup_name'],
                "restore_abs_path": data['path'],
                "container":
                    backup.data_dict[0]['backup_metadata']['container'],
                "restore_from_host": client.hostname,
                "max_retries": 3,
                "max_retries_interval": 60,
                "mandatory": False
            }
            return freezer_api.action_create(request, restore_action)
        except Exception:
            exceptions.handle(request)
            return False