feat: manual host add from Hosts list via WinRM/SSH (0.4.5)
Add host button probes Windows by hostname or Linux by IP, registers host in SAC and deploys agent in background. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -163,6 +163,54 @@ async function executeRemoteAction(
|
||||
}
|
||||
}
|
||||
|
||||
export async function pollHostRemoteAction(
|
||||
hostId: number,
|
||||
title: string,
|
||||
): Promise<HostRemoteActionJobStatus | null> {
|
||||
const existingPromise = hostRunningPromises.get(hostId);
|
||||
if (existingPromise) {
|
||||
const existing = findLoadingLogForHost(hostId);
|
||||
if (existing) {
|
||||
existing.open = true;
|
||||
}
|
||||
return existingPromise;
|
||||
}
|
||||
|
||||
const entry: HostRemoteActionLogEntry = {
|
||||
id: newLogId(),
|
||||
hostId,
|
||||
open: true,
|
||||
loading: true,
|
||||
ok: null,
|
||||
title,
|
||||
message: "Выполняется на удалённом хосте…",
|
||||
output: "",
|
||||
};
|
||||
hostRemoteActionLogs.push(entry);
|
||||
|
||||
const promise = (async () => {
|
||||
try {
|
||||
const job = await pollRemoteJob(hostId, entry);
|
||||
finishEntry(entry, job);
|
||||
await patchHostFromJob(hostId, job);
|
||||
return job;
|
||||
} catch (e) {
|
||||
entry.loading = false;
|
||||
entry.ok = false;
|
||||
entry.message = e instanceof Error ? e.message : "Ошибка выполнения";
|
||||
entry.open = true;
|
||||
return null;
|
||||
}
|
||||
})();
|
||||
|
||||
hostRunningPromises.set(hostId, promise);
|
||||
try {
|
||||
return await promise;
|
||||
} finally {
|
||||
hostRunningPromises.delete(hostId);
|
||||
}
|
||||
}
|
||||
|
||||
export async function runHostRemoteAction(
|
||||
hostId: number,
|
||||
title: string,
|
||||
|
||||
Reference in New Issue
Block a user