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 getHostOsDetailsFromCmd(self): hostDo = HostDo() hostOsName = None ntVersion = None strWindowsVersion = self.langBund.getString( 'windows_ver_str_version') + ' ' ver = self.shell.execCmd( 'ver', useCache=1) #@@CMD_PERMISION ntcmd protocol execution if ver: m = re.match("(.*)\s+\[.*\s+(.*)\]", ver) if m: ntVersion = m.group(2) hostOsName = m.group(1).strip() else: startIndex = ver.find(strWindowsVersion) if (startIndex > 0): hostOsName = ver[:startIndex] ntVersion = ver[startIndex:] else: hostOsName = ver ntVersion = self.__standardizeVersion(ntVersion) hostDo.hostOsName = hostOsName hostDo.ntVersion = ntVersion 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 getHostOsDetailsFromProdspecFile(self): #@raise Exception: hostDo = HostDo() resultBuffer = self.shell.safecat('%systemroot%\system32\prodspec.ini') if resultBuffer: matcher = re.search('\n\s*Product=(.+?)\n', resultBuffer) if matcher: prodspec = matcher.group(1).strip() (vendor, name, install_type) = separateCaption(prodspec) hostDo.installType = install_type or prodspec hostDo.hostOsName = name hostDo.vendor = vendor else: #raise Exception ? logger.warn('Failed to discover OS install type.') 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
def getHostOsDetailsFromCmd(self): hostDo = HostDo() hostOsName = None ntVersion = None strWindowsVersion = self.langBund.getString('windows_ver_str_version') + ' ' ver = self.shell.execCmd('ver', useCache = 1)#@@CMD_PERMISION ntcmd protocol execution if ver: m = re.match("(.*)\s+\[.*\s+(.*)\]", ver) if m: ntVersion = m.group(2) hostOsName = m.group(1).strip() else: startIndex = ver.find(strWindowsVersion) if (startIndex > 0): hostOsName = ver[:startIndex] ntVersion = ver[startIndex:] else: hostOsName = ver ntVersion = self.__standardizeVersion(ntVersion) hostDo.hostOsName = hostOsName hostDo.ntVersion = ntVersion return hostDo