@ornncompute/cli 1.0.140 → 1.0.142
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/package.json +1 -1
- package/src/vm-commands.mjs +35 -46
- package/vendor/capabilities/cli.js +490 -460
package/package.json
CHANGED
package/src/vm-commands.mjs
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
import {
|
|
2
|
+
sshKeyListCapability,
|
|
3
|
+
sshKeyAddCapability,
|
|
4
|
+
sshKeyDeleteCapability,
|
|
5
|
+
sshKeyAssignmentStatusCapability,
|
|
6
|
+
sshKeyDeliveryStatus,
|
|
7
|
+
} from "../vendor/capabilities/cli.js";
|
|
1
8
|
import * as orchestrator from "../vendor/api-client/orchestrator.js";
|
|
2
9
|
import * as gatewayApi from "../vendor/api-client/gateway.js";
|
|
3
10
|
import { getReservation } from "../vendor/api-client/commerce.js";
|
|
@@ -529,7 +536,7 @@ async function fetchOrganizationKeys(context) {
|
|
|
529
536
|
const seen = new Set();
|
|
530
537
|
let cursor = null;
|
|
531
538
|
do {
|
|
532
|
-
const page = await
|
|
539
|
+
const page = await sshKeyListCapability.execute(context, {
|
|
533
540
|
status: "active",
|
|
534
541
|
limit: 500,
|
|
535
542
|
...(cursor ? { cursor } : {}),
|
|
@@ -664,11 +671,11 @@ export async function materializeKey(context, plan, interaction, idempotencyKey)
|
|
|
664
671
|
const replay = keys.find((key) => text(key.public_key) === publicKey);
|
|
665
672
|
if (replay) return replay;
|
|
666
673
|
const created = record(
|
|
667
|
-
await
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
)
|
|
674
|
+
await sshKeyAddCapability.execute(context, {
|
|
675
|
+
publicKey,
|
|
676
|
+
label: text(plan.key.label),
|
|
677
|
+
idempotencyKey,
|
|
678
|
+
})
|
|
672
679
|
);
|
|
673
680
|
if (!resourceId(created) || text(created.public_key) !== publicKey) {
|
|
674
681
|
interaction.error("The saved SSH key did not match the reviewed public key.", {
|
|
@@ -731,41 +738,22 @@ function virtualMachineForNode(payload, node, interaction) {
|
|
|
731
738
|
return matches[0] ?? null;
|
|
732
739
|
}
|
|
733
740
|
|
|
734
|
-
function keyDeliveryForMachine(key, machine) {
|
|
735
|
-
const keyId = resourceId(key);
|
|
736
|
-
const metadata = Array.isArray(machine.authorized_key_metadata)
|
|
737
|
-
? machine.authorized_key_metadata
|
|
738
|
-
.map(record)
|
|
739
|
-
.find(
|
|
740
|
-
(item) =>
|
|
741
|
-
text(item.ssh_key_id) === keyId || text(item.fingerprint) === text(key.fingerprint)
|
|
742
|
-
)
|
|
743
|
-
: null;
|
|
744
|
-
const fingerprints = Array.isArray(machine.authorized_key_fingerprints)
|
|
745
|
-
? machine.authorized_key_fingerprints
|
|
746
|
-
: [];
|
|
747
|
-
const installed =
|
|
748
|
-
text(key.fingerprint) && fingerprints.includes(text(key.fingerprint)) && machine.keys_pushed_at;
|
|
749
|
-
return {
|
|
750
|
-
machine_id: machineId(machine),
|
|
751
|
-
hostname: machineHostname(machine) || null,
|
|
752
|
-
machine_state: machineState(machine),
|
|
753
|
-
status: text(metadata?.status) ?? (installed ? "installed" : "associated"),
|
|
754
|
-
queued_at: text(metadata?.queued_at),
|
|
755
|
-
pushed_at: text(metadata?.pushed_at) ?? (installed ? text(machine.keys_pushed_at) : null),
|
|
756
|
-
failed_at: text(metadata?.failed_at),
|
|
757
|
-
failure_reason: text(metadata?.failure_reason),
|
|
758
|
-
request_id: text(metadata?.request_id),
|
|
759
|
-
};
|
|
760
|
-
}
|
|
761
|
-
|
|
762
741
|
function assignmentStatus(reservationId, keys, machines) {
|
|
763
742
|
return {
|
|
764
743
|
reservation_id: reservationId,
|
|
765
744
|
machine_count: machines.length,
|
|
766
745
|
keys: keys.map((key) => ({
|
|
767
746
|
...projectKey(key),
|
|
768
|
-
machines: machines.map((machine) =>
|
|
747
|
+
machines: machines.map((machine) => {
|
|
748
|
+
const { linux_username: _username, ...delivery } = sshKeyDeliveryStatus(key, machine);
|
|
749
|
+
return {
|
|
750
|
+
machine_id: machine.node_id,
|
|
751
|
+
hostname: machine.hostname || null,
|
|
752
|
+
machine_state: machine.status,
|
|
753
|
+
queued_at: null,
|
|
754
|
+
...delivery,
|
|
755
|
+
};
|
|
756
|
+
}),
|
|
769
757
|
})),
|
|
770
758
|
};
|
|
771
759
|
}
|
|
@@ -4317,7 +4305,7 @@ export async function executeSshKeyCommand(command, input, context, interaction)
|
|
|
4317
4305
|
if (command === "list") {
|
|
4318
4306
|
positional(input, 0, "ornn ssh-keys list [--limit <1-500>] [--cursor <cursor>]", interaction);
|
|
4319
4307
|
const limit = input.limit ?? 50;
|
|
4320
|
-
const payload = await
|
|
4308
|
+
const payload = await sshKeyListCapability.execute(context, {
|
|
4321
4309
|
status: "active",
|
|
4322
4310
|
limit,
|
|
4323
4311
|
...(text(input.cursor) ? { cursor: input.cursor } : {}),
|
|
@@ -4411,8 +4399,9 @@ export async function executeSshKeyCommand(command, input, context, interaction)
|
|
|
4411
4399
|
presentation: { lines: ["SSH-key deletion declined."] },
|
|
4412
4400
|
});
|
|
4413
4401
|
}
|
|
4414
|
-
await
|
|
4415
|
-
|
|
4402
|
+
await sshKeyDeleteCapability.execute(context, {
|
|
4403
|
+
keyId: resourceId(key),
|
|
4404
|
+
idempotencyKey: text(input.idempotencyKey) ?? interaction.idempotencyKey(),
|
|
4416
4405
|
});
|
|
4417
4406
|
return interaction.result({
|
|
4418
4407
|
data: { ssh_key: projectKey(key) },
|
|
@@ -4435,10 +4424,10 @@ export async function executeSshKeyCommand(command, input, context, interaction)
|
|
|
4435
4424
|
}
|
|
4436
4425
|
|
|
4437
4426
|
if (command === "assignments.status") {
|
|
4438
|
-
const
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
|
|
4427
|
+
const { keys, nodes: machines } = await sshKeyAssignmentStatusCapability.execute(
|
|
4428
|
+
{ actor: "", role: "user", fetch: context.fetch },
|
|
4429
|
+
{ reservationId }
|
|
4430
|
+
);
|
|
4442
4431
|
keys.sort((left, right) => String(resourceId(left)).localeCompare(String(resourceId(right))));
|
|
4443
4432
|
const page = cursorPage(keys, input, interaction);
|
|
4444
4433
|
const status = assignmentStatus(reservationId, page.items, machines);
|
|
@@ -4503,10 +4492,10 @@ export async function executeSshKeyCommand(command, input, context, interaction)
|
|
|
4503
4492
|
}
|
|
4504
4493
|
|
|
4505
4494
|
if (command === "assignments.sync") {
|
|
4506
|
-
const
|
|
4507
|
-
|
|
4508
|
-
|
|
4509
|
-
|
|
4495
|
+
const { keys, nodes: machines } = await sshKeyAssignmentStatusCapability.execute(
|
|
4496
|
+
{ actor: "", role: "user", fetch: context.fetch },
|
|
4497
|
+
{ reservationId }
|
|
4498
|
+
);
|
|
4510
4499
|
if (!keys.length) {
|
|
4511
4500
|
interaction.error("No SSH keys are assigned to this capacity reservation.", {
|
|
4512
4501
|
code: "ssh_key_assignment_missing",
|