feat(instances): ISO eject/mount with boot-order switch and hybrid reboot
- Images: show real ISO files already on the node storage (incl. those present before the node joined the panel) via existing node/isos endpoint - ISO dialog: rename "detach" to "Eject", show current image inside the select (drop overflowing side text), add "boot from disk" checkbox - Backend: on eject, put disk first in boot order; on mount, optional "boot from this ISO" puts CD-ROM first - Reboot to apply the new boot order via hybrid restart: graceful ACPI shutdown with forceStop fallback, then start (fixes guest-ping timeout on freshly installed OS without QEMU Guest Agent) - Update iso_next_steps hint to reflect the automated flow
This commit is contained in:
@@ -50,6 +50,28 @@ export function useNodeArch(serverId?: number, node?: string) {
|
||||
});
|
||||
}
|
||||
|
||||
// Реальные ISO-образы, уже лежащие на ISO-хранилищах ноды (в т.ч. загруженные
|
||||
// до подключения ноды к панели). Отдельно от каталога/зеркал — это содержимое storage.
|
||||
export interface NodeIso {
|
||||
volid: string;
|
||||
storage: string;
|
||||
size: number | null;
|
||||
format: string | null;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export function useNodeIsos(serverId?: number, node?: string) {
|
||||
return useQuery({
|
||||
queryKey: ['node-isos', serverId, node],
|
||||
queryFn: () =>
|
||||
apiClient.get<{ isos: NodeIso[] }>(
|
||||
`/proxmox/api/${serverId}/node/${encodeURIComponent(node!)}/isos`,
|
||||
),
|
||||
enabled: !!serverId && !!node,
|
||||
staleTime: 60 * 1000,
|
||||
});
|
||||
}
|
||||
|
||||
// Целевые хранилища ноды по типу контента (import|vztmpl|iso).
|
||||
export function useImageStorages(serverId?: number, node?: string, content?: string) {
|
||||
return useQuery({
|
||||
|
||||
@@ -826,22 +826,34 @@ export function useNodeIsos(serverId: number, node: string, enabled = true) {
|
||||
|
||||
export function useAttachIso(serverId: number, vmid: number, node: string) {
|
||||
const qc = useQueryClient();
|
||||
return useMutation<{ status: string }, Error, { volid: string; device?: string }>({
|
||||
return useMutation<
|
||||
{ status: string; boot_from_iso?: boolean; rebooted?: boolean },
|
||||
Error,
|
||||
{ volid: string; device?: string; boot_from_iso?: boolean; reboot_after?: boolean }
|
||||
>({
|
||||
mutationFn: (body) =>
|
||||
apiClient.post(`/proxmox/api/${serverId}/vm/${vmid}/iso/attach?node=${node}`, body),
|
||||
onSuccess: () => {
|
||||
qc.invalidateQueries({ queryKey: vmKeys.config(serverId, vmid) });
|
||||
qc.invalidateQueries({ queryKey: vmKeys.status(serverId, vmid) });
|
||||
qc.invalidateQueries({ queryKey: ['resources'] });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function useDetachIso(serverId: number, vmid: number, node: string) {
|
||||
const qc = useQueryClient();
|
||||
return useMutation<{ status: string }, Error, { device?: string }>({
|
||||
return useMutation<
|
||||
{ status: string; boot_from_disk?: boolean; rebooted?: boolean },
|
||||
Error,
|
||||
{ device?: string; boot_from_disk?: boolean; reboot_after?: boolean }
|
||||
>({
|
||||
mutationFn: (body) =>
|
||||
apiClient.post(`/proxmox/api/${serverId}/vm/${vmid}/iso/detach?node=${node}`, body || {}),
|
||||
onSuccess: () => {
|
||||
qc.invalidateQueries({ queryKey: vmKeys.config(serverId, vmid) });
|
||||
qc.invalidateQueries({ queryKey: vmKeys.status(serverId, vmid) });
|
||||
qc.invalidateQueries({ queryKey: ['resources'] });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user