@ornncompute/cli 1.0.309 → 1.0.310
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/README.md +10 -2
- package/package.json +1 -1
- package/src/admin-capacity-reservations.mjs +51 -0
- package/vendor/capabilities/cli.js +46 -1
package/README.md
CHANGED
|
@@ -184,8 +184,16 @@ customer and takes `--organization-id UUID`, `--listing-id UUID`,
|
|
|
184
184
|
`--listing-term-id UUID`, `--nodes COUNT`, `--starts-at TIME`, `--ends-at TIME`,
|
|
185
185
|
`--price-per-gpu-hour-micro-usd N`, and `--idempotency-key KEY`. The window is
|
|
186
186
|
whole seconds, the term is non-renewable Reserved, and the price is the term's.
|
|
187
|
-
Reuse the key and payload on retries.
|
|
188
|
-
terminal.
|
|
187
|
+
Reuse the key and payload on retries. This booking command requires an eligible
|
|
188
|
+
human terminal.
|
|
189
|
+
|
|
190
|
+
For exact-node delivery off the market, `ornn admin reservations direct-delivery`
|
|
191
|
+
accepts a draft primary listing's Reserved term, every attached
|
|
192
|
+
node UUID, a named organization, and the reservation window. Reuse the supplied
|
|
193
|
+
transaction UUID with the same inputs on retries. Use `--format json` for
|
|
194
|
+
automation. See the [staff command reference](../../docs/cli.md#staff-namespace).
|
|
195
|
+
|
|
196
|
+
Native capacity creation takes
|
|
189
197
|
`--gpu-slug`, `--gpus-per-node`, `--facility-id`, `--provisioning-type`,
|
|
190
198
|
`--state`, `--terms` (a JSON array) and `--idempotency-key`, plus optional
|
|
191
199
|
`--organization-id`. CPU capacity takes `--gpu-slug cpu` and
|
package/package.json
CHANGED
|
@@ -130,6 +130,27 @@ function parseReservationCreate(argv) {
|
|
|
130
130
|
};
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
+
function parseDirectDelivery(argv, capability) {
|
|
134
|
+
const { $positionals, ...input } = parseSemanticArguments(argv);
|
|
135
|
+
const usage = `Usage: ${capability.cli.vnext.human}`;
|
|
136
|
+
if ($positionals.length) throw new AdminMutationError(usage);
|
|
137
|
+
if (input.nodeIds !== undefined) {
|
|
138
|
+
try {
|
|
139
|
+
input.nodeIds = JSON.parse(input.nodeIds);
|
|
140
|
+
} catch {
|
|
141
|
+
throw new AdminMutationError("--node-ids must be a JSON array of node UUIDs.", {
|
|
142
|
+
field: "node-ids",
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
const parsed = capability.input.safeParse(input);
|
|
147
|
+
if (!parsed.success) {
|
|
148
|
+
const issue = parsed.error.issues[0];
|
|
149
|
+
throw new AdminMutationError(`${usage}\n${issue.message}`, { field: issue.path[0] });
|
|
150
|
+
}
|
|
151
|
+
return { input: parsed.data };
|
|
152
|
+
}
|
|
153
|
+
|
|
133
154
|
function capacityOfferReview(body, editing) {
|
|
134
155
|
return {
|
|
135
156
|
title: editing ? "Edit listing term" : "Create capacity offer",
|
|
@@ -188,6 +209,30 @@ async function runReservationCreate({ execute, input, mutation, runtime }) {
|
|
|
188
209
|
});
|
|
189
210
|
}
|
|
190
211
|
|
|
212
|
+
async function runDirectDelivery({ execute, input, runtime }) {
|
|
213
|
+
return runAdminMutation({
|
|
214
|
+
...runtime,
|
|
215
|
+
safety: ADMIN_MUTATION_SAFETY.direct,
|
|
216
|
+
prepare: async () => ({
|
|
217
|
+
value: input,
|
|
218
|
+
review: {
|
|
219
|
+
title: "Reserve nodes for customer",
|
|
220
|
+
fields: [
|
|
221
|
+
{ label: "Customer organization", value: input.organizationId },
|
|
222
|
+
{ label: "Listing term", value: input.listingTermId },
|
|
223
|
+
{ label: "Node IDs", value: input.nodeIds },
|
|
224
|
+
{ label: "Starts at", value: input.startsAt },
|
|
225
|
+
{ label: "Ends at", value: input.endsAt },
|
|
226
|
+
{ label: "Transaction ID", value: input.transactionId },
|
|
227
|
+
...(input.vmDiskId ? [{ label: "VM disk", value: input.vmDiskId }] : []),
|
|
228
|
+
],
|
|
229
|
+
consequence: "Creates the reservation at the draft listing's saved terms.",
|
|
230
|
+
},
|
|
231
|
+
}),
|
|
232
|
+
execute: (value) => execute(value, { confirmed: true }),
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
|
|
191
236
|
export const adminCapacityReservationHandlers = [
|
|
192
237
|
{
|
|
193
238
|
capabilityId: "listing.create",
|
|
@@ -207,4 +252,10 @@ export const adminCapacityReservationHandlers = [
|
|
|
207
252
|
run: runReservationCreate,
|
|
208
253
|
safety: ADMIN_MUTATION_SAFETY.eligibleHumanOnly,
|
|
209
254
|
},
|
|
255
|
+
{
|
|
256
|
+
capabilityId: "reservations.direct-delivery",
|
|
257
|
+
parse: parseDirectDelivery,
|
|
258
|
+
run: runDirectDelivery,
|
|
259
|
+
safety: ADMIN_MUTATION_SAFETY.direct,
|
|
260
|
+
},
|
|
210
261
|
];
|
|
@@ -1321,6 +1321,9 @@ function listReservationInvoices(request, id, signal) {
|
|
|
1321
1321
|
...signal ? { signal } : {}
|
|
1322
1322
|
});
|
|
1323
1323
|
}
|
|
1324
|
+
function createReservation(request, input) {
|
|
1325
|
+
return request(BASE2, { method: "POST", body: input });
|
|
1326
|
+
}
|
|
1324
1327
|
|
|
1325
1328
|
// ../../packages/api-client/dist/commerce/query.js
|
|
1326
1329
|
function queryString4(input) {
|
|
@@ -2648,9 +2651,51 @@ var adminReservationsCreateCapability = defineCapability({
|
|
|
2648
2651
|
return placeBookings(ctx.fetch, body2, resolveIdempotencyKey(ctx, idempotencyKey));
|
|
2649
2652
|
}
|
|
2650
2653
|
});
|
|
2654
|
+
var directDeliveryInput = z11.strictObject({
|
|
2655
|
+
organizationId: z11.uuid().describe("The customer organization receiving the reservation."),
|
|
2656
|
+
listingTermId: z11.uuid().describe("A non-renewable Reserved term on the draft primary listing."),
|
|
2657
|
+
nodeIds: z11.array(z11.uuid()).min(1).max(5e3).describe("Every attached node ID on the draft."),
|
|
2658
|
+
startsAt: wholeSecondInstant.describe("RFC 3339 start in whole seconds, with a timezone."),
|
|
2659
|
+
endsAt: wholeSecondInstant.describe("RFC 3339 end in whole seconds, within the term's duration."),
|
|
2660
|
+
transactionId: z11.uuid().describe("A caller-generated UUID. Reuse it on retry with the same input."),
|
|
2661
|
+
vmDiskId: z11.uuid().optional().describe("Optional boot disk for a VM reservation.")
|
|
2662
|
+
}).refine((input) => new Set(input.nodeIds.map((id) => id.toLowerCase())).size === input.nodeIds.length, {
|
|
2663
|
+
path: ["nodeIds"],
|
|
2664
|
+
message: "Provide distinct node IDs."
|
|
2665
|
+
}).refine((input) => Date.parse(input.endsAt) - Date.parse(input.startsAt) >= 36e5, {
|
|
2666
|
+
path: ["endsAt"],
|
|
2667
|
+
message: "Choose an end at least an hour after the start."
|
|
2668
|
+
});
|
|
2669
|
+
var directDeliveryCapabilityId = "reservations.direct-delivery";
|
|
2670
|
+
var adminReservationDirectDeliveryCapability = defineCapability({
|
|
2671
|
+
id: directDeliveryCapabilityId,
|
|
2672
|
+
domain: "reservations",
|
|
2673
|
+
roles: ["admin"],
|
|
2674
|
+
description: "Reserve exact nodes for a customer off the market. Use a draft primary VM or Bare Metal listing with every selected node attached and a non-renewable Reserved term. Creates the reservation immediately, even with a future start. Reuse the transactionId and inputs after an uncertain response. Returns the saved reservation.",
|
|
2675
|
+
mutation: "preview-confirm",
|
|
2676
|
+
cli: {
|
|
2677
|
+
command: ["admin", "reservations", "direct-delivery"],
|
|
2678
|
+
vnext: adminHelp("Reserve exact nodes for a customer off the market.", "ornn admin reservations direct-delivery --organization-id UUID --listing-term-id UUID --node-ids JSON --starts-at TIME --ends-at TIME --transaction-id UUID [--vm-disk-id UUID]", "Use --format json. Supply all node UUIDs as a JSON array and reuse --transaction-id with the same inputs when retrying.")
|
|
2679
|
+
},
|
|
2680
|
+
slack: false,
|
|
2681
|
+
input: directDeliveryInput,
|
|
2682
|
+
execute: async (ctx, input) => {
|
|
2683
|
+
const { organizationId, nodeIds: nodeIds2, ...fields } = directDeliveryInput.parse(input);
|
|
2684
|
+
const body2 = {
|
|
2685
|
+
...fields,
|
|
2686
|
+
customerId: organizationId,
|
|
2687
|
+
nodes: nodeIds2.map((nodeId3) => ({ nodeId: nodeId3 })),
|
|
2688
|
+
directDelivery: true
|
|
2689
|
+
};
|
|
2690
|
+
if (!ctx.confirmed)
|
|
2691
|
+
return preview(directDeliveryCapabilityId, body2);
|
|
2692
|
+
return createReservation(ctx.fetch, body2);
|
|
2693
|
+
}
|
|
2694
|
+
});
|
|
2651
2695
|
var adminCapacityReservationCapabilities = [
|
|
2652
2696
|
adminCapacityOffersCreateCapability,
|
|
2653
|
-
adminReservationsCreateCapability
|
|
2697
|
+
adminReservationsCreateCapability,
|
|
2698
|
+
adminReservationDirectDeliveryCapability
|
|
2654
2699
|
];
|
|
2655
2700
|
|
|
2656
2701
|
// ../../packages/capabilities/dist/capabilities/commerce-market.js
|