@opscompass/opscompass-cli 1.0.22 → 1.0.24
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 +5 -1
- package/modules/data-gathering-scripts.js +197 -44
- package/modules/license-manager.js +326 -13
- package/package.json +2 -2
package/lib/homeInteraction.js
CHANGED
|
@@ -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
|
/**
|
|
@@ -23,6 +23,14 @@ const exec = util.promisify(require("child_process").exec);
|
|
|
23
23
|
* Lists script types that are locally installed
|
|
24
24
|
*/
|
|
25
25
|
async function listLocalScripts(args) {
|
|
26
|
+
let quiet = false;
|
|
27
|
+
for (let i = 0; i < args.length; i++) {
|
|
28
|
+
switch (args[i].toLowerCase()) {
|
|
29
|
+
case "--quiet":
|
|
30
|
+
quiet = true;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
26
34
|
const scriptTypes = Object.values(ScriptType);
|
|
27
35
|
let scriptsLocal;
|
|
28
36
|
|
|
@@ -50,14 +58,19 @@ async function listLocalScripts(args) {
|
|
|
50
58
|
}
|
|
51
59
|
}
|
|
52
60
|
|
|
53
|
-
if (items.length
|
|
54
|
-
console.log(scriptsLocal);
|
|
55
|
-
} else {
|
|
61
|
+
if (items.length <= 0) {
|
|
56
62
|
throw "Cannot list scripts. Make sure the scripts are downloaded.\nIf the issue persists, contact your OpsCompass rep.";
|
|
63
|
+
} else {
|
|
64
|
+
if (!quiet) {
|
|
65
|
+
// Go with compact output for this display
|
|
66
|
+
// console.log(JSON.stringify(scriptsLocal, null, 2));
|
|
67
|
+
console.log(scriptsLocal);
|
|
68
|
+
}
|
|
57
69
|
}
|
|
58
70
|
} catch (err) {
|
|
59
71
|
console.log(err);
|
|
60
72
|
}
|
|
73
|
+
|
|
61
74
|
return scriptsLocal;
|
|
62
75
|
}
|
|
63
76
|
|
|
@@ -94,22 +107,67 @@ async function downloadScripts(args) {
|
|
|
94
107
|
try {
|
|
95
108
|
const client = await getOpsCompassClient();
|
|
96
109
|
|
|
97
|
-
await downloadScriptsToHome(
|
|
110
|
+
const rcvdVersion = await downloadScriptsToHome(
|
|
111
|
+
scriptType,
|
|
112
|
+
scriptVersion,
|
|
113
|
+
companySlug,
|
|
114
|
+
client
|
|
115
|
+
);
|
|
98
116
|
|
|
99
|
-
console.log("
|
|
117
|
+
console.log("Downloaded %s (v%s)", scriptType, rcvdVersion);
|
|
100
118
|
} catch (err) {
|
|
101
119
|
console.log("Download failed...");
|
|
102
120
|
console.log(err);
|
|
103
121
|
}
|
|
104
122
|
}
|
|
105
123
|
|
|
124
|
+
/**
|
|
125
|
+
* Checks the available script versions from the server
|
|
126
|
+
*/
|
|
127
|
+
async function listAvailableScripts(args) {
|
|
128
|
+
let quiet = false;
|
|
129
|
+
for (let i = 0; i < args.length; i++) {
|
|
130
|
+
switch (args[i].toLowerCase()) {
|
|
131
|
+
case "--company":
|
|
132
|
+
companySlug = args[++i];
|
|
133
|
+
break;
|
|
134
|
+
case "--quiet":
|
|
135
|
+
quiet = true;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
try {
|
|
140
|
+
const client = await getOpsCompassClient();
|
|
141
|
+
|
|
142
|
+
const scriptsRemote = await client.dataGatheringScripts.getScriptVersions(
|
|
143
|
+
company
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
if (!quiet) {
|
|
147
|
+
// Go with compact output for this display
|
|
148
|
+
//console.log(JSON.stringify(scriptsRemote, null, 2));
|
|
149
|
+
console.log(scriptsRemote);
|
|
150
|
+
}
|
|
151
|
+
return scriptsRemote;
|
|
152
|
+
} catch (err) {
|
|
153
|
+
console.log("List available script versions failed...");
|
|
154
|
+
console.log(err);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
106
158
|
/**
|
|
107
159
|
* Checks the installed scripts version against the latest scripts version for a given scriptType.
|
|
160
|
+
* or all scriptTypes if not specified
|
|
108
161
|
*/
|
|
109
162
|
async function checkScriptUpdates(args) {
|
|
110
163
|
let scriptType = undefined;
|
|
111
|
-
|
|
164
|
+
let autoUpdate = false;
|
|
165
|
+
for (let i = 0; i < args.length; i++) {
|
|
112
166
|
switch (args[i].toLowerCase()) {
|
|
167
|
+
case "--auto-update":
|
|
168
|
+
case "--autoupdate":
|
|
169
|
+
autoUpdate = true;
|
|
170
|
+
break;
|
|
113
171
|
case "--company":
|
|
114
172
|
companySlug = args[++i];
|
|
115
173
|
break;
|
|
@@ -120,47 +178,129 @@ async function checkScriptUpdates(args) {
|
|
|
120
178
|
}
|
|
121
179
|
}
|
|
122
180
|
|
|
123
|
-
// If script type is not supported, we do not want to continue.
|
|
124
|
-
const scriptTypes = Object.values(ScriptType);
|
|
125
|
-
if (!scriptTypes.includes(scriptType)) {
|
|
126
|
-
console.log("Unsupported script type...");
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
181
|
const client = await getOpsCompassClient();
|
|
131
|
-
const currentScriptVersion = await getInstalledScriptVersion(scriptType);
|
|
132
182
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
);
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
183
|
+
// If script type was specified, just check that one
|
|
184
|
+
if (scriptType) {
|
|
185
|
+
// If script type is not supported, we do not want to continue.
|
|
186
|
+
const scriptTypes = Object.values(ScriptType);
|
|
187
|
+
if (!scriptTypes.includes(scriptType)) {
|
|
188
|
+
console.log("Unsupported script type...");
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
140
191
|
|
|
141
|
-
|
|
142
|
-
await client.dataGatheringScripts.checkScriptUpdates(
|
|
143
|
-
companySlug,
|
|
144
|
-
scriptType
|
|
145
|
-
);
|
|
192
|
+
const currentScriptVersion = await getInstalledScriptVersion(scriptType);
|
|
146
193
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
194
|
+
if (!currentScriptVersion) {
|
|
195
|
+
console.log(
|
|
196
|
+
`Local scripts for type ${scriptType} not found. Please make sure they are installed.`
|
|
197
|
+
);
|
|
198
|
+
console.log("If the issue persists, please contact your OpsCompass rep.");
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
console.log("Checking for latest version of module %s...", scriptType);
|
|
203
|
+
const latestScriptVersion =
|
|
204
|
+
await client.dataGatheringScripts.checkScriptUpdates(
|
|
205
|
+
companySlug,
|
|
206
|
+
scriptType
|
|
207
|
+
);
|
|
208
|
+
|
|
209
|
+
//Semver returns true if the latest version is higher than the currentScriptVersion.
|
|
210
|
+
if (semver.gt(latestScriptVersion.scriptVersion, currentScriptVersion)) {
|
|
211
|
+
console.log(
|
|
212
|
+
yellowText,
|
|
213
|
+
`Warning! You are using version ${currentScriptVersion} of the the ${scriptType} scripts, but the latest version is ${latestScriptVersion.scriptVersion}. To update to the latest version, please run:`
|
|
214
|
+
);
|
|
215
|
+
console.log(
|
|
216
|
+
greenText,
|
|
217
|
+
` ${cliCommand} data-gathering-scripts download-scripts --company ${companySlug} --scriptType ${scriptType} `
|
|
218
|
+
);
|
|
219
|
+
console.log();
|
|
220
|
+
} else {
|
|
221
|
+
console.log(
|
|
222
|
+
greenText,
|
|
223
|
+
`You are already using the latest version of ${scriptType} script, ${latestScriptVersion.scriptVersion}.`
|
|
224
|
+
);
|
|
225
|
+
console.log();
|
|
226
|
+
}
|
|
158
227
|
} else {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
228
|
+
const scriptsLocal = await listLocalScripts([...args, "--quiet"]);
|
|
229
|
+
|
|
230
|
+
if (
|
|
231
|
+
scriptsLocal &&
|
|
232
|
+
Array.isArray(scriptsLocal?.versions) &&
|
|
233
|
+
scriptsLocal.versions?.length > 0
|
|
234
|
+
) {
|
|
235
|
+
// We have at least one scriptType downloaded
|
|
236
|
+
} else {
|
|
237
|
+
console.error("Scripts available for download:");
|
|
238
|
+
listAvailableScripts(args);
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// Sort by script-type
|
|
243
|
+
scriptsLocal.versions.sort(function (a, b) {
|
|
244
|
+
return a.scriptType < b.scriptType
|
|
245
|
+
? -1
|
|
246
|
+
: a.scriptType > b.scriptType
|
|
247
|
+
? 1
|
|
248
|
+
: 0;
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
console.log("\nFetching remote versions...");
|
|
252
|
+
const scriptsRemote = await listAvailableScripts([...args, "--quiet"]);
|
|
253
|
+
|
|
254
|
+
for (const scriptVer of scriptsLocal.versions) {
|
|
255
|
+
const remoteVer = scriptsRemote.versions.find(
|
|
256
|
+
(version) => version.scriptType === scriptVer.scriptType
|
|
257
|
+
);
|
|
258
|
+
|
|
259
|
+
const needsUpdate = semver.gt(
|
|
260
|
+
remoteVer.scriptVersion,
|
|
261
|
+
scriptVer.scriptVersion
|
|
262
|
+
);
|
|
263
|
+
|
|
264
|
+
if (needsUpdate) {
|
|
265
|
+
console.log(
|
|
266
|
+
"\nmodule %s: Local=%s, needs update=%s",
|
|
267
|
+
scriptVer.scriptType,
|
|
268
|
+
scriptVer.scriptVersion,
|
|
269
|
+
remoteVer.scriptVersion
|
|
270
|
+
);
|
|
271
|
+
console.log(
|
|
272
|
+
greenText,
|
|
273
|
+
` ${cliCommand} data-gathering-scripts download-scripts --company ${companySlug} --scriptType ${scriptVer.scriptType} \n`
|
|
274
|
+
);
|
|
275
|
+
if (autoUpdate) {
|
|
276
|
+
try {
|
|
277
|
+
// Get the latest version
|
|
278
|
+
const rcvdVersion = await downloadScriptsToHome(
|
|
279
|
+
scriptVer.scriptType,
|
|
280
|
+
undefined,
|
|
281
|
+
companySlug,
|
|
282
|
+
client
|
|
283
|
+
);
|
|
284
|
+
|
|
285
|
+
console.log(
|
|
286
|
+
"Downloaded %s (v%s)",
|
|
287
|
+
scriptVer.scriptType,
|
|
288
|
+
rcvdVersion
|
|
289
|
+
);
|
|
290
|
+
} catch (err) {
|
|
291
|
+
console.log("Download failed...");
|
|
292
|
+
console.log(err);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
} else {
|
|
296
|
+
console.log(
|
|
297
|
+
"\nmodule %s: Local=%s, is up to date",
|
|
298
|
+
scriptVer.scriptType,
|
|
299
|
+
scriptVer.scriptVersion
|
|
300
|
+
);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
//console.log(scriptsRemote);
|
|
164
304
|
}
|
|
165
305
|
}
|
|
166
306
|
|
|
@@ -250,10 +390,20 @@ async function manuallyRunScripts() {
|
|
|
250
390
|
async function printHelp() {
|
|
251
391
|
console.log("Actions available for data-gathering-scripts:");
|
|
252
392
|
console.log();
|
|
393
|
+
console.log(
|
|
394
|
+
"list-available",
|
|
395
|
+
"Lists all script types and versions available for download"
|
|
396
|
+
);
|
|
397
|
+
console.log("Parameters:");
|
|
398
|
+
console.log("--company [company_slug]");
|
|
399
|
+
console.log("--quiet does not generate output on stdout");
|
|
400
|
+
console.log();
|
|
253
401
|
console.log(
|
|
254
402
|
"list-local",
|
|
255
403
|
"Lists all locally downloaded script types and versions"
|
|
256
404
|
);
|
|
405
|
+
console.log("Parameters:");
|
|
406
|
+
console.log("--quiet does not generate output on stdout");
|
|
257
407
|
console.log();
|
|
258
408
|
console.log(
|
|
259
409
|
"download-scripts",
|
|
@@ -270,9 +420,10 @@ async function printHelp() {
|
|
|
270
420
|
console.log();
|
|
271
421
|
console.log(
|
|
272
422
|
"check-script-updates",
|
|
273
|
-
"Checks
|
|
423
|
+
"Checks local script version against the latest published version for the passed script type, or all locally downloaded script types if none specified"
|
|
274
424
|
);
|
|
275
425
|
console.log("Parameters:");
|
|
426
|
+
console.log("--auto-update automatically downloads any needed updates");
|
|
276
427
|
console.log("--company [company_slug]");
|
|
277
428
|
console.log(
|
|
278
429
|
"--script-type ['oracle-compliance', 'oracle-features', 'vsphere', 'msql-license', 'msql-compliance']"
|
|
@@ -301,8 +452,10 @@ const dataGatheringScriptsModule = (action, ...args) => {
|
|
|
301
452
|
return downloadScripts(args);
|
|
302
453
|
case "check-script-updates":
|
|
303
454
|
return checkScriptUpdates(args);
|
|
455
|
+
case "list-available":
|
|
456
|
+
return listAvailableScripts(args);
|
|
304
457
|
case "list-local":
|
|
305
|
-
return listLocalScripts();
|
|
458
|
+
return listLocalScripts(args);
|
|
306
459
|
case "manually-run-scripts":
|
|
307
460
|
return manuallyRunScripts();
|
|
308
461
|
case "help":
|
|
@@ -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 "--
|
|
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 = {
|
|
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 "--
|
|
431
|
-
optionalParams.
|
|
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 "--
|
|
515
|
-
callParams.
|
|
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] === "--
|
|
557
|
-
callParams.
|
|
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
|
-
"
|
|
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("--
|
|
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("--
|
|
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("--
|
|
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.
|
|
3
|
+
"version": "1.0.24",
|
|
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.
|
|
18
|
+
"@opscompass/opscompass-api": "^1.0.24",
|
|
19
19
|
"adm-zip": "^0.5.9",
|
|
20
20
|
"axios": "^0.21.1",
|
|
21
21
|
"fs-extra": "^10.1.0",
|