vmsan 0.1.0-alpha.13 → 0.1.0-alpha.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_chunks/connect.mjs +55 -11
- package/dist/_chunks/context.mjs +2397 -0
- package/dist/_chunks/create.mjs +54 -193
- package/dist/_chunks/download.mjs +5 -20
- package/dist/_chunks/errors.mjs +10 -4
- package/dist/_chunks/list.mjs +59 -55
- package/dist/_chunks/network.mjs +5 -6
- package/dist/_chunks/remove.mjs +8 -9
- package/dist/_chunks/start.mjs +15 -165
- package/dist/_chunks/stop.mjs +7 -8
- package/dist/_chunks/summary.mjs +69 -0
- package/dist/_chunks/upload.mjs +5 -20
- package/dist/_chunks/validation.mjs +1 -1
- package/dist/_chunks/vm-context.mjs +34 -0
- package/dist/_chunks/vm-state.mjs +56 -26
- package/dist/bin/cli.mjs +2 -2
- package/dist/index.d.mts +568 -365
- package/dist/index.mjs +89 -9
- package/package.json +6 -5
- package/dist/_chunks/cleanup.mjs +0 -334
- package/dist/_chunks/connect2.mjs +0 -72
- package/dist/_chunks/environment.mjs +0 -1144
- package/dist/_chunks/file-lock.mjs +0 -67
- package/dist/_chunks/image-rootfs.mjs +0 -331
- package/dist/_chunks/vm.mjs +0 -146
package/dist/_chunks/connect.mjs
CHANGED
|
@@ -1,13 +1,57 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { n as vmsanPaths } from "./paths.mjs";
|
|
2
|
+
import { t as handleCommandError } from "./errors.mjs";
|
|
3
|
+
import { t as createCommandLogger } from "./logger.mjs";
|
|
4
|
+
import "./vm-state.mjs";
|
|
5
|
+
import { n as waitForAgent, t as resolveVmState } from "./vm-context.mjs";
|
|
6
|
+
import { t as ShellSession } from "./shell.mjs";
|
|
7
|
+
import { consola } from "consola";
|
|
8
|
+
import { defineCommand } from "citty";
|
|
9
|
+
const connectCommand = defineCommand({
|
|
10
|
+
meta: {
|
|
11
|
+
name: "connect",
|
|
12
|
+
description: "Connect to a running VM"
|
|
13
|
+
},
|
|
14
|
+
args: {
|
|
15
|
+
vmId: {
|
|
16
|
+
type: "positional",
|
|
17
|
+
description: "VM ID to connect to",
|
|
18
|
+
required: true
|
|
19
|
+
},
|
|
20
|
+
session: {
|
|
21
|
+
type: "string",
|
|
22
|
+
alias: "s",
|
|
23
|
+
description: "Attach to an existing shell session ID",
|
|
24
|
+
required: false
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
async run({ args }) {
|
|
28
|
+
const cmdLog = createCommandLogger("connect");
|
|
29
|
+
const paths = vmsanPaths();
|
|
6
30
|
try {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
31
|
+
const { state, guestIp, port } = resolveVmState(args.vmId, paths);
|
|
32
|
+
const log = consola.withTag(args.vmId);
|
|
33
|
+
consola.debug(`Agent endpoint: ${guestIp}:${port}`);
|
|
34
|
+
log.start("Waiting for agent to become ready...");
|
|
35
|
+
await waitForAgent(guestIp, port);
|
|
36
|
+
log.success("Agent is ready. Connecting via PTY shell...");
|
|
37
|
+
const shell = new ShellSession({
|
|
38
|
+
host: guestIp,
|
|
39
|
+
port,
|
|
40
|
+
token: state.agentToken,
|
|
41
|
+
sessionId: args.session
|
|
42
|
+
});
|
|
43
|
+
const closeInfo = await shell.connect();
|
|
44
|
+
cmdLog.set({
|
|
45
|
+
vmId: args.vmId,
|
|
46
|
+
method: "pty"
|
|
47
|
+
});
|
|
48
|
+
cmdLog.emit();
|
|
49
|
+
if (!closeInfo.sessionDestroyed && shell.sessionId) process.stderr.write(`\n[2mResume this session with:\n vmsan connect ${args.vmId} --session ${shell.sessionId}[0m\n`);
|
|
50
|
+
process.exit(0);
|
|
51
|
+
} catch (error) {
|
|
52
|
+
handleCommandError(error, cmdLog);
|
|
53
|
+
process.exit(1);
|
|
54
|
+
}
|
|
10
55
|
}
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
export { waitForAgent as t };
|
|
56
|
+
});
|
|
57
|
+
export { connectCommand as default };
|