示例#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 DiscoveryMain(Framework):
	OSHVResult = ObjectStateHolderVector()	
	exchangeServerId = Framework.getDestinationAttribute('id')
	exchangeServerOsh = ms_exchange_utils.restoreExchangeServerOSH(exchangeServerId)
	
	try:
		shellClient = Framework.createClient()
		client = PowerShellClient(shellClient, Framework)
		try:
			ExchangeServer = client.executeScenario("Exchange_Server_2007_Discovery.ps1")
			
			exchangeSystemName = extractOrganizationNameFromDn(ExchangeServer.ExchangeLegacyDN)
			exchangeSystemOsh = ObjectStateHolder('exchangesystem')
			exchangeSystemOsh.setAttribute('data_name', exchangeSystemName)
			modeling.setAppSystemVendor(exchangeSystemOsh)
			OSHVResult.add(exchangeSystemOsh)
			OSHVResult.add(modeling.createLinkOSH('member', exchangeSystemOsh, exchangeServerOsh))
			adminGroupName = extractAdminGrouptFromDn(ExchangeServer.ExchangeLegacyDN)
			if adminGroupName and exchangeSystemOsh:
				adminGroupOsh = ObjectStateHolder('exchange_administrative_group')
				adminGroupOsh.setAttribute('data_name' , adminGroupName)
				adminGroupOsh.setContainer(exchangeSystemOsh)
				OSHVResult.add(adminGroupOsh)
				OSHVResult.add(modeling.createLinkOSH('member', adminGroupOsh, exchangeServerOsh))

			createServerRoles(exchangeServerOsh, ExchangeServer.ServerRole, OSHVResult)
			dagList = []
			clusteredMailBox = None
			try:
				dagList = ExchangeServer.dagList
				if not dagList:
					raise ValueError('Failed getting DAG information')
			except:
				logger.debugException('')
			else:
				OSHVResult.addAll(TopologyBuilder(None, None, None, None).buildDagRelatedTopology(exchangeServerOsh, dagList))
				
			try:
				clusteredMailBox = ExchangeServer.clusteredMailBox
				if not clusteredMailBox:
					raise ValueError('Failed getting Clustered Mailbox')
			except:
				logger.debugException('')
			else:
				setattr(clusteredMailBox, "exchOrgName", exchangeSystemName)
				OSHVResult.addAll(TopologyBuilder(None, None, None, None).buildClusteredMailBoxRelatedTopology(exchangeServerOsh, clusteredMailBox))
			OSHVResult.add(exchangeServerOsh)
		finally:
			client.close()
	except Exception, ex:
		logger.debugException('')
		strException = str(ex.getMessage())
		errormessages.resolveAndReport(strException, PROTOCOL_NAME, Framework)
def DiscoveryMain(Framework):
    OSHVResult = ObjectStateHolderVector()
    exchangeServerId = Framework.getDestinationAttribute('id')
    exchangeServerOsh = ms_exchange_utils.restoreExchangeServerOSH(
        exchangeServerId)

    try:
        shellClient = Framework.createClient()
        client = PowerShellClient(shellClient, Framework)
        try:
            ExchangeServer = client.executeScenario(
                "Exchange_Server_2007_Discovery.ps1")

            exchangeSystemName = extractOrganizationNameFromDn(
                ExchangeServer.ExchangeLegacyDN)
            exchangeSystemOsh = ObjectStateHolder('exchangesystem')
            exchangeSystemOsh.setAttribute('data_name', exchangeSystemName)
            modeling.setAppSystemVendor(exchangeSystemOsh)
            OSHVResult.add(exchangeSystemOsh)
            OSHVResult.add(
                modeling.createLinkOSH('member', exchangeSystemOsh,
                                       exchangeServerOsh))
            adminGroupName = extractAdminGrouptFromDn(
                ExchangeServer.ExchangeLegacyDN)
            if adminGroupName and exchangeSystemOsh:
                adminGroupOsh = ObjectStateHolder(
                    'exchange_administrative_group')
                adminGroupOsh.setAttribute('data_name', adminGroupName)
                adminGroupOsh.setContainer(exchangeSystemOsh)
                OSHVResult.add(adminGroupOsh)
                OSHVResult.add(
                    modeling.createLinkOSH('member', adminGroupOsh,
                                           exchangeServerOsh))

            createServerRoles(exchangeServerOsh, ExchangeServer.ServerRole,
                              OSHVResult)
            dagList = []
            clusteredMailBox = None
            try:
                dagList = ExchangeServer.dagList
                if not dagList:
                    raise ValueError('Failed getting DAG information')
            except:
                logger.debugException('')
            else:
                OSHVResult.addAll(
                    TopologyBuilder(None, None, None,
                                    None).buildDagRelatedTopology(
                                        exchangeServerOsh, dagList))

            try:
                clusteredMailBox = ExchangeServer.clusteredMailBox
                if not clusteredMailBox:
                    raise ValueError('Failed getting Clustered Mailbox')
            except:
                logger.debugException('')
            else:
                setattr(clusteredMailBox, "exchOrgName", exchangeSystemName)
                OSHVResult.addAll(
                    TopologyBuilder(None, None, None,
                                    None).buildClusteredMailBoxRelatedTopology(
                                        exchangeServerOsh, clusteredMailBox))
            OSHVResult.add(exchangeServerOsh)
        finally:
            client.close()
    except Exception, ex:
        logger.debugException('')
        strException = str(ex.getMessage())
        errormessages.resolveAndReport(strException, PROTOCOL_NAME, Framework)