@microsoft/windows-admin-center-sdk
Version:
Microsoft - Windows Admin Center Shell
1 lines • 7.59 kB
Source Map (JSON)
{"version":3,"sources":["../../../packages/core/shared/server-inventory/server-inventory-cache.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAGpD,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAEjG;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,WAAW,CAAC,eAAe,EAAE,mBAAmB,EAAE,qBAAqB,CAAC;IA2ElG,OAAO,CAAC,UAAU;IA1E9B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAqC;IAC5D,OAAO,CAAC,MAAM,CAAC,aAAa,CAAM;IAElC;;;;;OAKG;WACW,yBAAyB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,eAAe;IA2DjF;;;;;OAKG;gBACiB,UAAU,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,kBAAkB;IAWxE;;;;;OAKG;IACH,OAAO,CAAC,SAAS;IAMjB;;;;;OAKG;IACH,OAAO,CAAC,cAAc;IAItB;;;;OAIG;IACH,OAAO,CAAC,eAAe;IAKvB;;;;OAIG;IACH,OAAO,CAAC,aAAa;CAIxB","file":"server-inventory-cache.d.ts","sourcesContent":["import { Observable } from 'rxjs';\r\nimport { map } from 'rxjs/operators';\r\nimport { AppContext } from '../../data/app-context';\r\nimport { PowerShell } from '../../data/powershell';\r\nimport { PowerShellScripts } from '../../generated/powershell-scripts';\r\nimport { SharedCache, SharedCacheOptions } from '../shared-cache';\r\nimport { ServerInventory, ServerInventoryData, ServerInventoryParams } from './server-inventory';\r\n\r\n/**\r\n * Server Inventory cache class.\r\n */\r\nexport class ServerInventoryCache extends SharedCache<ServerInventory, ServerInventoryData, ServerInventoryParams> {\r\n private static uniqueId = '@msft-sme/shell:serverInventory';\r\n private static uniqueVersion = 17;\r\n\r\n /**\r\n * Create Server Inventory data from the script result data.\r\n *\r\n * @param name the name of server node.\r\n * @param data the PowerShell script result data.\r\n */\r\n public static createServerInventoryData(name: string, data: any): ServerInventory {\r\n const inventory = new ServerInventory(name);\r\n\r\n if (data && data.results && data.results.length > 0) {\r\n const result = data.results[0];\r\n const operatingSystem = result.operatingSystem;\r\n const computerSystem = result.computerSystem;\r\n\r\n inventory.isAdministrator = result.isAdministrator;\r\n inventory.isWmfInstalled = result.isWmfInstalled;\r\n inventory.name = operatingSystem.csName ? operatingSystem.csName.toString().toLowerCase() : null;\r\n inventory.operatingSystemName = operatingSystem.caption;\r\n inventory.operatingSystemSKU = operatingSystem.operatingSystemSKU;\r\n inventory.operatingSystemVersion = operatingSystem.version;\r\n inventory.productType = operatingSystem.productType;\r\n inventory.osType = operatingSystem.osType;\r\n inventory.lastBootUpTime = operatingSystem.lastBootUpTime;\r\n inventory.osSerialNumber = operatingSystem.serialNumber;\r\n inventory.buildNumber = operatingSystem.currentBuild;\r\n inventory.updateBuildRevision = operatingSystem.updateBuildRevision;\r\n inventory.operatingSystemDisplayVersion = operatingSystem.displayVersion;\r\n\r\n inventory.totalPhysicalMemory = computerSystem.totalPhysicalMemory;\r\n inventory.domainRole = computerSystem.domainRole;\r\n inventory.computerManufacturer = computerSystem.manufacturer;\r\n inventory.computerModel = computerSystem.model;\r\n inventory.totalLogicalProcessors = computerSystem.numberOfLogicalProcessors;\r\n inventory.isRemoteAppEnabled = result.isRemoteAppEnabled;\r\n\r\n if (computerSystem.partOfDomain) {\r\n inventory.domainName = computerSystem.domain;\r\n } else {\r\n inventory.workgroupName = computerSystem.workgroup;\r\n }\r\n\r\n inventory.fullyQualifiedDomainName = result.fqdn.toLowerCase();\r\n inventory.fullyQualifiedDomainNameRaw = result.fqdn;\r\n inventory.addressList = result.addressList;\r\n inventory.hostname = result.hostname.toLowerCase();\r\n inventory.hostnameRaw = result.hostname;\r\n inventory.netBios = result.netBios;\r\n inventory.clusterFqdn = result.clusterFqdn ? result.clusterFqdn.toLowerCase() : null;\r\n inventory.isCluster = result.isCluster;\r\n inventory.isManagementToolsAvailable = result.isManagementToolsAvailable;\r\n inventory.isServerManagerAvailable = result.isServerManagerAvailable;\r\n inventory.isS2dEnabled = result.isS2dEnabled;\r\n inventory.isBritannicaEnabled = result.isBritannicaEnabled;\r\n inventory.isHyperVRoleInstalled = result.isHyperVRoleInstalled;\r\n inventory.isHyperVPowershellInstalled = result.isHyperVPowershellInstalled;\r\n inventory.isCredSSPEnabled = result.isCredSSPEnabled;\r\n inventory.smbiosData = result.smbiosData;\r\n inventory.azureArcStatus = result.azureArcStatus;\r\n inventory.systemLockdownPolicy = result.systemLockdownPolicy;\r\n inventory.isHciServer = result.isHciServer;\r\n }\r\n\r\n return inventory;\r\n }\r\n\r\n /**\r\n * Initializes a new instance of the ServerInventoryCache 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 ServerInventoryCache.uniqueId,\r\n ServerInventoryCache.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\r\n /**\r\n * Defines how to collect the server inventory data.\r\n *\r\n * @param params the server inventory query params.\r\n * @return the Observable of ServerInventory data.\r\n */\r\n private dataQuery(params: ServerInventoryParams): Observable<ServerInventory> {\r\n const psSession = this.appContext.powerShell.createSession(params.name, null, { ...{ automatic: true }, ...params.requestOptions });\r\n return this.appContext.powerShell.run(psSession, PowerShell.createCommand(PowerShellScripts.Get_ServerInventory))\r\n .pipe(map((data: any) => ServerInventoryCache.createServerInventoryData(params.name, data)));\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: ServerInventoryParams): 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): ServerInventory {\r\n const inventory: ServerInventoryData = JSON.parse(serialized);\r\n return new ServerInventory(inventory.serverName, 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: ServerInventory): string {\r\n // automatically stripped out class related data.\r\n return JSON.stringify(instance);\r\n }\r\n}\r\n"]}