@opscompass/opscompass-cli 1.3.5 → 1.3.7
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/lib/cliHelpers.js +10 -6
- package/lib/dataGathering/sendDg.js +171 -1
- package/lib/homeInteraction.js +276 -68
- package/lib/utils.js +22 -0
- package/modules/data-gathering-scripts.js +191 -54
- package/modules/data-gathering.js +45 -1
- package/modules/license-manager/microsoft.js +31 -5
- package/modules/license-manager/oracle.js +513 -0
- package/modules/license-manager.js +57 -6
- package/package.json +7 -6
|
@@ -0,0 +1,513 @@
|
|
|
1
|
+
import { getOpsCompassClient } from "../../opscompass.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Guard that the next argument in args at i+1 is present and not another flag.
|
|
5
|
+
* If invalid, prints an error to stderr and returns false.
|
|
6
|
+
* @param {string[]} args - CLI arguments array
|
|
7
|
+
* @param {number} i - Current index in args
|
|
8
|
+
* @param {string} flagName - Flag name for error messages (without -- prefix)
|
|
9
|
+
* @returns {boolean} true if the next argument is a valid value
|
|
10
|
+
*/
|
|
11
|
+
function requireArgValue(args, i, flagName) {
|
|
12
|
+
if (i + 1 >= args.length || args[i + 1] === undefined) {
|
|
13
|
+
console.error(`ERROR: --${flagName} requires a value.`);
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
if (args[i + 1].startsWith("--")) {
|
|
17
|
+
console.error(`ERROR: --${flagName} requires a value (got "${args[i + 1]}").`);
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Validate that raw string value is a positive integer.
|
|
25
|
+
* Prints an error to stderr on failure.
|
|
26
|
+
* @param {string} value - Raw string value to validate
|
|
27
|
+
* @param {string} flagName - Flag name for error messages
|
|
28
|
+
* @returns {number|undefined} The parsed positive integer, or undefined on error
|
|
29
|
+
*/
|
|
30
|
+
function validatePositiveIntFlag(value, flagName) {
|
|
31
|
+
const n = Number(value);
|
|
32
|
+
if (isNaN(n) || n < 1 || !Number.isSafeInteger(n)) {
|
|
33
|
+
console.error(`ERROR: --${flagName} must be a positive integer (got "${value}").`);
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
return n;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Validate that raw string value is a non-negative integer (0 or greater).
|
|
41
|
+
* Prints an error to stderr on failure.
|
|
42
|
+
* @param {string} value - Raw string value to validate
|
|
43
|
+
* @param {string} flagName - Flag name for error messages
|
|
44
|
+
* @returns {number|undefined} The parsed non-negative integer, or undefined on error
|
|
45
|
+
*/
|
|
46
|
+
function validateNonNegativeIntFlag(value, flagName) {
|
|
47
|
+
const n = Number(value);
|
|
48
|
+
if (isNaN(n) || n < 0 || !Number.isSafeInteger(n)) {
|
|
49
|
+
console.error(`ERROR: --${flagName} must be a non-negative integer (got "${value}").`);
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
return n;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Client-side maximum pagination values for Oracle entitlement commands.
|
|
57
|
+
* These match the public API contract enforced by the service, allowing the CLI
|
|
58
|
+
* to reject obviously invalid requests before sending them.
|
|
59
|
+
*/
|
|
60
|
+
const MAX_PAGINATION_LIMIT = 1000;
|
|
61
|
+
const MAX_PAGINATION_OFFSET = 10000;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* @module license-manager:oracle
|
|
65
|
+
* @description License Manager Oracle entitlement read-only module for OpsCompass CLI
|
|
66
|
+
*/
|
|
67
|
+
|
|
68
|
+
async function getOracleCurrentEntitlements(args) {
|
|
69
|
+
let companySlug = global.company;
|
|
70
|
+
let accountId = undefined;
|
|
71
|
+
let limit = undefined;
|
|
72
|
+
let offset = undefined;
|
|
73
|
+
for (let i = 0; i < args.length - 1; i++) {
|
|
74
|
+
switch (args[i].toLowerCase()) {
|
|
75
|
+
case "--company":
|
|
76
|
+
if (!requireArgValue(args, i, "company")) return;
|
|
77
|
+
companySlug = args[++i];
|
|
78
|
+
break;
|
|
79
|
+
case "--account-id":
|
|
80
|
+
case "--accountid":
|
|
81
|
+
if (!requireArgValue(args, i, "account-id")) return;
|
|
82
|
+
accountId = args[++i];
|
|
83
|
+
break;
|
|
84
|
+
case "--limit":
|
|
85
|
+
if (!requireArgValue(args, i, "limit")) return;
|
|
86
|
+
limit = args[++i];
|
|
87
|
+
break;
|
|
88
|
+
case "--offset":
|
|
89
|
+
if (!requireArgValue(args, i, "offset")) return;
|
|
90
|
+
offset = args[++i];
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (accountId === undefined || accountId === null) {
|
|
96
|
+
accountId = global.account;
|
|
97
|
+
}
|
|
98
|
+
if (accountId === undefined || accountId === null) {
|
|
99
|
+
console.error("ERROR: --account is required (or set a default account).");
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const parsedAccountId = String(accountId).trim();
|
|
104
|
+
if (parsedAccountId === "") {
|
|
105
|
+
console.error("ERROR: --account is required (or set a default account).");
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const options = {};
|
|
110
|
+
if (limit !== undefined) {
|
|
111
|
+
const n = validatePositiveIntFlag(limit, "limit");
|
|
112
|
+
if (n === undefined) return;
|
|
113
|
+
if (n > MAX_PAGINATION_LIMIT) {
|
|
114
|
+
console.error(`ERROR: --limit must not exceed ${MAX_PAGINATION_LIMIT} (got ${n}).`);
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
options.limit = n;
|
|
118
|
+
}
|
|
119
|
+
if (offset !== undefined) {
|
|
120
|
+
const n = validateNonNegativeIntFlag(offset, "offset");
|
|
121
|
+
if (n === undefined) return;
|
|
122
|
+
if (n > MAX_PAGINATION_OFFSET) {
|
|
123
|
+
console.error(`ERROR: --offset must not exceed ${MAX_PAGINATION_OFFSET} (got ${n}).`);
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
options.offset = n;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const client = await getOpsCompassClient();
|
|
130
|
+
const result = await client.licenseManager.getOracleCurrentEntitlements(
|
|
131
|
+
companySlug,
|
|
132
|
+
parsedAccountId,
|
|
133
|
+
Object.keys(options).length > 0 ? options : undefined,
|
|
134
|
+
);
|
|
135
|
+
console.log(JSON.stringify(result, null, 2));
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
async function listOracleMetrics(args) {
|
|
139
|
+
let companySlug = global.company;
|
|
140
|
+
let limit = undefined;
|
|
141
|
+
let offset = undefined;
|
|
142
|
+
for (let i = 0; i < args.length - 1; i++) {
|
|
143
|
+
switch (args[i].toLowerCase()) {
|
|
144
|
+
case "--company":
|
|
145
|
+
if (!requireArgValue(args, i, "company")) return;
|
|
146
|
+
companySlug = args[++i];
|
|
147
|
+
break;
|
|
148
|
+
case "--limit":
|
|
149
|
+
if (!requireArgValue(args, i, "limit")) return;
|
|
150
|
+
limit = args[++i];
|
|
151
|
+
break;
|
|
152
|
+
case "--offset":
|
|
153
|
+
if (!requireArgValue(args, i, "offset")) return;
|
|
154
|
+
offset = args[++i];
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const options = {};
|
|
160
|
+
if (limit !== undefined) {
|
|
161
|
+
const n = validatePositiveIntFlag(limit, "limit");
|
|
162
|
+
if (n === undefined) return;
|
|
163
|
+
if (n > MAX_PAGINATION_LIMIT) {
|
|
164
|
+
console.error(`ERROR: --limit must not exceed ${MAX_PAGINATION_LIMIT} (got ${n}).`);
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
options.limit = n;
|
|
168
|
+
}
|
|
169
|
+
if (offset !== undefined) {
|
|
170
|
+
const n = validateNonNegativeIntFlag(offset, "offset");
|
|
171
|
+
if (n === undefined) return;
|
|
172
|
+
if (n > MAX_PAGINATION_OFFSET) {
|
|
173
|
+
console.error(`ERROR: --offset must not exceed ${MAX_PAGINATION_OFFSET} (got ${n}).`);
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
options.offset = n;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const client = await getOpsCompassClient();
|
|
180
|
+
const result = await client.licenseManager.listOracleMetrics(
|
|
181
|
+
companySlug,
|
|
182
|
+
Object.keys(options).length > 0 ? options : undefined,
|
|
183
|
+
);
|
|
184
|
+
console.log(JSON.stringify(result, null, 2));
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
async function listOracleLimitations(args) {
|
|
188
|
+
let companySlug = global.company;
|
|
189
|
+
let limit = undefined;
|
|
190
|
+
let offset = undefined;
|
|
191
|
+
for (let i = 0; i < args.length - 1; i++) {
|
|
192
|
+
switch (args[i].toLowerCase()) {
|
|
193
|
+
case "--company":
|
|
194
|
+
if (!requireArgValue(args, i, "company")) return;
|
|
195
|
+
companySlug = args[++i];
|
|
196
|
+
break;
|
|
197
|
+
case "--limit":
|
|
198
|
+
if (!requireArgValue(args, i, "limit")) return;
|
|
199
|
+
limit = args[++i];
|
|
200
|
+
break;
|
|
201
|
+
case "--offset":
|
|
202
|
+
if (!requireArgValue(args, i, "offset")) return;
|
|
203
|
+
offset = args[++i];
|
|
204
|
+
break;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
const options = {};
|
|
209
|
+
if (limit !== undefined) {
|
|
210
|
+
const n = validatePositiveIntFlag(limit, "limit");
|
|
211
|
+
if (n === undefined) return;
|
|
212
|
+
if (n > MAX_PAGINATION_LIMIT) {
|
|
213
|
+
console.error(`ERROR: --limit must not exceed ${MAX_PAGINATION_LIMIT} (got ${n}).`);
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
options.limit = n;
|
|
217
|
+
}
|
|
218
|
+
if (offset !== undefined) {
|
|
219
|
+
const n = validateNonNegativeIntFlag(offset, "offset");
|
|
220
|
+
if (n === undefined) return;
|
|
221
|
+
if (n > MAX_PAGINATION_OFFSET) {
|
|
222
|
+
console.error(`ERROR: --offset must not exceed ${MAX_PAGINATION_OFFSET} (got ${n}).`);
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
options.offset = n;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
const client = await getOpsCompassClient();
|
|
229
|
+
const result = await client.licenseManager.listOracleLimitations(
|
|
230
|
+
companySlug,
|
|
231
|
+
Object.keys(options).length > 0 ? options : undefined,
|
|
232
|
+
);
|
|
233
|
+
console.log(JSON.stringify(result, null, 2));
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
async function listOracleProductAliases(args) {
|
|
237
|
+
let companySlug = global.company;
|
|
238
|
+
let limit = undefined;
|
|
239
|
+
let offset = undefined;
|
|
240
|
+
for (let i = 0; i < args.length - 1; i++) {
|
|
241
|
+
switch (args[i].toLowerCase()) {
|
|
242
|
+
case "--company":
|
|
243
|
+
if (!requireArgValue(args, i, "company")) return;
|
|
244
|
+
companySlug = args[++i];
|
|
245
|
+
break;
|
|
246
|
+
case "--limit":
|
|
247
|
+
if (!requireArgValue(args, i, "limit")) return;
|
|
248
|
+
limit = args[++i];
|
|
249
|
+
break;
|
|
250
|
+
case "--offset":
|
|
251
|
+
if (!requireArgValue(args, i, "offset")) return;
|
|
252
|
+
offset = args[++i];
|
|
253
|
+
break;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
const options = {};
|
|
258
|
+
if (limit !== undefined) {
|
|
259
|
+
const n = validatePositiveIntFlag(limit, "limit");
|
|
260
|
+
if (n === undefined) return;
|
|
261
|
+
if (n > MAX_PAGINATION_LIMIT) {
|
|
262
|
+
console.error(`ERROR: --limit must not exceed ${MAX_PAGINATION_LIMIT} (got ${n}).`);
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
options.limit = n;
|
|
266
|
+
}
|
|
267
|
+
if (offset !== undefined) {
|
|
268
|
+
const n = validateNonNegativeIntFlag(offset, "offset");
|
|
269
|
+
if (n === undefined) return;
|
|
270
|
+
if (n > MAX_PAGINATION_OFFSET) {
|
|
271
|
+
console.error(`ERROR: --offset must not exceed ${MAX_PAGINATION_OFFSET} (got ${n}).`);
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
options.offset = n;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
const client = await getOpsCompassClient();
|
|
278
|
+
const result = await client.licenseManager.listOracleProductAliases(
|
|
279
|
+
companySlug,
|
|
280
|
+
Object.keys(options).length > 0 ? options : undefined,
|
|
281
|
+
);
|
|
282
|
+
console.log(JSON.stringify(result, null, 2));
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
async function listOracleOrders(args) {
|
|
286
|
+
let companySlug = global.company;
|
|
287
|
+
let accountId = undefined;
|
|
288
|
+
let limit = undefined;
|
|
289
|
+
let offset = undefined;
|
|
290
|
+
for (let i = 0; i < args.length - 1; i++) {
|
|
291
|
+
switch (args[i].toLowerCase()) {
|
|
292
|
+
case "--company":
|
|
293
|
+
if (!requireArgValue(args, i, "company")) return;
|
|
294
|
+
companySlug = args[++i];
|
|
295
|
+
break;
|
|
296
|
+
case "--account-id":
|
|
297
|
+
case "--accountid":
|
|
298
|
+
if (
|
|
299
|
+
args[i + 1] === undefined ||
|
|
300
|
+
args[i + 1].startsWith("--")
|
|
301
|
+
) {
|
|
302
|
+
console.error("ERROR: --account is required (or set a default account).");
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
accountId = args[++i];
|
|
306
|
+
break;
|
|
307
|
+
case "--limit":
|
|
308
|
+
if (!requireArgValue(args, i, "limit")) return;
|
|
309
|
+
limit = args[++i];
|
|
310
|
+
break;
|
|
311
|
+
case "--offset":
|
|
312
|
+
if (!requireArgValue(args, i, "offset")) return;
|
|
313
|
+
offset = args[++i];
|
|
314
|
+
break;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
const trailingArg = args.at(-1)?.toLowerCase();
|
|
319
|
+
if (
|
|
320
|
+
accountId === undefined &&
|
|
321
|
+
(trailingArg === "--account-id" || trailingArg === "--accountid")
|
|
322
|
+
) {
|
|
323
|
+
console.error("ERROR: --account is required (or set a default account).");
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
if (accountId === undefined || accountId === null) {
|
|
327
|
+
accountId = global.account;
|
|
328
|
+
}
|
|
329
|
+
if (accountId === undefined || accountId === null) {
|
|
330
|
+
console.error("ERROR: --account is required (or set a default account).");
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
const normalizedAccountId = String(accountId).trim();
|
|
335
|
+
if (normalizedAccountId === "") {
|
|
336
|
+
console.error("ERROR: --account is required (or set a default account).");
|
|
337
|
+
return;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
const options = {};
|
|
341
|
+
if (limit !== undefined) {
|
|
342
|
+
const n = validatePositiveIntFlag(limit, "limit");
|
|
343
|
+
if (n === undefined) return;
|
|
344
|
+
if (n > MAX_PAGINATION_LIMIT) {
|
|
345
|
+
console.error(`ERROR: --limit must not exceed ${MAX_PAGINATION_LIMIT} (got ${n}).`);
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
options.limit = n;
|
|
349
|
+
}
|
|
350
|
+
if (offset !== undefined) {
|
|
351
|
+
const n = validateNonNegativeIntFlag(offset, "offset");
|
|
352
|
+
if (n === undefined) return;
|
|
353
|
+
if (n > MAX_PAGINATION_OFFSET) {
|
|
354
|
+
console.error(`ERROR: --offset must not exceed ${MAX_PAGINATION_OFFSET} (got ${n}).`);
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
options.offset = n;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
const client = await getOpsCompassClient();
|
|
361
|
+
const result = await client.licenseManager.listOracleOrders(
|
|
362
|
+
companySlug,
|
|
363
|
+
normalizedAccountId,
|
|
364
|
+
Object.keys(options).length > 0 ? options : undefined,
|
|
365
|
+
);
|
|
366
|
+
console.log(JSON.stringify(result, null, 2));
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
async function getOracleOrderItems(args) {
|
|
370
|
+
let companySlug = global.company;
|
|
371
|
+
let accountId = undefined;
|
|
372
|
+
const orderItemIds = [];
|
|
373
|
+
for (let i = 0; i < args.length - 1; i++) {
|
|
374
|
+
switch (args[i].toLowerCase()) {
|
|
375
|
+
case "--company":
|
|
376
|
+
if (!requireArgValue(args, i, "company")) return;
|
|
377
|
+
companySlug = args[++i];
|
|
378
|
+
break;
|
|
379
|
+
case "--account-id":
|
|
380
|
+
case "--accountid":
|
|
381
|
+
if (
|
|
382
|
+
args[i + 1] === undefined ||
|
|
383
|
+
args[i + 1].startsWith("--")
|
|
384
|
+
) {
|
|
385
|
+
console.error("ERROR: --account is required (or set a default account).");
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
388
|
+
accountId = args[++i];
|
|
389
|
+
break;
|
|
390
|
+
case "--id":
|
|
391
|
+
if (!requireArgValue(args, i, "id")) return;
|
|
392
|
+
orderItemIds.push(args[++i]);
|
|
393
|
+
break;
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
const trailingArg = args.at(-1)?.toLowerCase();
|
|
398
|
+
if (
|
|
399
|
+
accountId === undefined &&
|
|
400
|
+
(trailingArg === "--account-id" || trailingArg === "--accountid")
|
|
401
|
+
) {
|
|
402
|
+
console.error("ERROR: --account is required (or set a default account).");
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
if (accountId === undefined || accountId === null) {
|
|
406
|
+
accountId = global.account;
|
|
407
|
+
}
|
|
408
|
+
if (accountId === undefined || accountId === null) {
|
|
409
|
+
console.error("ERROR: --account is required (or set a default account).");
|
|
410
|
+
return;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
const normalizedAccountId = String(accountId).trim();
|
|
414
|
+
if (normalizedAccountId === "") {
|
|
415
|
+
console.error("ERROR: --account is required (or set a default account).");
|
|
416
|
+
return;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
if (orderItemIds.length === 0) {
|
|
420
|
+
console.error("ERROR: At least one --id is required.");
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
// Validate each --id value is a positive integer before dispatch
|
|
425
|
+
for (const rawId of orderItemIds) {
|
|
426
|
+
if (validatePositiveIntFlag(rawId, "id") === undefined) return;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
const client = await getOpsCompassClient();
|
|
430
|
+
try {
|
|
431
|
+
const result = await client.licenseManager.getOracleOrderItems(
|
|
432
|
+
companySlug,
|
|
433
|
+
normalizedAccountId,
|
|
434
|
+
orderItemIds.map(Number),
|
|
435
|
+
);
|
|
436
|
+
console.log(JSON.stringify(result, null, 2));
|
|
437
|
+
} catch (err) {
|
|
438
|
+
console.error("ERROR:", err.message);
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
async function printOracleHelp() {
|
|
443
|
+
console.log();
|
|
444
|
+
console.log(
|
|
445
|
+
"get-oracle-current-entitlements",
|
|
446
|
+
"Gets current Oracle entitlements for the specified account.",
|
|
447
|
+
);
|
|
448
|
+
console.log("Parameters:");
|
|
449
|
+
console.log("--company [company_slug] (optional, defaults to current company)");
|
|
450
|
+
console.log("--account [account-id-or-cloudSubscriptionId] (optional, defaults to current account) The account ID or cloudSubscriptionId to retrieve entitlements for.");
|
|
451
|
+
console.log(`--limit [number] (optional) Maximum number of results to return (max ${MAX_PAGINATION_LIMIT}), e.g. --limit 50.`);
|
|
452
|
+
console.log(`--offset [number] (optional) Number of results to skip for pagination (max ${MAX_PAGINATION_OFFSET}), e.g. --offset 100.`);
|
|
453
|
+
console.log();
|
|
454
|
+
console.log(
|
|
455
|
+
"list-oracle-metrics",
|
|
456
|
+
"Lists Oracle metric reference data.",
|
|
457
|
+
);
|
|
458
|
+
console.log("Parameters:");
|
|
459
|
+
console.log("--company [company_slug] (optional, defaults to current company)");
|
|
460
|
+
console.log(`--limit [number] (optional) Maximum number of results to return (max ${MAX_PAGINATION_LIMIT}), e.g. --limit 50.`);
|
|
461
|
+
console.log(`--offset [number] (optional) Number of results to skip for pagination (max ${MAX_PAGINATION_OFFSET}), e.g. --offset 100.`);
|
|
462
|
+
console.log();
|
|
463
|
+
console.log(
|
|
464
|
+
"list-oracle-limitations",
|
|
465
|
+
"Lists Oracle limitation reference data.",
|
|
466
|
+
);
|
|
467
|
+
console.log("Parameters:");
|
|
468
|
+
console.log("--company [company_slug] (optional, defaults to current company)");
|
|
469
|
+
console.log(`--limit [number] (optional) Maximum number of results to return (max ${MAX_PAGINATION_LIMIT}), e.g. --limit 50.`);
|
|
470
|
+
console.log(`--offset [number] (optional) Number of results to skip for pagination (max ${MAX_PAGINATION_OFFSET}), e.g. --offset 100.`);
|
|
471
|
+
console.log();
|
|
472
|
+
console.log(
|
|
473
|
+
"list-oracle-product-aliases",
|
|
474
|
+
"Lists Oracle product-alias lookup data.",
|
|
475
|
+
);
|
|
476
|
+
console.log("Parameters:");
|
|
477
|
+
console.log("--company [company_slug] (optional, defaults to current company)");
|
|
478
|
+
console.log(`--limit [number] (optional) Maximum number of results to return (max ${MAX_PAGINATION_LIMIT}), e.g. --limit 50.`);
|
|
479
|
+
console.log(`--offset [number] (optional) Number of results to skip for pagination (max ${MAX_PAGINATION_OFFSET}), e.g. --offset 100.`);
|
|
480
|
+
console.log();
|
|
481
|
+
console.log(
|
|
482
|
+
"list-oracle-orders",
|
|
483
|
+
"Lists Oracle orders for the specified account.",
|
|
484
|
+
);
|
|
485
|
+
console.log("Parameters:");
|
|
486
|
+
console.log("--company [company_slug] (optional, defaults to current company)");
|
|
487
|
+
console.log("--account [account-id-or-cloudSubscriptionId] (optional, defaults to current account) The account ID or cloudSubscriptionId to retrieve orders for.");
|
|
488
|
+
console.log("--account-id, --accountid [account-id-or-cloudSubscriptionId] (optional legacy aliases; override the current account)");
|
|
489
|
+
console.log(`--limit [number] (optional) Maximum number of results to return (max ${MAX_PAGINATION_LIMIT}), e.g. --limit 50.`);
|
|
490
|
+
console.log(`--offset [number] (optional) Number of results to skip for pagination (max ${MAX_PAGINATION_OFFSET}), e.g. --offset 100.`);
|
|
491
|
+
console.log();
|
|
492
|
+
console.log(
|
|
493
|
+
"get-oracle-order-items",
|
|
494
|
+
"Gets Oracle order-item details for the specified IDs.",
|
|
495
|
+
);
|
|
496
|
+
console.log("Parameters:");
|
|
497
|
+
console.log("--company [company_slug] (optional, defaults to current company)");
|
|
498
|
+
console.log("--account [account-id-or-cloudSubscriptionId] (optional, defaults to current account) The account ID or cloudSubscriptionId used to scope the request.");
|
|
499
|
+
console.log("--account-id, --accountid [account-id-or-cloudSubscriptionId] (optional legacy aliases; override the current account)");
|
|
500
|
+
console.log('--id [number] Use parameter multiple times to retrieve multiple items, e.g. --id 10 --id 11');
|
|
501
|
+
console.log("Note: A maximum of 100 order-item IDs can be requested at once.");
|
|
502
|
+
console.log();
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
export {
|
|
506
|
+
getOracleCurrentEntitlements,
|
|
507
|
+
listOracleMetrics,
|
|
508
|
+
listOracleLimitations,
|
|
509
|
+
listOracleProductAliases,
|
|
510
|
+
listOracleOrders,
|
|
511
|
+
getOracleOrderItems,
|
|
512
|
+
printOracleHelp,
|
|
513
|
+
};
|
|
@@ -37,6 +37,17 @@ import {
|
|
|
37
37
|
deleteMssqlConfiguration,
|
|
38
38
|
} from "./license-manager/microsoft.js";
|
|
39
39
|
|
|
40
|
+
// Oracle entitlement read-only functions
|
|
41
|
+
import {
|
|
42
|
+
printOracleHelp,
|
|
43
|
+
getOracleCurrentEntitlements,
|
|
44
|
+
listOracleMetrics,
|
|
45
|
+
listOracleLimitations,
|
|
46
|
+
listOracleProductAliases,
|
|
47
|
+
listOracleOrders,
|
|
48
|
+
getOracleOrderItems,
|
|
49
|
+
} from "./license-manager/oracle.js";
|
|
50
|
+
|
|
40
51
|
// Vcenter configuration functions
|
|
41
52
|
import {
|
|
42
53
|
printVcenterHelp,
|
|
@@ -813,22 +824,46 @@ async function createNetworkDiscoveryConfiguration(args) {
|
|
|
813
824
|
}
|
|
814
825
|
|
|
815
826
|
async function checkOracleConfigMetadata(args) {
|
|
816
|
-
|
|
827
|
+
const callParams = {};
|
|
828
|
+
let hasExplicitAccount = false;
|
|
829
|
+
for (let i = 0; i < args.length; i++) {
|
|
817
830
|
switch (args[i].toLowerCase()) {
|
|
818
831
|
case "--account-id":
|
|
819
832
|
case "--accountid":
|
|
820
|
-
|
|
833
|
+
hasExplicitAccount = true;
|
|
834
|
+
if (
|
|
835
|
+
args[i + 1] !== undefined &&
|
|
836
|
+
!args[i + 1].startsWith("--")
|
|
837
|
+
) {
|
|
838
|
+
callParams.accountId = args[++i];
|
|
839
|
+
}
|
|
821
840
|
break;
|
|
822
841
|
case "--last-collected-before":
|
|
823
842
|
case "--lastcollectedbefore":
|
|
824
|
-
|
|
843
|
+
if (args[i + 1] !== undefined) {
|
|
844
|
+
callParams.lastCollectedBefore = args[++i];
|
|
845
|
+
}
|
|
825
846
|
break;
|
|
826
847
|
}
|
|
827
848
|
}
|
|
828
849
|
|
|
850
|
+
const selectedAccount = hasExplicitAccount
|
|
851
|
+
? callParams.accountId
|
|
852
|
+
: global.account;
|
|
853
|
+
if (selectedAccount === undefined || selectedAccount === null) {
|
|
854
|
+
console.error("ERROR: --account is required (or set a default account).");
|
|
855
|
+
return;
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
const normalizedAccount = String(selectedAccount).trim();
|
|
859
|
+
if (normalizedAccount === "") {
|
|
860
|
+
console.error("ERROR: --account is required (or set a default account).");
|
|
861
|
+
return;
|
|
862
|
+
}
|
|
863
|
+
|
|
829
864
|
const client = await getOpsCompassClient();
|
|
830
865
|
const response = await client.licenseManager.checkOracleConfigMetadata(
|
|
831
|
-
|
|
866
|
+
normalizedAccount,
|
|
832
867
|
global.company,
|
|
833
868
|
callParams.lastCollectedBefore,
|
|
834
869
|
);
|
|
@@ -1107,13 +1142,17 @@ async function printHelp() {
|
|
|
1107
1142
|
"Checks the oracle configuration metadata for a company.",
|
|
1108
1143
|
);
|
|
1109
1144
|
console.log("Parameters:");
|
|
1110
|
-
console.log("--
|
|
1145
|
+
console.log("--account [account-id-or-cloudSubscriptionId] (optional, defaults to current account) The account ID or cloudSubscriptionId for the company.");
|
|
1146
|
+
console.log("--account-id, --accountid [account-id-or-cloudSubscriptionId] (optional legacy aliases; override the current account)");
|
|
1111
1147
|
console.log(`--company [company_slug] (default: ${global.company})\n`);
|
|
1112
1148
|
console.log(
|
|
1113
1149
|
"--lastCollectedBefore [string] (optional) Only returns records that have not been collected since the given date. Format: UTC, example: '2022-08-23T17:00:00Z'",
|
|
1114
1150
|
);
|
|
1115
1151
|
console.log();
|
|
1116
1152
|
|
|
1153
|
+
// Add Oracle help
|
|
1154
|
+
printOracleHelp();
|
|
1155
|
+
|
|
1117
1156
|
// Add Mssql help
|
|
1118
1157
|
printMssqlHelp();
|
|
1119
1158
|
|
|
@@ -1125,7 +1164,7 @@ async function printHelp() {
|
|
|
1125
1164
|
}
|
|
1126
1165
|
|
|
1127
1166
|
const licenseManagerModule = (action, ...args) => {
|
|
1128
|
-
utils.processStandardArgs(args);
|
|
1167
|
+
if (utils.processStandardArgs(args) === false) return;
|
|
1129
1168
|
switch (action?.toLowerCase() ?? "") {
|
|
1130
1169
|
case "create-oracle-shared-credential":
|
|
1131
1170
|
return createOracleSharedCredential(args);
|
|
@@ -1252,6 +1291,18 @@ const licenseManagerModule = (action, ...args) => {
|
|
|
1252
1291
|
return updateNutanixConfigurations(args);
|
|
1253
1292
|
case "delete-nutanix-configuration":
|
|
1254
1293
|
return deleteNutanixConfiguration(args);
|
|
1294
|
+
case "get-oracle-current-entitlements":
|
|
1295
|
+
return getOracleCurrentEntitlements(args);
|
|
1296
|
+
case "list-oracle-metrics":
|
|
1297
|
+
return listOracleMetrics(args);
|
|
1298
|
+
case "list-oracle-limitations":
|
|
1299
|
+
return listOracleLimitations(args);
|
|
1300
|
+
case "list-oracle-product-aliases":
|
|
1301
|
+
return listOracleProductAliases(args);
|
|
1302
|
+
case "list-oracle-orders":
|
|
1303
|
+
return listOracleOrders(args);
|
|
1304
|
+
case "get-oracle-order-items":
|
|
1305
|
+
return getOracleOrderItems(args);
|
|
1255
1306
|
case "help":
|
|
1256
1307
|
case "":
|
|
1257
1308
|
return printHelp();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opscompass/opscompass-cli",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.7",
|
|
4
4
|
"description": "Calls OpsCompass's APIs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -9,9 +9,10 @@
|
|
|
9
9
|
"check:publish-environment": "node ./scripts/check-publish-environment.mjs",
|
|
10
10
|
"check:pack-contents": "node ./scripts/check-pack-contents.mjs",
|
|
11
11
|
"check:restricted-apis": "node ./scripts/check-restricted-apis.mjs",
|
|
12
|
+
"check:prod-engines": "node ./scripts/check-prod-engines.mjs",
|
|
12
13
|
"check:prod-deprecations": "node ./scripts/check-prod-deprecations.mjs",
|
|
13
14
|
"check:prod-vulnerabilities": "node ./scripts/check-prod-vulnerabilities.mjs",
|
|
14
|
-
"test": "npm run ensure-current-environment && npm run check:restricted-apis && npm run check:prod-deprecations && npm run check:prod-vulnerabilities && node --experimental-vm-modules ./node_modules/jest/bin/jest.js --config ./jest.config.js --runInBand",
|
|
15
|
+
"test": "npm run ensure-current-environment && npm run check:restricted-apis && npm run check:prod-engines && npm run check:prod-deprecations && npm run check:prod-vulnerabilities && node --experimental-vm-modules ./node_modules/jest/bin/jest.js --config ./jest.config.js --runInBand",
|
|
15
16
|
"pack:check": "npm run ensure-current-environment && npm run check:pack-contents",
|
|
16
17
|
"build": "cd ../api;npx tsc; cd -"
|
|
17
18
|
},
|
|
@@ -24,11 +25,11 @@
|
|
|
24
25
|
"author": "opscompass",
|
|
25
26
|
"license": "SEE LICENSE IN license.txt",
|
|
26
27
|
"engines": {
|
|
27
|
-
"node": "
|
|
28
|
+
"node": "^22.19.0 || ^24.0.0"
|
|
28
29
|
},
|
|
29
30
|
"dependencies": {
|
|
30
|
-
"@opscompass/opscompass-api": "^1.3.
|
|
31
|
-
"adm-zip": "^0.
|
|
31
|
+
"@opscompass/opscompass-api": "^1.3.7",
|
|
32
|
+
"adm-zip": "^0.6.0",
|
|
32
33
|
"axios": "^1.18.1",
|
|
33
34
|
"better-sqlite3": "12.11.1",
|
|
34
35
|
"fs-extra": "^10.1.0",
|
|
@@ -36,7 +37,7 @@
|
|
|
36
37
|
"open": "^8.2.1",
|
|
37
38
|
"openpgp": "6.2.2",
|
|
38
39
|
"semver": "^7.3.7",
|
|
39
|
-
"tar": "^7.5.
|
|
40
|
+
"tar": "^7.5.22"
|
|
40
41
|
},
|
|
41
42
|
"devDependencies": {
|
|
42
43
|
"jest": "^30.4.2"
|