@opscompass/opscompass-cli 1.0.26 → 1.0.28
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/homeInteraction.js +3 -2
- package/lib/pgpTools.js +14 -8
- package/modules/data-gathering-scripts.js +4 -4
- package/modules/license-manager.js +7 -1
- package/modules/resources.js +102 -0
- package/package.json +3 -3
package/lib/homeInteraction.js
CHANGED
|
@@ -202,9 +202,10 @@ async function downloadScriptsToHome(
|
|
|
202
202
|
);
|
|
203
203
|
|
|
204
204
|
// Attempt to verify the download - returns true if signed and verified
|
|
205
|
-
//
|
|
205
|
+
// outputs validation error(s) and returns false otherwise
|
|
206
|
+
// - we continue regardless of validation for now...
|
|
206
207
|
scriptDownloadInfo.filePath = path.join(scriptTypeFolderPath, fileName);
|
|
207
|
-
await pgp.Verify(scriptDownloadInfo);
|
|
208
|
+
const zipValidated = await pgp.Verify(scriptDownloadInfo);
|
|
208
209
|
|
|
209
210
|
await unzipFile(scriptTypeFolderPath, fileName);
|
|
210
211
|
|
package/lib/pgpTools.js
CHANGED
|
@@ -13,7 +13,9 @@ async function Verify(scriptDownloadInfo) {
|
|
|
13
13
|
// Create a readable stream for the archive file
|
|
14
14
|
let readableStream = undefined;
|
|
15
15
|
if (fs.existsSync(scriptDownloadInfo.filePath)) {
|
|
16
|
-
|
|
16
|
+
// This seems to break openpgp.js if the file is > 128kb
|
|
17
|
+
// readableStream = fs.createReadStream(scriptDownloadInfo.filePath);
|
|
18
|
+
readableStream = fs.readFileSync(scriptDownloadInfo.filePath);
|
|
17
19
|
} else {
|
|
18
20
|
console.error("Cannot read archive file:", scriptDownloadInfo.filePath);
|
|
19
21
|
return false;
|
|
@@ -34,7 +36,7 @@ async function Verify(scriptDownloadInfo) {
|
|
|
34
36
|
publicKeyArmored = response?.data;
|
|
35
37
|
})
|
|
36
38
|
.catch(function (error) {
|
|
37
|
-
console.error("
|
|
39
|
+
console.error("Key error:", error.message);
|
|
38
40
|
});
|
|
39
41
|
|
|
40
42
|
// Wait for API response from public key repo
|
|
@@ -42,7 +44,10 @@ async function Verify(scriptDownloadInfo) {
|
|
|
42
44
|
if (!!publicKeyArmored) {
|
|
43
45
|
//console.log(publicKeyArmored);
|
|
44
46
|
} else {
|
|
45
|
-
console.error(
|
|
47
|
+
console.error(
|
|
48
|
+
"Validation error retrieving public key for: %s",
|
|
49
|
+
gpgSigner
|
|
50
|
+
);
|
|
46
51
|
return false;
|
|
47
52
|
}
|
|
48
53
|
|
|
@@ -50,7 +55,7 @@ async function Verify(scriptDownloadInfo) {
|
|
|
50
55
|
try {
|
|
51
56
|
publicKey = await openpgp.readKey({ armoredKey: publicKeyArmored });
|
|
52
57
|
} catch (err) {
|
|
53
|
-
console.error("
|
|
58
|
+
console.error("Validation error reading public key:\n", err);
|
|
54
59
|
return false;
|
|
55
60
|
}
|
|
56
61
|
// Public key is good
|
|
@@ -64,7 +69,7 @@ async function Verify(scriptDownloadInfo) {
|
|
|
64
69
|
});
|
|
65
70
|
} catch (err) {
|
|
66
71
|
console.error(
|
|
67
|
-
"
|
|
72
|
+
"Validation error reading file signature:\n",
|
|
68
73
|
scriptDownloadInfo?.gpgSignature
|
|
69
74
|
);
|
|
70
75
|
console.error("ERROR:", JSON.stringify(err, null, 2));
|
|
@@ -81,14 +86,15 @@ async function Verify(scriptDownloadInfo) {
|
|
|
81
86
|
});
|
|
82
87
|
const { verified, keyID } = verificationResult.signatures[0];
|
|
83
88
|
try {
|
|
89
|
+
// console.log("Awaiting verify...", verified);
|
|
84
90
|
await verified; // throws on invalid signature
|
|
85
|
-
//console.log("VERIFIED: Signed by key id " + keyID.toHex());
|
|
91
|
+
// console.log("VERIFIED: Signed by key id " + keyID.toHex());
|
|
86
92
|
} catch (e) {
|
|
87
|
-
console.log("Archive file verification failed
|
|
93
|
+
console.log("Archive file verification failed:\n" + e.message);
|
|
88
94
|
return false;
|
|
89
95
|
}
|
|
90
96
|
console.log(
|
|
91
|
-
"Archive file digitally signed by
|
|
97
|
+
"Archive file digitally signed by:\n %s",
|
|
92
98
|
publicKey?.users[0]?.userID?.userID || gpgSigner
|
|
93
99
|
);
|
|
94
100
|
return true;
|
|
@@ -116,7 +116,7 @@ async function downloadScripts(args) {
|
|
|
116
116
|
|
|
117
117
|
console.log("Downloaded %s (v%s)", scriptType, rcvdVersion);
|
|
118
118
|
} catch (err) {
|
|
119
|
-
console.log("Download failed...");
|
|
119
|
+
console.log("Download script type %s failed...", scriptType);
|
|
120
120
|
console.log(err);
|
|
121
121
|
}
|
|
122
122
|
}
|
|
@@ -224,9 +224,9 @@ async function checkScriptUpdates(args) {
|
|
|
224
224
|
client
|
|
225
225
|
);
|
|
226
226
|
|
|
227
|
-
console.log("Downloaded %s (v%s)",
|
|
227
|
+
console.log("Downloaded %s (v%s)", scriptType, rcvdVersion);
|
|
228
228
|
} catch (err) {
|
|
229
|
-
console.log("
|
|
229
|
+
console.log("Update script type %s failed...", scriptType);
|
|
230
230
|
console.log(err);
|
|
231
231
|
}
|
|
232
232
|
}
|
|
@@ -304,7 +304,7 @@ async function checkScriptUpdates(args) {
|
|
|
304
304
|
rcvdVersion
|
|
305
305
|
);
|
|
306
306
|
} catch (err) {
|
|
307
|
-
console.log("
|
|
307
|
+
console.log("Auto update script type %s failed...", scriptType);
|
|
308
308
|
console.log(err);
|
|
309
309
|
}
|
|
310
310
|
}
|
|
@@ -661,7 +661,7 @@ async function createOracleDatabaseConfiguration(args) {
|
|
|
661
661
|
|
|
662
662
|
async function updateMonitoringConfiguration(args) {
|
|
663
663
|
// Prep any arguments that are arrays
|
|
664
|
-
args = setArgumentArrays(["--
|
|
664
|
+
args = setArgumentArrays(["--emailTo", "--notificationEmailTo"], args);
|
|
665
665
|
|
|
666
666
|
callParams.id = monitoringConfig;
|
|
667
667
|
for (let i = 0; i < args.length - 1; i++) {
|
|
@@ -700,6 +700,9 @@ async function updateMonitoringConfiguration(args) {
|
|
|
700
700
|
case "--emailto":
|
|
701
701
|
callParams.emailTo = args[++i];
|
|
702
702
|
break;
|
|
703
|
+
case "--notificationemailto":
|
|
704
|
+
callParams.notificationEmailTo = args[++i];
|
|
705
|
+
break;
|
|
703
706
|
case "--logfileretaindays":
|
|
704
707
|
callParams.logFileRetainDays = args[++i];
|
|
705
708
|
break;
|
|
@@ -1629,6 +1632,9 @@ async function printHelp() {
|
|
|
1629
1632
|
console.log(
|
|
1630
1633
|
"--emailTo (optional) [Use parameter multiple times to send multiple email addresses. Identifies the destination email addresses when file delivery is done through email.]"
|
|
1631
1634
|
);
|
|
1635
|
+
console.log(
|
|
1636
|
+
"--notificationEmailTo (optional) [Use parameter multiple times to send multiple email addresses. Identifies the destination email addresses when notifications are sent.]"
|
|
1637
|
+
);
|
|
1632
1638
|
console.log(
|
|
1633
1639
|
"--logFileRetainDays (optional) [determines how many days to retain log files locally]"
|
|
1634
1640
|
);
|
package/modules/resources.js
CHANGED
|
@@ -366,6 +366,81 @@ async function getLatestConfiguration(args) {
|
|
|
366
366
|
console.log(JSON.stringify(latestConfiguration, null, 2));
|
|
367
367
|
}
|
|
368
368
|
|
|
369
|
+
async function getOverprovisioned(args) {
|
|
370
|
+
for (let i = 0; i < args.length - 1; i++) {
|
|
371
|
+
switch (args[i].toLowerCase()) {
|
|
372
|
+
case "--company":
|
|
373
|
+
callParams.company = args[++i];
|
|
374
|
+
break;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
const client = await getOpsCompassClient();
|
|
379
|
+
const resource = await client.resources.getOverprovisioned(callParams);
|
|
380
|
+
console.log(JSON.stringify(resource, null, 2));
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
async function getMetricCheckResults(args) {
|
|
384
|
+
for (let i = 0; i < args.length - 1; i++) {
|
|
385
|
+
switch (args[i].toLowerCase()) {
|
|
386
|
+
case "--company":
|
|
387
|
+
callParams.company = args[++i];
|
|
388
|
+
break;
|
|
389
|
+
case "--id":
|
|
390
|
+
callParams.id = args[++i];
|
|
391
|
+
break;
|
|
392
|
+
case "--resourceid":
|
|
393
|
+
case "--resource-id":
|
|
394
|
+
callParams.resourceId = args[++i];
|
|
395
|
+
break;
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
const client = await getOpsCompassClient();
|
|
400
|
+
const metricCheckResults = await client.resources.getMetricCheckResults(callParams);
|
|
401
|
+
console.log(JSON.stringify(metricCheckResults, null, 2));
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
async function getAggregateMetrics(args) {
|
|
405
|
+
for (let i = 0; i < args.length - 1; i++) {
|
|
406
|
+
switch (args[i].toLowerCase()) {
|
|
407
|
+
case "--granularity":
|
|
408
|
+
callParams.granularity = args[++i];
|
|
409
|
+
break;
|
|
410
|
+
case "--offset":
|
|
411
|
+
callParams.offset = args[++i];
|
|
412
|
+
break;
|
|
413
|
+
case "--limit":
|
|
414
|
+
callParams.limit = args[++i];
|
|
415
|
+
break;
|
|
416
|
+
case "--metriccheckresultid":
|
|
417
|
+
case "--metric-check-result-id":
|
|
418
|
+
callParams.metricCheckResultId = args[++i];
|
|
419
|
+
break;
|
|
420
|
+
case "--resourceid":
|
|
421
|
+
case "--resource-id":
|
|
422
|
+
callParams.resourceId = args[++i];
|
|
423
|
+
break;
|
|
424
|
+
case "--metrictype":
|
|
425
|
+
case "--metric-type":
|
|
426
|
+
callParams.metricType = args[++i];
|
|
427
|
+
break;
|
|
428
|
+
case "--calculatedatfrom":
|
|
429
|
+
case "--calculated-at-from":
|
|
430
|
+
callParams.calculatedAtFrom = args[++i];
|
|
431
|
+
break;
|
|
432
|
+
case "--calculatedatto":
|
|
433
|
+
case "--calculated-at-to":
|
|
434
|
+
callParams.calculatedAtTo = args[++i];
|
|
435
|
+
break;
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
const client = await getOpsCompassClient();
|
|
440
|
+
const aggregateMetrics = await client.resources.getAggregateMetrics(callParams.granularity, callParams);
|
|
441
|
+
console.log(JSON.stringify(aggregateMetrics, null, 2));
|
|
442
|
+
}
|
|
443
|
+
|
|
369
444
|
async function printHelp() {
|
|
370
445
|
console.log("Actions available for resources:");
|
|
371
446
|
console.log();
|
|
@@ -467,6 +542,27 @@ async function printHelp() {
|
|
|
467
542
|
console.log("--id [resource id]");
|
|
468
543
|
console.log("--resource-id [cloud-resource-id]");
|
|
469
544
|
console.log();
|
|
545
|
+
console.log("get-overprovisioned", "Gets resources that have been marked as being overprovisioned.");
|
|
546
|
+
console.log("Parameters:");
|
|
547
|
+
console.log("--company [company_id]");
|
|
548
|
+
console.log();
|
|
549
|
+
console.log("get-metric-check-results", "Gets the metric check results for a resource.");
|
|
550
|
+
console.log("Parameters:");
|
|
551
|
+
console.log("--company [company_id]");
|
|
552
|
+
console.log("--id [resource id]");
|
|
553
|
+
console.log("--resource-id [cloud-resource-id]");
|
|
554
|
+
console.log();
|
|
555
|
+
console.log("get-aggregate-metrics", "Gets the aggregate metrics for a resource.");
|
|
556
|
+
console.log("Parameters:");
|
|
557
|
+
console.log("--granularity ['Day' or 'Hour']");
|
|
558
|
+
console.log("--metric-check-result-id (optional) [metric check result id]");
|
|
559
|
+
console.log("--offset (optional) [number] assists in pagination of records, default is 0");
|
|
560
|
+
console.log("--limit (optional) [number] assists in pagination of records, default is 100, max is 250");
|
|
561
|
+
console.log("--resource-id (optional) [database resource id]");
|
|
562
|
+
console.log("--metric-type (optional) [string]");
|
|
563
|
+
console.log("--calculated-at-from (optional) [timestamp]");
|
|
564
|
+
console.log("--calculated-at-to (optional) [timestamp]");
|
|
565
|
+
console.log();
|
|
470
566
|
}
|
|
471
567
|
|
|
472
568
|
const resourcesModule = (action, ...args) => {
|
|
@@ -493,6 +589,12 @@ const resourcesModule = (action, ...args) => {
|
|
|
493
589
|
return uploadMetrics(args);
|
|
494
590
|
case "get-latest-configuration":
|
|
495
591
|
return getLatestConfiguration(args);
|
|
592
|
+
case "get-overprovisioned":
|
|
593
|
+
return getOverprovisioned(args);
|
|
594
|
+
case "get-metric-check-results":
|
|
595
|
+
return getMetricCheckResults(args);
|
|
596
|
+
case "get-aggregate-metrics":
|
|
597
|
+
return getAggregateMetrics(args);
|
|
496
598
|
case "help":
|
|
497
599
|
case "":
|
|
498
600
|
return printHelp();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opscompass/opscompass-cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.28",
|
|
4
4
|
"description": "Calls OpsCompass's APIs",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -15,13 +15,13 @@
|
|
|
15
15
|
"author": "opscompass",
|
|
16
16
|
"license": "SEE LICENSE IN license.txt",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@opscompass/opscompass-api": "^1.0.
|
|
18
|
+
"@opscompass/opscompass-api": "^1.0.28",
|
|
19
19
|
"adm-zip": "^0.5.9",
|
|
20
20
|
"axios": "^0.21.1",
|
|
21
21
|
"fs-extra": "^10.1.0",
|
|
22
22
|
"https-proxy-agent": "^5.0.1",
|
|
23
23
|
"open": "^8.2.1",
|
|
24
|
-
"openpgp": "^5.
|
|
24
|
+
"openpgp": "^5.11.0",
|
|
25
25
|
"semver": "^7.3.7"
|
|
26
26
|
},
|
|
27
27
|
"bin": {
|