def retry_view(self, request, restore_id):
        retry_from = get_object_or_404(DatabaseRestore, pk=restore_id)

        error = False
        if not retry_from.is_status_error:
            error = True
            messages.add_message(
                request,
                messages.ERROR,
                "You can not do retry because restore status is '{}'".format(
                    retry_from.get_status_display()),
            )

        if not retry_from.can_do_retry:
            error = True
            messages.add_message(request, messages.ERROR,
                                 "Restore retry is disabled")

        if error:
            return HttpResponseRedirect(
                reverse('admin:maintenance_databaserestore_change',
                        args=(restore_id, )))

        TaskRegister.restore_snapshot(
            database=retry_from.database,
            snapshot=retry_from.group.backups.first().id,
            user=request.user,
            retry_from=retry_from)

        url = reverse('admin:notification_taskhistory_changelist')
        filter = "user={}".format(request.user.username)
        return HttpResponseRedirect('{}?{}'.format(url, filter))
Esempio n. 2
0
    def restore(cls, database, snapshot, user):
        from notification.tasks import TaskRegister

        LOG.info(
            "Changing database volume with params: database {} snapshot: {}, user: {}"
            .format(database, snapshot, user))
        TaskRegister.restore_snapshot(database=database,
                                      snapshot=snapshot,
                                      user=user)
Esempio n. 3
0
    def restore(cls, database, snapshot, user):
        from notification.tasks import TaskRegister

        LOG.info(
            "Changing database volume with params: database {} snapshot: {}, user: {}".format(
                database, snapshot, user
            )
        )
        TaskRegister.restore_snapshot(
            database=database, snapshot=snapshot, user=user
        )
    def retry_view(self, request, restore_id):
        retry_from = get_object_or_404(DatabaseRestore, pk=restore_id)

        error = False
        if not retry_from.is_status_error:
            error = True
            messages.add_message(
                request, messages.ERROR,
                "You can not do retry because restore status is '{}'".format(
                    retry_from.get_status_display()
                ),
            )

        if not retry_from.can_do_retry:
            error = True
            messages.add_message(
                request, messages.ERROR, "Restore retry is disabled"
            )

        if error:
            return HttpResponseRedirect(
                reverse(
                    'admin:maintenance_databaserestore_change',
                    args=(restore_id,)
                )
            )

        TaskRegister.restore_snapshot(
            database=retry_from.database,
            snapshot=retry_from.group.backups.first().id,
            user=request.user,
            retry_from=retry_from
        )

        url = reverse('admin:notification_taskhistory_changelist')
        filter = "user={}".format(request.user.username)
        return HttpResponseRedirect('{}?{}'.format(url, filter))