示例#1
0
def _buildProbeRanges(framework, rangeString, probeName):
    'str -> Range'
    if rangeString != 'NA' and rangeString:
        rangeString = re.sub(r"\s+",'',rangeString)
        selectedRangeList = map(RangeFactory().newRange, rangeString.split(';')) #creating Range for each range string
    else:
        selectedRangeList = None
    return icmp_utils.getProbeRanges(selectedRangeList, probeName, framework, True, True)
示例#2
0
def _buildProbeRanges(framework, rangeString, probeName):
    'str -> Range'
    if rangeString != 'NA' and rangeString:
        rangeString = re.sub(r"\s+", '', rangeString)
        selectedRangeList = map(
            RangeFactory().newRange,
            rangeString.split(';'))  #creating Range for each range string
    else:
        selectedRangeList = None
    return icmp_utils.getProbeRanges(selectedRangeList, probeName, framework,
                                     True, True)
示例#3
0
def DiscoveryMain(Framework):
    properties = Properties()

    properties.setProperty('timeoutDiscover', Framework.getParameter('timeoutDiscover'))
    properties.setProperty('retryDiscover', Framework.getParameter('retryDiscover'))
    properties.setProperty('pingProtocol', Framework.getParameter('pingProtocol'))
    properties.setProperty('threadPoolSize', Framework.getParameter('threadPoolSize'))

    excludePatterns = icmp_utils.preparePatterns(Framework.getParameter('excludePatternsList'))
    rangeString = Framework.getParameter('range') or 'NA'
    probeName = Framework.getDestinationAttribute('probeName')
    selectedRangeList = None

    #clear it because IP seep will load state for 'IP range'. See 'icmp_utils.getProbeRanges()'
    Framework.clearState()
    
    try:
        client = Framework.createClient(ClientsConsts.ICMP_PROTOCOL_NAME, properties)
        try:
            if rangeString != 'NA':
                selectedRangeList = SNMP_Connection_Utils.splitByRanges(rangeString)
            probeRangesForIPv6 = icmp_utils.getProbeRanges(selectedRangeList, probeName, Framework, False, True)
            if SNMP_Connection_Utils.isIPv6Overflow(probeRangesForIPv6): # if IPv6 addresses exceeds the max allowed count, won't ping
                return []
            probeRanges = icmp_utils.getProbeRanges(selectedRangeList, probeName, Framework, True, True)

            logger.debug('Start working on total probe ranges: ', len(probeRanges))
            for probeRange in probeRanges:
                if (probeRange.getType().equals(RangeType.CLIENT)
                    or probeRange.getType().equals('Client')):
                    SNMP_Connection_Utils.discoverClientInRange(Framework, client, probeRange, excludePatterns)
            logger.debug('Finished working on all Probes Ranges.')
        finally:
            client.close()
    except:
        msg = logger.prepareJythonStackTrace('')
        errormessages.resolveAndReport(msg, ClientsConsts.ICMP_PROTOCOL_NAME, Framework)

    return ObjectStateHolderVector()
示例#4
0
def DiscoveryMain(Framework):
    properties = Properties()

    properties.setProperty('timeoutDiscover', Framework.getParameter('timeoutDiscover'))
    properties.setProperty('retryDiscover', Framework.getParameter('retryDiscover'))
    properties.setProperty('pingProtocol', Framework.getParameter('pingProtocol'))
    properties.setProperty('threadPoolSize', Framework.getParameter('threadPoolSize'))

    excludePatterns = icmp_utils.preparePatterns(Framework.getParameter('excludePatternsList'))
    
    virtualMode = Framework.getParameter('virtualModeDiscover').lower() == "true"
    rangeString = Framework.getParameter('range') or 'NA'
    probeName = Framework.getDestinationAttribute('probeName')
    ignoreClientType = getGlobalSetting().getPropertyStringValue('pingClientTypeIp', "False").lower() == "false"
    maxAllowedIPv6CountPerRange = long(getGlobalSetting().getPropertyStringValue('maxPingIPv6CountPerRange', str(DEFAULT_MAX_PING_IPV6_COUNT_PER_RANGE)))

    logger.debug("Max allowed IPv6 range size:", maxAllowedIPv6CountPerRange)
    isPingIPv4, isPingIPv6 = getIPSupport(Framework)

    try:
        client = Framework.createClient(ClientsConsts.ICMP_PROTOCOL_NAME, properties)
        try:
            totalReportedIps = 0
            selectedRangeList = _convertToRanges(rangeString)
            probeRanges = icmp_utils.getProbeRanges(selectedRangeList, probeName, Framework, isPingIPv4, isPingIPv6)

            logger.info('Start working on total probe ranges: ', len(probeRanges))
            logger.info('ignoreClientType = ', ignoreClientType)
            #probeRanges = getDataCenterIPRanges(probeRanges)
            for probeRange in probeRanges:
                rangeSize = long(probeRange.getRangeSize())
                if rangeSize > maxAllowedIPv6CountPerRange:
                    logger.reportWarning(
                        "The size of IPv6 range (%s) is %d, exceeds the max range size %d, will skip it." % (
                            probeRange.toRangeString(), rangeSize, maxAllowedIPv6CountPerRange))
                    continue
                totalReportedIps += icmp_utils.pingIPsInRange(Framework, client, probeRange, virtualMode,
                                                              excludePatterns=excludePatterns,ignoreClientType=ignoreClientType)
                Framework.saveState(probeRange.toRangeString())
            logger.debug('Total reported IPs %s ' % totalReportedIps)
            logger.info('Finished working on all Probes Ranges..')

            Framework.clearState()
            if not totalReportedIps:
                logger.reportWarning("No live IPs found in probe ranges")
        finally:
            client.close()
    except:
        msg = logger.prepareJythonStackTrace('')
        errormessages.resolveAndReport(msg, ClientsConsts.ICMP_PROTOCOL_NAME, Framework)
    return ObjectStateHolderVector()
示例#5
0
def DiscoveryMain(Framework):
    properties = Properties()

    properties.setProperty('timeoutDiscover', Framework.getParameter('timeoutDiscover'))
    properties.setProperty('retryDiscover', Framework.getParameter('retryDiscover'))
    properties.setProperty('pingProtocol', Framework.getParameter('pingProtocol'))
    properties.setProperty('threadPoolSize', Framework.getParameter('threadPoolSize'))

    virtualMode = Framework.getParameter('virtualModeDiscover').lower() == "true"
    byRangeFlag = Framework.getParameter("byScopeDiscover").lower() == "true"


    netAddress = Framework.getDestinationAttribute("netAddress")
    netMask = Framework.getDestinationAttribute("netMask")
    probeName = Framework.getDestinationAttribute("probeName")

    ignoreClientType = getGlobalSetting().getPropertyStringValue('pingClientTypeIp', "False").lower() == "false"

    try:
        client = Framework.createClient(ClientsConsts.ICMP_PROTOCOL_NAME, properties)
        try:
            ipRange = getRangeByNetwork(netAddress, netMask)
            if byRangeFlag:
                rangesList = icmp_utils.getProbeRanges([ipRange], probeName, Framework)
            else:
                rangesList = [ipRange]
            logger.info('Start working on range: ', len(rangesList))
            totalReportedIps = 0
            for aRange in rangesList:
                totalReportedIps += icmp_utils.pingIPsInRange(Framework, client, aRange, virtualMode, netAddress, netMask,ignoreClientType=ignoreClientType)
                Framework.saveState(aRange.toRangeString())

            logger.debug('Total reported IPs %s ' % totalReportedIps)
            logger.info('Finished working on all ranges..')
            Framework.clearState()
            if not totalReportedIps:
                logger.reportWarning("No live DataCenter IPs found in probe ranges")
        finally:
            client.close()
    except:
        msg = logger.prepareJythonStackTrace('')
        errormessages.resolveAndReport(msg, ClientsConsts.ICMP_PROTOCOL_NAME, Framework)
    return ObjectStateHolderVector()
示例#6
0
def DiscoveryMain(Framework):
    properties = Properties()

    properties.setProperty('timeoutDiscover',
                           Framework.getParameter('timeoutDiscover'))
    properties.setProperty('retryDiscover',
                           Framework.getParameter('retryDiscover'))
    properties.setProperty('pingProtocol',
                           Framework.getParameter('pingProtocol'))
    properties.setProperty('threadPoolSize',
                           Framework.getParameter('threadPoolSize'))

    excludePatterns = icmp_utils.preparePatterns(
        Framework.getParameter('excludePatternsList'))

    virtualMode = Framework.getParameter(
        'virtualModeDiscover').lower() == "true"
    rangeString = Framework.getParameter('range') or 'NA'
    probeName = Framework.getDestinationAttribute('probeName')
    ignoreClientType = getGlobalSetting().getPropertyStringValue(
        'pingClientTypeIp', "False").lower() == "false"
    maxAllowedIPv6CountPerRange = long(
        getGlobalSetting().getPropertyStringValue(
            'maxPingIPv6CountPerRange',
            str(DEFAULT_MAX_PING_IPV6_COUNT_PER_RANGE)))

    logger.debug("Max allowed IPv6 range size:", maxAllowedIPv6CountPerRange)
    isPingIPv4, isPingIPv6 = getIPSupport(Framework)

    try:
        client = Framework.createClient(ClientsConsts.ICMP_PROTOCOL_NAME,
                                        properties)
        try:
            totalReportedIps = 0
            selectedRangeList = _convertToRanges(rangeString)
            probeRanges = icmp_utils.getProbeRanges(selectedRangeList,
                                                    probeName, Framework,
                                                    isPingIPv4, isPingIPv6)

            logger.info('Start working on total probe ranges: ',
                        len(probeRanges))
            logger.info('ignoreClientType = ', ignoreClientType)
            #probeRanges = getDataCenterIPRanges(probeRanges)
            for probeRange in probeRanges:
                rangeSize = long(probeRange.getRangeSize())
                if rangeSize > maxAllowedIPv6CountPerRange:
                    logger.reportWarning(
                        "The size of IPv6 range (%s) is %d, exceeds the max range size %d, will skip it."
                        % (probeRange.toRangeString(), rangeSize,
                           maxAllowedIPv6CountPerRange))
                    continue
                totalReportedIps += icmp_utils.pingIPsInRange(
                    Framework,
                    client,
                    probeRange,
                    virtualMode,
                    excludePatterns=excludePatterns,
                    ignoreClientType=ignoreClientType)
                Framework.saveState(probeRange.toRangeString())
            logger.debug('Total reported IPs %s ' % totalReportedIps)
            logger.info('Finished working on all Probes Ranges..')

            Framework.clearState()
            if not totalReportedIps:
                logger.reportWarning("No live IPs found in probe ranges")
        finally:
            client.close()
    except:
        msg = logger.prepareJythonStackTrace('')
        errormessages.resolveAndReport(msg, ClientsConsts.ICMP_PROTOCOL_NAME,
                                       Framework)
    return ObjectStateHolderVector()