def discoverExchangeServer(wmiAgent, ipAddress, credentialsId, OSHVResult, Framework, hostOsh, hostName):
	queryBuilder = WmiQueryBuilder('Exchange_Server')
	queryBuilder.addWmiObjectProperties('FQDN', 'GUID', 'Type', 'MTADataPath',
									'CreationTime', 'ExchangeVersion', 'MonitoringEnabled', 
									'AdministrativeNote', 'MessageTrackingEnabled', 
									'MessageTrackingLogFilePath', 'MessageTrackingLogFileLifetime')
	
	queryBuilder.addWhereClause('Name = \'%s\'' % hostName)	
	Exchange_Servers = wmiAgent.getWmiData(queryBuilder)
	
	if len(Exchange_Servers) == 0:
		errobj = errorobject.createError(errorcodes.EMPTY_DATA_RECEIVED, ['Exchange servers', 'WMI'], 'No Exchange servers available via WMI')
		logger.reportWarningObject(errobj)
		return
		
	for Exchange_Server in Exchange_Servers:
		exchangeServerOsh = modeling.createExchangeServer(hostOsh, ipAddress, credentialsId, ms_exchange_utils.VERSION_2003)
		exchangeServerOsh.setAttribute('guid', extractId(Exchange_Server.GUID))
		exchangeServerOsh.setAttribute('fqdn', Exchange_Server.FQDN)
		exchangeServerOsh.setAttribute('application_version_number', ms_exchange_utils.VERSION_2003)
		exchangeServerOsh.setAttribute('build_number', Exchange_Server.ExchangeVersion)
		exchangeServerOsh.setAttribute('data_description', Exchange_Server.AdministrativeNote)
		exchangeServerOsh.setAttribute('mta_data_path', Exchange_Server.MTADataPath)
		exchangeServerOsh.setBoolAttribute('is_monitoring_enabled', Exchange_Server.MonitoringEnabled)
		exchangeServerOsh.setAttribute('log_file_path', Exchange_Server.MessageTrackingLogFilePath)
		exchangeServerOsh.setBoolAttribute('message_tracking_enabled', Exchange_Server.MessageTrackingEnabled)
		exchangeServerOsh.setIntegerAttribute('log_file_lifetyme', Exchange_Server.MessageTrackingLogFileLifetime)			
		exchangeServerOsh.setDateAttribute('creation_date', parseDate(Exchange_Server.CreationTime))
		exchangeServerOsh.setAttribute('type', SERVER_TYPES[Exchange_Server.Type])
		
		OSHVResult.add(hostOsh)			
		OSHVResult.add(exchangeServerOsh)
Exemplo n.º 2
0
    def doFolderTrees(self):
        queryBuilder = WmiQueryBuilder('Exchange_FolderTree')
        queryBuilder.addWmiObjectProperties('Name', 'GUID', 'Description',
                                            'CreationTime', 'RootFolderURL',
                                            'AdministrativeNote',
                                            'AdministrativeGroup')

        Exchange_FolderTrees = self.wmiAgent.getWmiData(queryBuilder)
        nameToFolderTree = {}

        for Exchange_FolderTree in Exchange_FolderTrees:
            administrativeGroupOsh = ObjectStateHolder(
                'exchange_administrative_group')
            administrativeGroupOsh.setAttribute(
                'data_name', Exchange_FolderTree.AdministrativeGroup)
            administrativeGroupOsh.setContainer(self.exchangeSystemOsh)
            self.add(administrativeGroupOsh)

            folderTreeOsh = ObjectStateHolder('ms_exchange_folder_tree')
            folderTreeOsh.setAttribute('data_name', Exchange_FolderTree.Name)
            folderTreeOsh.setAttribute('data_description',
                                       Exchange_FolderTree.Description)
            folderTreeOsh.setAttribute('root_folder_url',
                                       Exchange_FolderTree.RootFolderURL)
            folderTreeOsh.setAttribute('administrative_note',
                                       Exchange_FolderTree.AdministrativeNote)
            folderTreeOsh.setAttribute('guid',
                                       extractId(Exchange_FolderTree.GUID))
            folderTreeOsh.setDateAttribute(
                'creation_time', parseDate(Exchange_FolderTree.CreationTime))

            folderTreeOsh.setContainer(administrativeGroupOsh)
            self.add(folderTreeOsh)

            nameToFolderTree[Exchange_FolderTree.Name] = folderTreeOsh

        self.doPublicFolders(nameToFolderTree)