@opscompass/opscompass-cli 1.0.41 → 1.0.42
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/environment/current.js +2 -0
- package/environment/demo.js +2 -0
- package/environment/dev.js +2 -0
- package/environment/local.js +2 -0
- package/environment/production.js +2 -0
- package/index.js +1 -0
- package/lib/consts.js +1 -0
- package/lib/maskValues.js +7 -7
- package/lib/utils.js +168 -47
- package/modules/compliance.js +24 -0
- package/modules/defaults.js +1 -1
- package/modules/license-manager/maskedConfig.js +114 -0
- package/modules/license-manager/microsoft.js +862 -0
- package/modules/license-manager/nutanix.js +285 -0
- package/modules/license-manager/vcenter.js +281 -0
- package/modules/license-manager.js +211 -1243
- package/opscompass.js +14 -1
- package/package.json +2 -2
|
@@ -0,0 +1,862 @@
|
|
|
1
|
+
const { getOpsCompassClient } = require("../../opscompass.js");
|
|
2
|
+
const { utilsModule: utils } = require("../../lib/utils.js");
|
|
3
|
+
const maskValues = require("../../lib/maskValues.js");
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @module license-manager:microsoft
|
|
7
|
+
* @description License Manager Microsoft module for OpsCompass CLI
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
const { createMaskedConfig, updateMaskedConfig } = require("./maskedConfig.js");
|
|
11
|
+
|
|
12
|
+
async function deleteMssqlEntitlements(args) {
|
|
13
|
+
args = setArgumentArrays(["--id"], args);
|
|
14
|
+
|
|
15
|
+
let recordIds = undefined;
|
|
16
|
+
for (let i = 0; i < args.length - 1; i++) {
|
|
17
|
+
switch (args[i].toLowerCase()) {
|
|
18
|
+
case "--id":
|
|
19
|
+
recordIds = args[++i];
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const client = await getOpsCompassClient();
|
|
25
|
+
const response = await client.licenseManager.mssql.deleteMssqlEntitlements(
|
|
26
|
+
global.company,
|
|
27
|
+
recordIds
|
|
28
|
+
);
|
|
29
|
+
console.log(JSON.stringify(response, null, 2));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async function createMssqlEntitlement(args) {
|
|
33
|
+
let newRecord = {
|
|
34
|
+
purchaseDate: undefined,
|
|
35
|
+
quantity: undefined,
|
|
36
|
+
supportStart: undefined,
|
|
37
|
+
supportEnd: undefined,
|
|
38
|
+
msqlProduct: undefined,
|
|
39
|
+
msqlEdition: undefined,
|
|
40
|
+
msqlVersion: undefined,
|
|
41
|
+
msqlMetric: undefined,
|
|
42
|
+
};
|
|
43
|
+
for (let i = 0; i < args.length - 1; i++) {
|
|
44
|
+
switch (args[i].toLowerCase()) {
|
|
45
|
+
case "--purchase-date":
|
|
46
|
+
case "--purchasedate":
|
|
47
|
+
newRecord.purchaseDate = args[++i];
|
|
48
|
+
break;
|
|
49
|
+
case "--quantity":
|
|
50
|
+
newRecord.quantity = args[++i];
|
|
51
|
+
break;
|
|
52
|
+
case "--support-start":
|
|
53
|
+
case "--supportstart":
|
|
54
|
+
newRecord.supportStart = args[++i];
|
|
55
|
+
break;
|
|
56
|
+
case "--support-end":
|
|
57
|
+
case "--supportend":
|
|
58
|
+
newRecord.supportEnd = args[++i];
|
|
59
|
+
break;
|
|
60
|
+
case "--mssql-product":
|
|
61
|
+
case "--mssqlproduct":
|
|
62
|
+
newRecord.msqlProduct = args[++i];
|
|
63
|
+
break;
|
|
64
|
+
case "--mssql-edition":
|
|
65
|
+
case "--mssqledition":
|
|
66
|
+
newRecord.msqlEdition = args[++i];
|
|
67
|
+
break;
|
|
68
|
+
case "--mssql-version":
|
|
69
|
+
case "--mssqlversion":
|
|
70
|
+
newRecord.msqlVersion = args[++i];
|
|
71
|
+
break;
|
|
72
|
+
case "--mssql-metric":
|
|
73
|
+
case "--mssqlmetric":
|
|
74
|
+
newRecord.msqlMetric = args[++i];
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const client = await getOpsCompassClient();
|
|
80
|
+
const response = await client.licenseManager.mssql.createMssqlEntitlements(
|
|
81
|
+
global.company,
|
|
82
|
+
[newRecord]
|
|
83
|
+
);
|
|
84
|
+
console.log(JSON.stringify(response, null, 2));
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
async function updateMssqlEntitlement(args) {
|
|
88
|
+
let updateRecord = {
|
|
89
|
+
id: undefined,
|
|
90
|
+
purchaseDate: undefined,
|
|
91
|
+
quantity: undefined,
|
|
92
|
+
supportStart: undefined,
|
|
93
|
+
supportEnd: undefined,
|
|
94
|
+
msqlProduct: undefined,
|
|
95
|
+
msqlEdition: undefined,
|
|
96
|
+
msqlVersion: undefined,
|
|
97
|
+
msqlMetric: undefined,
|
|
98
|
+
};
|
|
99
|
+
for (let i = 0; i < args.length - 1; i++) {
|
|
100
|
+
switch (args[i].toLowerCase()) {
|
|
101
|
+
case "--id":
|
|
102
|
+
updateRecord.id = args[++i];
|
|
103
|
+
break;
|
|
104
|
+
case "--purchase-date":
|
|
105
|
+
case "--purchasedate":
|
|
106
|
+
updateRecord.purchaseDate = args[++i];
|
|
107
|
+
break;
|
|
108
|
+
case "--quantity":
|
|
109
|
+
updateRecord.quantity = args[++i];
|
|
110
|
+
break;
|
|
111
|
+
case "--support-start":
|
|
112
|
+
case "--supportstart":
|
|
113
|
+
updateRecord.supportStart = args[++i];
|
|
114
|
+
break;
|
|
115
|
+
case "--support-end":
|
|
116
|
+
case "--supportend":
|
|
117
|
+
updateRecord.supportEnd = args[++i];
|
|
118
|
+
break;
|
|
119
|
+
case "--mssql-product":
|
|
120
|
+
case "--mssqlproduct":
|
|
121
|
+
updateRecord.msqlProduct = args[++i];
|
|
122
|
+
break;
|
|
123
|
+
case "--mssql-edition":
|
|
124
|
+
case "--mssqledition":
|
|
125
|
+
updateRecord.msqlEdition = args[++i];
|
|
126
|
+
break;
|
|
127
|
+
case "--mssql-version":
|
|
128
|
+
case "--mssqlversion":
|
|
129
|
+
updateRecord.msqlVersion = args[++i];
|
|
130
|
+
break;
|
|
131
|
+
case "--mssql-metric":
|
|
132
|
+
case "--mssqlmetric":
|
|
133
|
+
updateRecord.msqlMetric = args[++i];
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
const client = await getOpsCompassClient();
|
|
138
|
+
const response = await client.licenseManager.mssql.updateMssqlEntitlements(
|
|
139
|
+
global.company,
|
|
140
|
+
[updateRecord]
|
|
141
|
+
);
|
|
142
|
+
console.log(JSON.stringify(response, null, 2));
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
async function getMssqlEntitlements(args) {
|
|
146
|
+
const client = await getOpsCompassClient();
|
|
147
|
+
const mssqlEntitlements =
|
|
148
|
+
await client.licenseManager.mssql.getMssqlEntitlements(global.company);
|
|
149
|
+
|
|
150
|
+
console.log(JSON.stringify(mssqlEntitlements, null, 2));
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
async function getMssqlEntitlementComponents(args) {
|
|
154
|
+
const client = await getOpsCompassClient();
|
|
155
|
+
const entitlementComponents =
|
|
156
|
+
await client.licenseManager.mssql.getMssqlEntitlementComponents(
|
|
157
|
+
global.company
|
|
158
|
+
);
|
|
159
|
+
console.log(JSON.stringify(entitlementComponents, null, 2));
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
async function listMssqlAssessments(args) {
|
|
163
|
+
const client = await getOpsCompassClient();
|
|
164
|
+
const response = await client.licenseManager.mssql.listMssqlAssessments(
|
|
165
|
+
global.company
|
|
166
|
+
);
|
|
167
|
+
|
|
168
|
+
console.log(JSON.stringify(response, null, 2));
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
async function getMssqlAssessment(args) {
|
|
172
|
+
let assessmentId = undefined;
|
|
173
|
+
for (let i = 0; i < args.length - 1; i++) {
|
|
174
|
+
switch (args[i].toLowerCase()) {
|
|
175
|
+
case "--assessmentId":
|
|
176
|
+
case "--id":
|
|
177
|
+
case "--assessmentid":
|
|
178
|
+
assessmentId = args[++i];
|
|
179
|
+
break;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const client = await getOpsCompassClient();
|
|
184
|
+
const response = await client.licenseManager.mssql.getMssqlAssessment(
|
|
185
|
+
assessmentId
|
|
186
|
+
);
|
|
187
|
+
|
|
188
|
+
console.log(JSON.stringify(response, null, 2));
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
async function getMssqlAssessmentEntitlements(args) {
|
|
192
|
+
let assessmentId = undefined;
|
|
193
|
+
for (let i = 0; i < args.length - 1; i++) {
|
|
194
|
+
switch (args[i].toLowerCase()) {
|
|
195
|
+
case "--assessmentId":
|
|
196
|
+
case "--id":
|
|
197
|
+
case "--assessmentid":
|
|
198
|
+
assessmentId = args[++i];
|
|
199
|
+
break;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
const client = await getOpsCompassClient();
|
|
204
|
+
const response =
|
|
205
|
+
await client.licenseManager.mssql.getMssqlAssessmentEntitlements(
|
|
206
|
+
assessmentId
|
|
207
|
+
);
|
|
208
|
+
|
|
209
|
+
console.log(JSON.stringify(response, null, 2));
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
async function getMssqlAssessmentLicenseUsageMaps(args) {
|
|
213
|
+
let assessmentId = undefined;
|
|
214
|
+
for (let i = 0; i < args.length - 1; i++) {
|
|
215
|
+
switch (args[i].toLowerCase()) {
|
|
216
|
+
case "--assessmentId":
|
|
217
|
+
case "--id":
|
|
218
|
+
case "--assessmentid":
|
|
219
|
+
assessmentId = args[++i];
|
|
220
|
+
break;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
const client = await getOpsCompassClient();
|
|
225
|
+
const response =
|
|
226
|
+
await client.licenseManager.mssql.getMssqlAssessmentLicenseUsageMaps(
|
|
227
|
+
assessmentId
|
|
228
|
+
);
|
|
229
|
+
|
|
230
|
+
console.log(JSON.stringify(response, null, 2));
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
async function getMssqlAssessmentResources(args) {
|
|
234
|
+
let assessmentId = undefined;
|
|
235
|
+
for (let i = 0; i < args.length - 1; i++) {
|
|
236
|
+
switch (args[i].toLowerCase()) {
|
|
237
|
+
case "--assessmentId":
|
|
238
|
+
case "--id":
|
|
239
|
+
case "--assessmentid":
|
|
240
|
+
assessmentId = args[++i];
|
|
241
|
+
break;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
const client = await getOpsCompassClient();
|
|
246
|
+
const response =
|
|
247
|
+
await client.licenseManager.mssql.getMssqlAssessmentResources(assessmentId);
|
|
248
|
+
|
|
249
|
+
console.log(JSON.stringify(response, null, 2));
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
async function checkMssqlConfigMetadata(args) {
|
|
253
|
+
for (let i = 0; i < args.length - 1; i++) {
|
|
254
|
+
switch (args[i].toLowerCase()) {
|
|
255
|
+
case "--account-id":
|
|
256
|
+
case "--accountid":
|
|
257
|
+
callParams.accountId = args[++i];
|
|
258
|
+
break;
|
|
259
|
+
case "--last-collected-before":
|
|
260
|
+
case "--lastcollectedbefore":
|
|
261
|
+
callParams.lastCollectedBefore = args[++i];
|
|
262
|
+
break;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
const client = await getOpsCompassClient();
|
|
267
|
+
const response = await client.licenseManager.mssql.checkMssqlConfigMetadata(
|
|
268
|
+
callParams.accountId,
|
|
269
|
+
global.company,
|
|
270
|
+
callParams.lastCollectedBefore
|
|
271
|
+
);
|
|
272
|
+
console.log(JSON.stringify(response, null, 2));
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
async function getMssqlDefaultCredential(args) {
|
|
276
|
+
const client = await getOpsCompassClient();
|
|
277
|
+
const getResponse =
|
|
278
|
+
await client.licenseManager.mssql.getMssqlDefaultCredential(
|
|
279
|
+
global.monitoringConfig
|
|
280
|
+
);
|
|
281
|
+
|
|
282
|
+
console.log(JSON.stringify(getResponse, null, 2));
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
async function createMssqlSharedCredential(args) {
|
|
286
|
+
let optionalParams = {};
|
|
287
|
+
for (let i = 0; i < args.length - 1; i++) {
|
|
288
|
+
switch (args[i].toLowerCase()) {
|
|
289
|
+
case "--user":
|
|
290
|
+
optionalParams.user = args[++i];
|
|
291
|
+
break;
|
|
292
|
+
case "--password":
|
|
293
|
+
optionalParams.password = args[++i];
|
|
294
|
+
break;
|
|
295
|
+
case "--credential-name":
|
|
296
|
+
case "--credentialname":
|
|
297
|
+
optionalParams.credentialName = args[++i];
|
|
298
|
+
break;
|
|
299
|
+
case "--directory-auth":
|
|
300
|
+
optionalParams.directory_auth = args[++i];
|
|
301
|
+
break;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
try {
|
|
306
|
+
const client = await getOpsCompassClient();
|
|
307
|
+
const createResponse =
|
|
308
|
+
await client.licenseManager.mssql.createMssqlSharedCredential(
|
|
309
|
+
global.monitoringConfig,
|
|
310
|
+
optionalParams
|
|
311
|
+
);
|
|
312
|
+
|
|
313
|
+
console.log(JSON.stringify(createResponse, null, 2));
|
|
314
|
+
} catch (err) {
|
|
315
|
+
console.error(JSON.stringify(err.message, null, 2));
|
|
316
|
+
console.error("It is likely the default credential already exists\n");
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
async function deleteMssqlSharedCredential(args) {
|
|
321
|
+
let id = undefined;
|
|
322
|
+
for (let i = 0; i < args.length - 1; i++) {
|
|
323
|
+
switch (args[i].toLowerCase()) {
|
|
324
|
+
case "--id":
|
|
325
|
+
id = args[++i];
|
|
326
|
+
break;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
const client = await getOpsCompassClient();
|
|
331
|
+
const deleteResponse =
|
|
332
|
+
await client.licenseManager.mssql.deleteMssqlSharedCredential(id);
|
|
333
|
+
|
|
334
|
+
console.log(JSON.stringify(deleteResponse, null, 2));
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
async function updateMssqlSharedCredential(args) {
|
|
338
|
+
let id = undefined;
|
|
339
|
+
let optionalParams = {};
|
|
340
|
+
for (let i = 0; i < args.length - 1; i++) {
|
|
341
|
+
switch (args[i].toLowerCase()) {
|
|
342
|
+
case "--id":
|
|
343
|
+
id = args[++i];
|
|
344
|
+
break;
|
|
345
|
+
case "--user":
|
|
346
|
+
optionalParams.user = args[++i];
|
|
347
|
+
break;
|
|
348
|
+
case "--password":
|
|
349
|
+
optionalParams.password = args[++i];
|
|
350
|
+
break;
|
|
351
|
+
case "--credential-name":
|
|
352
|
+
case "--credentialname":
|
|
353
|
+
optionalParams.credentialName = args[++i];
|
|
354
|
+
break;
|
|
355
|
+
case "--directory-auth":
|
|
356
|
+
optionalParams.directory_auth = args[++i];
|
|
357
|
+
break;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
const client = await getOpsCompassClient();
|
|
361
|
+
const updateResponse =
|
|
362
|
+
await client.licenseManager.mssql.updateMssqlSharedCredential(
|
|
363
|
+
id,
|
|
364
|
+
optionalParams
|
|
365
|
+
);
|
|
366
|
+
|
|
367
|
+
console.log(JSON.stringify(updateResponse, null, 2));
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
async function deleteMssqlConfiguration(args) {
|
|
371
|
+
let id = undefined;
|
|
372
|
+
for (let i = 0; i < args.length - 1; i++) {
|
|
373
|
+
switch (args[i].toLowerCase()) {
|
|
374
|
+
case "--id":
|
|
375
|
+
id = args[++i];
|
|
376
|
+
break;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
const client = await getOpsCompassClient();
|
|
381
|
+
const response = await client.licenseManager.mssql.deleteMssqlConfiguration(
|
|
382
|
+
id
|
|
383
|
+
);
|
|
384
|
+
|
|
385
|
+
console.log(JSON.stringify(response, null, 2));
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
async function listMssqlConfigurations(args) {
|
|
389
|
+
const client = await getOpsCompassClient();
|
|
390
|
+
const listMssqlConfigs =
|
|
391
|
+
await client.licenseManager.mssql.listMssqlConfigurations(
|
|
392
|
+
global.monitoringConfig
|
|
393
|
+
);
|
|
394
|
+
|
|
395
|
+
console.log(JSON.stringify(listMssqlConfigs, null, 2));
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
async function createMssqlConfiguration(args) {
|
|
399
|
+
let configurationName = undefined;
|
|
400
|
+
let optionalParams = {
|
|
401
|
+
actions: undefined,
|
|
402
|
+
server: undefined,
|
|
403
|
+
user: undefined,
|
|
404
|
+
password: undefined,
|
|
405
|
+
directory_auth: undefined,
|
|
406
|
+
};
|
|
407
|
+
|
|
408
|
+
for (let i = 0; i < args.length - 1; i++) {
|
|
409
|
+
switch (args[i].toLowerCase()) {
|
|
410
|
+
case "--name":
|
|
411
|
+
case "--configuration-name":
|
|
412
|
+
case "--configurationname":
|
|
413
|
+
configurationName = args[++i];
|
|
414
|
+
break;
|
|
415
|
+
case "--action":
|
|
416
|
+
if (optionalParams.actions === undefined) optionalParams.actions = [];
|
|
417
|
+
optionalParams.actions.push(args[++i]);
|
|
418
|
+
break;
|
|
419
|
+
case "--server":
|
|
420
|
+
optionalParams.server = args[++i];
|
|
421
|
+
break;
|
|
422
|
+
case "--user":
|
|
423
|
+
optionalParams.user = args[++i];
|
|
424
|
+
break;
|
|
425
|
+
case "--password":
|
|
426
|
+
optionalParams.password = args[++i];
|
|
427
|
+
break;
|
|
428
|
+
case "--directory-auth":
|
|
429
|
+
authArg = args[++i];
|
|
430
|
+
if (authArg.toLowerCase === "null") {
|
|
431
|
+
optionalParams.directory_auth = null;
|
|
432
|
+
} else {
|
|
433
|
+
optionalParams.directory_auth = "SESSION";
|
|
434
|
+
}
|
|
435
|
+
break;
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
const msqlConfiguration = await createMaskedConfig(
|
|
440
|
+
arguments.callee.name,
|
|
441
|
+
configurationName,
|
|
442
|
+
optionalParams
|
|
443
|
+
);
|
|
444
|
+
console.log(JSON.stringify(msqlConfiguration, null, 2));
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
async function getMssqlConfiguration(args) {
|
|
448
|
+
let id = undefined;
|
|
449
|
+
for (let i = 0; i < args.length - 1; i++) {
|
|
450
|
+
switch (args[i].toLowerCase()) {
|
|
451
|
+
case "--id":
|
|
452
|
+
id = args[++i];
|
|
453
|
+
break;
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
const client = await getOpsCompassClient();
|
|
458
|
+
const getMssqlConfig =
|
|
459
|
+
await client.licenseManager.mssql.getMssqlConfiguration(id);
|
|
460
|
+
|
|
461
|
+
console.log(JSON.stringify(getMssqlConfig, null, 2));
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
async function updateMssqlConfiguration(args) {
|
|
465
|
+
for (let i = 0; i < args.length - 1; i++) {
|
|
466
|
+
switch (args[i].toLowerCase()) {
|
|
467
|
+
case "--id":
|
|
468
|
+
callParams.id = args[++i];
|
|
469
|
+
break;
|
|
470
|
+
case "--name":
|
|
471
|
+
case "--configurationname":
|
|
472
|
+
case "--configuration-name":
|
|
473
|
+
callParams.configurationName = args[++i];
|
|
474
|
+
break;
|
|
475
|
+
case "--action":
|
|
476
|
+
if (callParams.actions === undefined) callParams.actions = [];
|
|
477
|
+
callParams.actions.push(args[++i]);
|
|
478
|
+
break;
|
|
479
|
+
case "--server":
|
|
480
|
+
callParams.server = args[++i];
|
|
481
|
+
break;
|
|
482
|
+
case "--user":
|
|
483
|
+
callParams.user = args[++i];
|
|
484
|
+
break;
|
|
485
|
+
case "--password":
|
|
486
|
+
callParams.password = args[++i];
|
|
487
|
+
break;
|
|
488
|
+
case "--directory-auth":
|
|
489
|
+
authArg = args[++i];
|
|
490
|
+
if (authArg.toLowerCase === "null") {
|
|
491
|
+
callParams.directory_auth = null;
|
|
492
|
+
} else {
|
|
493
|
+
callParams.directory_auth = "SESSION";
|
|
494
|
+
}
|
|
495
|
+
break;
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
const msqlConfiguration = await updateMaskedConfig(
|
|
500
|
+
arguments.callee.name,
|
|
501
|
+
callParams.id,
|
|
502
|
+
callParams
|
|
503
|
+
);
|
|
504
|
+
console.log(JSON.stringify(msqlConfiguration, null, 2));
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
async function updateMssqlConfigurations(args) {
|
|
508
|
+
let callParamsArray = [];
|
|
509
|
+
let jsonIndex = args.indexOf("--json-updates");
|
|
510
|
+
let idIndex = args.indexOf("--id");
|
|
511
|
+
let callParams = {};
|
|
512
|
+
|
|
513
|
+
/* Process bulk update with JSON */
|
|
514
|
+
if (jsonIndex !== -1) {
|
|
515
|
+
const jsonString = args[jsonIndex + 1] || (await utils.readFromStdinSync());
|
|
516
|
+
if (!jsonString) {
|
|
517
|
+
if (process.stdin.isTTY) {
|
|
518
|
+
console.error(
|
|
519
|
+
"No JSON Microsoft DB string provided as argument or stdin"
|
|
520
|
+
);
|
|
521
|
+
return console.log("");
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
callParamsArray = utils.parseConfigurationJson(jsonString);
|
|
525
|
+
/* If no '--json-updates' flag, process bulk update with parameter flags (e.g. --id, --name, etc.) */
|
|
526
|
+
} else if (idIndex !== -1) {
|
|
527
|
+
for (let i = 0; i < args.length - 1; i++) {
|
|
528
|
+
if (args[i] === "--id") {
|
|
529
|
+
/* Reset callParams object when a second id is encountered */
|
|
530
|
+
callParams = {};
|
|
531
|
+
/* if theres an existing callParams object, toss it into the array and move on. */
|
|
532
|
+
callParamsArray.push(callParams);
|
|
533
|
+
/* Create the object's properties based on the index (e.g. if the index is --id, you'll find the value at the next index */
|
|
534
|
+
callParams.id = args[i + 1];
|
|
535
|
+
} else if (
|
|
536
|
+
args[i].toLowerCase() === "--configurationname" ||
|
|
537
|
+
args[i].toLowerCase() === "--configuration-name" ||
|
|
538
|
+
args[i].toLowerCase() === "--name"
|
|
539
|
+
) {
|
|
540
|
+
callParams.configurationName = args[i + 1];
|
|
541
|
+
} else if (args[i].toLowerCase() === "--action") {
|
|
542
|
+
if (callParams.actions === undefined) callParams.actions = [];
|
|
543
|
+
callParams.actions.push(args[i + 1]);
|
|
544
|
+
} else if (args[i].toLowerCase() === "--server") {
|
|
545
|
+
callParams.server = args[i + 1];
|
|
546
|
+
} else if (args[i].toLowerCase() === "--user") {
|
|
547
|
+
callParams.user = args[i + 1];
|
|
548
|
+
} else if (args[i].toLowerCase() === "--password") {
|
|
549
|
+
callParams.password = args[i + 1];
|
|
550
|
+
} else if (args[i].toLowerCase() === "--directory-auth") {
|
|
551
|
+
authArg = args[i + 1];
|
|
552
|
+
if (authArg.toLowerCase === "null") {
|
|
553
|
+
callParams.directory_auth = null;
|
|
554
|
+
} else {
|
|
555
|
+
callParams.directory_auth = "SESSION";
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
} else {
|
|
560
|
+
console.warn("Invalid input, please see help for examples.");
|
|
561
|
+
return console.log("");
|
|
562
|
+
}
|
|
563
|
+
// In case the cut/paste from an local config with values hashed
|
|
564
|
+
utils.decryptValues(callParamsArray);
|
|
565
|
+
|
|
566
|
+
// If the callParamsArray is empty, we have nothing to mask
|
|
567
|
+
if (!callParamsArray) {
|
|
568
|
+
console.warn("No Microsoft database configurations provided to update.");
|
|
569
|
+
return console.log("");
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
// Here we need to mask the callParamsArray object
|
|
573
|
+
await maskValues.maskObjValues(callParamsArray);
|
|
574
|
+
|
|
575
|
+
/* Call the API and print to console */
|
|
576
|
+
const client = await getOpsCompassClient();
|
|
577
|
+
const msqlConfigurations =
|
|
578
|
+
await client.licenseManager.mssql.updateMssqlConfigurations(
|
|
579
|
+
callParamsArray
|
|
580
|
+
);
|
|
581
|
+
console.log(JSON.stringify(msqlConfigurations, null, 2));
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
async function printMssqlHelp() {
|
|
585
|
+
console.log(
|
|
586
|
+
"create-mssql-shared-credential",
|
|
587
|
+
"Creates MS SQL shared credentials"
|
|
588
|
+
);
|
|
589
|
+
console.log(
|
|
590
|
+
"--monitoring-configuration-id monitoring configuration ID to make the shared credentials for"
|
|
591
|
+
);
|
|
592
|
+
console.log("--user (optional) [string]");
|
|
593
|
+
console.log("--password (optional) [string]");
|
|
594
|
+
console.log("--directory-auth (optional) 'SESSION' | null");
|
|
595
|
+
console.log();
|
|
596
|
+
console.log(
|
|
597
|
+
"delete-mssql-shared-credential",
|
|
598
|
+
"Delete a MS SQL shared credential"
|
|
599
|
+
);
|
|
600
|
+
console.log("--id ID of the mssql shared credential to delete");
|
|
601
|
+
console.log();
|
|
602
|
+
console.log(
|
|
603
|
+
"get-mssql-default-credential",
|
|
604
|
+
"Get MS SQL default credential record"
|
|
605
|
+
);
|
|
606
|
+
console.log(
|
|
607
|
+
"--monitoring-configuration-id monitoring configuration ID to get the default credentials for"
|
|
608
|
+
);
|
|
609
|
+
console.log();
|
|
610
|
+
console.log(
|
|
611
|
+
"update-mssql-shared-credential",
|
|
612
|
+
"Update MS SQL shared credential record"
|
|
613
|
+
);
|
|
614
|
+
console.log("--id ID of the mssql shared credential to update");
|
|
615
|
+
console.log("--user (optional) [string]");
|
|
616
|
+
console.log("--password (optional) [string]");
|
|
617
|
+
console.log("--directory-auth (optional) 'SESSION' | null");
|
|
618
|
+
console.log();
|
|
619
|
+
console.log(
|
|
620
|
+
"list-mssql-configurations",
|
|
621
|
+
"Lists all of the mssql configurations associated with the given monitoring configuration"
|
|
622
|
+
);
|
|
623
|
+
console.log("Parameters:");
|
|
624
|
+
console.log("--monitoring-configuration-id [monitoring_configuration_id]");
|
|
625
|
+
console.log();
|
|
626
|
+
console.log(
|
|
627
|
+
"create-mssql-configuration",
|
|
628
|
+
"Create a single mssql configuration associated with the given monitoring configuration."
|
|
629
|
+
);
|
|
630
|
+
console.log("Parameters:");
|
|
631
|
+
console.log("--monitoring-configuration-id [monitoring_configuration_id]");
|
|
632
|
+
console.log("--name or --configuration-name [unique name]");
|
|
633
|
+
console.log(
|
|
634
|
+
`--action (optional) pass multiple times to define which actions this configuration can take e.g. --action "skip" --action "dbcompliance"`
|
|
635
|
+
);
|
|
636
|
+
console.log("--server (optional) [the hostname or ip address]");
|
|
637
|
+
console.log("--user (optional) [server username]");
|
|
638
|
+
console.log("--password (optional) [server password]");
|
|
639
|
+
console.log("--directory-auth (optional) ['SESSION' or NULL]");
|
|
640
|
+
console.log();
|
|
641
|
+
console.log(
|
|
642
|
+
"get-mssql-configuration",
|
|
643
|
+
"Get a single mssql configuration associated with the given monitoring configuration"
|
|
644
|
+
);
|
|
645
|
+
console.log("Parameters:");
|
|
646
|
+
console.log("--id [mssql_configuration_id]");
|
|
647
|
+
console.log();
|
|
648
|
+
console.log(
|
|
649
|
+
"create-oracle-database-configuration",
|
|
650
|
+
"Create a single oracle database configuration associated with the given monitoring configuration."
|
|
651
|
+
);
|
|
652
|
+
console.log("Parameters:");
|
|
653
|
+
console.log("--monitoring-configuration-id [monitoring_configuration_id]");
|
|
654
|
+
console.log("--configuration-name [unique name]");
|
|
655
|
+
console.log(
|
|
656
|
+
`--action (optional) pass multiple times to define which actions this configuration can take e.g. --action "skip" --action "dbcompliance"`
|
|
657
|
+
);
|
|
658
|
+
console.log("--user (optional) [user to use for connection]");
|
|
659
|
+
console.log("--password (optional) [password to use for connection]");
|
|
660
|
+
console.log("--server (optional) [server to use for connection]");
|
|
661
|
+
console.log();
|
|
662
|
+
console.log("delete-mssql-configuration", "Delete a mssql configuration");
|
|
663
|
+
console.log("Parameters:");
|
|
664
|
+
console.log("--id [mssql_configuration_id]");
|
|
665
|
+
console.log();
|
|
666
|
+
console.log(
|
|
667
|
+
"update-mssql-configuration",
|
|
668
|
+
"Update a single mssql configuration."
|
|
669
|
+
);
|
|
670
|
+
console.log("Parameters:");
|
|
671
|
+
console.log("--id [configuration id]");
|
|
672
|
+
console.log("--name or --configuration-name (optional) [unique name]");
|
|
673
|
+
console.log(
|
|
674
|
+
"--action (optional) pass multiple times to define which actions this configuration can take e.g. --action 'skip' --action 'dblicensing'"
|
|
675
|
+
);
|
|
676
|
+
console.log("--server (optional) [the server]");
|
|
677
|
+
console.log("--user (optional) [server username]");
|
|
678
|
+
console.log("--password (optional) [server password]");
|
|
679
|
+
console.log("--directory-auth (optional) ['SESSION' or NULL]");
|
|
680
|
+
console.log();
|
|
681
|
+
console.log();
|
|
682
|
+
console.log(
|
|
683
|
+
"update-mssql-configurations",
|
|
684
|
+
"Bulk Update MS SQL Configurations."
|
|
685
|
+
);
|
|
686
|
+
console.log("Parameters:");
|
|
687
|
+
console.log("--id [configuration id]");
|
|
688
|
+
console.log("--name or --configuration-name (optional) [unique name]");
|
|
689
|
+
console.log(
|
|
690
|
+
"--action (optional) pass multiple times to define which actions this configuration can take e.g. --action 'skip' --action 'dblicensing'"
|
|
691
|
+
);
|
|
692
|
+
console.log("--server (optional) [the server]");
|
|
693
|
+
console.log("--user (optional) [server username]");
|
|
694
|
+
console.log("--password (optional) [server password]");
|
|
695
|
+
console.log("--directory-auth (optional) ['SESSION' or NULL]");
|
|
696
|
+
console.log("OR --json-updates [stringified json objects with your updates]");
|
|
697
|
+
console.log("For quick updates, you may use the above parameters");
|
|
698
|
+
console.log(
|
|
699
|
+
`e.g. opscompass license-manager update-mssql-configurations --id 31 --name "newname" --server "233.533.343" --user "joe" --action "skip" --id 25 --name "secondname" --action "skip" --action "dblicensing"`
|
|
700
|
+
);
|
|
701
|
+
console.log(
|
|
702
|
+
"For larger updates, JavaScript Object Notation (JSON) may be used with the --json-updates flag"
|
|
703
|
+
);
|
|
704
|
+
console.log(
|
|
705
|
+
`e.g. opscompass license-manager update-mssql-configurations --json-updates '[{\"id\":\"25\",\"configurationName\":\"25\", \"server\":\"100.232.2423\", \"user\":\"tony\", \"actions\":[\"skip\", \"dblicensing\"]}, {\"id\":\"31\",\"configurationName\":\"31\", \"server\":\"100.232.2423\", \"user\":\"tony\", \"actions\":[\"skip\", \"dblicensing\"]}]'`
|
|
706
|
+
);
|
|
707
|
+
console.log();
|
|
708
|
+
console.log(
|
|
709
|
+
"get-mssql-entitlement-components",
|
|
710
|
+
"Gets the components that can be used to build MSSql entitlement objects."
|
|
711
|
+
);
|
|
712
|
+
console.log("Parameters:");
|
|
713
|
+
console.log(`--company [company_slug] (default: ${global.company})\n`);
|
|
714
|
+
console.log();
|
|
715
|
+
console.log(
|
|
716
|
+
"create-mssql-entitlement",
|
|
717
|
+
"Creates a Mssql Entitlement record."
|
|
718
|
+
);
|
|
719
|
+
console.log("Parameters:");
|
|
720
|
+
console.log(`--company [company_slug] (default: ${global.company})\n`);
|
|
721
|
+
console.log("--purchase-date [Date] the date of purchase.");
|
|
722
|
+
console.log(
|
|
723
|
+
"Format: UTC, example: '2022-08-23T17:00:00Z' to set August 8th, 2022 at 17:00 UTC."
|
|
724
|
+
);
|
|
725
|
+
console.log("--quantity [number] the number for this entry");
|
|
726
|
+
console.log(
|
|
727
|
+
"--support-start (optional) [Date] the date when support started"
|
|
728
|
+
);
|
|
729
|
+
console.log(
|
|
730
|
+
"Format: UTC, example: '2022-08-23T17:00:00Z' to set August 8th, 2022 at 17:00 UTC."
|
|
731
|
+
);
|
|
732
|
+
console.log("--support-end (optional) [Date] the date when support ended");
|
|
733
|
+
console.log(
|
|
734
|
+
"Format: UTC, example: '2022-08-23T17:00:00Z' to set August 8th, 2022 at 17:00 UTC."
|
|
735
|
+
);
|
|
736
|
+
console.log(
|
|
737
|
+
"--mssql-product [string] the slug of the associated mssql product"
|
|
738
|
+
);
|
|
739
|
+
console.log(
|
|
740
|
+
"--mssql-edition [string] the slug of the associated mssql edition"
|
|
741
|
+
);
|
|
742
|
+
console.log(
|
|
743
|
+
"--mssql-version [string] the slug of the associated mssql version"
|
|
744
|
+
);
|
|
745
|
+
console.log(
|
|
746
|
+
"--mssql-metric [string] the slug of the associated mssql metric"
|
|
747
|
+
);
|
|
748
|
+
console.log();
|
|
749
|
+
console.log(
|
|
750
|
+
"update-mssql-entitlement",
|
|
751
|
+
"Creates a Mssql Entitlement record."
|
|
752
|
+
);
|
|
753
|
+
console.log("Parameters:");
|
|
754
|
+
console.log(`--company [company_slug] (default: ${global.company})\n`);
|
|
755
|
+
console.log("--id [number] the mssql entitlement record id");
|
|
756
|
+
console.log("--purchase-date [Date] the date of purchase.");
|
|
757
|
+
console.log(
|
|
758
|
+
"Format: UTC, example: '2022-08-23T17:00:00Z' to set August 8th, 2022 at 17:00 UTC."
|
|
759
|
+
);
|
|
760
|
+
console.log("--quantity [number] the number for this entry");
|
|
761
|
+
console.log(
|
|
762
|
+
"--support-start (optional) [Date] the date when support started"
|
|
763
|
+
);
|
|
764
|
+
console.log(
|
|
765
|
+
"Format: UTC, example: '2022-08-23T17:00:00Z' to set August 8th, 2022 at 17:00 UTC."
|
|
766
|
+
);
|
|
767
|
+
console.log("--support-end (optional) [Date] the date when support ended");
|
|
768
|
+
console.log(
|
|
769
|
+
"Format: UTC, example: '2022-08-23T17:00:00Z' to set August 8th, 2022 at 17:00 UTC."
|
|
770
|
+
);
|
|
771
|
+
console.log(
|
|
772
|
+
"--mssql-product [string] the slug of the associated mssql product"
|
|
773
|
+
);
|
|
774
|
+
console.log(
|
|
775
|
+
"--mssql-edition [string] the slug of the associated mssql edition"
|
|
776
|
+
);
|
|
777
|
+
console.log(
|
|
778
|
+
"--mssql-version [string] the slug of the associated mssql version"
|
|
779
|
+
);
|
|
780
|
+
console.log(
|
|
781
|
+
"--mssql-metric [string] the slug of the associated mssql metric"
|
|
782
|
+
);
|
|
783
|
+
console.log();
|
|
784
|
+
console.log(
|
|
785
|
+
"delete-mssql-entitlements",
|
|
786
|
+
"Deletes Mssql Entitlement records."
|
|
787
|
+
);
|
|
788
|
+
console.log("Parameters:");
|
|
789
|
+
console.log(`--company [company_slug] (default: ${global.company})\n`);
|
|
790
|
+
console.log(
|
|
791
|
+
"--id [string] Use parameter multiple times to delete multiple records."
|
|
792
|
+
);
|
|
793
|
+
console.log();
|
|
794
|
+
console.log("list-mssql-assessments", "Lists MSSQL Assessments");
|
|
795
|
+
console.log("Parameters:");
|
|
796
|
+
console.log(`--company [company_slug] (default: ${global.company})\n`);
|
|
797
|
+
console.log();
|
|
798
|
+
console.log("get-mssql-assessment", "Get Full MSSQL Assessment");
|
|
799
|
+
console.log("Parameters:");
|
|
800
|
+
console.log("--assessmentId [number] The id of the assessment to retrieve.");
|
|
801
|
+
console.log();
|
|
802
|
+
console.log(
|
|
803
|
+
"get-mssql-assessment-entitlements",
|
|
804
|
+
"Gets Entitlements for an MSSQL Assessment"
|
|
805
|
+
);
|
|
806
|
+
console.log("Parameters:");
|
|
807
|
+
console.log("--assessmentId [number] The id of the assessment to retrieve.");
|
|
808
|
+
console.log();
|
|
809
|
+
console.log(
|
|
810
|
+
"(DEPRECATED) get-mssql-assessment-license-usage-maps",
|
|
811
|
+
"Gets LicenseUsageMaps for an MSSQL Assessment"
|
|
812
|
+
);
|
|
813
|
+
console.log("Parameters:");
|
|
814
|
+
console.log("--assessmentId [number] The id of the assessment to retrieve.");
|
|
815
|
+
console.log();
|
|
816
|
+
console.log(
|
|
817
|
+
"(DEPRECATED) get-mssql-assessment-resources",
|
|
818
|
+
"Gets Resources for an MSSQL Assessment"
|
|
819
|
+
);
|
|
820
|
+
console.log("Parameters:");
|
|
821
|
+
console.log("--assessmentId [number] The id of the assessment to retrieve.");
|
|
822
|
+
console.log();
|
|
823
|
+
console.log(
|
|
824
|
+
"check-mssql-config-metadata",
|
|
825
|
+
"Checks the mssql configuration metadata for a company."
|
|
826
|
+
);
|
|
827
|
+
console.log("Parameters:");
|
|
828
|
+
console.log("--accountId [string] The account id for the company.");
|
|
829
|
+
console.log(`--company [company_slug] (default: ${global.company})\n`);
|
|
830
|
+
console.log(
|
|
831
|
+
"--lastCollectedBefore [string] (optional) Only returns records that have not been collected since the given date. Format: UTC, example: '2022-08-23T17:00:00Z'"
|
|
832
|
+
);
|
|
833
|
+
console.log();
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
const licenseManagerMssqlModule = {
|
|
837
|
+
description: "License Manager Microsoft module for OpsCompass CLI",
|
|
838
|
+
requiresLogin: true,
|
|
839
|
+
deleteMssqlEntitlements,
|
|
840
|
+
createMssqlEntitlement,
|
|
841
|
+
updateMssqlEntitlement,
|
|
842
|
+
getMssqlEntitlements,
|
|
843
|
+
getMssqlEntitlementComponents,
|
|
844
|
+
listMssqlAssessments,
|
|
845
|
+
getMssqlAssessment,
|
|
846
|
+
getMssqlAssessmentEntitlements,
|
|
847
|
+
getMssqlAssessmentLicenseUsageMaps,
|
|
848
|
+
getMssqlAssessmentResources,
|
|
849
|
+
checkMssqlConfigMetadata,
|
|
850
|
+
listMssqlConfigurations,
|
|
851
|
+
getMssqlDefaultCredential,
|
|
852
|
+
createMssqlSharedCredential,
|
|
853
|
+
deleteMssqlSharedCredential,
|
|
854
|
+
updateMssqlSharedCredential,
|
|
855
|
+
getMssqlConfiguration,
|
|
856
|
+
createMssqlConfiguration,
|
|
857
|
+
updateMssqlConfiguration,
|
|
858
|
+
updateMssqlConfigurations,
|
|
859
|
+
deleteMssqlConfiguration,
|
|
860
|
+
printMssqlHelp,
|
|
861
|
+
};
|
|
862
|
+
module.exports = licenseManagerMssqlModule;
|