Exemplo n.º 1
0
	def discoverSitesAndForest(self):
		FIRST = 0
		self.adSystemOsh = active_directory_utils.createAdSystemOsh()
		forestDiscoverer = active_directory_utils.AdForestDiscoverer(self.__adDaoService, self.adSystemOsh)
		vector = forestDiscoverer.discover()
		self.forestOsh = vector.get(FIRST)
		siteDiscoverer = active_directory_utils.AdSiteDiscoverer(self.__adDaoService, self.forestOsh)
		siteDiscoverer.discover()
		siteDtoToOshMap = siteDiscoverer.getResult().getMap()
		for [key, siteOsh ]in siteDtoToOshMap.items():
			siteDn = key.id.value
			self.siteDnToOshMap[siteDn] = siteOsh
def discover(daoService,
             hostId,
             tryToDiscoverGlobalCatalogFlag=None,
             isOuUnitsTreeReportedAsConfig=False,
             discoveryResult=None):
    '''
    tryToDiscoverGlobalCatalogFlag used here to prevent from setting
    application_port in domainController CI if not prevent this is possible
    multiple bulks error
    @types: ?
    '''
    OSHVResult = ObjectStateHolderVector()
    FIRST_RESULT = 0
    #Active Directory System
    '''
    Create the fake Active Directory System OSH that is the root
    of whole AD hierarchy
    '''
    adSystemOsh = createAdSystemOsh()
    OSHVResult.add(adSystemOsh)

    #discover forest
    forestDiscoverer = AdForestDiscoverer(daoService, adSystemOsh)
    vector = forestDiscoverer.discover()
    forestOsh = vector.get(FIRST_RESULT)
    OSHVResult.addAll(vector)

    #discover forest->site      (container)
    siteDiscoverer = AdSiteDiscoverer(daoService, forestOsh)
    OSHVResult.addAll(siteDiscoverer.discover())
    siteDtoToSiteOshMap = siteDiscoverer.getResult().getMap()

    serverDao = daoService.getServerDao()
    serverConfigurationDtos = []
    for siteDto, siteOsh in siteDtoToSiteOshMap.items():
        try:
            serverConfigurationDtos.extend(
                serverDao.obtainServersBySite(siteDto))
        except NotFoundException, nfe:
            logger.reportWarning("Failed to get servers for %s site" % siteDto)
            logger.warnException(nfe.getMessage())
def discover(daoService, hostId, tryToDiscoverGlobalCatalogFlag=None,
             isOuUnitsTreeReportedAsConfig=False,
             discoveryResult=None):
    '''
    tryToDiscoverGlobalCatalogFlag used here to prevent from setting
    application_port in domainController CI if not prevent this is possible
    multiple bulks error
    @types: ?
    '''
    OSHVResult = ObjectStateHolderVector()
    FIRST_RESULT = 0
    #Active Directory System
    '''
    Create the fake Active Directory System OSH that is the root
    of whole AD hierarchy
    '''
    adSystemOsh = createAdSystemOsh()
    OSHVResult.add(adSystemOsh)

    #discover forest
    forestDiscoverer = AdForestDiscoverer(daoService, adSystemOsh)
    vector = forestDiscoverer.discover()
    forestOsh = vector.get(FIRST_RESULT)
    OSHVResult.addAll(vector)

    #discover forest->site      (container)
    siteDiscoverer = AdSiteDiscoverer(daoService, forestOsh)
    OSHVResult.addAll(siteDiscoverer.discover())
    siteDtoToSiteOshMap = siteDiscoverer.getResult().getMap()

    serverDao = daoService.getServerDao()
    serverConfigurationDtos = []
    for siteDto, siteOsh in siteDtoToSiteOshMap.items():
        try:
            serverConfigurationDtos.extend(serverDao.obtainServersBySite(siteDto))
        except NotFoundException, nfe:
            logger.reportWarning("Failed to get servers for %s site" % siteDto)
            logger.warnException(nfe.getMessage())