feat(nodes): TLS-сертификаты ноды и массовая миграция инстансов
All checks were successful
Backend Tests / pytest (Python 3.12) (push) Successful in 57s
Deploy to Production / Trigger production update (push) Successful in 8s

- Сертификаты: методы клиента + endpoints GET/POST/DELETE
  /nodes/{node}/certificates, хуки и вкладка «Сертификаты» в
  NodeAdminManager (просмотр, загрузка PEM cert+key, удаление кастомного,
  бейдж срока действия)
- Bulk migrate: тип bulk_migrate в очереди задач с WS-прогрессом,
  target_node/online в BulkOperationItem, диалог выбора целевой ноды и
  кнопка в тулбаре инстансов (в пределах одного сервера/кластера)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
markmorado
2026-07-09 02:48:25 +05:00
parent afde2bf569
commit 0d056a89a5
10 changed files with 570 additions and 14 deletions

View File

@@ -487,6 +487,8 @@ interface BulkItem {
vm_type: string;
name: string;
node: string;
target_node?: string; // для action='migrate'
online?: boolean;
}
interface BulkOperationResponse {

View File

@@ -75,6 +75,19 @@ export interface NodeTime {
localtime?: number;
}
export interface NodeCertificate {
filename?: string;
fingerprint?: string;
subject?: string;
issuer?: string;
notbefore?: number;
notafter?: number;
san?: string[];
pem?: string;
'public-key-type'?: string;
'public-key-bits'?: number;
}
export const nodeAdminKeys = {
services: (s: number, n: string) => ['node-services', s, n] as const,
updates: (s: number, n: string) => ['apt-updates', s, n] as const,
@@ -85,6 +98,7 @@ export const nodeAdminKeys = {
dns: (s: number, n: string) => ['node-dns', s, n] as const,
hosts: (s: number, n: string) => ['node-hosts', s, n] as const,
time: (s: number, n: string) => ['node-time', s, n] as const,
certificates: (s: number, n: string) => ['node-certificates', s, n] as const,
};
const base = (s: number, n: string) => `/proxmox/api/servers/${s}/nodes/${n}`;
@@ -225,3 +239,30 @@ export function useSetAptRepository(serverId: number, node: string) {
onSuccess: () => qc.invalidateQueries({ queryKey: nodeAdminKeys.repos(serverId, node) }),
});
}
// ---------- TLS certificates ----------
export function useNodeCertificates(serverId: number, node: string, enabled = true) {
return useQuery({
queryKey: nodeAdminKeys.certificates(serverId, node),
queryFn: () => apiClient.get<{ certificates: NodeCertificate[] }>(`${base(serverId, node)}/certificates`),
enabled: serverId > 0 && !!node && enabled,
});
}
export function useUploadNodeCertificate(serverId: number, node: string) {
const qc = useQueryClient();
return useMutation({
mutationFn: (data: { certificates: string; key?: string; force?: boolean; restart?: boolean }) =>
apiClient.post(`${base(serverId, node)}/certificates`, data),
onSuccess: () => qc.invalidateQueries({ queryKey: nodeAdminKeys.certificates(serverId, node) }),
});
}
export function useDeleteNodeCertificate(serverId: number, node: string) {
const qc = useQueryClient();
return useMutation<unknown, Error, boolean>({
mutationFn: (restart) =>
apiClient.delete(`${base(serverId, node)}/certificates?restart=${restart ? 'true' : 'false'}`),
onSuccess: () => qc.invalidateQueries({ queryKey: nodeAdminKeys.certificates(serverId, node) }),
});
}