Пример #1
0
def DiscoveryMain(framework):
    vector = ObjectStateHolderVector()
    protocol = 'local_shell'
    try:
        zoneNameList, includeOutscopeIPs, ip, reportBrokenAliases = _obtainParams(framework)
        if not zoneNameList:
            logger.reportError('List of zones for transfer is not specified')
            return
        client = framework.createClient(ClientsConsts.LOCAL_SHELL_PROTOCOL_NAME)
        shell = None
        try:
            shell = shellutils.ShellUtils(client)
            #pass name server IP to the discoverer
            dnsDiscoverer = dns_discoverer.createDiscovererByShell(shell, ip)
            zoneTopologies = dns_discoverer.discoverDnsZoneTopologies(dnsDiscoverer, zoneNameList, protocol)
            vector.addAll(dns_discoverer.reportTopologies(zoneTopologies, includeOutscopeIPs, reportBrokenAliases))
        finally:
            try:
                shell and shell.closeClient()
            except:
                logger.debugException('')
                logger.error('Unable to close shell')
    except JException, ex:
        exInfo = ex.getMessage()
        errormessages.resolveAndReport(exInfo, protocol, framework)
Пример #2
0
def DiscoveryMain(framework, credsManager):
    config = (flow.DiscoveryConfigBuilder(framework)
              .dest_data_required_params_as_str('Protocol')
              .dest_data_params_as_str(
                    language=None)
              .bool_params(discoverUnknownIPs=False)
              .params(
                    DNSServerName=None,
                    DNSServerDomain=None,
              )).build()

    warnings = []
    with closing(_createClient(framework, config.Protocol)) as client:
        shell = shellutils.ShellFactory().createShell(client)

        dnsServerAddress = config.DNSServerName
        domain = config.DNSServerDomain
        if not (domain and dnsServerAddress):
            logger.info("DNS Server address or domain is not specified. "
                        "Determine automatically")
            dnsServerAddress, domain = getServerAndDomain(framework, client, config)

        discoverer = dns_discoverer.createDiscovererByShell(shell, dnsServerAddress)
        types = (dns.ResourceRecord.Type.A,)  # @UndefinedVariable
        records = discoverer.transferZone(dns.Zone(domain), *types)
        logger.info("Found %s records" % len(records))
        oshs = _reportHosts(records, config.discoverUnknownIPs)
        return oshs,  warnings
    return [], warnings
Пример #3
0
def getNameServersFromShell(domainName, shell=None, dnsServer=None):
    ret = []
    if not domainName or domainName == '':
        return ret
    try:
        dnsDiscoverer = dns_discoverer.createDiscovererByShell(shell, dnsServer)
        records = dnsDiscoverer.listRecords(domainName, dnsServer, (RecordType.NS))
        ret = []                
        for record in records:
            if record.type == RecordType.NS:
                ret.append(record.cname)
        logger.debug("NS for %s: %s" % (domainName, ret))
    except:
        logger.warnException("Error getting name servers for %s:" % domainName)
    return ret
def DiscoveryMain(framework):
    vector = ObjectStateHolderVector()
    protocol = framework.getDestinationAttribute("Protocol")
    try:
        client = framework.createClient()
        shell = None
        try:
            shell = shellutils.ShellUtils(client)
            dnsDiscoverer = dns_discoverer.createDiscovererByShell(shell)
            params = _obtainParams(framework)
            zoneNameList, includeOutscopeIPs, reportBrokenAliases = params
            zoneTopologies = dns_discoverer.discoverDnsZoneTopologies(dnsDiscoverer, zoneNameList, protocol)
            vector.addAll(dns_discoverer.reportTopologies(zoneTopologies, includeOutscopeIPs, reportBrokenAliases))
        finally:
            try:
                shell and shell.closeClient()
            except:
                logger.debugException("")
                logger.error("Unable to close shell")
    except JException, ex:
        exInfo = ex.getMessage()
        errormessages.resolveAndReport(exInfo, protocol, framework)