Beispiel #1
0
 def get_workflow_name(self):
     backup = freezer_api.backup_get(self.request, self.kwargs['backup_id'])
     backup_date = datetime.datetime.fromtimestamp(
         int(backup.data_dict[0]['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_date_str)
Beispiel #2
0
 def get_object(self, *args, **kwargs):
     id = self.kwargs['backup_id']
     try:
         return freezer_api.backup_get(self.request, id)
     except Exception:
         redirect = reverse("horizon:freezer_ui:backups:index")
         msg = _('Unable to retrieve details.')
         exceptions.handle(self.request, msg, redirect=redirect)
Beispiel #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
Beispiel #4
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
Beispiel #5
0
    def get_context_data(self, **kwargs):

        backup = freezer_api.backup_get(self.request, kwargs['backup_id'])
        return {'data': pprint.pformat(backup.data_dict)}