Exemplo n.º 1
0
def DiscoveryMain(Framework):
    OSHVResult = ObjectStateHolderVector()    
    ipAddress = Framework.getDestinationAttribute('ip_address')
    credentialsId = Framework.getDestinationAttribute('credentialsId')
    hostId = Framework.getDestinationAttribute('hostId')
    
    hostOsh = ms_exchange_utils.restoreHostById(hostId)

    try:
        shellClient = Framework.createClient()
        client = PowerShellClient(shellClient, Framework)
        try:
            ExchangeServer = client.executeScenario("Exchange_Server_2007_Discovery.ps1")
            
            exchangeServerOsh = modeling.createExchangeServer(hostOsh, ipAddress, credentialsId, ExchangeServer.ExchangeSnapInVersion)
            exchangeServerOsh.setAttribute('guid', normalizeGuid(ExchangeServer.Guid))
            exchangeServerOsh.setAttribute('fqdn', ExchangeServer.Fqdn)
            
            buildNumber = parseBuildNumber(ExchangeServer.AdminDisplayVersion)
            if buildNumber:                
                exchangeServerOsh.setAttribute('build_number', buildNumber)
            #exchangeServerOsh.setAttribute('application_version_number', ExchangeServer.ExchangeSnapInVersion)
            versionNumber = parseExchangeVersion(ExchangeServer.AdminDisplayVersion)
            if versionNumber:
                exchangeServerOsh.setAttribute('application_version_number', exchange_version_mapping[versionNumber])
            exchangeServerOsh.setAttribute('application_version', ExchangeServer.AdminDisplayVersion)
            exchangeServerOsh.setDateAttribute('creation_date', DATE_FORMAT.parse(ExchangeServer.WhenCreated))
            
            OSHVResult.add(exchangeServerOsh)
        finally:
            client.close()
    except Exception, ex:
        logger.debugException('')
        strException = str(ex.getMessage())
        errormessages.resolveAndReport(strException, PROTOCOL_NAME, Framework)
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.º 3
0
 def buildExchangeServerOsh(self, exchangeServer, hostOsh, ipAddress, credentialsId):
     # string, osh, string, string -> osh
     exchangeServerOsh = modeling.createExchangeServer(hostOsh, ipAddress, credentialsId, exchangeServer.version)
     exchangeServerOsh.setAttribute('guid', exchangeServer.getGuid())
     exchangeServerOsh.setAttribute('fqdn', exchangeServer.fqdn)
     exchangeServerOsh.setAttribute('build_number', exchangeServer.buildNumber)
     exchangeServerOsh.setAttribute('application_version_number', exchangeServer.version)
     exchangeServerOsh.setAttribute('application_version', exchangeServer.adminDisplayVersion)
     exchangeServerOsh.setDateAttribute('creation_date', exchangeServer.creationDate)
     return exchangeServerOsh
Exemplo n.º 4
0
    def build(self):
        #@return: oshv
        OSHVResult = ObjectStateHolderVector()
        exchageOsh = self.buildExchangeServerOsh(self.exchangeServer,
                            self.hostOsh, self.ipAddress, self.credentialsId)

        if self.exchangeServer.organization:
            exchOrgOsh = self.buildExchangeOrganization(self.exchangeServer.organization)
            OSHVResult.add(exchOrgOsh)
            OSHVResult.add(modeling.createLinkOSH('member', exchOrgOsh, exchageOsh))
            if self.exchangeServer.organizationalUnit:
                adminGrOsh = self.buildExchAdminGrOsh(exchOrgOsh, self.exchangeServer.organizationalUnit)
                OSHVResult.add(adminGrOsh)
                OSHVResult.add(modeling.createLinkOSH('member', adminGrOsh, exchageOsh))

        if self.exchangeServer.dagList:
            OSHVResult.addAll(self.buildDagRelatedTopology(exchageOsh, self.exchangeServer.dagList))

        if self.exchangeServer.clusteredMailBox:
            self.exchangeServer.clusteredMailBox.exchOrgName = self.exchangeServer.clusteredMailBox.exchOrgName or self.exchangeServer.organization
            OSHVResult.addAll(self.buildClusteredMailBoxRelatedTopology(exchageOsh, self.exchangeServer.clusteredMailBox))

        if self.exchangeServer.mdbList:
            for mdb in self.exchangeServer.mdbList:
                containerOsh = None
                if mdb.relateTo == RELATE_TO_DAG:
                    if self.exchangeServer.dagList:
                        for dag in self.exchangeServer.dagList:
                            if dag.dagName == mdb.containerName:
                                exchOrgOsh = self.buildExchangeOrganization(dag.exchOrgName)
                                containerOsh = self.buildDag(exchOrgOsh, dag)
                if containerOsh:
                    mdbOsh = self.buildMailboxDatabase(mdb, containerOsh)
                    if mdbOsh:
                        OSHVResult.add(containerOsh)
                        OSHVResult.add(mdbOsh)
                        if mdb.servers:
                            for server in mdb.servers:
                                if server.ips:
                                    hostOsh = modeling.createHostOSH(str(server.ips[0]))
                                    exchangeServerOsh = modeling.createExchangeServer(hostOsh)
                                    linkOsh = modeling.createLinkOSH('ownership', exchangeServerOsh, mdbOsh)
                                    OSHVResult.add(exchangeServerOsh)
                                    OSHVResult.add(linkOsh)
                                    OSHVResult.add(hostOsh)
                                    if server.name == mdb.runningServer:
                                        linkOsh = modeling.createLinkOSH('run', exchangeServerOsh, mdbOsh)
                                        OSHVResult.add(linkOsh)
        OSHVResult.add(exchageOsh)
        OSHVResult.addAll(self.buildServerRoles(exchageOsh, self.exchangeServer))
        OSHVResult.add(self.hostOsh)
        return OSHVResult
Exemplo n.º 5
0
 def buildExchangeServerOsh(self, exchangeServer, hostOsh, ipAddress,
                            credentialsId):
     # string, osh, string, string -> osh
     exchangeServerOsh = modeling.createExchangeServer(
         hostOsh, ipAddress, credentialsId, exchangeServer.version)
     exchangeServerOsh.setAttribute('guid', exchangeServer.getGuid())
     exchangeServerOsh.setAttribute('fqdn', exchangeServer.fqdn)
     exchangeServerOsh.setAttribute('build_number',
                                    exchangeServer.buildNumber)
     exchangeServerOsh.setAttribute('application_version_number',
                                    exchangeServer.version)
     exchangeServerOsh.setAttribute('application_version',
                                    exchangeServer.adminDisplayVersion)
     exchangeServerOsh.setDateAttribute('creation_date',
                                        exchangeServer.creationDate)
     return exchangeServerOsh
Exemplo n.º 6
0
    def build(self):
        #@return: oshv
        OSHVResult = ObjectStateHolderVector()
        exchageOsh = self.buildExchangeServerOsh(self.exchangeServer,
                                                 self.hostOsh, self.ipAddress,
                                                 self.credentialsId)

        if self.exchangeServer.organization:
            exchOrgOsh = self.buildExchangeOrganization(
                self.exchangeServer.organization)
            OSHVResult.add(exchOrgOsh)
            OSHVResult.add(
                modeling.createLinkOSH('member', exchOrgOsh, exchageOsh))
            if self.exchangeServer.organizationalUnit:
                adminGrOsh = self.buildExchAdminGrOsh(
                    exchOrgOsh, self.exchangeServer.organizationalUnit)
                OSHVResult.add(adminGrOsh)
                OSHVResult.add(
                    modeling.createLinkOSH('member', adminGrOsh, exchageOsh))

        if self.exchangeServer.dagList:
            OSHVResult.addAll(
                self.buildDagRelatedTopology(exchageOsh,
                                             self.exchangeServer.dagList))

        if self.exchangeServer.clusteredMailBox:
            self.exchangeServer.clusteredMailBox.exchOrgName = self.exchangeServer.clusteredMailBox.exchOrgName or self.exchangeServer.organization
            OSHVResult.addAll(
                self.buildClusteredMailBoxRelatedTopology(
                    exchageOsh, self.exchangeServer.clusteredMailBox))

        if self.exchangeServer.mdbList:
            for mdb in self.exchangeServer.mdbList:
                containerOsh = None
                if mdb.relateTo == RELATE_TO_DAG:
                    if self.exchangeServer.dagList:
                        for dag in self.exchangeServer.dagList:
                            if dag.dagName == mdb.containerName:
                                exchOrgOsh = self.buildExchangeOrganization(
                                    dag.exchOrgName)
                                containerOsh = self.buildDag(exchOrgOsh, dag)
                if containerOsh:
                    mdbOsh = self.buildMailboxDatabase(mdb, containerOsh)
                    if mdbOsh:
                        OSHVResult.add(containerOsh)
                        OSHVResult.add(mdbOsh)
                        if mdb.servers:
                            for server in mdb.servers:
                                if server.ips:
                                    hostOsh = modeling.createHostOSH(
                                        str(server.ips[0]))
                                    exchangeServerOsh = modeling.createExchangeServer(
                                        hostOsh)
                                    linkOsh = modeling.createLinkOSH(
                                        'ownership', exchangeServerOsh, mdbOsh)
                                    OSHVResult.add(exchangeServerOsh)
                                    OSHVResult.add(linkOsh)
                                    OSHVResult.add(hostOsh)
                                    if server.name == mdb.runningServer:
                                        linkOsh = modeling.createLinkOSH(
                                            'run', exchangeServerOsh, mdbOsh)
                                        OSHVResult.add(linkOsh)
        OSHVResult.add(exchageOsh)
        OSHVResult.addAll(
            self.buildServerRoles(exchageOsh, self.exchangeServer))
        OSHVResult.add(self.hostOsh)
        return OSHVResult