Example #1
0
    def save_note(self):
        request = self.request
        ser = BackupSerializer(request, self.bkp, data=self.data, partial=True)

        if ser.is_valid():
            ser.object.save()
            return SuccessTaskResponse(request, ser.data)
        else:
            return FailureTaskResponse(request, ser.errors)
Example #2
0
    def post(self):
        bkp, vm, define = self.bkp, self.vm, self.define
        bkp.disk_id = self.real_disk_id
        bkp.dc = vm.dc
        bkp.vm = vm
        bkp.json = vm.json_active
        bkp.define = define
        bkp.node = define.node
        bkp.zpool = define.zpool
        bkp.type = define.type
        bkp.status = bkp.PENDING
        ser = BackupSerializer(self.request, bkp, data=self.data)

        if not ser.is_valid():
            return FailureTaskResponse(self.request, ser.errors, vm=vm)

        if define.fsfreeze:  # Store in self.fsfreeze, because it is displayed in response/tasklog detail
            qga_socket = vm.qga_socket_path
            if qga_socket:
                bkp.fsfreeze = True
                if vm.status == vm.STOPPED:
                    qga_socket = None
        else:
            qga_socket = None

        self._check_bkp_dc_size_limit()  # Issue #chili-848
        self._check_vm(vm)
        self.obj = vm
        self._check_bkp_node()
        bkp.save()
        self.msg = LOG_BKP_CREATE

        if self.execute(get_backup_cmd('create',
                                       bkp,
                                       define=define,
                                       zfs_filesystem=self.zfs_filesystem,
                                       fsfreeze=qga_socket),
                        lock=self.LOCK % (vm.uuid, bkp.disk_id),
                        stdin=bkp.json.dump()):
            return self.task_response

        bkp.delete()
        return self.error_response