def getHostOsDetailsFromRegistry(self): ' -> HostDo' hostDo = HostDo() hostOsName = queryRegistry(self.shell, HostDiscovererByShell.KEY_NAME_WIN_VERSION, 'ProductName') currentVersion = queryRegistry( self.shell, HostDiscovererByShell.KEY_NAME_WIN_VERSION, 'CurrentVersion') buildNumber = queryRegistry(self.shell, HostDiscovererByShell.KEY_NAME_WIN_VERSION, 'CurrentBuildNumber') servicePack = queryRegistry(self.shell, HostDiscovererByShell.KEY_NAME_WIN_VERSION, 'CSDVersion') if hostOsName: (vendor, name, install_type) = separateCaption(hostOsName) hostDo.hostOsName = name hostDo.installType = install_type hostDo.vendor = vendor if currentVersion and buildNumber: hostDo.ntVersion = '%s.%s' % (currentVersion, buildNumber) hostDo.buildNumber = buildNumber hostDo.servicePack = __parseServicePack(servicePack) return hostDo
def getOperatingSystemInfo(self): '''@types: -> HostDo @raise Exception: if wmi query failed''' hostDo = HostDo() queryBuilder = self._wmiProvider.getBuilder('Win32_OperatingSystem') queryBuilder.addWmiObjectProperties('Caption', 'otherTypeDescription', 'Version', 'BuildNumber', 'csdversion', 'lastBootUpTime', 'registeredUser', 'totalVisibleMemorySize', 'organization') osDataList = self._wmiProvider.getAgent().getWmiData(queryBuilder) for osData in osDataList: if osData.Caption: otherTypeDescription = osData.otherTypeDescription if not otherTypeDescription: otherTypeDescription = None (vendor, name, installType) = separateCaption( self.__normalizeWindowsOSAndType(osData.Caption), self.__normalizeWindowsOSAndType(otherTypeDescription)) hostDo.hostOsName = name hostDo.installType = installType hostDo.vendor = vendor hostDo.registeredOwner = osData.registeredUser hostDo.physicalMemory = osData.totalVisibleMemorySize hostDo.organization = osData.organization else: logger.warn( "Caption field is empty. Host OS name, installation type and vendor will not be parsed out." ) if osData.Version: hostDo.ntVersion = self.__normalizeWindowsOSAndType( osData.Version) else: logger.warn('Version field is empty. Skipping.') if osData.csdversion: hostDo.servicePack = __parseServicePack( self.__normalizeWindowsOSAndType(osData.csdversion)) else: logger.warn('Service pack field is empty. Skipping.') if osData.BuildNumber: hostDo.buildNumber = osData.BuildNumber else: logger.warn('Build number filed is empty. Skipping') try: hostDo.lastBootDate = modeling.getDateFromUtcString( osData.lastBootUpTime) except: logger.warn("Failed to parse last boot date from value '%s'" % osData.lastBootUpTime) return hostDo
def getOperatingSystemInfo(self): '''@types: -> HostDo @raise Exception: if wmi query failed''' hostDo = HostDo() queryBuilder = self._wmiProvider.getBuilder('Win32_OperatingSystem') queryBuilder.addWmiObjectProperties('Caption', 'otherTypeDescription', 'Version', 'BuildNumber', 'csdversion', 'lastBootUpTime', 'registeredUser', 'totalVisibleMemorySize', 'organization') osDataList = self._wmiProvider.getAgent().getWmiData(queryBuilder) for osData in osDataList: if osData.Caption: otherTypeDescription = osData.otherTypeDescription if not otherTypeDescription: otherTypeDescription = None (vendor, name, installType) = separateCaption(self.__normalizeWindowsOSAndType(osData.Caption), self.__normalizeWindowsOSAndType(otherTypeDescription)) hostDo.hostOsName = name hostDo.installType = installType hostDo.vendor = vendor hostDo.registeredOwner = osData.registeredUser hostDo.physicalMemory = osData.totalVisibleMemorySize hostDo.organization = osData.organization else: logger.warn("Caption field is empty. Host OS name, installation type and vendor will not be parsed out.") if osData.Version: hostDo.ntVersion = self.__normalizeWindowsOSAndType(osData.Version) else: logger.warn('Version field is empty. Skipping.') if osData.csdversion: hostDo.servicePack = __parseServicePack(self.__normalizeWindowsOSAndType(osData.csdversion)) else: logger.warn('Service pack field is empty. Skipping.') if osData.BuildNumber: hostDo.buildNumber = osData.BuildNumber else: logger.warn('Build number filed is empty. Skipping') try: hostDo.lastBootDate = modeling.getDateFromUtcString(osData.lastBootUpTime) except: logger.warn("Failed to parse last boot date from value '%s'" % osData.lastBootUpTime) return hostDo
def getHostOsDetailsFromRegistry(self): ' -> HostDo' hostDo = HostDo() hostOsName = queryRegistry(self.shell, HostDiscovererByShell.KEY_NAME_WIN_VERSION, 'ProductName') currentVersion = queryRegistry(self.shell, HostDiscovererByShell.KEY_NAME_WIN_VERSION, 'CurrentVersion') buildNumber = queryRegistry(self.shell, HostDiscovererByShell.KEY_NAME_WIN_VERSION, 'CurrentBuildNumber') servicePack = queryRegistry(self.shell, HostDiscovererByShell.KEY_NAME_WIN_VERSION, 'CSDVersion') if hostOsName: (vendor, name, install_type) = separateCaption(hostOsName) hostDo.hostOsName = name hostDo.installType = install_type hostDo.vendor = vendor if currentVersion and buildNumber: hostDo.ntVersion = '%s.%s' % (currentVersion, buildNumber) hostDo.buildNumber = buildNumber hostDo.servicePack = __parseServicePack(servicePack) return hostDo