@opscompass/opscompass-cli 1.0.22 → 1.0.23

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.
@@ -135,12 +135,13 @@ async function downloadScriptsToHome(
135
135
  ) {
136
136
  // Ensure base scripts are downloaded/updated
137
137
  if (scriptType !== ScriptType.baseScripts) {
138
- await downloadScriptsToHome(
138
+ const baseVersion = await downloadScriptsToHome(
139
139
  ScriptType.baseScripts,
140
140
  undefined,
141
141
  companySlug,
142
142
  client
143
143
  );
144
+ console.log("Base scripts (v%s)", baseVersion);
144
145
  }
145
146
 
146
147
  // Download specific script
@@ -197,6 +198,9 @@ async function downloadScriptsToHome(
197
198
  await setScriptMetadata(scriptTypeFolderPath, scriptVersion);
198
199
 
199
200
  deleteFile(path.join(scriptTypeFolderPath, fileName));
201
+
202
+ // Return the version downloaded
203
+ return scriptVersion;
200
204
  }
201
205
 
202
206
  /**
@@ -51,6 +51,8 @@ async function listLocalScripts(args) {
51
51
  }
52
52
 
53
53
  if (items.length > 0) {
54
+ // Go with compact output for this display
55
+ //console.log(JSON.stringify(scriptsLocal, null, 2));
54
56
  console.log(scriptsLocal);
55
57
  } else {
56
58
  throw "Cannot list scripts. Make sure the scripts are downloaded.\nIf the issue persists, contact your OpsCompass rep.";
@@ -94,15 +96,47 @@ async function downloadScripts(args) {
94
96
  try {
95
97
  const client = await getOpsCompassClient();
96
98
 
97
- await downloadScriptsToHome(scriptType, scriptVersion, companySlug, client);
99
+ const rcvdVersion = await downloadScriptsToHome(
100
+ scriptType,
101
+ scriptVersion,
102
+ companySlug,
103
+ client
104
+ );
98
105
 
99
- console.log("Download Successful!");
106
+ console.log("Downloaded %s (v%s)", scriptType, rcvdVersion);
100
107
  } catch (err) {
101
108
  console.log("Download failed...");
102
109
  console.log(err);
103
110
  }
104
111
  }
105
112
 
113
+ /**
114
+ * Checks the available script versions from the server
115
+ */
116
+ async function listAvailableScripts(args) {
117
+ for (let i = 0; i < args.length - 1; i++) {
118
+ switch (args[i].toLowerCase()) {
119
+ case "--company":
120
+ companySlug = args[++i];
121
+ break;
122
+ }
123
+ }
124
+
125
+ try {
126
+ const client = await getOpsCompassClient();
127
+
128
+ const scriptsRemote = await client.dataGatheringScripts.getScriptVersions(
129
+ company
130
+ );
131
+ // Go with compact output for this display
132
+ //console.log(JSON.stringify(scriptsRemote, null, 2));
133
+ console.log(scriptsRemote);
134
+ } catch (err) {
135
+ console.log("List available script versions failed...");
136
+ console.log(err);
137
+ }
138
+ }
139
+
106
140
  /**
107
141
  * Checks the installed scripts version against the latest scripts version for a given scriptType.
108
142
  */
@@ -250,6 +284,11 @@ async function manuallyRunScripts() {
250
284
  async function printHelp() {
251
285
  console.log("Actions available for data-gathering-scripts:");
252
286
  console.log();
287
+ console.log(
288
+ "list-available",
289
+ "Lists all script types and versions available for download"
290
+ );
291
+ console.log();
253
292
  console.log(
254
293
  "list-local",
255
294
  "Lists all locally downloaded script types and versions"
@@ -301,6 +340,8 @@ const dataGatheringScriptsModule = (action, ...args) => {
301
340
  return downloadScripts(args);
302
341
  case "check-script-updates":
303
342
  return checkScriptUpdates(args);
343
+ case "list-available":
344
+ return listAvailableScripts(args);
304
345
  case "list-local":
305
346
  return listLocalScripts();
306
347
  case "manually-run-scripts":
@@ -1,6 +1,214 @@
1
1
  const { setArgumentArrays } = require("../lib/cliHelpers.js");
2
2
  const { getOpsCompassClient } = require("../opscompass.js");
3
3
 
4
+ async function createOracleSharedCredential(args) {
5
+ let optionalParams = {};
6
+ for (let i = 0; i < args.length - 1; i++) {
7
+ switch (args[i].toLowerCase()) {
8
+ case "--monitoring-configuration-id":
9
+ case "--monitoringconfigurationid":
10
+ monitoringConfig = args[++i];
11
+ break;
12
+ case "--user":
13
+ optionalParams.user = args[++i];
14
+ break;
15
+ case "--password":
16
+ optionalParams.password = args[++i];
17
+ break;
18
+ case "--credential-name":
19
+ case "--credentialname":
20
+ optionalParams.credentialName = args[++i];
21
+ break;
22
+ }
23
+ }
24
+
25
+ const client = await getOpsCompassClient();
26
+ try {
27
+ const createResponse =
28
+ await client.licenseManager.createOracleSharedCredential(
29
+ monitoringConfig,
30
+ optionalParams
31
+ );
32
+
33
+ console.log(JSON.stringify(createResponse, null, 2));
34
+ } catch (err) {
35
+ console.error(JSON.stringify(err.message, null, 2));
36
+ console.error("It is likely the default credential already exists\n");
37
+ }
38
+ }
39
+
40
+ async function deleteOracleSharedCredential(args) {
41
+ let id = undefined;
42
+ for (let i = 0; i < args.length - 1; i++) {
43
+ switch (args[i].toLowerCase()) {
44
+ case "--id":
45
+ id = args[++i];
46
+ break;
47
+ }
48
+ }
49
+
50
+ const client = await getOpsCompassClient();
51
+ const deleteResponse =
52
+ await client.licenseManager.deleteOracleSharedCredential(id);
53
+
54
+ console.log(JSON.stringify(deleteResponse, null, 2));
55
+ }
56
+
57
+ async function getOracleDefaultCredential(args) {
58
+ for (let i = 0; i < args.length - 1; i++) {
59
+ switch (args[i].toLowerCase()) {
60
+ case "--monitoring-configuration-id":
61
+ case "--monitoringconfigurationid":
62
+ monitoringConfig = args[++i];
63
+ break;
64
+ }
65
+ }
66
+
67
+ const client = await getOpsCompassClient();
68
+ const getResponse = await client.licenseManager.getOracleDefaultCredential(
69
+ monitoringConfig
70
+ );
71
+
72
+ console.log(JSON.stringify(getResponse, null, 2));
73
+ }
74
+
75
+ async function updateOracleSharedCredential(args) {
76
+ let id = undefined;
77
+ let optionalParams = {};
78
+ for (let i = 0; i < args.length - 1; i++) {
79
+ switch (args[i].toLowerCase()) {
80
+ case "--id":
81
+ id = args[++i];
82
+ break;
83
+ case "--user":
84
+ optionalParams.user = args[++i];
85
+ break;
86
+ case "--password":
87
+ optionalParams.password = args[++i];
88
+ break;
89
+ case "--credential-name":
90
+ case "--credentialname":
91
+ optionalParams.credentialName = args[++i];
92
+ break;
93
+ }
94
+ }
95
+ const client = await getOpsCompassClient();
96
+ const updateResponse =
97
+ await client.licenseManager.updateOracleSharedCredential(
98
+ id,
99
+ optionalParams
100
+ );
101
+
102
+ console.log(JSON.stringify(updateResponse, null, 2));
103
+ }
104
+
105
+ async function getMsqlDefaultCredential(args) {
106
+ for (let i = 0; i < args.length - 1; i++) {
107
+ switch (args[i].toLowerCase()) {
108
+ case "--monitoring-configuration-id":
109
+ case "--monitoringconfigurationid":
110
+ monitoringConfig = args[++i];
111
+ break;
112
+ }
113
+ }
114
+
115
+ const client = await getOpsCompassClient();
116
+ const getResponse = await client.licenseManager.getMsqlDefaultCredential(
117
+ monitoringConfig
118
+ );
119
+
120
+ console.log(JSON.stringify(getResponse, null, 2));
121
+ }
122
+
123
+ async function createMsqlSharedCredential(args) {
124
+ let optionalParams = {};
125
+ for (let i = 0; i < args.length - 1; i++) {
126
+ switch (args[i].toLowerCase()) {
127
+ case "--monitoring-configuration-id":
128
+ case "--monitoringconfigurationid":
129
+ monitoringConfig = args[++i];
130
+ break;
131
+ case "--user":
132
+ optionalParams.user = args[++i];
133
+ break;
134
+ case "--password":
135
+ optionalParams.password = args[++i];
136
+ break;
137
+ case "--credential-name":
138
+ case "--credentialname":
139
+ optionalParams.credentialName = args[++i];
140
+ break;
141
+ case "--directory-auth":
142
+ optionalParams.directory_auth = args[++i];
143
+ break;
144
+ }
145
+ }
146
+
147
+ try {
148
+ const client = await getOpsCompassClient();
149
+ const createResponse =
150
+ await client.licenseManager.createMsqlSharedCredential(
151
+ monitoringConfig,
152
+ optionalParams
153
+ );
154
+
155
+ console.log(JSON.stringify(createResponse, null, 2));
156
+ } catch (err) {
157
+ console.error(JSON.stringify(err.message, null, 2));
158
+ console.error("It is likely the default credential already exists\n");
159
+ }
160
+ }
161
+
162
+ async function deleteMsqlSharedCredential(args) {
163
+ let id = undefined;
164
+ for (let i = 0; i < args.length - 1; i++) {
165
+ switch (args[i].toLowerCase()) {
166
+ case "--id":
167
+ id = args[++i];
168
+ break;
169
+ }
170
+ }
171
+
172
+ const client = await getOpsCompassClient();
173
+ const deleteResponse = await client.licenseManager.deleteMsqlSharedCredential(
174
+ id
175
+ );
176
+
177
+ console.log(JSON.stringify(deleteResponse, null, 2));
178
+ }
179
+
180
+ async function updateMsqlSharedCredential(args) {
181
+ let id = undefined;
182
+ let optionalParams = {};
183
+ for (let i = 0; i < args.length - 1; i++) {
184
+ switch (args[i].toLowerCase()) {
185
+ case "--id":
186
+ id = args[++i];
187
+ break;
188
+ case "--user":
189
+ optionalParams.user = args[++i];
190
+ break;
191
+ case "--password":
192
+ optionalParams.password = args[++i];
193
+ break;
194
+ case "--credential-name":
195
+ case "--credentialname":
196
+ optionalParams.credentialName = args[++i];
197
+ break;
198
+ case "--directory-auth":
199
+ optionalParams.directory_auth = args[++i];
200
+ break;
201
+ }
202
+ }
203
+ const client = await getOpsCompassClient();
204
+ const updateResponse = await client.licenseManager.updateMsqlSharedCredential(
205
+ id,
206
+ optionalParams
207
+ );
208
+
209
+ console.log(JSON.stringify(updateResponse, null, 2));
210
+ }
211
+
4
212
  async function listMonitoringConfigurations(args) {
5
213
  for (let i = 0; i < args.length - 1; i++) {
6
214
  switch (args[i].toLowerCase()) {
@@ -153,7 +361,8 @@ async function getSecretForConfiguration(args) {
153
361
  case "--id":
154
362
  id = args[++i];
155
363
  break;
156
- case "--recordtype":
364
+ case "--recordType":
365
+ case "--record-type":
157
366
  recordType = args[++i];
158
367
  break;
159
368
  }
@@ -413,7 +622,7 @@ async function getMssqlEntitlements(args) {
413
622
 
414
623
  async function createOracleDatabaseConfiguration(args) {
415
624
  let name = undefined;
416
- let optionalParams = { actions: undefined, connection: undefined };
625
+ let optionalParams = { };
417
626
  for (let i = 0; i < args.length - 1; i++) {
418
627
  switch (args[i].toLowerCase()) {
419
628
  case "--monitoringconfigurationid":
@@ -427,8 +636,14 @@ async function createOracleDatabaseConfiguration(args) {
427
636
  if (optionalParams.actions === undefined) optionalParams.actions = [];
428
637
  optionalParams.actions.push(args[++i]);
429
638
  break;
430
- case "--connectionstring":
431
- optionalParams.connection = args[++i];
639
+ case "--password":
640
+ optionalParams.password = args[++i];
641
+ break;
642
+ case "--user":
643
+ optionalParams.user = args[++i];
644
+ break;
645
+ case "--server":
646
+ optionalParams.server = args[++i];
432
647
  break;
433
648
  }
434
649
  }
@@ -511,8 +726,14 @@ async function updateOracleDatabaseConfiguration(args) {
511
726
  if (callParams.actions === undefined) callParams.actions = [];
512
727
  callParams.actions.push(args[++i]);
513
728
  break;
514
- case "--connectionstring":
515
- callParams.connectionString = args[++i];
729
+ case "--password":
730
+ callParams.password = args[++i];
731
+ break;
732
+ case "--user":
733
+ callParams.user = args[++i];
734
+ break;
735
+ case "--server":
736
+ callParams.server = args[++i];
516
737
  break;
517
738
  }
518
739
  }
@@ -553,8 +774,12 @@ async function updateOracleDatabaseConfigurations(args) {
553
774
  args[i].toLowerCase() === "--name"
554
775
  ) {
555
776
  callParams.configurationName = args[i + 1];
556
- } else if (args[i] === "--connectionstring") {
557
- callParams.connectionString = args[i + 1];
777
+ } else if (args[i] === "--server") {
778
+ callParams.server = args[i + 1];
779
+ } else if (args[i] === "--user") {
780
+ callParams.user = args[i + 1];
781
+ } else if (args[i] === "--password") {
782
+ callParams.password = args[i + 1];
558
783
  } else if (args[i] === "--action") {
559
784
  if (callParams.actions === undefined) callParams.actions = [];
560
785
  callParams.actions.push(args[i + 1]);
@@ -1132,11 +1357,77 @@ async function printHelp() {
1132
1357
  );
1133
1358
  console.log("Parameters:");
1134
1359
  console.log(
1135
- "--id [vcenter_configuration_id | oracle_database_configuration_id | msql_configuration_id]"
1360
+ "--id [vcenter_configuration_id | oracle_database_configuration_id | msql_configuration_id | msql_default_credential_id | oracle_default_credential_id]"
1361
+ );
1362
+ console.log(
1363
+ "--record-type ['oracle_database_configuration' | 'vcenter_configuration' | 'msql_configuration' | 'msql_shared_monitoring_credential' | 'oracle_shared_monitoring_credential'"
1136
1364
  );
1365
+ console.log();
1366
+ console.log(
1367
+ "create-oracle-shared-credential",
1368
+ "Creates Oracle shared credentials"
1369
+ );
1370
+ console.log(
1371
+ "--monitoring-configuration-id monitoring configuration ID to make the shared credentials for"
1372
+ );
1373
+ console.log("--user (optional) [string]");
1374
+ console.log("--password (optional) [string]");
1375
+ console.log();
1376
+ console.log(
1377
+ "delete-oracle-shared-credential",
1378
+ "Delete a Oracle shared credential"
1379
+ );
1380
+ console.log("--id ID of the oracle shared credential to delete");
1381
+ console.log();
1382
+ console.log(
1383
+ "get-oracle-default-credential",
1384
+ "Get Oracle default credential record"
1385
+ );
1386
+ console.log(
1387
+ "--monitoring-configuration-id monitoring configuration ID to get the default credentials for"
1388
+ );
1389
+ console.log();
1390
+ console.log(
1391
+ "update-oracle-shared-credential",
1392
+ "Update Oracle shared credential record"
1393
+ );
1394
+ console.log("--id ID of the oracle shared credential to update");
1395
+ console.log("--user (optional) [string]");
1396
+ console.log("--password (optional) [string]");
1397
+ console.log();
1398
+ console.log(
1399
+ "create-msql-shared-credential",
1400
+ "Creates MSQL shared credentials"
1401
+ );
1402
+ console.log(
1403
+ "--monitoring-configuration-id monitoring configuration ID to make the shared credentials for"
1404
+ );
1405
+ console.log("--user (optional) [string]");
1406
+ console.log("--password (optional) [string]");
1407
+ console.log("--directory-auth (optional) 'SESSION' | null");
1408
+ console.log();
1409
+ console.log(
1410
+ "delete-msql-shared-credential",
1411
+ "Delete a MSQL shared credential"
1412
+ );
1413
+ console.log("--id ID of the msql shared credential to delete");
1414
+ console.log();
1415
+ console.log(
1416
+ "get-msql-default-credential",
1417
+ "Get MSQL default credential record"
1418
+ );
1419
+ console.log(
1420
+ "--monitoring-configuration-id monitoring configuration ID to get the default credentials for"
1421
+ );
1422
+ console.log();
1137
1423
  console.log(
1138
- "--recordType ['oracle_database_configuration' | 'vcenter_configuration' | 'msql_configuration'"
1424
+ "update-msql-shared-credential",
1425
+ "Update MSQL shared credential record"
1139
1426
  );
1427
+ console.log("--id ID of the msql shared credential to update");
1428
+ console.log("--user (optional) [string]");
1429
+ console.log("--password (optional) [string]");
1430
+ console.log("--directory-auth (optional) 'SESSION' | null");
1140
1431
  console.log();
1141
1432
  console.log(
1142
1433
  "list-monitoring-configurations",
@@ -1299,7 +1590,9 @@ async function printHelp() {
1299
1590
  console.log(
1300
1591
  `--action (optional) pass multiple times to define which actions this connection can take e.g. --action "skip" --action "dbcompliance"`
1301
1592
  );
1302
- console.log("--connectionString (optional) [the database connection string]");
1593
+ console.log("--user (optional) [user to use for connection]");
1594
+ console.log("--password (optional) [password to use for connection]");
1595
+ console.log("--server (optional) [server to use for connection]");
1303
1596
  console.log();
1304
1597
  console.log(
1305
1598
  "update-monitoring-configuration",
@@ -1343,7 +1636,9 @@ async function printHelp() {
1343
1636
  console.log(
1344
1637
  `--action (optional) pass multiple times to define which actions this connection can take --action "skip" --action "dbcompliance"`
1345
1638
  );
1346
- console.log("--connectionString (optional) [the database connection string]");
1639
+ console.log("--user (optional) [user to use for connection]");
1640
+ console.log("--password (optional) [password to use for connection]");
1641
+ console.log("--server (optional) [server to use for connection]");
1347
1642
  console.log();
1348
1643
  console.log(
1349
1644
  "update-oracle-database-configurations",
@@ -1355,7 +1650,9 @@ async function printHelp() {
1355
1650
  console.log(
1356
1651
  `--action (optional) pass multiple times to define which actions this connection can take e.g. --action "skip" --action "dbcompliance"`
1357
1652
  );
1358
- console.log("--connectionString (optional) [the database connection string]");
1653
+ console.log("--user (optional) [the user to use for the connection]");
1654
+ console.log("--password (optional) [the password to use for the connection]");
1655
+ console.log("--server (optional) [the server to use for the connection]");
1359
1656
  console.log("OR --json-updates [stringified json objects with your updates]");
1360
1657
  console.log("For quick updates, you may use the above parameters");
1361
1658
  console.log(
@@ -1594,6 +1891,22 @@ async function printHelp() {
1594
1891
 
1595
1892
  const licenseManagerModule = (action, ...args) => {
1596
1893
  switch (action?.toLowerCase() ?? "") {
1894
+ case "create-oracle-shared-credential":
1895
+ return createOracleSharedCredential(args);
1896
+ case "delete-oracle-shared-credential":
1897
+ return deleteOracleSharedCredential(args);
1898
+ case "get-oracle-default-credential":
1899
+ return getOracleDefaultCredential(args);
1900
+ case "update-oracle-shared-credential":
1901
+ return updateOracleSharedCredential(args);
1902
+ case "create-msql-shared-credential":
1903
+ return createMsqlSharedCredential(args);
1904
+ case "delete-msql-shared-credential":
1905
+ return deleteMsqlSharedCredential(args);
1906
+ case "get-msql-default-credential":
1907
+ return getMsqlDefaultCredential(args);
1908
+ case "update-msql-shared-credential":
1909
+ return updateMsqlSharedCredential(args);
1597
1910
  case "create-network-discovery-configuration":
1598
1911
  return createNetworkDiscoveryConfiguration(args);
1599
1912
  case "update-network-discovery-configuration":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opscompass/opscompass-cli",
3
- "version": "1.0.22",
3
+ "version": "1.0.23",
4
4
  "description": "Calls OpsCompass's APIs",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -15,7 +15,7 @@
15
15
  "author": "opscompass",
16
16
  "license": "SEE LICENSE IN license.txt",
17
17
  "dependencies": {
18
- "@opscompass/opscompass-api": "^1.0.22",
18
+ "@opscompass/opscompass-api": "^1.0.23",
19
19
  "adm-zip": "^0.5.9",
20
20
  "axios": "^0.21.1",
21
21
  "fs-extra": "^10.1.0",