fix(reinstall): use OSTemplate.vmid (not template_vmid) and convert memory bytes->MB
- AttributeError: OSTemplate has no 'template_vmid' field; the actual column is 'vmid'. - Use OSTemplate.get_vmid_for_node() to support cross-node replicated templates, falling back to source_node/vmid otherwise. - VMInstance.memory is stored in bytes, but Proxmox config expects MB.
This commit is contained in:
58
frontend/src/stores/deploy-tasks-store.ts
Normal file
58
frontend/src/stores/deploy-tasks-store.ts
Normal file
@@ -0,0 +1,58 @@
|
||||
import { create } from 'zustand';
|
||||
import { persist } from 'zustand/middleware';
|
||||
|
||||
export interface DeployTask {
|
||||
id: number;
|
||||
name: string;
|
||||
status: 'pending' | 'running' | 'completed' | 'failed';
|
||||
step: string | null;
|
||||
progress: number;
|
||||
vmid: number | null;
|
||||
node: string | null;
|
||||
error_message: string | null;
|
||||
created_at: number;
|
||||
}
|
||||
|
||||
interface DeployTasksState {
|
||||
tasks: DeployTask[];
|
||||
addTask: (task: Omit<DeployTask, 'created_at'>) => void;
|
||||
updateTask: (id: number, update: Partial<DeployTask>) => void;
|
||||
removeTask: (id: number) => void;
|
||||
clearCompleted: () => void;
|
||||
}
|
||||
|
||||
export const useDeployTasksStore = create<DeployTasksState>()(
|
||||
persist(
|
||||
(set) => ({
|
||||
tasks: [],
|
||||
addTask: (task) =>
|
||||
set((state) => ({
|
||||
tasks: [
|
||||
...state.tasks.filter((t) => t.id !== task.id),
|
||||
{ ...task, created_at: Date.now() },
|
||||
],
|
||||
})),
|
||||
updateTask: (id, update) =>
|
||||
set((state) => ({
|
||||
tasks: state.tasks.map((t) => (t.id === id ? { ...t, ...update } : t)),
|
||||
})),
|
||||
removeTask: (id) =>
|
||||
set((state) => ({
|
||||
tasks: state.tasks.filter((t) => t.id !== id),
|
||||
})),
|
||||
clearCompleted: () =>
|
||||
set((state) => ({
|
||||
tasks: state.tasks.filter(
|
||||
(t) => t.status !== 'completed' && t.status !== 'failed',
|
||||
),
|
||||
})),
|
||||
}),
|
||||
{
|
||||
name: 'pve-deploy-tasks',
|
||||
partialize: (state) => ({
|
||||
// Don't persist completed tasks
|
||||
tasks: state.tasks.filter((t) => t.status !== 'completed'),
|
||||
}),
|
||||
},
|
||||
),
|
||||
);
|
||||
Reference in New Issue
Block a user