@microsoft/windows-admin-center-sdk 2.154.1 → 2.165.0
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/angular/bundles/microsoft-windows-admin-center-sdk-angular.umd.js +150 -142
- package/angular/bundles/microsoft-windows-admin-center-sdk-angular.umd.js.map +1 -1
- package/angular/bundles/microsoft-windows-admin-center-sdk-angular.umd.min.js +1 -1
- package/angular/bundles/microsoft-windows-admin-center-sdk-angular.umd.min.js.map +1 -1
- package/angular/esm2015/src/controls/data-table/data-table.component.js +133 -127
- package/angular/esm2015/src/controls/dialog/dialog.component.js +10 -4
- package/angular/esm2015/src/controls/dialog/dialog.service.js +6 -13
- package/angular/esm2015/src/service/connectivity-enforcer.js +5 -2
- package/angular/fesm2015/microsoft-windows-admin-center-sdk-angular.js +150 -142
- package/angular/fesm2015/microsoft-windows-admin-center-sdk-angular.js.map +1 -1
- package/core/azure/azure-constants.d.ts +8 -0
- package/core/azure/azure-constants.js +8 -0
- package/core/azure/azure-constants.js.map +1 -1
- package/core/azure/azure-manager.d.ts +1 -0
- package/core/azure/azure-manager.js +7 -1
- package/core/azure/azure-manager.js.map +1 -1
- package/core/base/environment.d.ts +3 -0
- package/core/base/environment.js.map +1 -1
- package/core/base/msft-sme.mock.js +3 -0
- package/core/base/msft-sme.mock.js.map +1 -1
- package/core/base/utilities.d.ts +0 -3
- package/core/base/utilities.js +0 -34
- package/core/base/utilities.js.map +1 -1
- package/core/data/settings-manager.d.ts +3 -0
- package/core/data/settings-manager.js +14 -1
- package/core/data/settings-manager.js.map +1 -1
- package/core/dom/dom.d.ts +5 -0
- package/core/dom/dom.js +20 -0
- package/core/dom/dom.js.map +1 -1
- package/core/manifest/environment-modules.js +3 -0
- package/core/manifest/environment-modules.js.map +1 -1
- package/core/notification/client-notification-instance.d.ts +5 -2
- package/core/notification/client-notification-instance.js +9 -5
- package/core/notification/client-notification-instance.js.map +1 -1
- package/core/notification/client-notification.d.ts +4 -0
- package/core/notification/client-notification.js.map +1 -1
- package/core/notification/notification.d.ts +6 -1
- package/core/notification/notification.js +3 -1
- package/core/notification/notification.js.map +1 -1
- package/core/rpc/credssp/rpc-credssp-model.d.ts +4 -0
- package/core/rpc/credssp/rpc-credssp-model.js.map +1 -1
- package/core/rpc/dialog/rpc-dialog-client.js +11 -5
- package/core/rpc/dialog/rpc-dialog-client.js.map +1 -1
- package/core/rpc/rpc.d.ts +6 -6
- package/core/rpc/rpc.js +7 -7
- package/core/rpc/rpc.js.map +1 -1
- package/core/security/credssp-manager.d.ts +13 -6
- package/core/security/credssp-manager.js +37 -21
- package/core/security/credssp-manager.js.map +1 -1
- package/core/shared/cluster-inventory/cluster-inventory-cache.js +2 -1
- package/core/shared/cluster-inventory/cluster-inventory-cache.js.map +1 -1
- package/e2e/assets/strings/cs-CZ/strings.json +1 -1
- package/e2e/assets/strings/de-DE/strings.json +1 -1
- package/e2e/assets/strings/es-ES/strings.json +1 -1
- package/e2e/assets/strings/fr-FR/strings.json +1 -1
- package/e2e/assets/strings/hu-HU/strings.json +1 -1
- package/e2e/assets/strings/it-IT/strings.json +1 -1
- package/e2e/assets/strings/ja-JP/strings.json +1 -1
- package/e2e/assets/strings/ko-KR/strings.json +1 -1
- package/e2e/assets/strings/nl-NL/strings.json +1 -1
- package/e2e/assets/strings/pl-PL/strings.json +1 -1
- package/e2e/assets/strings/pt-BR/strings.json +1 -1
- package/e2e/assets/strings/pt-PT/strings.json +1 -1
- package/e2e/assets/strings/ru-RU/strings.json +1 -1
- package/e2e/assets/strings/strings.json +1 -1
- package/e2e/assets/strings/sv-SE/strings.json +1 -1
- package/e2e/assets/strings/tr-TR/strings.json +1 -1
- package/e2e/assets/strings/zh-CN/strings.json +1 -1
- package/e2e/assets/strings/zh-TW/strings.json +1 -1
- package/package.json +7 -2
- package/angular/assets/strings/en-US/strings.json +0 -1
- package/core/assets/strings/en-US/strings.json +0 -1
- package/e2e/assets/strings/en-US/strings.json +0 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { from, of, Subject, throwError } from 'rxjs';
|
|
2
2
|
import { filter, mergeMap, take } from 'rxjs/operators';
|
|
3
|
+
import { ErrorExtended } from '../data/error-extended';
|
|
3
4
|
import { Logging } from '../diagnostics/logging';
|
|
4
5
|
import { RpcCredSSPOperationType, RpcCredSspResponseKey } from '../rpc/credssp/rpc-credssp-model';
|
|
5
6
|
import { RpcCredSspRequestClient } from '../rpc/credssp/rpc-credssp-request-client';
|
|
@@ -26,8 +27,9 @@ export class CredSSPManager {
|
|
|
26
27
|
* New Enable CredSSP on the passed in server.
|
|
27
28
|
*
|
|
28
29
|
* @param serverName This server on which CredSSP should be enabled
|
|
30
|
+
* @param verbose (Optional) Specify whether a solution (if any) should be returned if CredSSP errored
|
|
29
31
|
*/
|
|
30
|
-
wsmanEnableManagedServer(serverName) {
|
|
32
|
+
wsmanEnableManagedServer(serverName, verbose = false) {
|
|
31
33
|
if (this.rpc.isShell) {
|
|
32
34
|
throw new Error('Not supported on the shell environment.');
|
|
33
35
|
}
|
|
@@ -40,14 +42,15 @@ export class CredSSPManager {
|
|
|
40
42
|
serverNames: [serverName],
|
|
41
43
|
notificationTitle: null,
|
|
42
44
|
notificationId: null
|
|
43
|
-
});
|
|
45
|
+
}, verbose);
|
|
44
46
|
}
|
|
45
47
|
/**
|
|
46
48
|
* New Disable CredSSP for the passed in server.
|
|
47
49
|
*
|
|
48
50
|
* @param serverName This server on which CredSSP should be disabled
|
|
51
|
+
* @param verbose (Optional) Specify whether a solution (if any) should be returned if CredSSP errored
|
|
49
52
|
*/
|
|
50
|
-
wsmanDisableManagedServer(serverName) {
|
|
53
|
+
wsmanDisableManagedServer(serverName, verbose = false) {
|
|
51
54
|
if (this.rpc.isShell) {
|
|
52
55
|
throw new Error('Not supported on the shell environment.');
|
|
53
56
|
}
|
|
@@ -60,14 +63,15 @@ export class CredSSPManager {
|
|
|
60
63
|
serverNames: [serverName],
|
|
61
64
|
notificationTitle: null,
|
|
62
65
|
notificationId: null
|
|
63
|
-
});
|
|
66
|
+
}, verbose);
|
|
64
67
|
}
|
|
65
68
|
/**
|
|
66
69
|
* New Enable CredSSP client role for the gateway and delegate to the list of servers.
|
|
67
70
|
*
|
|
68
71
|
* @param serverNames This list of servers where CredSSP should be enabled.
|
|
72
|
+
* @param verbose (Optional) Specify whether a solution (if any) should be returned if CredSSP errored
|
|
69
73
|
*/
|
|
70
|
-
wsmanEnableClientRole(serverNames) {
|
|
74
|
+
wsmanEnableClientRole(serverNames, verbose = false) {
|
|
71
75
|
if (this.rpc.isShell) {
|
|
72
76
|
throw new Error('Not supported on the shell environment.');
|
|
73
77
|
}
|
|
@@ -80,14 +84,15 @@ export class CredSSPManager {
|
|
|
80
84
|
serverNames: serverNames,
|
|
81
85
|
notificationTitle: null,
|
|
82
86
|
notificationId: null
|
|
83
|
-
});
|
|
87
|
+
}, verbose);
|
|
84
88
|
}
|
|
85
89
|
/**
|
|
86
90
|
* New Disable CredSSP client role for the gateway and remove all delegated servers.
|
|
87
91
|
*
|
|
88
92
|
* @param serverNames This list of servers where CredSSP should be disabled.
|
|
93
|
+
* @param verbose (Optional) Specify whether a solution (if any) should be returned if CredSSP errored
|
|
89
94
|
*/
|
|
90
|
-
wsmanDisableClientRole(serverNames) {
|
|
95
|
+
wsmanDisableClientRole(serverNames, verbose = false) {
|
|
91
96
|
if (this.rpc.isShell) {
|
|
92
97
|
throw new Error('Not supported on the shell environment.');
|
|
93
98
|
}
|
|
@@ -100,14 +105,15 @@ export class CredSSPManager {
|
|
|
100
105
|
serverNames,
|
|
101
106
|
notificationTitle: null,
|
|
102
107
|
notificationId: null
|
|
103
|
-
});
|
|
108
|
+
}, verbose);
|
|
104
109
|
}
|
|
105
110
|
/**
|
|
106
111
|
* New Enable the server as a CredSSP server, and enable the gateway as a CredSSP client of the server.
|
|
107
112
|
*
|
|
108
113
|
* @param serverName The sever where CredSSP delegation should be enabled.
|
|
114
|
+
* @param verbose (Optional) Specify whether a solution (if any) should be returned if CredSSP errored
|
|
109
115
|
*/
|
|
110
|
-
wsmanEnableDelegation(serverName) {
|
|
116
|
+
wsmanEnableDelegation(serverName, verbose = false) {
|
|
111
117
|
if (this.rpc.isShell) {
|
|
112
118
|
throw new Error('Not supported on the shell environment.');
|
|
113
119
|
}
|
|
@@ -120,15 +126,16 @@ export class CredSSPManager {
|
|
|
120
126
|
serverNames: [serverName],
|
|
121
127
|
notificationTitle: null,
|
|
122
128
|
notificationId: null
|
|
123
|
-
});
|
|
129
|
+
}, verbose);
|
|
124
130
|
}
|
|
125
131
|
/**
|
|
126
132
|
* Test WSMan CredSSP connection from gateway to server(s)
|
|
127
133
|
* @param serverNames the servers to test connection to from gateway
|
|
128
134
|
* @param credentials explicit credentials(username and password) to be used to WSMan CredSSP test
|
|
135
|
+
* @param verbose (Optional) Specify whether a solution (if any) should be returned if CredSSP errored
|
|
129
136
|
* @returns true if we can safely connect to all server without isssues otherwise returns false
|
|
130
137
|
*/
|
|
131
|
-
testCredSSP(serverNames, credentials) {
|
|
138
|
+
testCredSSP(serverNames, credentials, verbose = false) {
|
|
132
139
|
if (this.rpc.isShell) {
|
|
133
140
|
throw new Error('Not supported on the shell environment.');
|
|
134
141
|
}
|
|
@@ -145,7 +152,7 @@ export class CredSSPManager {
|
|
|
145
152
|
credentials,
|
|
146
153
|
notificationTitle: null,
|
|
147
154
|
notificationId: null
|
|
148
|
-
});
|
|
155
|
+
}, verbose);
|
|
149
156
|
}
|
|
150
157
|
/**
|
|
151
158
|
* @deprecated
|
|
@@ -171,7 +178,7 @@ export class CredSSPManager {
|
|
|
171
178
|
serverNames: [serverName],
|
|
172
179
|
notificationTitle: alertTitle,
|
|
173
180
|
notificationId: alertId
|
|
174
|
-
});
|
|
181
|
+
}, false);
|
|
175
182
|
}
|
|
176
183
|
/**
|
|
177
184
|
* @deprecated
|
|
@@ -197,7 +204,7 @@ export class CredSSPManager {
|
|
|
197
204
|
serverNames: [serverName],
|
|
198
205
|
notificationTitle: alertTitle,
|
|
199
206
|
notificationId: alertId
|
|
200
|
-
});
|
|
207
|
+
}, false);
|
|
201
208
|
}
|
|
202
209
|
/**
|
|
203
210
|
* @deprecated
|
|
@@ -223,7 +230,7 @@ export class CredSSPManager {
|
|
|
223
230
|
serverNames: serverNames,
|
|
224
231
|
notificationTitle: alertTitle,
|
|
225
232
|
notificationId: alertId
|
|
226
|
-
});
|
|
233
|
+
}, false);
|
|
227
234
|
}
|
|
228
235
|
/**
|
|
229
236
|
* @deprecated
|
|
@@ -249,7 +256,7 @@ export class CredSSPManager {
|
|
|
249
256
|
serverNames,
|
|
250
257
|
notificationTitle: alertTitle,
|
|
251
258
|
notificationId: alertId
|
|
252
|
-
});
|
|
259
|
+
}, false);
|
|
253
260
|
}
|
|
254
261
|
/**
|
|
255
262
|
* @deprecated
|
|
@@ -276,7 +283,7 @@ export class CredSSPManager {
|
|
|
276
283
|
serverNames: [serverName],
|
|
277
284
|
notificationTitle: alertTitle,
|
|
278
285
|
notificationId: alertId
|
|
279
|
-
});
|
|
286
|
+
}, false);
|
|
280
287
|
}
|
|
281
288
|
/**
|
|
282
289
|
* @deprecated
|
|
@@ -294,15 +301,24 @@ export class CredSSPManager {
|
|
|
294
301
|
/**
|
|
295
302
|
* The RPC request to the CredSSPManagerShellService.
|
|
296
303
|
* @param request The requested CredSSP manager operation
|
|
304
|
+
* @param verbose Specify whether a solution (if any) should be returned if CredSSP errored
|
|
297
305
|
*/
|
|
298
|
-
sendRequest(request) {
|
|
306
|
+
sendRequest(request, verbose) {
|
|
299
307
|
Logging.logDebug('CredSSPManager', 'Sending request to CredSSPManagerService. Request:{0}'.format(JSON.stringify(request)));
|
|
300
308
|
return from(RpcCredSspRequestClient.credSspRequest(this.rpc, request))
|
|
301
309
|
.pipe(mergeMap(() => this.watcher), filter(result => result.requestId === request.requestId), take(1), mergeMap(result => {
|
|
310
|
+
// shell reports 'error' property originated from the CredSSP operation.
|
|
311
|
+
// the client using this API should get this error message to display to user.
|
|
302
312
|
if (result.error) {
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
313
|
+
if (verbose) {
|
|
314
|
+
const error = new ErrorExtended(result.error);
|
|
315
|
+
error.extendedSource = `${request.operation}-credSSPError`;
|
|
316
|
+
error.extended = { solutionMessage: result.solutionMessage };
|
|
317
|
+
return throwError(error);
|
|
318
|
+
}
|
|
319
|
+
else {
|
|
320
|
+
return throwError(new Error(result.error));
|
|
321
|
+
}
|
|
306
322
|
}
|
|
307
323
|
return of(result.succeeded);
|
|
308
324
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../packages/core/security/credssp-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAc,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAE6C,uBAAuB,EAAE,qBAAqB,EACjG,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,uBAAuB,EAAE,MAAM,2CAA2C,CAAC;AAIpF;;GAEG;AACH,MAAM,OAAO,cAAc;IAGvB;;;;OAIG;IACH,YAAoB,GAAQ;QAAR,QAAG,GAAH,GAAG,CAAK;QACxB,IAAI,CAAC,OAAO,GAAG,IAAI,OAAO,EAA6B,CAAC;IAC5D,CAAC;IAEM,UAAU;QACb,iCAAiC;QACjC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE;YACnB,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,qBAAqB,CAAC,OAAO,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;SACnF;IACL,CAAC;IAED;;;;OAIG;IACI,wBAAwB,CAAC,UAAkB;QAC9C,IAAI,IAAI,CAAC,GAAG,CAAC,O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AC,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,EAC5B,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,SAAS,KAAK,OAAO,CAAC,SAAS,CAAC,EACxD,IAAI,CAAC,CAAC,CAAC,EACP,QAAQ,CAAC,MAAM,CAAC,EAAE;YACd,IAAI,MAAM,CAAC,KAAK,EAAE;gBACd,wEAAwE;gBACxE,8EAA8E;gBAC9E,OAAO,UAAU,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;aAC9C;YAED,OAAO,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAChC,CAAC,CAAC,CAAC,CAAC;IAChB,CAAC;IAED;;;OAGG;IACK,aAAa,CAAC,IAA+B;QACjD,OAAO,CAAC,QAAQ,CACZ,gBAAgB,EAChB,6DAA6D,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAEhG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAExB,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC7B,CAAC;CACJ","file":"credssp-manager.js","sourcesContent":["import { from, Observable, of, Subject, throwError } from 'rxjs';\r\nimport { filter, mergeMap, take } from 'rxjs/operators';\r\nimport { Logging } from '../diagnostics/logging';\r\nimport {\r\n Credentials,\r\n RpcCredSSPOperation, RpcCredSSPOperationResult, RpcCredSSPOperationType, RpcCredSspResponseKey\r\n} from '../rpc/credssp/rpc-credssp-model';\r\nimport { RpcCredSspRequestClient } from '../rpc/credssp/rpc-credssp-request-client';\r\nimport { Rpc } from '../rpc/rpc';\r\nimport { CreateAuthorizationTokenOptions } from './authorization-manager';\r\n\r\n/**\r\n * CredSPP Manager class. Handles detecting and configuring CredSSP on a set of servers.\r\n */\r\nexport class CredSSPManager {\r\n private watcher: Subject<RpcCredSSPOperationResult>;\r\n\r\n /**\r\n * Initializes a new instance of the Authorization Manager class.\r\n *\r\n * @param rpc The rpc to forward auth requests to a parent window\r\n */\r\n constructor(private rpc: Rpc) {\r\n this.watcher = new Subject<RpcCredSSPOperationResult>();\r\n }\r\n\r\n public initialize() {\r\n // When in Shell do not register.\r\n if (!this.rpc.isShell) {\r\n this.rpc.register(RpcCredSspResponseKey.command, this.onRpcResponse.bind(this));\r\n }\r\n }\r\n\r\n /**\r\n * New Enable CredSSP on the passed in server.\r\n *\r\n * @param serverName This server on which CredSSP should be enabled\r\n */\r\n public wsmanEnableManagedServer(serverName: string): Observable<boolean> {\r\n if (this.rpc.isShell) {\r\n throw new Error('Not supported on the shell environment.');\r\n }\r\n\r\n if (MsftSme.isNullOrWhiteSpace(serverName)) {\r\n throw new Error('A server name must be provided.');\r\n }\r\n\r\n return this.sendRequest({\r\n requestId: MsftSme.getUniqueId(),\r\n operation: RpcCredSSPOperationType.EnableManagedServer,\r\n serverNames: [serverName],\r\n notificationTitle: null,\r\n notificationId: null\r\n });\r\n }\r\n\r\n /**\r\n * New Disable CredSSP for the passed in server.\r\n *\r\n * @param serverName This server on which CredSSP should be disabled\r\n */\r\n public wsmanDisableManagedServer(serverName: string): Observable<boolean> {\r\n if (this.rpc.isShell) {\r\n throw new Error('Not supported on the shell environment.');\r\n }\r\n\r\n if (MsftSme.isNullOrWhiteSpace(serverName)) {\r\n throw new Error('A server name must be provided.');\r\n }\r\n\r\n return this.sendRequest({\r\n requestId: MsftSme.getUniqueId(),\r\n operation: RpcCredSSPOperationType.DisableManagedServer,\r\n serverNames: [serverName],\r\n notificationTitle: null,\r\n notificationId: null\r\n });\r\n }\r\n\r\n /**\r\n * New Enable CredSSP client role for the gateway and delegate to the list of servers.\r\n *\r\n * @param serverNames This list of servers where CredSSP should be enabled.\r\n */\r\n public wsmanEnableClientRole(serverNames: string[]): Observable<boolean> {\r\n if (this.rpc.isShell) {\r\n throw new Error('Not supported on the shell environment.');\r\n }\r\n\r\n if (!serverNames || serverNames.length < 1) {\r\n throw new Error('At least one server name must be provided.');\r\n }\r\n\r\n return this.sendRequest({\r\n requestId: MsftSme.getUniqueId(),\r\n operation: RpcCredSSPOperationType.EnableClientRole,\r\n serverNames: serverNames,\r\n notificationTitle: null,\r\n notificationId: null\r\n });\r\n }\r\n\r\n /**\r\n * New Disable CredSSP client role for the gateway and remove all delegated servers.\r\n *\r\n * @param serverNames This list of servers where CredSSP should be disabled.\r\n */\r\n public wsmanDisableClientRole(serverNames: string[]): Observable<boolean> {\r\n if (this.rpc.isShell) {\r\n throw new Error('Not supported on the shell environment.');\r\n }\r\n\r\n if (!serverNames || serverNames.length < 1) {\r\n throw new Error('At least one server name must be provided.');\r\n }\r\n\r\n return this.sendRequest({\r\n requestId: MsftSme.getUniqueId(),\r\n operation: RpcCredSSPOperationType.DisableClientRole,\r\n serverNames,\r\n notificationTitle: null,\r\n notificationId: null\r\n });\r\n }\r\n\r\n /**\r\n * New Enable the server as a CredSSP server, and enable the gateway as a CredSSP client of the server.\r\n *\r\n * @param serverName The sever where CredSSP delegation should be enabled.\r\n */\r\n public wsmanEnableDelegation(serverName: string): Observable<boolean> {\r\n if (this.rpc.isShell) {\r\n throw new Error('Not supported on the shell environment.');\r\n }\r\n\r\n if (MsftSme.isNullOrWhiteSpace(serverName)) {\r\n throw new Error('The server name must be provided.');\r\n }\r\n\r\n return this.sendRequest({\r\n requestId: MsftSme.getUniqueId(),\r\n operation: RpcCredSSPOperationType.EnableDelegation,\r\n serverNames: [serverName],\r\n notificationTitle: null,\r\n notificationId: null\r\n });\r\n }\r\n\r\n /**\r\n * Test WSMan CredSSP connection from gateway to server(s)\r\n * @param serverNames the servers to test connection to from gateway\r\n * @param credentials explicit credentials(username and password) to be used to WSMan CredSSP test\r\n * @returns true if we can safely connect to all server without isssues otherwise returns false\r\n */\r\n public testCredSSP(serverNames: string[], credentials: Credentials): Observable<boolean> {\r\n if (this.rpc.isShell) {\r\n throw new Error('Not supported on the shell environment.');\r\n }\r\n\r\n if (!serverNames.length || serverNames.some(\r\n serverName => MsftSme.isNullOrWhiteSpace(serverName))\r\n ) {\r\n throw new Error('The server name(s) must be provided.');\r\n }\r\n\r\n if (!credentials || !credentials.username || !credentials.password) {\r\n throw new Error('Username and password must be provided in the options.');\r\n }\r\n\r\n return this.sendRequest({\r\n requestId: MsftSme.getUniqueId(),\r\n operation: RpcCredSSPOperationType.TestCredSSP,\r\n serverNames: serverNames,\r\n credentials,\r\n notificationTitle: null,\r\n notificationId: null\r\n });\r\n }\r\n\r\n /**\r\n * @deprecated\r\n * Notification message wouldn't be displayed from this call. Display the notification by own code,\r\n * and use wsmanEnableManagedServer instead.\r\n *\r\n * Enable CredSSP on the passed in server.\r\n *\r\n * @param alertTitle Title for notifications raised by this servers. Should be contextual to the scenario that is using this service\r\n * @param serverName This server on which CredSSP should be enabled\r\n * @param alertId Optional notification Id\r\n */\r\n public enableManagedServer(alertTitle: string, serverName: string, alertId?: string): Observable<boolean> {\r\n if (this.rpc.isShell) {\r\n throw new Error('Not supported on the shell environment.');\r\n }\r\n\r\n if (MsftSme.isNullOrWhiteSpace(serverName)) {\r\n throw new Error('A server name must be provided.');\r\n }\r\n\r\n return this.sendRequest({\r\n requestId: MsftSme.getUniqueId(),\r\n operation: RpcCredSSPOperationType.EnableManagedServer,\r\n serverNames: [serverName],\r\n notificationTitle: alertTitle,\r\n notificationId: alertId\r\n });\r\n }\r\n\r\n /**\r\n * @deprecated\r\n * Notification message wouldn't be displayed from this call. Display the notification by own code,\r\n * and use wsmanDisableManagedServer instead.\r\n *\r\n * Disable CredSSP for the passed in server.\r\n *\r\n * @param alertTitle Title for notifications raised by this servers. Should be contextual to the scenario that is using this service\r\n * @param serverName This server on which CredSSP should be disabled\r\n * @param alertId Optional notification Id\r\n */\r\n public disableManagedServer(alertTitle: string, serverName: string, alertId?: string): Observable<boolean> {\r\n if (this.rpc.isShell) {\r\n throw new Error('Not supported on the shell environment.');\r\n }\r\n\r\n if (MsftSme.isNullOrWhiteSpace(serverName)) {\r\n throw new Error('A server name must be provided.');\r\n }\r\n\r\n return this.sendRequest({\r\n requestId: MsftSme.getUniqueId(),\r\n operation: RpcCredSSPOperationType.DisableManagedServer,\r\n serverNames: [serverName],\r\n notificationTitle: alertTitle,\r\n notificationId: alertId\r\n });\r\n }\r\n\r\n /**\r\n * @deprecated\r\n * Notification message wouldn't be displayed from this call. Display the notification by own code,\r\n * and use wsmanEnableClientRole instead.\r\n *\r\n * Enable CredSSP client role for the gateway and delegate to the list of servers.\r\n *\r\n * @param alertTitle Title for notifications raised by this servers. Should be contextual to the scenario that is using this service\r\n * @param serverNames This list of servers where CredSSP should be enabled.\r\n * @param alertId Optional notification Id\r\n */\r\n public enableClientRole(alertTitle: string, serverNames: string[], alertId?: string): Observable<boolean> {\r\n if (this.rpc.isShell) {\r\n throw new Error('Not supported on the shell environment.');\r\n }\r\n\r\n if (!serverNames || serverNames.length < 1) {\r\n throw new Error('At least one server name must be provided.');\r\n }\r\n\r\n return this.sendRequest({\r\n requestId: MsftSme.getUniqueId(),\r\n operation: RpcCredSSPOperationType.EnableClientRole,\r\n serverNames: serverNames,\r\n notificationTitle: alertTitle,\r\n notificationId: alertId\r\n });\r\n }\r\n\r\n /**\r\n * @deprecated\r\n * Notification message wouldn't be displayed from this call. Display the notification by own code,\r\n * and use wsmanDisableClientRole instead.\r\n *\r\n * Disable CredSSP client role for the gateway and remove all delegated servers.\r\n *\r\n * @param alertTitle Title for notifications raised by this servers. Should be contextual to the scenario that is using this service\r\n * @param serverNames This list of servers where CredSSP should be disabled.\r\n * @param alertId Optional notification Id\r\n */\r\n public disableClientRole(alertTitle: string, serverNames: string[], alertId?: string): Observable<boolean> {\r\n if (this.rpc.isShell) {\r\n throw new Error('Not supported on the shell environment.');\r\n }\r\n\r\n if (!serverNames || serverNames.length < 1) {\r\n throw new Error('At least one server name must be provided.');\r\n }\r\n\r\n return this.sendRequest({\r\n requestId: MsftSme.getUniqueId(),\r\n operation: RpcCredSSPOperationType.DisableClientRole,\r\n serverNames,\r\n notificationTitle: alertTitle,\r\n notificationId: alertId\r\n });\r\n }\r\n\r\n\r\n /**\r\n * @deprecated\r\n * Notification message wouldn't be displayed from this call. Display the notification by own code,\r\n * and use wsmanEnableDelegation instead.\r\n *\r\n * Enable the server as a CredSSP server, and enable the gateway as a CredSSP client of the server.\r\n *\r\n * @param alertTitle Title for notifications raised by this servers. Should be contextual to the scenario that is using this service\r\n * @param serverName The sever where CredSSP delegation should be enabled.\r\n * @param disableTaskDelay Time in hours, for the scheduled that disables CredSSP to wait before being triggered\r\n * @param alertId Optional notification Id\r\n */\r\n public enableDelegation(alertTitle: string, serverName: string, alertId?: string, disableTaskDelay?: number): Observable<boolean> {\r\n if (this.rpc.isShell) {\r\n throw new Error('Not supported on the shell environment.');\r\n }\r\n\r\n if (MsftSme.isNullOrWhiteSpace(serverName)) {\r\n throw new Error('The server name must be provided.');\r\n }\r\n\r\n return this.sendRequest({\r\n requestId: MsftSme.getUniqueId(),\r\n operation: RpcCredSSPOperationType.EnableDelegation,\r\n serverNames: [serverName],\r\n notificationTitle: alertTitle,\r\n notificationId: alertId\r\n });\r\n }\r\n\r\n /**\r\n * @deprecated\r\n * This method is obsolete!\r\n *\r\n * Disable the server as a CredSSP server, and disable the gateway as a CredSSP client of the server.\r\n *\r\n * @param alertTitle Title for notifications raised by this servers. Should be contextual to the scenario that is using this service\r\n * @param serverName The sever where CredSSP delegation should be disabled.\r\n * @param alertId Optional notification Id\r\n */\r\n public disableDelegation(alertTitle: string, serverName: string, alertId?: string): Observable<boolean> {\r\n return of(true);\r\n }\r\n\r\n /**\r\n * The RPC request to the CredSSPManagerShellService.\r\n * @param request The requested CredSSP manager operation\r\n */\r\n private sendRequest(request: RpcCredSSPOperation): Observable<boolean> {\r\n Logging.logDebug(\r\n 'CredSSPManager',\r\n 'Sending request to CredSSPManagerService. Request:{0}'.format(JSON.stringify(request)));\r\n\r\n return from(RpcCredSspRequestClient.credSspRequest(this.rpc, request))\r\n .pipe(\r\n mergeMap(() => this.watcher),\r\n filter(result => result.requestId === request.requestId),\r\n take(1),\r\n mergeMap(result => {\r\n if (result.error) {\r\n // shell reports 'error' property originated from the CredSSP operation.\r\n // the client using this API should get this error message to display to user.\r\n return throwError(new Error(result.error));\r\n }\r\n\r\n return of(result.succeeded);\r\n }));\r\n }\r\n\r\n /**\r\n * Process the RPC response from the CredSSPManagerShellService.\r\n * @param data The requested CredSSP manager operation result.\r\n */\r\n private onRpcResponse(data: RpcCredSSPOperationResult): Promise<any> {\r\n Logging.logDebug(\r\n 'CredSSPManager',\r\n 'Processing response from CredSSPManagerService Response:{0}'.format(JSON.stringify(data)));\r\n\r\n this.watcher.next(data);\r\n\r\n return Promise.resolve();\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"sources":["../../../packages/core/security/credssp-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAc,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAE6C,uBAAuB,EAAE,qBAAqB,EACjG,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,uBAAuB,EAAE,MAAM,2CAA2C,CAAC;AAGpF;;GAEG;AACH,MAAM,OAAO,cAAc;IAGvB;;;;OAIG;IACH,YAAoB,GAAQ;QAAR,QAAG,GAAH,GAAG,CAAK;QACxB,IAAI,CAAC,OAAO,GAAG,IAAI,OAAO,EAA6B,CAAC;IAC5D,CAAC;IAEM,UAAU;QACb,iCAAiC;QACjC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE;YACnB,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,qBAAqB,CAAC,OAAO,EAAE,IAAI,CAAC,a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AAQ,CACZ,gBAAgB,EAChB,6DAA6D,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAEhG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAExB,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC7B,CAAC;CACJ","file":"credssp-manager.js","sourcesContent":["import { from, Observable, of, Subject, throwError } from 'rxjs';\r\nimport { filter, mergeMap, take } from 'rxjs/operators';\r\nimport { ErrorExtended } from '../data/error-extended';\r\nimport { Logging } from '../diagnostics/logging';\r\nimport {\r\n Credentials,\r\n RpcCredSSPOperation, RpcCredSSPOperationResult, RpcCredSSPOperationType, RpcCredSspResponseKey\r\n} from '../rpc/credssp/rpc-credssp-model';\r\nimport { RpcCredSspRequestClient } from '../rpc/credssp/rpc-credssp-request-client';\r\nimport { Rpc } from '../rpc/rpc';\r\n\r\n/**\r\n * CredSPP Manager class. Handles detecting and configuring CredSSP on a set of servers.\r\n */\r\nexport class CredSSPManager {\r\n private watcher: Subject<RpcCredSSPOperationResult>;\r\n\r\n /**\r\n * Initializes a new instance of the Authorization Manager class.\r\n *\r\n * @param rpc The rpc to forward auth requests to a parent window\r\n */\r\n constructor(private rpc: Rpc) {\r\n this.watcher = new Subject<RpcCredSSPOperationResult>();\r\n }\r\n\r\n public initialize() {\r\n // When in Shell do not register.\r\n if (!this.rpc.isShell) {\r\n this.rpc.register(RpcCredSspResponseKey.command, this.onRpcResponse.bind(this));\r\n }\r\n }\r\n\r\n /**\r\n * New Enable CredSSP on the passed in server.\r\n *\r\n * @param serverName This server on which CredSSP should be enabled\r\n * @param verbose (Optional) Specify whether a solution (if any) should be returned if CredSSP errored\r\n */\r\n public wsmanEnableManagedServer(serverName: string, verbose: boolean = false): Observable<boolean> {\r\n if (this.rpc.isShell) {\r\n throw new Error('Not supported on the shell environment.');\r\n }\r\n\r\n if (MsftSme.isNullOrWhiteSpace(serverName)) {\r\n throw new Error('A server name must be provided.');\r\n }\r\n\r\n return this.sendRequest({\r\n requestId: MsftSme.getUniqueId(),\r\n operation: RpcCredSSPOperationType.EnableManagedServer,\r\n serverNames: [serverName],\r\n notificationTitle: null,\r\n notificationId: null\r\n }, verbose);\r\n }\r\n\r\n /**\r\n * New Disable CredSSP for the passed in server.\r\n *\r\n * @param serverName This server on which CredSSP should be disabled\r\n * @param verbose (Optional) Specify whether a solution (if any) should be returned if CredSSP errored\r\n */\r\n public wsmanDisableManagedServer(serverName: string, verbose: boolean = false): Observable<boolean> {\r\n if (this.rpc.isShell) {\r\n throw new Error('Not supported on the shell environment.');\r\n }\r\n\r\n if (MsftSme.isNullOrWhiteSpace(serverName)) {\r\n throw new Error('A server name must be provided.');\r\n }\r\n\r\n return this.sendRequest({\r\n requestId: MsftSme.getUniqueId(),\r\n operation: RpcCredSSPOperationType.DisableManagedServer,\r\n serverNames: [serverName],\r\n notificationTitle: null,\r\n notificationId: null\r\n }, verbose);\r\n }\r\n\r\n /**\r\n * New Enable CredSSP client role for the gateway and delegate to the list of servers.\r\n *\r\n * @param serverNames This list of servers where CredSSP should be enabled.\r\n * @param verbose (Optional) Specify whether a solution (if any) should be returned if CredSSP errored\r\n */\r\n public wsmanEnableClientRole(serverNames: string[], verbose: boolean = false): Observable<boolean> {\r\n if (this.rpc.isShell) {\r\n throw new Error('Not supported on the shell environment.');\r\n }\r\n\r\n if (!serverNames || serverNames.length < 1) {\r\n throw new Error('At least one server name must be provided.');\r\n }\r\n\r\n return this.sendRequest({\r\n requestId: MsftSme.getUniqueId(),\r\n operation: RpcCredSSPOperationType.EnableClientRole,\r\n serverNames: serverNames,\r\n notificationTitle: null,\r\n notificationId: null\r\n }, verbose);\r\n }\r\n\r\n /**\r\n * New Disable CredSSP client role for the gateway and remove all delegated servers.\r\n *\r\n * @param serverNames This list of servers where CredSSP should be disabled.\r\n * @param verbose (Optional) Specify whether a solution (if any) should be returned if CredSSP errored\r\n */\r\n public wsmanDisableClientRole(serverNames: string[], verbose: boolean = false): Observable<boolean> {\r\n if (this.rpc.isShell) {\r\n throw new Error('Not supported on the shell environment.');\r\n }\r\n\r\n if (!serverNames || serverNames.length < 1) {\r\n throw new Error('At least one server name must be provided.');\r\n }\r\n\r\n return this.sendRequest({\r\n requestId: MsftSme.getUniqueId(),\r\n operation: RpcCredSSPOperationType.DisableClientRole,\r\n serverNames,\r\n notificationTitle: null,\r\n notificationId: null\r\n }, verbose);\r\n }\r\n\r\n /**\r\n * New Enable the server as a CredSSP server, and enable the gateway as a CredSSP client of the server.\r\n *\r\n * @param serverName The sever where CredSSP delegation should be enabled.\r\n * @param verbose (Optional) Specify whether a solution (if any) should be returned if CredSSP errored\r\n */\r\n public wsmanEnableDelegation(serverName: string, verbose: boolean = false): Observable<boolean> {\r\n if (this.rpc.isShell) {\r\n throw new Error('Not supported on the shell environment.');\r\n }\r\n\r\n if (MsftSme.isNullOrWhiteSpace(serverName)) {\r\n throw new Error('The server name must be provided.');\r\n }\r\n\r\n return this.sendRequest({\r\n requestId: MsftSme.getUniqueId(),\r\n operation: RpcCredSSPOperationType.EnableDelegation,\r\n serverNames: [serverName],\r\n notificationTitle: null,\r\n notificationId: null\r\n }, verbose);\r\n }\r\n\r\n /**\r\n * Test WSMan CredSSP connection from gateway to server(s)\r\n * @param serverNames the servers to test connection to from gateway\r\n * @param credentials explicit credentials(username and password) to be used to WSMan CredSSP test\r\n * @param verbose (Optional) Specify whether a solution (if any) should be returned if CredSSP errored\r\n * @returns true if we can safely connect to all server without isssues otherwise returns false\r\n */\r\n public testCredSSP(serverNames: string[], credentials: Credentials, verbose: boolean = false): Observable<boolean> {\r\n if (this.rpc.isShell) {\r\n throw new Error('Not supported on the shell environment.');\r\n }\r\n\r\n if (!serverNames.length || serverNames.some(\r\n serverName => MsftSme.isNullOrWhiteSpace(serverName))\r\n ) {\r\n throw new Error('The server name(s) must be provided.');\r\n }\r\n\r\n if (!credentials || !credentials.username || !credentials.password) {\r\n throw new Error('Username and password must be provided in the options.');\r\n }\r\n\r\n return this.sendRequest({\r\n requestId: MsftSme.getUniqueId(),\r\n operation: RpcCredSSPOperationType.TestCredSSP,\r\n serverNames: serverNames,\r\n credentials,\r\n notificationTitle: null,\r\n notificationId: null\r\n }, verbose);\r\n }\r\n\r\n /**\r\n * @deprecated\r\n * Notification message wouldn't be displayed from this call. Display the notification by own code,\r\n * and use wsmanEnableManagedServer instead.\r\n *\r\n * Enable CredSSP on the passed in server.\r\n *\r\n * @param alertTitle Title for notifications raised by this servers. Should be contextual to the scenario that is using this service\r\n * @param serverName This server on which CredSSP should be enabled\r\n * @param alertId Optional notification Id\r\n */\r\n public enableManagedServer(alertTitle: string, serverName: string, alertId?: string): Observable<boolean> {\r\n if (this.rpc.isShell) {\r\n throw new Error('Not supported on the shell environment.');\r\n }\r\n\r\n if (MsftSme.isNullOrWhiteSpace(serverName)) {\r\n throw new Error('A server name must be provided.');\r\n }\r\n\r\n return this.sendRequest({\r\n requestId: MsftSme.getUniqueId(),\r\n operation: RpcCredSSPOperationType.EnableManagedServer,\r\n serverNames: [serverName],\r\n notificationTitle: alertTitle,\r\n notificationId: alertId\r\n }, false);\r\n }\r\n\r\n /**\r\n * @deprecated\r\n * Notification message wouldn't be displayed from this call. Display the notification by own code,\r\n * and use wsmanDisableManagedServer instead.\r\n *\r\n * Disable CredSSP for the passed in server.\r\n *\r\n * @param alertTitle Title for notifications raised by this servers. Should be contextual to the scenario that is using this service\r\n * @param serverName This server on which CredSSP should be disabled\r\n * @param alertId Optional notification Id\r\n */\r\n public disableManagedServer(alertTitle: string, serverName: string, alertId?: string): Observable<boolean> {\r\n if (this.rpc.isShell) {\r\n throw new Error('Not supported on the shell environment.');\r\n }\r\n\r\n if (MsftSme.isNullOrWhiteSpace(serverName)) {\r\n throw new Error('A server name must be provided.');\r\n }\r\n\r\n return this.sendRequest({\r\n requestId: MsftSme.getUniqueId(),\r\n operation: RpcCredSSPOperationType.DisableManagedServer,\r\n serverNames: [serverName],\r\n notificationTitle: alertTitle,\r\n notificationId: alertId\r\n }, false);\r\n }\r\n\r\n /**\r\n * @deprecated\r\n * Notification message wouldn't be displayed from this call. Display the notification by own code,\r\n * and use wsmanEnableClientRole instead.\r\n *\r\n * Enable CredSSP client role for the gateway and delegate to the list of servers.\r\n *\r\n * @param alertTitle Title for notifications raised by this servers. Should be contextual to the scenario that is using this service\r\n * @param serverNames This list of servers where CredSSP should be enabled.\r\n * @param alertId Optional notification Id\r\n */\r\n public enableClientRole(alertTitle: string, serverNames: string[], alertId?: string): Observable<boolean> {\r\n if (this.rpc.isShell) {\r\n throw new Error('Not supported on the shell environment.');\r\n }\r\n\r\n if (!serverNames || serverNames.length < 1) {\r\n throw new Error('At least one server name must be provided.');\r\n }\r\n\r\n return this.sendRequest({\r\n requestId: MsftSme.getUniqueId(),\r\n operation: RpcCredSSPOperationType.EnableClientRole,\r\n serverNames: serverNames,\r\n notificationTitle: alertTitle,\r\n notificationId: alertId\r\n }, false);\r\n }\r\n\r\n /**\r\n * @deprecated\r\n * Notification message wouldn't be displayed from this call. Display the notification by own code,\r\n * and use wsmanDisableClientRole instead.\r\n *\r\n * Disable CredSSP client role for the gateway and remove all delegated servers.\r\n *\r\n * @param alertTitle Title for notifications raised by this servers. Should be contextual to the scenario that is using this service\r\n * @param serverNames This list of servers where CredSSP should be disabled.\r\n * @param alertId Optional notification Id\r\n */\r\n public disableClientRole(alertTitle: string, serverNames: string[], alertId?: string): Observable<boolean> {\r\n if (this.rpc.isShell) {\r\n throw new Error('Not supported on the shell environment.');\r\n }\r\n\r\n if (!serverNames || serverNames.length < 1) {\r\n throw new Error('At least one server name must be provided.');\r\n }\r\n\r\n return this.sendRequest({\r\n requestId: MsftSme.getUniqueId(),\r\n operation: RpcCredSSPOperationType.DisableClientRole,\r\n serverNames,\r\n notificationTitle: alertTitle,\r\n notificationId: alertId\r\n }, false);\r\n }\r\n\r\n\r\n /**\r\n * @deprecated\r\n * Notification message wouldn't be displayed from this call. Display the notification by own code,\r\n * and use wsmanEnableDelegation instead.\r\n *\r\n * Enable the server as a CredSSP server, and enable the gateway as a CredSSP client of the server.\r\n *\r\n * @param alertTitle Title for notifications raised by this servers. Should be contextual to the scenario that is using this service\r\n * @param serverName The sever where CredSSP delegation should be enabled.\r\n * @param disableTaskDelay Time in hours, for the scheduled that disables CredSSP to wait before being triggered\r\n * @param alertId Optional notification Id\r\n */\r\n public enableDelegation(alertTitle: string, serverName: string, alertId?: string, disableTaskDelay?: number): Observable<boolean> {\r\n if (this.rpc.isShell) {\r\n throw new Error('Not supported on the shell environment.');\r\n }\r\n\r\n if (MsftSme.isNullOrWhiteSpace(serverName)) {\r\n throw new Error('The server name must be provided.');\r\n }\r\n\r\n return this.sendRequest({\r\n requestId: MsftSme.getUniqueId(),\r\n operation: RpcCredSSPOperationType.EnableDelegation,\r\n serverNames: [serverName],\r\n notificationTitle: alertTitle,\r\n notificationId: alertId\r\n }, false);\r\n }\r\n\r\n /**\r\n * @deprecated\r\n * This method is obsolete!\r\n *\r\n * Disable the server as a CredSSP server, and disable the gateway as a CredSSP client of the server.\r\n *\r\n * @param alertTitle Title for notifications raised by this servers. Should be contextual to the scenario that is using this service\r\n * @param serverName The sever where CredSSP delegation should be disabled.\r\n * @param alertId Optional notification Id\r\n */\r\n public disableDelegation(alertTitle: string, serverName: string, alertId?: string): Observable<boolean> {\r\n return of(true);\r\n }\r\n\r\n /**\r\n * The RPC request to the CredSSPManagerShellService.\r\n * @param request The requested CredSSP manager operation\r\n * @param verbose Specify whether a solution (if any) should be returned if CredSSP errored\r\n */\r\n private sendRequest(request: RpcCredSSPOperation, verbose: boolean): Observable<boolean> {\r\n Logging.logDebug(\r\n 'CredSSPManager',\r\n 'Sending request to CredSSPManagerService. Request:{0}'.format(JSON.stringify(request)));\r\n\r\n return from(RpcCredSspRequestClient.credSspRequest(this.rpc, request))\r\n .pipe(\r\n mergeMap(() => this.watcher),\r\n filter(result => result.requestId === request.requestId),\r\n take(1),\r\n mergeMap(result => {\r\n // shell reports 'error' property originated from the CredSSP operation.\r\n // the client using this API should get this error message to display to user.\r\n if (result.error) {\r\n if (verbose) {\r\n const error = new ErrorExtended<{solutionMessage: string}>(result.error);\r\n error.extendedSource = `${request.operation}-credSSPError`;\r\n error.extended = { solutionMessage: result.solutionMessage };\r\n return throwError(error);\r\n } else {\r\n return throwError(new Error(result.error));\r\n }\r\n }\r\n\r\n return of(result.succeeded);\r\n }));\r\n }\r\n\r\n /**\r\n * Process the RPC response from the CredSSPManagerShellService.\r\n * @param data The requested CredSSP manager operation result.\r\n */\r\n private onRpcResponse(data: RpcCredSSPOperationResult): Promise<any> {\r\n Logging.logDebug(\r\n 'CredSSPManager',\r\n 'Processing response from CredSSPManagerService Response:{0}'.format(JSON.stringify(data)));\r\n\r\n this.watcher.next(data);\r\n\r\n return Promise.resolve();\r\n }\r\n}\r\n"]}
|
|
@@ -60,6 +60,7 @@ export class ClusterInventoryCache extends SharedCache {
|
|
|
60
60
|
const clusterNodePsSession = this.appContext.powerShell.createSession(params.name, null, options);
|
|
61
61
|
return zip(this.appContext.powerShell.run(clusterPsSession, PowerShellScripts.Get_ClusterInventory), this.appContext.powerShell.run(clusterNodePsSession, PowerShellScripts.Get_ClusterNodes))
|
|
62
62
|
.pipe(map(([cluster, nodes]) => {
|
|
63
|
+
var _a;
|
|
63
64
|
const inventory = new ClusterInventory(params.name);
|
|
64
65
|
if (!cluster || !cluster.results || cluster.results.length === 0) {
|
|
65
66
|
return inventory;
|
|
@@ -72,7 +73,7 @@ export class ClusterInventoryCache extends SharedCache {
|
|
|
72
73
|
const nodesResultLower = {};
|
|
73
74
|
// make node name and fqdn lower casing.
|
|
74
75
|
inventory.isClusterCmdletAvailable = clusterResult.isClusterCmdletAvailable;
|
|
75
|
-
clusterResult.fqdn = clusterResult.fqdn.toLowerCase();
|
|
76
|
+
clusterResult.fqdn = (_a = clusterResult.fqdn) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
76
77
|
inventory.fqdn = clusterResult.fqdn;
|
|
77
78
|
inventory.currentClusterNode = clusterResult.currentClusterNode.toLowerCase();
|
|
78
79
|
inventory.nodeNames = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../packages/core/shared/cluster-inventory/cluster-inventory-cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,EAAE,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAC3C,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAI/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,4CAA4C,CAAC;AAClF,OAAO,EAAE,WAAW,EAAsB,MAAM,iBAAiB,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAgD,MAAM,qBAAqB,CAAC;AACrG,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAElF;;GAEG;AACH,MAAM,OAAO,qBAAsB,SAAQ,WAA2E;IAMlH;;;;;OAKG;IACH,YAAoB,UAAsB,EAAE,OAA4B;QACpE,KAAK,CACD,qBAAqB,CAAC,QAAQ,EAC9B,qBAAqB,CAAC,aAAa,EACnC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,EACvC,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,EAC1C,CAAC,UAAU,EAAE,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,EAChD,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAClC,OAAO,CAAC,CAAC;QARG,eAAU,GAAV,UAAU,CAAY;QAUtC,IAAI,CAAC,oBAAoB,GAAG,IAAI,oBAAoB,CAAC,UAAU,CAAC,CAAC;IACrE,CAAC;IAED;;;;;OAKG;IACK,cAAc,CAAC,MAA8B;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ACV,oBAAoB,CAAC,QAAQ,CAAC,GAAG,sBAAsB,CAAC,QAAQ,CAAC,CAAC;qBACrE;iBACJ;gBAED,gBAAgB,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,oBAAoB,CAAC;aAC/D;YAED,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE;gBAC1B,gBAAgB,CAAC,aAAa,GAAG,aAAa,CAAC;aAClD;YAED,OAAO,gBAAgB,CAAC;QAC5B,CAAC,CAAC,CAAC,CAAC;IACZ,CAAC;;AA1Mc,8BAAQ,GAAG,kCAAkC,CAAC;AAC9C,mCAAa,GAAG,CAAC,CAAC,CAAC,8CAA8C","file":"cluster-inventory-cache.js","sourcesContent":["import { Observable, of, zip } from 'rxjs';\r\nimport { map, mergeMap } from 'rxjs/operators';\r\nimport { AppContext } from '../../data/app-context';\r\nimport { NodeRequestOptions } from '../../data/node-connection';\r\nimport { PowerShellBatchResponseItem } from '../../data/powershell-batch';\r\nimport { PowerShellScripts } from '../../generated/powershell-scripts';\r\nimport { ServerInventoryCache } from '../server-inventory/server-inventory-cache';\r\nimport { SharedCache, SharedCacheOptions } from '../shared-cache';\r\nimport { ClusterInventory, ClusterInventoryData, ClusterInventoryParams } from './cluster-inventory';\r\nimport { ClusterNodeInventory, ClusterNodeState } from './cluster-node-inventory';\r\n\r\n/**\r\n * Cluster Inventory cache class.\r\n */\r\nexport class ClusterInventoryCache extends SharedCache<ClusterInventory, ClusterInventoryData, ClusterInventoryParams> {\r\n private static uniqueId = '@msft-sme/shell:clusterInventory';\r\n private static uniqueVersion = 1; // increment this if you make breaking changes\r\n\r\n private serverInventoryCache: ServerInventoryCache;\r\n\r\n /**\r\n * Initializes a new instance of the ClusterInventoryCache class.\r\n *\r\n * @param appContext the app context.\r\n * @param options the option of shared cache.\r\n */\r\n constructor(private appContext: AppContext, options?: SharedCacheOptions) {\r\n super(\r\n ClusterInventoryCache.uniqueId,\r\n ClusterInventoryCache.uniqueVersion,\r\n (params) => this.dataInstanceId(params),\r\n (instance) => this.dataSerialize(instance),\r\n (serialized) => this.dataDeserialize(serialized),\r\n (params) => this.dataQuery(params),\r\n options);\r\n\r\n this.serverInventoryCache = new ServerInventoryCache(appContext);\r\n }\r\n\r\n /**\r\n * Defines how to identify the cache entry by params.\r\n *\r\n * @param params the server inventory query params.\r\n * @return the id string.\r\n */\r\n private dataInstanceId(params: ClusterInventoryParams): string {\r\n return params.name;\r\n }\r\n\r\n /**\r\n * Defines how to deserialize the class object from serialized data.\r\n *\r\n * @param serialized the serialized string;\r\n */\r\n private dataDeserialize(serialized: string): ClusterInventory {\r\n const inventory: ClusterInventoryData = JSON.parse(serialized);\r\n return new ClusterInventory(inventory.clusterName, inventory);\r\n }\r\n\r\n /**\r\n * Defines how to serialize the class object to serialized data.\r\n *\r\n * @param instance the class instance.\r\n */\r\n private dataSerialize(instance: ClusterInventory): string {\r\n // automatically stripped out class related data.\r\n return JSON.stringify(instance);\r\n }\r\n\r\n /**\r\n * Defines how to collect the cluster inventory data.\r\n *\r\n * @param params the server inventory query params.\r\n * @return the Observable of ClusterInventory data.\r\n */\r\n private dataQuery(params: ClusterInventoryParams): Observable<ClusterInventory> {\r\n // options object will be updated at the http layer, so it makes an each copy before passing.\r\n const options = { ...params.requestOptions };\r\n const clusterPsSession = this.appContext.powerShell.createSession(params.name, null, options);\r\n const clusterNodePsSession = this.appContext.powerShell.createSession(params.name, null, options);\r\n\r\n return zip<any, any>(\r\n this.appContext.powerShell.run(clusterPsSession, PowerShellScripts.Get_ClusterInventory),\r\n this.appContext.powerShell.run(clusterNodePsSession, PowerShellScripts.Get_ClusterNodes))\r\n .pipe(map<any, any>(([cluster, nodes]) => {\r\n const inventory = new ClusterInventory(params.name);\r\n\r\n if (!cluster || !cluster.results || cluster.results.length === 0) {\r\n return inventory;\r\n }\r\n\r\n if (!nodes || !nodes.results || nodes.results.length === 0) {\r\n return inventory;\r\n }\r\n\r\n const nodesResult = nodes.results[0];\r\n const clusterResult = cluster.results[0];\r\n const nodesResultLower = {};\r\n\r\n // make node name and fqdn lower casing.\r\n inventory.isClusterCmdletAvailable = clusterResult.isClusterCmdletAvailable;\r\n clusterResult.fqdn = clusterResult.fqdn.toLowerCase();\r\n inventory.fqdn = clusterResult.fqdn;\r\n inventory.currentClusterNode = clusterResult.currentClusterNode.toLowerCase();\r\n inventory.nodeNames = [];\r\n for (const node in nodesResult) {\r\n if (node && nodesResult[node] && nodesResult[node].name) {\r\n nodesResult[node].name = nodesResult[node].name.toLowerCase();\r\n nodesResult[node].fullyQualifiedDomainName = nodesResult[node].fullyQualifiedDomainName.toLowerCase();\r\n inventory.nodeNames.push(nodesResult[node].name);\r\n const nodeLower = node.toLowerCase();\r\n nodesResultLower[nodeLower] = nodesResult[node];\r\n }\r\n }\r\n\r\n inventory.isS2dEnabled = clusterResult.isS2DEnabled;\r\n inventory.isTsdbEnabled = clusterResult.isTsdbEnabled;\r\n inventory.isBritannicaEnabled = clusterResult.isBritannicaEnabled;\r\n inventory.isBritannicaVirtualMachineEnabled = clusterResult.isBritannicaVirtualMachineEnabled;\r\n inventory.isBritannicaVirtualSwitchEnabled = clusterResult.isBritannicaVirtualSwitchEnabled;\r\n inventory.isClusterHealthCmdletAvailable = clusterResult.isClusterHealthCmdletAvailable;\r\n inventory.isHyperVPowershellInstalled = false;\r\n inventory.isHyperVRoleInstalled = false;\r\n inventory.isManagementToolsAvailable = false;\r\n inventory.nodeMap = nodesResultLower;\r\n return inventory;\r\n }),\r\n mergeMap(inventory => this.queryClusterNodeInventories(inventory, params)));\r\n }\r\n\r\n /**\r\n * Defines how to collect the cluster node-server inventory data.\r\n * @param clusterInventory the initial cluster inventory query params.\r\n * @param params the parameters for cluster inventory query.\r\n * @return Observable<ClusterInventory> the Observable of ClusterInventory data.\r\n */\r\n private queryClusterNodeInventories(clusterInventory: ClusterInventory, params: ClusterInventoryParams): Observable<ClusterInventory> {\r\n if (!clusterInventory.nodeNames || clusterInventory.nodeNames.length === 0) {\r\n return of(clusterInventory);\r\n }\r\n\r\n // Can only get server inventory data from live nodes\r\n const nodeMap = clusterInventory.nodeMap;\r\n const liveNodeNames: string[] = [];\r\n for (const key in nodeMap) {\r\n if (nodeMap[key].state === ClusterNodeState.Up || nodeMap[key].state === ClusterNodeState.Paused) {\r\n liveNodeNames.push(nodeMap[key].fullyQualifiedDomainName);\r\n }\r\n }\r\n\r\n const authToken = this.appContext.authorizationManager.getSavedNodeToken(params.name);\r\n let options: NodeRequestOptions = {};\r\n\r\n if (params.requestOptions) {\r\n options = <NodeRequestOptions>{ ...params.requestOptions };\r\n\r\n if (options.authToken == null && authToken) {\r\n // override auth token if not there.\r\n options.authToken = authToken;\r\n }\r\n } else if (authToken) {\r\n options.authToken = authToken;\r\n }\r\n\r\n const errorMessages: string[] = [];\r\n\r\n const batchSession = this.appContext.powerShell.createBatchSession(liveNodeNames, null, options);\r\n return this.appContext.powerShell.runBatchSingleCommand(batchSession, PowerShellScripts.Get_ServerInventory)\r\n .pipe(map((responseItems: PowerShellBatchResponseItem[]) => {\r\n for (let index = 0; index < responseItems.length; index++) {\r\n const response = responseItems[index];\r\n\r\n if (response.error || response.errors) {\r\n const message = (response.error && response.error.message) ||\r\n (response.errors && response.errors[0] && response.errors[0].message);\r\n errorMessages.push(message);\r\n continue;\r\n }\r\n\r\n const currentServer = liveNodeNames[index];\r\n const serverNameParts: string[] = currentServer.split('.');\r\n const serverName = serverNameParts.length > 1 ? serverNameParts[0] : currentServer;\r\n\r\n const data = response.properties;\r\n const serverInventory = ServerInventoryCache.createServerInventoryData(serverName, data);\r\n\r\n this.serverInventoryCache.save({ name: serverName }, serverInventory);\r\n\r\n const inventoryServerName = clusterInventory.nodeMap[clusterInventory.currentClusterNode].name;\r\n\r\n if (serverName === inventoryServerName) {\r\n clusterInventory.isHyperVPowershellInstalled = serverInventory.isHyperVPowershellInstalled;\r\n clusterInventory.isHyperVRoleInstalled = serverInventory.isHyperVRoleInstalled;\r\n clusterInventory.isManagementToolsAvailable = serverInventory.isManagementToolsAvailable;\r\n }\r\n\r\n // combine cluster node inventory and server inventory\r\n const clusterNodeInventory = new ClusterNodeInventory(serverName);\r\n const clusterServerInventory = clusterInventory.nodeMap[serverName];\r\n\r\n Object.assign(clusterNodeInventory, serverInventory);\r\n\r\n for (const property in clusterServerInventory) {\r\n if (property) {\r\n clusterNodeInventory[property] = clusterServerInventory[property];\r\n }\r\n }\r\n\r\n clusterInventory.nodeMap[serverName] = clusterNodeInventory;\r\n }\r\n\r\n if (errorMessages.length > 0) {\r\n clusterInventory.clusterErrors = errorMessages;\r\n }\r\n\r\n return clusterInventory;\r\n }));\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"sources":["../../../packages/core/shared/cluster-inventory/cluster-inventory-cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,EAAE,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAC3C,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAI/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,4CAA4C,CAAC;AAClF,OAAO,EAAE,WAAW,EAAsB,MAAM,iBAAiB,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAgD,MAAM,qBAAqB,CAAC;AACrG,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAElF;;GAEG;AACH,MAAM,OAAO,qBAAsB,SAAQ,WAA2E;IAMlH;;;;;OAKG;IACH,YAAoB,UAAsB,EAAE,OAA4B;QACpE,KAAK,CACD,qBAAqB,CAAC,QAAQ,EAC9B,qBAAqB,CAAC,aAAa,EACnC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,EACvC,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,EAC1C,CAAC,UAAU,EAAE,EAAE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gBAED,sDAAsD;gBACtD,MAAM,oBAAoB,GAAG,IAAI,oBAAoB,CAAC,UAAU,CAAC,CAAC;gBAClE,MAAM,sBAAsB,GAAG,gBAAgB,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;gBAEpE,MAAM,CAAC,MAAM,CAAC,oBAAoB,EAAE,eAAe,CAAC,CAAC;gBAErD,KAAK,MAAM,QAAQ,IAAI,sBAAsB,EAAE;oBAC3C,IAAI,QAAQ,EAAE;wBACV,oBAAoB,CAAC,QAAQ,CAAC,GAAG,sBAAsB,CAAC,QAAQ,CAAC,CAAC;qBACrE;iBACJ;gBAED,gBAAgB,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,oBAAoB,CAAC;aAC/D;YAED,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE;gBAC1B,gBAAgB,CAAC,aAAa,GAAG,aAAa,CAAC;aAClD;YAED,OAAO,gBAAgB,CAAC;QAC5B,CAAC,CAAC,CAAC,CAAC;IACZ,CAAC;;AA1Mc,8BAAQ,GAAG,kCAAkC,CAAC;AAC9C,mCAAa,GAAG,CAAC,CAAC,CAAC,8CAA8C","file":"cluster-inventory-cache.js","sourcesContent":["import { Observable, of, zip } from 'rxjs';\r\nimport { map, mergeMap } from 'rxjs/operators';\r\nimport { AppContext } from '../../data/app-context';\r\nimport { NodeRequestOptions } from '../../data/node-connection';\r\nimport { PowerShellBatchResponseItem } from '../../data/powershell-batch';\r\nimport { PowerShellScripts } from '../../generated/powershell-scripts';\r\nimport { ServerInventoryCache } from '../server-inventory/server-inventory-cache';\r\nimport { SharedCache, SharedCacheOptions } from '../shared-cache';\r\nimport { ClusterInventory, ClusterInventoryData, ClusterInventoryParams } from './cluster-inventory';\r\nimport { ClusterNodeInventory, ClusterNodeState } from './cluster-node-inventory';\r\n\r\n/**\r\n * Cluster Inventory cache class.\r\n */\r\nexport class ClusterInventoryCache extends SharedCache<ClusterInventory, ClusterInventoryData, ClusterInventoryParams> {\r\n private static uniqueId = '@msft-sme/shell:clusterInventory';\r\n private static uniqueVersion = 1; // increment this if you make breaking changes\r\n\r\n private serverInventoryCache: ServerInventoryCache;\r\n\r\n /**\r\n * Initializes a new instance of the ClusterInventoryCache class.\r\n *\r\n * @param appContext the app context.\r\n * @param options the option of shared cache.\r\n */\r\n constructor(private appContext: AppContext, options?: SharedCacheOptions) {\r\n super(\r\n ClusterInventoryCache.uniqueId,\r\n ClusterInventoryCache.uniqueVersion,\r\n (params) => this.dataInstanceId(params),\r\n (instance) => this.dataSerialize(instance),\r\n (serialized) => this.dataDeserialize(serialized),\r\n (params) => this.dataQuery(params),\r\n options);\r\n\r\n this.serverInventoryCache = new ServerInventoryCache(appContext);\r\n }\r\n\r\n /**\r\n * Defines how to identify the cache entry by params.\r\n *\r\n * @param params the server inventory query params.\r\n * @return the id string.\r\n */\r\n private dataInstanceId(params: ClusterInventoryParams): string {\r\n return params.name;\r\n }\r\n\r\n /**\r\n * Defines how to deserialize the class object from serialized data.\r\n *\r\n * @param serialized the serialized string;\r\n */\r\n private dataDeserialize(serialized: string): ClusterInventory {\r\n const inventory: ClusterInventoryData = JSON.parse(serialized);\r\n return new ClusterInventory(inventory.clusterName, inventory);\r\n }\r\n\r\n /**\r\n * Defines how to serialize the class object to serialized data.\r\n *\r\n * @param instance the class instance.\r\n */\r\n private dataSerialize(instance: ClusterInventory): string {\r\n // automatically stripped out class related data.\r\n return JSON.stringify(instance);\r\n }\r\n\r\n /**\r\n * Defines how to collect the cluster inventory data.\r\n *\r\n * @param params the server inventory query params.\r\n * @return the Observable of ClusterInventory data.\r\n */\r\n private dataQuery(params: ClusterInventoryParams): Observable<ClusterInventory> {\r\n // options object will be updated at the http layer, so it makes an each copy before passing.\r\n const options = { ...params.requestOptions };\r\n const clusterPsSession = this.appContext.powerShell.createSession(params.name, null, options);\r\n const clusterNodePsSession = this.appContext.powerShell.createSession(params.name, null, options);\r\n\r\n return zip<any, any>(\r\n this.appContext.powerShell.run(clusterPsSession, PowerShellScripts.Get_ClusterInventory),\r\n this.appContext.powerShell.run(clusterNodePsSession, PowerShellScripts.Get_ClusterNodes))\r\n .pipe(map<any, any>(([cluster, nodes]) => {\r\n const inventory = new ClusterInventory(params.name);\r\n\r\n if (!cluster || !cluster.results || cluster.results.length === 0) {\r\n return inventory;\r\n }\r\n\r\n if (!nodes || !nodes.results || nodes.results.length === 0) {\r\n return inventory;\r\n }\r\n\r\n const nodesResult = nodes.results[0];\r\n const clusterResult = cluster.results[0];\r\n const nodesResultLower = {};\r\n\r\n // make node name and fqdn lower casing.\r\n inventory.isClusterCmdletAvailable = clusterResult.isClusterCmdletAvailable;\r\n clusterResult.fqdn = clusterResult.fqdn?.toLowerCase();\r\n inventory.fqdn = clusterResult.fqdn;\r\n inventory.currentClusterNode = clusterResult.currentClusterNode.toLowerCase();\r\n inventory.nodeNames = [];\r\n for (const node in nodesResult) {\r\n if (node && nodesResult[node] && nodesResult[node].name) {\r\n nodesResult[node].name = nodesResult[node].name.toLowerCase();\r\n nodesResult[node].fullyQualifiedDomainName = nodesResult[node].fullyQualifiedDomainName.toLowerCase();\r\n inventory.nodeNames.push(nodesResult[node].name);\r\n const nodeLower = node.toLowerCase();\r\n nodesResultLower[nodeLower] = nodesResult[node];\r\n }\r\n }\r\n\r\n inventory.isS2dEnabled = clusterResult.isS2DEnabled;\r\n inventory.isTsdbEnabled = clusterResult.isTsdbEnabled;\r\n inventory.isBritannicaEnabled = clusterResult.isBritannicaEnabled;\r\n inventory.isBritannicaVirtualMachineEnabled = clusterResult.isBritannicaVirtualMachineEnabled;\r\n inventory.isBritannicaVirtualSwitchEnabled = clusterResult.isBritannicaVirtualSwitchEnabled;\r\n inventory.isClusterHealthCmdletAvailable = clusterResult.isClusterHealthCmdletAvailable;\r\n inventory.isHyperVPowershellInstalled = false;\r\n inventory.isHyperVRoleInstalled = false;\r\n inventory.isManagementToolsAvailable = false;\r\n inventory.nodeMap = nodesResultLower;\r\n return inventory;\r\n }),\r\n mergeMap(inventory => this.queryClusterNodeInventories(inventory, params)));\r\n }\r\n\r\n /**\r\n * Defines how to collect the cluster node-server inventory data.\r\n * @param clusterInventory the initial cluster inventory query params.\r\n * @param params the parameters for cluster inventory query.\r\n * @return Observable<ClusterInventory> the Observable of ClusterInventory data.\r\n */\r\n private queryClusterNodeInventories(clusterInventory: ClusterInventory, params: ClusterInventoryParams): Observable<ClusterInventory> {\r\n if (!clusterInventory.nodeNames || clusterInventory.nodeNames.length === 0) {\r\n return of(clusterInventory);\r\n }\r\n\r\n // Can only get server inventory data from live nodes\r\n const nodeMap = clusterInventory.nodeMap;\r\n const liveNodeNames: string[] = [];\r\n for (const key in nodeMap) {\r\n if (nodeMap[key].state === ClusterNodeState.Up || nodeMap[key].state === ClusterNodeState.Paused) {\r\n liveNodeNames.push(nodeMap[key].fullyQualifiedDomainName);\r\n }\r\n }\r\n\r\n const authToken = this.appContext.authorizationManager.getSavedNodeToken(params.name);\r\n let options: NodeRequestOptions = {};\r\n\r\n if (params.requestOptions) {\r\n options = <NodeRequestOptions>{ ...params.requestOptions };\r\n\r\n if (options.authToken == null && authToken) {\r\n // override auth token if not there.\r\n options.authToken = authToken;\r\n }\r\n } else if (authToken) {\r\n options.authToken = authToken;\r\n }\r\n\r\n const errorMessages: string[] = [];\r\n\r\n const batchSession = this.appContext.powerShell.createBatchSession(liveNodeNames, null, options);\r\n return this.appContext.powerShell.runBatchSingleCommand(batchSession, PowerShellScripts.Get_ServerInventory)\r\n .pipe(map((responseItems: PowerShellBatchResponseItem[]) => {\r\n for (let index = 0; index < responseItems.length; index++) {\r\n const response = responseItems[index];\r\n\r\n if (response.error || response.errors) {\r\n const message = (response.error && response.error.message) ||\r\n (response.errors && response.errors[0] && response.errors[0].message);\r\n errorMessages.push(message);\r\n continue;\r\n }\r\n\r\n const currentServer = liveNodeNames[index];\r\n const serverNameParts: string[] = currentServer.split('.');\r\n const serverName = serverNameParts.length > 1 ? serverNameParts[0] : currentServer;\r\n\r\n const data = response.properties;\r\n const serverInventory = ServerInventoryCache.createServerInventoryData(serverName, data);\r\n\r\n this.serverInventoryCache.save({ name: serverName }, serverInventory);\r\n\r\n const inventoryServerName = clusterInventory.nodeMap[clusterInventory.currentClusterNode].name;\r\n\r\n if (serverName === inventoryServerName) {\r\n clusterInventory.isHyperVPowershellInstalled = serverInventory.isHyperVPowershellInstalled;\r\n clusterInventory.isHyperVRoleInstalled = serverInventory.isHyperVRoleInstalled;\r\n clusterInventory.isManagementToolsAvailable = serverInventory.isManagementToolsAvailable;\r\n }\r\n\r\n // combine cluster node inventory and server inventory\r\n const clusterNodeInventory = new ClusterNodeInventory(serverName);\r\n const clusterServerInventory = clusterInventory.nodeMap[serverName];\r\n\r\n Object.assign(clusterNodeInventory, serverInventory);\r\n\r\n for (const property in clusterServerInventory) {\r\n if (property) {\r\n clusterNodeInventory[property] = clusterServerInventory[property];\r\n }\r\n }\r\n\r\n clusterInventory.nodeMap[serverName] = clusterNodeInventory;\r\n }\r\n\r\n if (errorMessages.length > 0) {\r\n clusterInventory.clusterErrors = errorMessages;\r\n }\r\n\r\n return clusterInventory;\r\n }));\r\n }\r\n}\r\n"]}
|