예제 #1
0
    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
예제 #2
0
    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
예제 #3
0
 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
예제 #4
0
 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
예제 #5
0
    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
예제 #6
0
    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