示例#1
0
    def doPublicFolders(self, nameToFolderTree):
        queryBuilder = WmiQueryBuilder('Exchange_PublicFolder')
        queryBuilder.addWmiObjectProperties('Name', 'Url', 'Path', 'Comment',
                                            'FolderTree', 'FriendlyUrl',
                                            'IsMailEnabled', 'AddressBookName',
                                            'AdministrativeNote',
                                            'ContactCount')
        pathToFolder = {}

        Exchange_PublicFolders = self.wmiAgent.getWmiData(queryBuilder)

        for publicFolder in Exchange_PublicFolders:

            folderName = publicFolder.Name
            if not folderName:
                try:
                    folderName = extractFolderNameFromPath(publicFolder.Path)
                except ValueError, ex:
                    logger.warn(str(ex))
                    continue

            parentPath = None
            try:
                parentPath = extractParentPath(publicFolder.Path, folderName)
            except ValueError, ex:
                logger.warn(str(ex))
                continue
示例#2
0
    def doExchangeSystem(self, fqdn):
        queryBuilder = WmiQueryBuilder('Exchange_Server')
        queryBuilder.addWmiObjectProperties('Name', 'FQDN', 'DN',
                                            'RoutingGroup',
                                            'AdministrativeGroup')

        Exchange_Servers = self.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:
            '''
			In case host name was not determined earlier, try to obtain it using Exchange_Server.FQDN property 
			'''
            if not self.exchangeServerName and fqdn == Exchange_Server.FQDN:
                self.exchangeServerName = Exchange_Server.Name

            exchangeSystemOsh = ObjectStateHolder('exchangesystem')
            exchangeSystemOsh.setAttribute(
                'data_name', extractOrganizationNameFromDn(Exchange_Server.DN))
            modeling.setAppSystemVendor(exchangeSystemOsh)
            self.add(exchangeSystemOsh)

            administrativeGroupOsh = ObjectStateHolder(
                'exchange_administrative_group')
            administrativeGroupOsh.setAttribute(
                'data_name', Exchange_Server.AdministrativeGroup)
            administrativeGroupOsh.setContainer(exchangeSystemOsh)
            self.add(administrativeGroupOsh)

            routingGroupOsh = ObjectStateHolder('routing_group')
            routingGroupOsh.setAttribute('data_name',
                                         Exchange_Server.RoutingGroup)
            routingGroupOsh.setContainer(administrativeGroupOsh)
            self.add(routingGroupOsh)

            if self.exchangeServerName and self.exchangeServerName.lower(
            ) == Exchange_Server.Name.lower():
                self.add(
                    modeling.createLinkOSH('member', administrativeGroupOsh,
                                           self.exchangeServerOsh))
                self.add(
                    modeling.createLinkOSH('member', routingGroupOsh,
                                           self.exchangeServerOsh))

            self.add(
                modeling.createLinkOSH('member', exchangeSystemOsh,
                                       self.exchangeServerOsh))
            self.exchangeSystemOsh = exchangeSystemOsh
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)
示例#4
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)